[libvirt] [PATCH 1/2] qemu: add vhost-scsi-pci definitions

Nicholas A. Bellinger nab at linux-iscsi.org
Fri Jul 25 06:18:14 UTC 2014


On Thu, 2014-07-24 at 10:53 +0100, Daniel P. Berrange wrote:
> On Thu, Jul 24, 2014 at 08:25:59AM +0200, Paolo Bonzini wrote:
> > Il 24/07/2014 05:24, Nicholas A. Bellinger ha scritto:
> > > From: Mike Perez <thingee at gmail.com>
> > > 
> > > This patch adds the necessary definitions to support vhost-scsi-pci and
> > > VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VHOST_SCSI in QEMU >= v1.5.x code.
> > > 
> > > This includes:
> > > 
> > >   - Add QEMU_CAPS_VHOST_SCSI
> > >   - Add virDomainControllerDef->wwpn pointer for the vhost-scsi wwpn.
> > >   - Setting the new model type in qemuSetSCSIControllerModel()
> > >   - Invoking virDomainPCIAddressReserveAddr() for vhost-scsi-pci in
> > >     qemuAssignDevicePCISlots()
> > >   - Add the 'wwpn=' device parameter in qemuBuildControllerDevStr()
> > >   - Add vhost-scsi-pci to >= v1.5.x qemucapabilitiesdata
> > >   - Add xml2argv and xml2xml tests for cmd_per_lun + max_sectors +
> > >     num_queues + wwpn.
> > > 
> > > Signed-off-by: Mike Perez <thingee at gmail.com>
> > > Signed-off-by: Nicholas Bellinger <nab at linux-iscsi.org>
> > 
> > Configuration still has to go through configfs; I'm not sure how using <disk>
> > and vhost-scsi together makes sense:
> > 
> > +    <disk type='block' device='disk'>
> > +      <source dev='/dev/HostVG/QEMUGuest1'/>
> > +      <target dev='sdb' bus='scsi'/>
> > +      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
> > +    </disk>
> > +    <controller type='usb' index='0'/>
> > +    <controller type='scsi' index='0' model='vhost-scsi'>
> > +      <driver wwpn='naa.60014050a13df4f2'/>
> > +    </controller>
> > 
> > ...
> > 
> > +-device vhost-scsi-pci,id=scsi0,wwpn=naa.60014050a13df4f2 \
> > +-usb \
> > +-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
> > +-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
> > +drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
> > 
> > and I'm not sure even how it can work since vhost-scsi-pci doesn't expose
> > a QEMU SCSI bus.
> 
> Indeed, it doesn't seem to actually work. I have a vm where I'm
> using virtio-scsi, so I changed the model to vhost-scsi and added
> a random wwpn string (unclear if there's any rules for generating
> these wwpn strings?).
> 
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/data1.img'/>
>       <target dev='sda' bus='scsi'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
>     </disk>
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/data2.img'/>
>       <target dev='sda' bus='scsi'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='1'/>
>     </disk>
>     <disk type='file' device='disk'>
>       <driver name='qemu' type='raw'/>
>       <source file='/var/lib/libvirt/images/data3.img'/>
>       <target dev='sda' bus='scsi'/>
>       <address type='drive' controller='0' bus='0' target='0' unit='2'/>
>     </disk>
>     <controller type='scsi' index='0' model='vhost-scsi'>
>       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
>       <driver wwpn='naa.60014050a13df4f2'/>
>     </controller>
> 
> When I try to start the guest it fails to find the SCSI controller
> 
>   qemu-system-x86_64: -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,\
>   lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0: Bus 'scsi0.0' not found
> 

Thanks for the comments.

Dropping the disk virtio-scsi disk sections now.

> A further problem is that the QEMU process itself wants access to the
> /dev/vhost-scsi device, which it cannot have unless running as root,
> which is not something people will do in production. It also requires
> us to update the cgroups device ACL to allow access to the device and
> update the SELinux policy to allow access. It is unclear to me if it
> is safe to allow untrusted processes access to /dev/vhost-scsi device.
> With vhost-net, libvirt itself opens the /dev/vhost-net device and
> passes the pre-opened file descriptors down to QEMU, so the untrusted
> processes never access the device directly, which I think is a better
> model that we use quite alot in QEMU.
> 

Yes.

Patch #2 attempts to follow what vhost-net currently does wrt opening
and passing FDs into QEMU monitor, and utilizes existing vhostfd=
parameter logic for passing active FDs into QEMU for this case.

--nab




More information about the libvir-list mailing list