> -----Original Message----- > From: Paolo Bonzini [mailto:[email protected]] On Behalf Of Paolo > Bonzini > Sent: Wednesday, October 10, 2012 2:34 PM > To: Chen HanXiao > Cc: 'Christoph Hellwig'; [email protected] > Subject: Re: [PATCH] Use SCSI command to get size of SG device > > Il 10/10/2012 04:11, Chen HanXiao ha scritto: > >> > > >> > On Tue, Oct 09, 2012 at 05:42:01PM +0800, Chen HanXiao wrote: > >>> > > When we use SCSI generic device as disk image, function lseek > >>> > > could not get the size of this kind of device. > >>> > > So try to use SCSI command Read Capacity(10) when lseek failed > >>> > > to get the size of SCSI generic device. > >> > > >> > Eww, this is ugly as hell. Why would you even need the size for a > >> > raw passthrough device? > > > > If we want to enable snapshot for SCSI generic device as disk image, > > the size of SCSI generic device is needed. Function lseek could not > > get this, SCSI command can finish the job. > > Only when lseek failed would Read Capacity command be sent. > > You need to use scsi-block instead of scsi-generic. However, I don't see how > this can work. After the snapshot, the image will be qcow2, not raw, and thus > it will not support bdrv_aio_ioctl. Hence any SCSI command (for scsi-generic) > or any non-data SCSI command (for scsi-block) will fail. > That's the issue what I also encountered. Do you mean that it is impossible for us to enable snapshot for scsi-generic? Or patched for qcow2 would solve this? > Can you give an example of what exactly you are trying to do? > I could enable snapshot for scsi-block device, but failed when using scsi-generic with parameter 'snapshot =on'. The first issue is failing to get the size of SG device. So I tried to fix it.
Command line: -drive if=none,id=hd,file=/dev/sg2,snapshot=on \ -device virtio-scsi-pci,id=scsi --enable-kvm \ -device scsi-generic,drive=hd,id=vd1 > Paolo Regards
