Extract the checking code into a separate function and prepare the
infrastructure for checking the new structure type.
---
src/conf/domain_conf.c | 41 ++++++++++++++++++++++++++++++-----------
1 file changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 631e1db..66fc6d3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17835,6 +17835,35 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src,
}
+static bool
+virDomainDefVcpuCheckAbiStability(virDomainDefPtr src,
+ virDomainDefPtr dst)
+{
+ size_t i;
+
+ if (src->maxvcpus != dst->maxvcpus) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Target domain vCPU max %zu does not match source
%zu"),
+ dst->maxvcpus, src->maxvcpus);
+ return false;
+ }
+
+ for (i = 0; i < src->maxvcpus; i++) {
+ virDomainVCpuInfoPtr svcpu = &src->vcpus[i];
+ virDomainVCpuInfoPtr dvcpu = &dst->vcpus[i];
+
+ if (svcpu->online != dvcpu->online) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("State of vCPU '%zu' differs between source and
"
+ "destination definitions"), i);
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
/* This compares two configurations and looks for any differences
* which will affect the guest ABI. This is primarily to allow
* validation of custom XML config passed in during migration
@@ -17908,18 +17937,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
goto error;
}
- if (virDomainDefGetVCpus(src) != virDomainDefGetVCpus(dst)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain vCPU count %d does not match source
%d"),
- virDomainDefGetVCpus(dst), virDomainDefGetVCpus(src));
+ if (!virDomainDefVcpuCheckAbiStability(src, dst))
goto error;
- }
- if (virDomainDefGetVCpusMax(src) != virDomainDefGetVCpusMax(dst)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target domain vCPU max %d does not match source
%d"),
- virDomainDefGetVCpusMax(dst), virDomainDefGetVCpusMax(src));
- goto error;
- }
if (src->iothreads != dst->iothreads) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
--
2.6.2