Propagate the raw bootindex and let the code decide whether to use it
when formatting.
---
src/qemu/qemu_command.c | 16 +++++++---------
src/qemu/qemu_command.h | 2 +-
src/qemu/qemu_hotplug.c | 2 +-
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 03a2e6855a..89bc41e468 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1716,7 +1716,7 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,
char *
qemuBuildDriveStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg,
- bool bootable,
+ int bootindex,
virQEMUCapsPtr qemuCaps)
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
@@ -1764,12 +1764,14 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
}
}
- if (bootable &&
+ 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");
@@ -2219,7 +2221,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
for (i = 0; i < def->ndisks; i++) {
char *optstr;
unsigned int bootindex = 0;
- bool driveBoot = false;
virDomainDiskDefPtr disk = def->disks[i];
qemuDomainStorageSourcePrivatePtr srcPriv =
QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
qemuDomainSecretInfoPtr secinfo = NULL;
@@ -2248,10 +2249,6 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
bootDisk = 0;
break;
}
- if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
- driveBoot = !!bootindex;
- bootindex = 0;
- }
}
if (qemuBuildDiskSecinfoCommandLine(cmd, secinfo) < 0)
@@ -2266,7 +2263,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
virCommandAddArg(cmd, "-drive");
- if (!(optstr = qemuBuildDriveStr(disk, cfg, driveBoot, qemuCaps)))
+ if (!(optstr = qemuBuildDriveStr(disk, cfg, bootindex, qemuCaps)))
return -1;
virCommandAddArg(cmd, optstr);
@@ -2287,7 +2284,8 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd,
}
VIR_FREE(optstr);
- if (bootindex) {
+ if (bootindex &&
+ virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX)) {
if (virAsprintf(&optstr, "bootindex%c=%u",
disk->info.addr.drive.unit
? 'B' : 'A',
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 2bcfc6c707..e60245427a 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -102,7 +102,7 @@ char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk);
/* Both legacy & current support */
char *qemuBuildDriveStr(virDomainDiskDefPtr disk,
virQEMUDriverConfigPtr cfg,
- bool bootable,
+ int bootindex,
virQEMUCapsPtr qemuCaps);
/* Current, best practice */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 72a57d89ed..5c8054f72d 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -409,7 +409,7 @@ qemuDomainAttachDiskGeneric(virConnectPtr conn,
disk->info.alias) < 0)
goto error;
- if (!(drivestr = qemuBuildDriveStr(disk, cfg, false, priv->qemuCaps)))
+ if (!(drivestr = qemuBuildDriveStr(disk, cfg, 0, priv->qemuCaps)))
goto error;
if (!(drivealias = qemuAliasFromDisk(disk)))
--
2.14.3