Greetings, I was wondering what is the proper way to configure a scsi cdrom pass-through so in when the qemu line is generated, host_Cdrom will be used instead of host_device. looking at https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_block.c#L1090, I see that hostcdrom must be true. in order for that to be true, the following must be (see https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_domain.c#L7167): 1. disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM 2. disksrc->format == VIR_STORAGE_FILE_RAW 3. virStorageSourceIsBlockLocal(disksrc) 4. virFileIsCDROM(disksrc->path) == 1 virFileIsCDROM uses the kernel, so I assume that as disksrc->path points to the actual path (I can see it in the qemu line) than #4 returns 1. the other 3 are more complicated. my xml snippet is this: <devices> <hostdev mode='subsystem' type='scsi' rawio='yes'> <source> <adapter name='scsi_host0'/> <address bus='0' target='0' unit='0'/> </source> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </hostdev> </devices> Thanks, Dagg
On Wed, Oct 28, 2020 at 15:06:51 +0100, daggs wrote:> Greetings, > > I was wondering what is the proper way to configure a scsi cdrom pass-through so in when the qemu line is generated, host_Cdrom will be used instead of host_device. > > looking at https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_block.c#L1090, I see that hostcdrom must be true. > in order for that to be true, the following must be (see https://gitlab.com/libvirt/libvirt/-/blob/master/src/qemu/qemu_domain.c#L7167): > 1. disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM > 2. disksrc->format == VIR_STORAGE_FILE_RAW > 3. virStorageSourceIsBlockLocal(disksrc) > 4. virFileIsCDROM(disksrc->path) == 1 > > virFileIsCDROM uses the kernel, so I assume that as disksrc->path points to the actual path (I can see it in the qemu line) than #4 returns 1.Note that all of the above is not "SCSI passthrough" but rather device emulation backed with a real cdrom. This is fine if you want to use the cdrom for block operations (reading) CDs. In that case qemu must use "host_cdrom" to provide functionality such as eject. For true SCSI passtrhrough, when all commands are passed to the host device (good also for other operations, e.g. writing CDs) For such operation the XML using <hostdev> ...> the other 3 are more complicated. my xml snippet is this: > <devices> > <hostdev mode='subsystem' type='scsi' rawio='yes'> > <source> > <adapter name='scsi_host0'/> > <address bus='0' target='0' unit='0'/> > </source> > <readonly/> > <address type='drive' controller='0' bus='0' target='0' unit='0'/> > </hostdev> > </devices>... as you've shown here is used. In such case we use 'host_device' even for cdroms. qemu only allows to use the 'host_device' protocol backend. The main difference is that for the emulation interface (<disk>) we use the block interface for the cdrom (/dev/sr0 for example). For hostdev we open the SCSI-generic interface which is a character device and is used to pass generic commads (/dev/sg0) I've originally attempted to change the way we open /dev/sg0 as you might know since you were CC'd on that thread, but testing actually proved that the above approach is correct, for scsi passthrough we don't need to treat the cdrom differently.
Greetings Peter,> Sent: Monday, November 02, 2020 at 4:20 PM > From: "Peter Krempa" <pkrempa@redhat.com> > To: "daggs" <daggs@gmx.com> > Cc: libvirt-users@redhat.com > Subject: Re: proper config for qemu's host_cdrom > > Note that all of the above is not "SCSI passthrough" but rather device > emulation backed with a real cdrom. This is fine if you want to use the > cdrom for block operations (reading) CDs. > > In that case qemu must use "host_cdrom" to provide functionality such as > eject. > > For true SCSI passtrhrough, when all commands are passed to the host > device (good also for other operations, e.g. writing CDs) > > For such operation the XML using <hostdev> ... > > ... as you've shown here is used. > > In such case we use 'host_device' even for cdroms. qemu only allows to > use the 'host_device' protocol backend. > > The main difference is that for the emulation interface (<disk>) we use > the block interface for the cdrom (/dev/sr0 for example). For hostdev we > open the SCSI-generic interface which is a character device and is used > to pass generic commads (/dev/sg0) > > I've originally attempted to change the way we open /dev/sg0 as you > might know since you were CC'd on that thread, but testing actually > proved that the above approach is correct, for scsi passthrough we don't > need to treat the cdrom differently. > >so host_device is the right way in this case? if so, any issues I see in the vm should be sent to qemu ml right? Dagg,