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

[libvirt] [PATCH 13/13] qemu: allow bus != 0 for scsi-disk when -device is used



All the way back at the end of 2009, commit d78554d8 added a check
that prevented scsi disks from having a bus != 0 due to problems that
caused (noted in the comments). At that time, -device wasn't supported
by qemu, so the -drive parameter had to identify each disk by bus
type (the "if" option), bus#, and unit#.

Since that time qemu has added the ability to provide such details
about a disk in a -device parameter, which will contain an id, and
that id can be referenced in -drive rather than giving
type/bus/unit. Since no bus= option is present in the -drive string in
this case, the problem with a non-0 bus is presumably no longer
present, so this patch makes the restriction active only when -device
isn't used.

qemuxml2argv-disk-scsi-lun-passthrough has been modified to set non-0
buses to assure that the restriction is no longer valid.
---
 src/qemu/qemu_command.c                                     | 13 +++++++++----
 .../qemuxml2argv-disk-scsi-lun-passthrough.args             | 12 ++++++------
 .../qemuxml2argv-disk-scsi-lun-passthrough.xml              |  4 ++--
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 12de4ca..260a468 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3546,10 +3546,15 @@ qemuBuildDriveStr(virConnectPtr conn,
             goto error;
         }
 
-        /* Setting bus= attr for SCSI drives, causes a controller
-         * to be created. Yes this is slightly odd. It is not possible
-         * to have > 1 bus on a SCSI controller (yet). */
-        if (disk->info.addr.drive.bus != 0) {
+        /* Setting bus= attr (only happens when *not* using -device to
+         * specify the other half of the disk device) for SCSI drives,
+         * causes a controller to be created. Yes this is slightly
+         * odd. And it means that is not possible to have > 1 bus on a
+         * SCSI controller unless -device is supported/used (at this
+         * point only very old qemu binaries don't support
+         * -device). */
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
+            disk->info.addr.drive.bus != 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            "%s", _("SCSI controller only supports 1 bus"));
             goto error;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.args
index e1dfc1a..739ceb4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.args
@@ -5,10 +5,10 @@ pc -m 214 -smp 1 -nographic -nodefaults \
 -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \
 -device lsi,id=scsi1,bus=pci.0,addr=0x4 \
 -usb \
--drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
--device scsi-block,channel=0,bus=scsi0.0,scsi-id=0,lun=0,\
-drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
--drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-0-1-1 \
--device scsi-block,channel=0,bus=scsi0.0,scsi-id=1,lun=1,\
-drive=drive-scsi0-0-1-1,id=scsi0-0-1-1 \
+-drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-1-0-0 \
+-device scsi-block,channel=1,bus=scsi0.0,scsi-id=0,lun=0,\
+drive=drive-scsi0-1-0-0,id=scsi0-1-0-0 \
+-drive file=/dev/HostVG/QEMUGuest2,if=none,id=drive-scsi0-2-1-1 \
+-device scsi-block,channel=2,bus=scsi0.0,scsi-id=1,lun=1,\
+drive=drive-scsi0-2-1-1,id=scsi0-2-1-1 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.xml
index 3858ede..84dd12e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-lun-passthrough.xml
@@ -17,12 +17,12 @@
     <disk type='block' device='lun'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='scsi'/>
-      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
     </disk>
     <disk type='block' device='lun'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
       <target dev='hdb' bus='scsi'/>
-      <address type='drive' controller='0' bus='0' target='1' unit='1'/>
+      <address type='drive' controller='0' bus='2' target='1' unit='1'/>
     </disk>
     <controller type='scsi' index='0' model='virtio-scsi'/>
     <controller type='scsi' index='1' model='lsilogic'/>
-- 
2.1.0


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