[PATCH V3 0/7] qemu: support updating device's bootindex

Support updating device's(support cdrom, disk and network) bootindex online in virDomainUpdateDeviceFlags. The new bootindex will take effect after guest rebooting. Enable bootindex can be set to 0, it means cancel the device's bootindex. To use this feature, we need to get the device's xml first and modify the boot order in the xml, then use 'virsh update-device <domain> <xml> --flag' to update the bootindex. Note that the flag should be --config or --persistent if the vm is running. Jiang Jiacheng (7): qemu: Introduce qemuDomainChangeBootIndex to update device's bootindex qemu: Marking a device's bootindex can be changed qemu: check the bootIndex could be changed or not qemu: Support update disk's bootindex qemu: Support update net's bootindex qemu: Support set bootindex to 0 to cancel bootindex setting test: add a test for bootIndex = 0 provided by the user diff to v2: * improve function description and commit message * move functions in qemu_conf.c to qemu_domain.c * add a test for bootindex = 0 provided by user * fix a bug in logical of checking bootindex src/conf/device_conf.h | 3 + src/conf/domain_conf.c | 10 ++- src/conf/domain_postparse.c | 8 ++- src/conf/schemas/domaincommon.rng | 2 +- src/qemu/qemu_conf.c | 41 +++++++++++ src/qemu/qemu_conf.h | 5 ++ src/qemu/qemu_domain.c | 69 +++++++++++++++++- src/qemu/qemu_domain.h | 9 +++ src/qemu/qemu_driver.c | 32 +++++++++ src/qemu/qemu_hotplug.c | 17 +++-- src/qemu/qemu_monitor.c | 12 ++++ src/qemu/qemu_monitor.h | 6 ++ src/qemu/qemu_monitor_json.c | 22 ++++++ src/qemu/qemu_monitor_json.h | 6 ++ tests/qemuxml2argvdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmloutdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 17 files changed, 376 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/boot-order-set-0.xml create mode 100644 tests/qemuxml2xmloutdata/boot-order-set-0.xml -- 2.33.0

