diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 513bc0efc3..1266e9d164 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -569,7 +569,8 @@
the order may be be duplicated accross all vcpus that need to be
enabled at once. Specifying order is not necessary, vcpus are then
added in an arbitrary order. If order info is used, it must be used for
- all online vcpus.
+ all online vcpus. Hypervisors may clear or update ordering information
+ during certain operations to assure valid configuration.
Note that hypervisors may create hotpluggable vcpus differently from
boot vcpus thus special initialization may be necessary.
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7972a4eac2..920529a76d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -25566,3 +25566,13 @@ virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
virBufferFreeAndReset(&buf);
return -1;
}
+
+
+void
+virDomainDefVcpuOrderClear(virDomainDefPtr def)
+{
+ size_t i;
+
+ for (i = 0; i < def->maxvcpus; i++)
+ def->vcpus[i]->order = 0;
+}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 561a179e63..fd3ae8e500 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2487,6 +2487,7 @@ unsigned int virDomainDefGetVcpus(const virDomainDef *def);
virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
ATTRIBUTE_RETURN_CHECK;
+void virDomainDefVcpuOrderClear(virDomainDefPtr def);
virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 68d0ea973f..eae817d14d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -264,6 +264,7 @@ virDomainDefSetMemoryTotal;
virDomainDefSetVcpus;
virDomainDefSetVcpusMax;
virDomainDefValidate;
+virDomainDefVcpuOrderClear;
virDomainDeleteConfig;
virDomainDeviceAddressIsValid;
virDomainDeviceAddressTypeToString;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 487bafc7d6..12ddbc0c9a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4745,6 +4745,9 @@ qemuDomainSetVcpusMax(virQEMUDriverPtr driver,
}
}
+ /* ordering information may become invalid, thus clear it */
+ virDomainDefVcpuOrderClear(persistentDef);
+
if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0)
goto cleanup;
@@ -4919,6 +4922,8 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def,
size_t maxvcpus = virDomainDefGetVcpusMax(def);
size_t i;
+ /* ordering information may become invalid, thus clear it */
+ virDomainDefVcpuOrderClear(def);
if (curvcpus == nvcpus)
return;