We can skip the formatting of the bootindex for floppies directly at the
place where it's being formatted.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_command.c | 23 ++++++++---------------
src/qemu/qemu_command.h | 1 -
src/qemu/qemu_hotplug.c | 2 +-
3 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b01421f61b..200f9a04b1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1659,9 +1659,9 @@ qemuBuildDriveDevCacheStr(virDomainDiskDef *disk,
char *
qemuBuildDiskDeviceStr(const virDomainDef *def,
virDomainDiskDef *disk,
- unsigned int bootindex,
virQEMUCaps *qemuCaps)
{
+ qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
const char *contAlias;
g_autofree char *backendAlias = NULL;
@@ -1876,8 +1876,10 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
}
virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
- if (bootindex)
- virBufferAsprintf(&opt, ",bootindex=%u", bootindex);
+ /* bootindex for floppies is configured via the fdc controller */
+ if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
+ diskPriv->effectiveBootindex > 0)
+ virBufferAsprintf(&opt, ",bootindex=%u",
diskPriv->effectiveBootindex);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
if (disk->blockio.logical_block_size > 0)
virBufferAsprintf(&opt, ",logical_block_size=%u",
@@ -2164,8 +2166,7 @@ static int
qemuBuildDiskCommandLine(virCommand *cmd,
const virDomainDef *def,
virDomainDiskDef *disk,
- virQEMUCaps *qemuCaps,
- unsigned int bootindex)
+ virQEMUCaps *qemuCaps)
{
g_autofree char *optstr = NULL;
@@ -2188,8 +2189,7 @@ qemuBuildDiskCommandLine(virCommand *cmd,
virCommandAddArg(cmd, "-device");
- if (!(optstr = qemuBuildDiskDeviceStr(def, disk, bootindex,
- qemuCaps)))
+ if (!(optstr = qemuBuildDiskDeviceStr(def, disk, qemuCaps)))
return -1;
virCommandAddArg(cmd, optstr);
@@ -2213,15 +2213,8 @@ qemuBuildDisksCommandLine(virCommand *cmd,
for (i = 0; i < def->ndisks; i++) {
virDomainDiskDef *disk = def->disks[i];
- qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
- unsigned int bootindex = 0;
-
- /* The floppy device itself does not support the bootindex property
- * so we need to set it up for the controller */
- if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY)
- bootindex = diskPriv->effectiveBootindex;
- if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps, bootindex) < 0)
+ if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps) < 0)
return -1;
}
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 4f1d2bf755..188e63ea1f 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -146,7 +146,6 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop(virStorageSource
*top,
char
*qemuBuildDiskDeviceStr(const virDomainDef *def,
virDomainDiskDef *disk,
- unsigned int bootindex,
virQEMUCaps *qemuCaps);
/* Current, best practice */
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a64cddb9e7..7a1b413be0 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -734,7 +734,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
goto cleanup;
}
- if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCaps)))
+ if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)))
goto cleanup;
VIR_REALLOC_N(vm->def->disks, vm->def->ndisks + 1);
--
2.31.1