mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 14:09:22 +00:00
conf: Introduce 'effectiveBootIndex' into 'virDomainDeviceInfo'
'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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
1419044940
commit
aee82fe616
@ -149,6 +149,10 @@ struct _virDomainDeviceInfo {
|
|||||||
/* bootIndex is only used for disk, network interface, hostdev
|
/* bootIndex is only used for disk, network interface, hostdev
|
||||||
* and redirdev devices */
|
* and redirdev devices */
|
||||||
unsigned int bootIndex;
|
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
|
/* Valid for any PCI device. Can be used for NIC to get
|
||||||
* stable numbering in Linux */
|
* stable numbering in Linux */
|
||||||
unsigned int acpiIndex;
|
unsigned int acpiIndex;
|
||||||
|
@ -6498,6 +6498,8 @@ virDomainDeviceBootParseXML(xmlNodePtr node,
|
|||||||
&info->bootIndex) < 0)
|
&info->bootIndex) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
info->effectiveBootIndex = info->bootIndex;
|
||||||
|
|
||||||
loadparm = virXMLPropString(node, "loadparm");
|
loadparm = virXMLPropString(node, "loadparm");
|
||||||
if (loadparm) {
|
if (loadparm) {
|
||||||
if (virStringToUpper(&info->loadparm, loadparm) != 1) {
|
if (virStringToUpper(&info->loadparm, loadparm) != 1) {
|
||||||
|
@ -1869,7 +1869,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
virDomainDiskDef *disk,
|
virDomainDiskDef *disk,
|
||||||
virQEMUCaps *qemuCaps)
|
virQEMUCaps *qemuCaps)
|
||||||
{
|
{
|
||||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
|
||||||
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) opt = VIR_BUFFER_INITIALIZER;
|
||||||
const char *contAlias;
|
const char *contAlias;
|
||||||
g_autofree char *backendAlias = NULL;
|
g_autofree char *backendAlias = NULL;
|
||||||
@ -2072,8 +2071,8 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
|
|||||||
virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
|
virBufferAsprintf(&opt, ",id=%s", disk->info.alias);
|
||||||
/* bootindex for floppies is configured via the fdc controller */
|
/* bootindex for floppies is configured via the fdc controller */
|
||||||
if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
if (disk->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY &&
|
||||||
diskPriv->effectiveBootindex > 0)
|
disk->info.effectiveBootIndex > 0)
|
||||||
virBufferAsprintf(&opt, ",bootindex=%u", diskPriv->effectiveBootindex);
|
virBufferAsprintf(&opt, ",bootindex=%u", disk->info.effectiveBootIndex);
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKIO)) {
|
||||||
if (disk->blockio.logical_block_size > 0)
|
if (disk->blockio.logical_block_size > 0)
|
||||||
virBufferAsprintf(&opt, ",logical_block_size=%u",
|
virBufferAsprintf(&opt, ",logical_block_size=%u",
|
||||||
@ -2187,7 +2186,6 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
|
|||||||
g_autofree char *backendStr = NULL;
|
g_autofree char *backendStr = NULL;
|
||||||
g_autofree char *bootindexStr = NULL;
|
g_autofree char *bootindexStr = NULL;
|
||||||
virDomainDiskDef *disk = def->disks[i];
|
virDomainDiskDef *disk = def->disks[i];
|
||||||
qemuDomainDiskPrivate *diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
|
||||||
|
|
||||||
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
|
if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
|
||||||
continue;
|
continue;
|
||||||
@ -2199,9 +2197,9 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
|
|||||||
else
|
else
|
||||||
driveLetter = 'A';
|
driveLetter = 'A';
|
||||||
|
|
||||||
if (diskPriv->effectiveBootindex > 0)
|
if (disk->info.effectiveBootIndex > 0)
|
||||||
bootindexStr = g_strdup_printf("bootindex%c=%u", driveLetter,
|
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 */
|
/* with -blockdev we setup the floppy device and it's backend with -device */
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
|
||||||
|
@ -270,10 +270,6 @@ struct _qemuDomainDiskPrivate {
|
|||||||
char *qomName; /* QOM path of the disk (also refers to the block backend) */
|
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 */
|
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
|
bool transientOverlayCreated; /* the overlay image of a transient disk was
|
||||||
created and the definition was updated */
|
created and the definition was updated */
|
||||||
};
|
};
|
||||||
|
@ -6271,6 +6271,9 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def)
|
|||||||
unsigned int bootFloppy = 0;
|
unsigned int bootFloppy = 0;
|
||||||
unsigned int bootDisk = 0;
|
unsigned int bootDisk = 0;
|
||||||
|
|
||||||
|
if (def->os.nBootDevs == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < def->os.nBootDevs; i++) {
|
for (i = 0; i < def->os.nBootDevs; i++) {
|
||||||
switch ((virDomainBootOrder) def->os.bootDevs[i]) {
|
switch ((virDomainBootOrder) def->os.bootDevs[i]) {
|
||||||
case VIR_DOMAIN_BOOT_CDROM:
|
case VIR_DOMAIN_BOOT_CDROM:
|
||||||
@ -6295,27 +6298,21 @@ qemuProcessPrepareDomainDiskBootorder(virDomainDef *def)
|
|||||||
|
|
||||||
for (i = 0; i < def->ndisks; i++) {
|
for (i = 0; i < def->ndisks; i++) {
|
||||||
virDomainDiskDef *disk = def->disks[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) {
|
switch (disk->device) {
|
||||||
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
||||||
diskPriv->effectiveBootindex = bootCD;
|
disk->info.effectiveBootIndex = bootCD;
|
||||||
bootCD = 0;
|
bootCD = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
||||||
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
case VIR_DOMAIN_DISK_DEVICE_LUN:
|
||||||
diskPriv->effectiveBootindex = bootDisk;
|
disk->info.effectiveBootIndex = bootDisk;
|
||||||
bootDisk = 0;
|
bootDisk = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
diskPriv->effectiveBootindex = bootFloppy;
|
disk->info.effectiveBootIndex = bootFloppy;
|
||||||
bootFloppy = 0;
|
bootFloppy = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user