[PATCH 5/6] qemu: add usb-scsi controller checking when building drive commandline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



libvirt XML snip
 <devices>
   <disk type='file' device='disk'>
     <driver name='qemu' type='raw'/>
     <source file='/var/lib/libvirt/images/seconddisk'/>
     <target dev='sdb' bus='scsi'/>
     <address type='drive' controller='0' bus='0' target='0' unit='1'/>
   </disk>
   <controller type='usb' index='2' model='ehci'>
   <controller type='scsi' index='0' model='usb-scsi'>
     <address type='usb' bus='2' port='1'/>
   </controller>
 </devices>

When a scsi disk is attached to usb-scsi controller, the target
id must 0(usb-scsi only provide one scsi target). The unit value
must in range of 0~255 for its lun number.
---
 src/qemu/qemu_command.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d459be0..dc86071 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2767,6 +2767,21 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
                 virBufferAddLit(&opt, "scsi-block");
             }
 
+            if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_UAS) {
+                if (disk->info.addr.drive.target != 0) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("Disk target must be 0 for usb-scsi controller"));
+                    goto error;
+                }
+
+                if (disk->info.addr.drive.unit & ~0xff) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("Disk unit must be less than 256 "
+                                     "for usb-scsi controller"));
+                    goto error;
+                }
+            }
+
             virBufferAsprintf(&opt, ",bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d",
                               disk->info.addr.drive.controller,
                               disk->info.addr.drive.bus,
-- 
1.7.11.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]