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

[libvirt] [PATCH 11/12] qemu: command: Move formatting of 'boot' attribute to -device



bootable flag is a property of the frontend thus should be formatted
with -device.

Note: The combination of capability flags basically mandates qemu
0.12.3 - 1.0.0, which I did not test.
---
 src/qemu/qemu_command.c                             | 21 +++++++++++----------
 .../qemuxml2argvdata/qemuxml2argv-boot-complex.args |  4 ++--
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 89bc41e468..08d96ef562 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1687,6 +1687,7 @@ qemuBuildDiskFrontendAttributeErrorPolicy(virDomainDiskDefPtr disk,
 static void
 qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
                                 virQEMUCapsPtr qemuCaps,
+                                int bootindex,
                                 virBufferPtr buf)
 {
     /* generate geometry command string */
@@ -1709,6 +1710,14 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
         virBufferEscape(buf, '\\', " ", "%s", disk->serial);
     }

+    if (bootindex &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
+        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) &&
+        (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
+         disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
+        disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
+        virBufferAddLit(buf, ",boot=on");
+
     qemuBuildDiskFrontendAttributeErrorPolicy(disk, qemuCaps, buf);
 }

@@ -1749,7 +1758,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
         virBufferAsprintf(&opt, "if=%s",
                           virDomainDiskQEMUBusTypeToString(disk->bus));
         virBufferAsprintf(&opt, ",index=%d", idx);
-        qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt);
+        qemuBuildDiskFrontendAttributes(disk, qemuCaps, bootindex, &opt);
     }

     if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
@@ -1764,14 +1773,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
         }
     }

-    if (bootindex &&
-        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
-        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) &&
-        (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
-         disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
-        disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
-        virBufferAddLit(&opt, ",boot=on");
-
     if (disk->src->readonly)
         virBufferAddLit(&opt, ",readonly=on");

@@ -2144,7 +2145,7 @@ qemuBuildDriveDevStr(const virDomainDef *def,
                               disk->blockio.physical_block_size);
     }

-    qemuBuildDiskFrontendAttributes(disk, qemuCaps, &opt);
+    qemuBuildDiskFrontendAttributes(disk, qemuCaps, bootindex, &opt);

     if (disk->wwn) {
         if (STRPREFIX(disk->wwn, "0x"))
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args
index b7a2fc119a..78d6d2745a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-complex.args
@@ -19,9 +19,9 @@ server,nowait \
 -no-acpi \
 -boot dnca \
 -usb \
--drive file=/tmp/vda.img,format=raw,if=none,id=drive-virtio-disk0,boot=on \
+-drive file=/tmp/vda.img,format=raw,if=none,id=drive-virtio-disk0 \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\
-id=virtio-disk0 \
+id=virtio-disk0,boot=on \
 -drive file=/tmp/vdb.img,format=raw,if=none,id=drive-virtio-disk1 \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,\
 id=virtio-disk1 \
-- 
2.14.3


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