Introduce qemuDomainChangeBootIndex to support update device's bootindex. These function will be used in following patches to support change device's (support cdrom, disk and net) bootindex with virsh command like 'virsh update-device <domain> <file> [--flag]'. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_conf.c | 41 ++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_monitor.c | 12 +++++++++++ src/qemu/qemu_monitor.h | 6 ++++++ src/qemu/qemu_monitor_json.c | 22 +++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 ++++++ 6 files changed, 92 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index ae5bbcd138..601357a7ee 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1641,3 +1641,44 @@ qemuHugepageMakeBasedir(virQEMUDriver *driver, return 0; } + +/** + * qemuDomainChangeBootIndex: + * @vm: domain object + * @devInfo: origin device info + * @newBootIndex: new bootIndex + * + * Update the bootIndex of @devInfo with @newBootIndex. Only the devices + * whose bootIndexSpecified = true can be updated with @newBootIndex. + * BootIndex of 0 means cancel the bootindex setting of @devInfo. + * + */ +int +qemuDomainChangeBootIndex(virDomainObj *vm, + virDomainDeviceInfo *devInfo, + int newBootIndex) +{ + int ret = -1; + qemuDomainObjPrivate *priv = vm->privateData; + + if (!devInfo->alias) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("cannot change boot index: device alias not found")); + return -1; + } + + VIR_DEBUG("Change dev: %s boot index from %d to %d", devInfo->alias, + devInfo->bootIndex, newBootIndex); + + /* qemu dosen't support multiple bootIndex = 0 and need a negative bootIndex + * to delete the device from fw_boot_order. So transmit -1 to qemu when setting + * bootIndex = 0 to cancel the bootIndex setting. */ + if (newBootIndex == 0) + newBootIndex = -1; + + qemuDomainObjEnterMonitor(vm); + ret = qemuMonitorSetBootIndex(priv->mon, devInfo->alias, newBootIndex); + qemuDomainObjExitMonitor(vm); + + return ret; +} diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 8cf2dd2ec5..e7447191df 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -375,3 +375,8 @@ int qemuGetMemoryBackingPath(virQEMUDriver *driver, int qemuHugepageMakeBasedir(virQEMUDriver *driver, virHugeTLBFS *hugepage); + +int qemuDomainChangeBootIndex(virDomainObj *vm, + virDomainDeviceInfo *devInfo, + int newBootIndex) + ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 734364e070..7866347564 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4493,3 +4493,15 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr, return NULL; } + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) +{ + VIR_DEBUG("name=%s, bootIndex=%d", alias, bootIndex); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONSetBootIndex(mon, alias, bootIndex); +} diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 906a919f52..fab6f7bcbf 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1569,3 +1569,9 @@ qemuMonitorExtractQueryStats(virJSONValue *info); virJSONValue * qemuMonitorGetStatsByQOMPath(virJSONValue *arr, char *qom_path); + +int +qemuMonitorSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9822097bd7..39a84c8ae6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8859,3 +8859,25 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, return virJSONValueObjectStealArray(reply, "return"); } + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) +{ + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; + + if (!(cmd = qemuMonitorJSONMakeCommand("qom-set", "s:path", alias, + "s:property", "bootindex", + "i:value", bootIndex, NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 484cb09830..00c04e62d1 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -825,3 +825,9 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon, qemuMonitorQueryStatsTargetType target, char **vcpus, GPtrArray *providers); + +int +qemuMonitorJSONSetBootIndex(qemuMonitor *mon, + const char *alias, + int bootIndex) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -- 2.33.0

We explicitly specify the boot order of some device in XML file to get the desired boot order, just like: <disk type='block' device='disk'> ... <boot order='1'/> ... </disk> Those devices are considered to be able to change the bootindex by the following patches. To distinguish those devices from others, we add a bool bootIndexSpecified into _virDomainDeviceInfo, which means the device's bootindex is specified in domain's XML file and can be changed after.BootIndexSpecified will be set to true only if the device's bootindex is set in XML. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/conf/device_conf.h | 3 +++ src/conf/domain_conf.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index f2907dc596..5259e25c10 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -144,6 +144,9 @@ struct _virDomainDeviceInfo { * not formatted back. This allows HV drivers to update it if <os><boot .. * is present. */ unsigned int effectiveBootIndex; + /* bootIndexSpecified is set to true when device's bootIndex is provided in + * the XML. This allows changing bootIndex online of some devices. */ + bool bootIndexSpecified; /* 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 6c088ff295..7f045b0d4a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5314,6 +5314,7 @@ virDomainDeviceBootParseXML(xmlNodePtr node, return -1; info->effectiveBootIndex = info->bootIndex; + info->bootIndexSpecified = true; loadparm = virXMLPropString(node, "loadparm"); if (loadparm) { -- 2.33.0

Introduce qemuCheckBootIndex to check whether the device's bootIndex can be changed or need to be changed. Only bootindex of devices whose bootIndexSpecified is true can be changed. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_domain.c | 32 ++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5c05032ce3..6ec3be14c0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -12277,3 +12277,35 @@ qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv) priv->schedCoreChildPID = -1; } } + +/** + * qemuCheckBootIndex: + * @devInfo: origin device info + * @new_bootindex: new bootIndex + * + * Check whether the device's bootIndex can be changed or need to + * be changed. Only devices with bootIndex specified before can be + * changed with @new_bootindex. + * + * Returns: 1 on need to change + * 0 on no need to change + * -1 on could not change with an error + */ +int +qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex) +{ + if (new_bootindex && !devInfo->bootIndexSpecified) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("this device does not set boot index, cannot change it.")); + return -1; + } + + /* if the new bootindex is different from the old bootindex, + * we will update the bootindex. */ + if (devInfo->bootIndex != new_bootindex) { + return 1; + } + + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 2f027fad87..5869771a0d 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1140,3 +1140,7 @@ qemuDomainSchedCoreStart(virQEMUDriverConfig *cfg, void qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv); + +int +qemuCheckBootIndex(virDomainDeviceInfo *devInfo, + const int new_bootindex); -- 2.33.0

Support to update the disk's bootindex using 'virsh update-device'. Using flag --config or --persistent to change the boot index and the change will be affected after reboot. With --persistent, we can get the result of change immediently, but it still takes effect after reboot. Currently, support update bootindex of disk type as cdrom or disk. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_domain.c | 37 ++++++++++++++++++++++++++++++++++++- src/qemu/qemu_domain.h | 5 +++++ src/qemu/qemu_driver.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6ec3be14c0..dfc4d15387 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -8235,7 +8235,8 @@ qemuDomainDiskChangeSupported(virDomainDiskDef *disk, /* device alias is checked already in virDomainDefCompatibleDevice */ - CHECK_EQ(info.bootIndex, "boot order", true); + if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) + CHECK_EQ(info.bootIndex, "boot order", true); CHECK_EQ(rawio, "rawio", true); CHECK_EQ(sgio, "sgio", true); CHECK_EQ(discard, "discard", true); @@ -12309,3 +12310,37 @@ qemuCheckBootIndex(virDomainDeviceInfo *devInfo, return 0; } + +/** + * qemuChangeDiskBootIndex: + * @vm: domain object + * @orig_disk: the origin disk + * @disk: the new disk to be updated to + * + * check device's type and if its type support update bootIndex, update it. + * + */ +int +qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk) +{ + switch (disk->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + if (qemuDomainChangeBootIndex(vm, &orig_disk->info, + disk->info.bootIndex) < 0) + return -1; + + orig_disk->info.bootIndex = disk->info.bootIndex; + break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The boot index of disk bus '%s' cannot be changed."), + virDomainDiskBusTypeToString(disk->bus)); + return -1; + } + return 0; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 5869771a0d..da661d11da 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1144,3 +1144,8 @@ qemuDomainSchedCoreStop(qemuDomainObjPrivate *priv); int qemuCheckBootIndex(virDomainDeviceInfo *devInfo, const int new_bootindex); + +int +qemuChangeDiskBootIndex(virDomainObj *vm, + virDomainDiskDef *orig_disk, + virDomainDiskDef *disk); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d509582719..d5fa9c022c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6795,6 +6795,7 @@ qemuDomainChangeDiskLive(virDomainObj *vm, virDomainDiskDef *orig_disk = NULL; virDomainStartupPolicy origStartupPolicy; virDomainDeviceDef oldDev = { .type = dev->type }; + int needChangeIndex = 0; if (!(orig_disk = virDomainDiskByTarget(vm->def, disk->dst))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -6812,6 +6813,10 @@ qemuDomainChangeDiskLive(virDomainObj *vm, if (!qemuDomainDiskChangeSupported(disk, orig_disk)) return -1; + if ((needChangeIndex = qemuCheckBootIndex(&orig_disk->info, + disk->info.bootIndex)) < 0) + return -1; + if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) { /* Disk source can be changed only for removable devices */ if (disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM && @@ -6835,6 +6840,11 @@ qemuDomainChangeDiskLive(virDomainObj *vm, dev->data.disk->src = NULL; } + if (needChangeIndex) { + if (qemuChangeDiskBootIndex(vm, orig_disk, disk) < 0) + return -1; + } + /* in case when we aren't updating disk source we update startup policy here */ orig_disk->startupPolicy = dev->data.disk->startupPolicy; orig_disk->snapshot = dev->data.disk->snapshot; @@ -7531,6 +7541,24 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, false) < 0) return -1; + switch (vmdef->disks[pos]->device) { + case VIR_DOMAIN_DISK_DEVICE_CDROM: + case VIR_DOMAIN_DISK_DEVICE_DISK: + case VIR_DOMAIN_DISK_DEVICE_LUN: + if (qemuCheckBootIndex(&vmdef->disks[pos]->info, + newDisk->info.bootIndex) < 0) + return -1; + break; + case VIR_DOMAIN_DISK_DEVICE_FLOPPY: + case VIR_DOMAIN_DISK_DEVICE_LAST: + if ((newDisk->info.bootIndex) && + (vmdef->disks[pos]->info.bootIndex != newDisk->info.bootIndex)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("this disk doesn't support update")); + return -1; + } + } + virDomainDiskDefFree(vmdef->disks[pos]); vmdef->disks[pos] = newDisk; dev->data.disk = NULL; -- 2.33.0

Support to update the net's bootindex using 'virsh update-device'. Using flag --config or --persistent to change the boot index and the change will be affected after reboot. With --persistent, we can get the result of change immediently, but it still takes effect after reboot. Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/qemu/qemu_driver.c | 4 ++++ src/qemu/qemu_hotplug.c | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d5fa9c022c..633abdcbca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7596,6 +7596,10 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, false) < 0) return -1; + if (qemuCheckBootIndex(&vmdef->nets[pos]->info, + net->info.bootIndex) < 0) + return -1; + if (virDomainNetUpdate(vmdef, pos, net)) return -1; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6e300f547c..af0cec3c46 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3468,6 +3468,7 @@ qemuDomainChangeNet(virQEMUDriver *driver, bool needCoalesceChange = false; bool needVlanUpdate = false; bool needIsolatedPortChange = false; + int needChangeIndex = 0; int ret = -1; int changeidx = -1; g_autoptr(virConnect) conn = NULL; @@ -3633,11 +3634,8 @@ qemuDomainChangeNet(virQEMUDriver *driver, goto cleanup; } - if (newdev->info.bootIndex == 0) - newdev->info.bootIndex = olddev->info.bootIndex; - if (olddev->info.bootIndex != newdev->info.bootIndex) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot modify network device boot index setting")); + if ((needChangeIndex = qemuCheckBootIndex(&olddev->info, + newdev->info.bootIndex)) < 0) { goto cleanup; } @@ -3918,6 +3916,15 @@ qemuDomainChangeNet(virQEMUDriver *driver, needReplaceDevDef = true; } + if (needChangeIndex) { + if (qemuDomainChangeBootIndex(vm, &olddev->info, newdev->info.bootIndex) < 0) + goto cleanup; + /* we successfully switched to the new boot index, and we've + * determined that the rest of newdev is equivalent to olddev, + * so move newdev into place */ + needReplaceDevDef = true; + } + if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in * the domain's nets list. -- 2.33.0

Support set bootindex to 0, which means cancel the previous bootindex setting. We get bootindex = 0 if the bootindex isn't set or specified to 0 in the device's xml, and is used with 'bootIndexSpecified'. Support format <boot order = '0'\> into xml when bootIndexSpecified is true wo keep the bootindex still changeble. Support set multiple bootindex = 0, and boot in a Qemu's default sequence 'disk->cdrom->net' if all devices' bootindex is set to 0; Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/conf/domain_conf.c | 9 ++++++--- src/conf/domain_postparse.c | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7f045b0d4a..90881f7dfe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5146,7 +5146,11 @@ virDomainDeviceInfoFormat(virBuffer *buf, g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER; g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf); - if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) { + if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && + (info->bootIndex || info->bootIndexSpecified)) { + /* format the boot order = 0 in XML when its bootIndexSpecified is true, + * which means the boot order could be changed by virsh update-device. + */ virBufferAsprintf(buf, "<boot order='%u'", info->bootIndex); if (info->loadparm) @@ -5308,8 +5312,7 @@ virDomainDeviceBootParseXML(xmlNodePtr node, { g_autofree char *loadparm = NULL; - if (virXMLPropUInt(node, "order", 10, - VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + if (virXMLPropUInt(node, "order", 10, VIR_XML_PROP_REQUIRED, &info->bootIndex) < 0) return -1; diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index 9a3e8f494c..2ba3186561 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -1031,7 +1031,7 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC_UNUSED, GHashTable *bootHash = data; g_autofree char *order = NULL; - if (info->bootIndex == 0) + if (info->bootIndex == 0 && !info->bootIndexSpecified) return 0; if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV && @@ -1045,6 +1045,12 @@ virDomainDefCollectBootOrder(virDomainDef *def G_GNUC_UNUSED, order = g_strdup_printf("%u", info->bootIndex); if (virHashLookup(bootHash, order)) { + /* 0 in the bootHash means cancel the bootIndex specified in + * XML, so it allowed to make more than one device use 0 with + * its bootIndexSpecified = true. + */ + if (info->bootIndex == 0) + return 0; virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("boot order '%s' used for more than one device"), order); -- 2.33.0

Signed-off-by: Jiang Jiacheng <jiangjiacheng@huawei.com> --- src/conf/schemas/domaincommon.rng | 2 +- tests/qemuxml2argvdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmloutdata/boot-order-set-0.xml | 72 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 4 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/boot-order-set-0.xml create mode 100644 tests/qemuxml2xmloutdata/boot-order-set-0.xml diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index c588a48fd2..0f42911cf0 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -7160,7 +7160,7 @@ <define name="deviceBoot"> <element name="boot"> <attribute name="order"> - <ref name="positiveInteger"/> + <ref name="unsignedInt"/> </attribute> <optional> <attribute name="loadparm"> diff --git a/tests/qemuxml2argvdata/boot-order-set-0.xml b/tests/qemuxml2argvdata/boot-order-set-0.xml new file mode 100644 index 0000000000..dc980e5e6f --- /dev/null +++ b/tests/qemuxml2argvdata/boot-order-set-0.xml @@ -0,0 +1,72 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest2'/> + <target dev='hdb' bus='ide'/> + <boot order='0'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <boot order='1'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='nbd' name='image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </disk> + <disk type='file' device='floppy'> + <driver name='qemu' type='raw'/> + <source file='/dev/null'/> + <target dev='fdb' bus='fdc'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='fdc' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio'/> + <boot order='2'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </interface> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/boot-order-set-0.xml b/tests/qemuxml2xmloutdata/boot-order-set-0.xml new file mode 100644 index 0000000000..dc980e5e6f --- /dev/null +++ b/tests/qemuxml2xmloutdata/boot-order-set-0.xml @@ -0,0 +1,72 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest1'/> + <target dev='hda' bus='ide'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> + <source dev='/dev/HostVG/QEMUGuest2'/> + <target dev='hdb' bus='ide'/> + <boot order='0'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source file='/root/boot.iso'/> + <target dev='hdc' bus='ide'/> + <readonly/> + <boot order='1'/> + <address type='drive' controller='0' bus='1' target='0' unit='0'/> + </disk> + <disk type='network' device='disk'> + <driver name='qemu' type='raw'/> + <source protocol='nbd' name='image'> + <host name='example.org' port='6000'/> + </source> + <target dev='vda' bus='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </disk> + <disk type='file' device='floppy'> + <driver name='qemu' type='raw'/> + <source file='/dev/null'/> + <target dev='fdb' bus='fdc'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='fdc' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <interface type='user'> + <mac address='00:11:22:33:44:55'/> + <model type='virtio'/> + <boot order='2'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </interface> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <audio id='1' type='none'/> + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </memballoon> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 0e729ca905..688c4171c0 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -256,6 +256,7 @@ mymain(void) DO_TEST_NOCAPS("boot-menu-disable"); DO_TEST_NOCAPS("boot-menu-disable-with-timeout"); DO_TEST_NOCAPS("boot-order"); + DO_TEST_NOCAPS("boot-order-set-0"); DO_TEST_NOCAPS("reboot-timeout-enabled"); DO_TEST_NOCAPS("reboot-timeout-disabled"); -- 2.33.0
participants (1)
-
Jiang Jiacheng