'effectiveBootIndex' is a copy of 'bootIndex' if '<boot order='
was
present and left unassigned if not. This allows hypervisor drivers to
reinterpret <os><boot> without being visible in the XML.
QEMU driver had a internal implementation for disks, which is now
replaced. Additionally this will simplify a refactor of network boot
assignment.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/conf/device_conf.h | 4 ++++
src/conf/domain_conf.c | 2 ++
src/qemu/qemu_command.c | 10 ++++------
src/qemu/qemu_domain.h | 4 ----
src/qemu/qemu_process.c | 15 ++++++---------
5 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index 09ef5dda92..d118966379 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -149,6 +149,10 @@ struct _virDomainDeviceInfo {
/* bootIndex is only used for disk, network interface, hostdev
* and redirdev devices */
unsigned int bootIndex;
+ /* 'effectiveBootIndex' is same as 'bootIndex' (if provided in the
XML) but
+ * not formatted back. This allows HV drivers to update it if <os><boot ..
+ * is present. */
+ unsigned int effectiveBootIndex;
/* Valid for any PCI device. Can be used for NIC to get
* stable numbering in Linux */
unsigned int acpiIndex;
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b8370f6950..6b89b9404c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6492,6 +6492,8 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
&info->bootIndex) < 0)
return -1;
+ info->effectiveBootIndex = info->bootIndex;
+
loadparm = virXMLPropString(node, "loadparm");
if (loadparm) {
if (virStringToUpper(&info->loadparm, loadparm) != 1) {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dc3320ba9a..07a8f104f4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1862,7 +1862,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
virDomainDiskDef *disk,
virQEMUCaps *qemuCaps)
{
- qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
const char *contAlias;
g_autofree char *backendAlias = NULL;
@@ -2065,8 +2064,8 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
/* 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);
+ disk->info.effectiveBootIndex > 0)
+ virBufferAsprintf(&opt, ",bootindex=%u",
disk->info.effectiveBootIndex);
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
if (disk->blockio.logical_block_size > 0)
virBufferAsprintf(&opt, ",logical_block_size=%u",
@@ -2180,7 +2179,6 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
g_autofree char *backendStr = NULL;
g_autofree char *bootindexStr = NULL;
virDomainDiskDef *disk = def->disks[i];
- qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
continue;
@@ -2192,9 +2190,9 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
else
driveLetter = 'A';
- if (diskPriv->effectiveBootindex > 0)
+ if (disk->info.effectiveBootIndex > 0)
bootindexStr = g_strdup_printf("bootindex%c=%u", driveLetter,
- diskPriv->effectiveBootindex);
+ disk->info.effectiveBootIndex);
/* with -blockdev we setup the floppy device and it's backend with -device
*/
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 31971e29ac..9cf5d5479e 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -270,10 +270,6 @@ struct _qemuDomainDiskPrivate {
char *qomName; /* QOM path of the disk (also refers to the block backend) */
char *nodeCopyOnRead; /* nodename of the disk-wide copy-on-read blockdev layer */
- unsigned int effectiveBootindex; /* boot index of the disk based on one
- of the two ways we use to select a boot
- device */
-
bool transientOverlayCreated; /* the overlay image of a transient disk was
created and the definition was updated */
};
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 09a2ff8ef2..f5c28ed4bf 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6271,6 +6271,9 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def)
unsigned int bootFloppy = 0;
unsigned int bootDisk = 0;
+ if (def->os.nBootDevs == 0)
+ return;
+
for (i = 0; i < def->os.nBootDevs; i++) {
switch ((virDomainBootOrder) def->os.bootDevs[i]) {
case VIR_DOMAIN_BOOT_CDROM:
@@ -6295,27 +6298,21 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def)
for (i = 0; i < def->ndisks; i++) {
virDomainDiskDef *disk = def->disks[i];
- qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
-
- if (disk->info.bootIndex > 0) {
- diskPriv->effectiveBootindex = disk->info.bootIndex;
- continue;
- }
switch (disk->device) {
case VIR_DOMAIN_DISK_DEVICE_CDROM:
- diskPriv->effectiveBootindex = bootCD;
+ disk->info.effectiveBootIndex = bootCD;
bootCD = 0;
break;
case VIR_DOMAIN_DISK_DEVICE_DISK:
case VIR_DOMAIN_DISK_DEVICE_LUN:
- diskPriv->effectiveBootindex = bootDisk;
+ disk->info.effectiveBootIndex = bootDisk;
bootDisk = 0;
break;
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
- diskPriv->effectiveBootindex = bootFloppy;
+ disk->info.effectiveBootIndex = bootFloppy;
bootFloppy = 0;
break;
--
2.31.1