]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce qemuDiskBusNeedsDeviceArg
authorJán Tomko <jtomko@redhat.com>
Thu, 19 May 2016 18:40:00 +0000 (20:40 +0200)
committerJán Tomko <jtomko@redhat.com>
Fri, 20 May 2016 07:03:42 +0000 (09:03 +0200)
Replace the two uses of the withDeviceArg bool in
qemuBuildDiskDriveCommandLine and allow this function to be reused in
qemuBuildDriveStr.

src/qemu/qemu_command.c

index c0d11b2d654fab56c6e5dc8506ade28b044949b2..75bd4b76089317ba6fb61d59289fbed64cce9546 100644 (file)
@@ -1080,6 +1080,18 @@ qemuCheckFips(void)
 }
 
 
+/* Unfortunately it is not possible to use
+   -device for floppies, or SD
+   devices. Fortunately, those don't need
+   static PCI addresses, so we don't really
+   care that we can't use -device */
+static bool
+qemuDiskBusNeedsDeviceArg(int bus)
+{
+    return bus != VIR_DOMAIN_DISK_BUS_SD;
+}
+
+
 char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
                   bool bootable,
@@ -1904,7 +1916,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
         char *optstr;
         unsigned int bootindex = 0;
         virDomainDiskDefPtr disk = def->disks[i];
-        bool withDeviceArg = false;
         bool deviceFlagMasked = false;
 
         /* PowerPC pseries based VMs do not support floppy device */
@@ -1934,14 +1945,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
 
         virCommandAddArg(cmd, "-drive");
 
-        /* Unfortunately it is not possible to use
-           -device for floppies, or SD
-           devices. Fortunately, those don't need
-           static PCI addresses, so we don't really
-           care that we can't use -device */
-        if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) {
-            withDeviceArg = true;
-        } else {
+        if (!qemuDiskBusNeedsDeviceArg(disk->bus)) {
             virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE);
             deviceFlagMasked = true;
         }
@@ -1960,7 +1964,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
         else if (disk->info.bootIndex)
             bootindex = disk->info.bootIndex;
 
-        if (withDeviceArg) {
+        if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
             if (disk->bus == VIR_DOMAIN_DISK_BUS_FDC) {
                 if (virAsprintf(&optstr, "drive%c=drive-%s",
                                 disk->info.addr.drive.unit ? 'B' : 'A',