From nobody Sun Apr 28 20:04:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149563719979346.322683471581286; Wed, 24 May 2017 07:46:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1818361E4A; Wed, 24 May 2017 14:46:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C97287FDCA; Wed, 24 May 2017 14:46:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D2DC4180BAF4; Wed, 24 May 2017 14:46:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4OEkCqh022401 for ; Wed, 24 May 2017 10:46:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id C2B627FDE4; Wed, 24 May 2017 14:46:12 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37D8B7F3BA for ; Wed, 24 May 2017 14:46:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1818361E4A Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1818361E4A From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 24 May 2017 16:45:55 +0200 Message-Id: <61c3ce5695e227ab423c4aacaa285a90b474fe6c.1495637025.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] virDomainDefCheckABIStabilityFlags: move memtune checks into a separate function X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 24 May 2017 14:46:34 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The checks are scattered all over the place. Move them into a single function. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 74 ++++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 32234e8a5..ef5b9d7f4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19803,6 +19803,53 @@ virDomainTPMDefCheckABIStability(virDomainTPMDefPt= r src, return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } =20 + +static bool +virDomainMemtuneCheckABIStability(const virDomainDef *src, + const virDomainDef *dst, + unsigned int flags) +{ + if (virDomainDefGetMemoryInitial(src) !=3D virDomainDefGetMemoryInitia= l(dst)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain max memory %lld " + "does not match source %lld"), + virDomainDefGetMemoryInitial(dst), + virDomainDefGetMemoryInitial(src)); + return false; + } + + if (!(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE) && + src->mem.cur_balloon !=3D dst->mem.cur_balloon) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain current memory %lld " + "does not match source %lld"), + dst->mem.cur_balloon, + src->mem.cur_balloon); + return false; + } + + if (src->mem.max_memory !=3D dst->mem.max_memory) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target maximum memory size '%llu' " + "doesn't match source '%llu'"), + dst->mem.max_memory, + src->mem.max_memory); + return false; + } + + if (src->mem.memory_slots !=3D dst->mem.memory_slots) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain memory slots " + "count '%u' doesn't match source '%u'"), + dst->mem.memory_slots, + src->mem.memory_slots); + return false; + } + + return true; +} + + static bool virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src, virDomainMemoryDefPtr dst) @@ -19957,37 +20004,12 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPt= r src, goto error; } =20 - if (virDomainDefGetMemoryInitial(src) !=3D virDomainDefGetMemoryInitia= l(dst)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain max memory %lld does not match sou= rce %lld"), - virDomainDefGetMemoryInitial(dst), - virDomainDefGetMemoryInitial(src)); + if (!virDomainMemtuneCheckABIStability(src, dst, flags)) goto error; - } - if (!(flags & VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE) && - src->mem.cur_balloon !=3D dst->mem.cur_balloon) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain current memory %lld does not match= source %lld"), - dst->mem.cur_balloon, src->mem.cur_balloon); - goto error; - } =20 if (!virDomainNumaCheckABIStability(src->numa, dst->numa)) goto error; =20 - if (src->mem.memory_slots !=3D dst->mem.memory_slots) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target domain memory slots count '%u' doesn't ma= tch source '%u'"), - dst->mem.memory_slots, src->mem.memory_slots); - goto error; - } - if (src->mem.max_memory !=3D dst->mem.max_memory) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target maximum memory size '%llu' doesn't match = source '%llu'"), - dst->mem.max_memory, src->mem.max_memory); - goto error; - } - if (!virDomainDefVcpuCheckAbiStability(src, dst)) goto error; =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:04:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495637208119910.5453295355411; Wed, 24 May 2017 07:46:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0BCC3D95F; Wed, 24 May 2017 14:46:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94EA381B73; Wed, 24 May 2017 14:46:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2723B180BAFB; Wed, 24 May 2017 14:46:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4OEkRfp022422 for ; Wed, 24 May 2017 10:46:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7132F7F8EB; Wed, 24 May 2017 14:46:27 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46497F8CD for ; Wed, 24 May 2017 14:46:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E0BCC3D95F Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E0BCC3D95F From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 24 May 2017 16:45:56 +0200 Message-Id: <00f390be56faf9639c56805b441c55236b8ee791.1495637025.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 2/3] virDomainXMLOption: Introduce virDomainABIStabilityDomain X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 24 May 2017 14:46:44 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" While checking for ABI stability, drivers might pose additional checks that are not valid for general case. For instance, qemu driver might check some memory backing attributes because of how qemu works. But those attributes may work well in other drivers. Signed-off-by: Michal Privoznik --- src/conf/domain_conf.c | 19 ++++++++++++++++--- src/conf/domain_conf.h | 16 ++++++++++++++-- src/conf/snapshot_conf.c | 5 +++-- src/conf/snapshot_conf.h | 3 ++- src/libxl/libxl_conf.c | 2 +- src/libxl/libxl_domain.c | 4 +++- src/lxc/lxc_conf.c | 3 ++- src/openvz/openvz_driver.c | 2 +- src/phyp/phyp_driver.c | 2 +- src/qemu/qemu_capabilities.c | 2 +- src/qemu/qemu_conf.c | 3 ++- src/qemu/qemu_domain.c | 1 + src/qemu/qemu_driver.c | 7 ++++--- src/test/test_driver.c | 8 +++++--- src/uml/uml_driver.c | 2 +- src/vbox/vbox_common.c | 2 +- src/vmware/vmware_driver.c | 2 +- src/vmx/vmx.c | 2 +- src/xen/xen_driver.c | 2 +- src/xenapi/xenapi_driver.c | 2 +- tests/qemuargv2xmltest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/sexpr2xmltest.c | 2 +- tests/testutils.c | 4 ++-- tests/vmx2xmltest.c | 2 +- tests/xlconfigtest.c | 2 +- tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 29 files changed, 72 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ef5b9d7f4..ab34cddfa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -76,6 +76,9 @@ struct _virDomainXMLOption { =20 /* XML namespace callbacks */ virDomainXMLNamespace ns; + + /* ABI stability callbacks */ + virDomainABIStability abi; }; =20 #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ @@ -1050,7 +1053,8 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, virDomainXMLPrivateDataCallbacksPtr priv, - virDomainXMLNamespacePtr xmlns) + virDomainXMLNamespacePtr xmlns, + virDomainABIStabilityPtr abi) { virDomainXMLOptionPtr xmlopt; =20 @@ -1069,6 +1073,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr con= fig, if (xmlns) xmlopt->ns =3D *xmlns; =20 + if (abi) + xmlopt->abi =3D *abi; + /* Technically this forbids to use one of Xerox's MAC address prefixes= in * our hypervisor drivers. This shouldn't ever be a problem. * @@ -19967,6 +19974,7 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr s= rc, bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, virDomainDefPtr dst, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { size_t i; @@ -20368,6 +20376,10 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr= src, !virDomainIOMMUDefCheckABIStability(src->iommu, dst->iommu)) goto error; =20 + if (xmlopt && xmlopt->abi.domain && + !xmlopt->abi.domain(src, dst)) + goto error; + /* Coverity is not very happy with this - all dead_error_condition */ #if !STATIC_ANALYSIS /* This switch statement is here to trigger compiler warning when addi= ng @@ -20427,9 +20439,10 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr= src, =20 bool virDomainDefCheckABIStability(virDomainDefPtr src, - virDomainDefPtr dst) + virDomainDefPtr dst, + virDomainXMLOptionPtr xmlopt) { - return virDomainDefCheckABIStabilityFlags(src, dst, 0); + return virDomainDefCheckABIStabilityFlags(src, dst, xmlopt, 0); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 34a35965b..1f536b9bd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2536,9 +2536,19 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataParseFunc parse; }; =20 +typedef bool (*virDomainABIStabilityDomain)(const virDomainDef *src, + const virDomainDef *dst); + +typedef struct _virDomainABIStability virDomainABIStability; +typedef virDomainABIStability *virDomainABIStabilityPtr; +struct _virDomainABIStability { + virDomainABIStabilityDomain domain; +}; + virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr co= nfig, virDomainXMLPrivateDataCallbac= ksPtr priv, - virDomainXMLNamespacePtr xmlns= ); + virDomainXMLNamespacePtr xmlns, + virDomainABIStabilityPtr abi); =20 void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr m= ac); =20 @@ -2805,10 +2815,12 @@ virDomainObjPtr virDomainObjParseFile(const char *f= ilename, unsigned int flags); =20 bool virDomainDefCheckABIStability(virDomainDefPtr src, - virDomainDefPtr dst); + virDomainDefPtr dst, + virDomainXMLOptionPtr xmlopt); =20 bool virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, virDomainDefPtr dst, + virDomainXMLOptionPtr xmlopt, unsigned int flags); =20 int virDomainDefAddImplicitDevices(virDomainDefPtr def); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 5daa8d11a..cdba60b4d 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -1194,7 +1194,8 @@ virDomainSnapshotIsExternal(virDomainSnapshotObjPtr s= nap) } =20 int -virDomainSnapshotRedefinePrep(virDomainPtr domain, +virDomainSnapshotRedefinePrep(virDomainXMLOptionPtr xmlopt, + virDomainPtr domain, virDomainObjPtr vm, virDomainSnapshotDefPtr *defptr, virDomainSnapshotObjPtr *snap, @@ -1286,7 +1287,7 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain, if (other->def->dom) { if (def->dom) { if (!virDomainDefCheckABIStability(other->def->dom, - def->dom)) + def->dom, xmlopt)) goto cleanup; } else { /* Transfer the domain def */ diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index fcf7a1e82..a8a51d323 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -177,7 +177,8 @@ int virDomainListSnapshots(virDomainSnapshotObjListPtr = snapshots, bool virDomainSnapshotDefIsExternal(virDomainSnapshotDefPtr def); bool virDomainSnapshotIsExternal(virDomainSnapshotObjPtr snap); =20 -int virDomainSnapshotRedefinePrep(virDomainPtr domain, +int virDomainSnapshotRedefinePrep(virDomainXMLOptionPtr xmlopt, + virDomainPtr domain, virDomainObjPtr vm, virDomainSnapshotDefPtr *def, virDomainSnapshotObjPtr *snap, diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index c56b05b38..886dc629f 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -2255,5 +2255,5 @@ libxlCreateXMLConf(void) { return virDomainXMLOptionNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, - NULL); + NULL, NULL); } diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 256cf1dc1..68a501cf1 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1452,7 +1452,9 @@ libxlDomainDefCheckABIStability(libxlDriverPrivatePtr= driver, !(migratableDefDst =3D virDomainDefCopy(dst, cfg->caps, driver->xm= lopt, NULL, true))) goto cleanup; =20 - ret =3D virDomainDefCheckABIStability(migratableDefSrc, migratableDefD= st); + ret =3D virDomainDefCheckABIStability(migratableDefSrc, + migratableDefDst, + driver->xmlopt); =20 cleanup: virDomainDefFree(migratableDefSrc); diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 508b98ba2..ff975decc 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -215,7 +215,8 @@ lxcDomainXMLConfInit(void) { return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, &virLXCDriverPrivateDataCallbacks, - &virLXCDriverDomainXMLNamespace); + &virLXCDriverDomainXMLNamespace, + NULL); } =20 =20 diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 9c4a19635..8e305a85c 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1483,7 +1483,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectP= tr conn, goto cleanup; =20 if (!(driver->xmlopt =3D virDomainXMLOptionNew(&openvzDomainDefParserC= onfig, - NULL, NULL))) + NULL, NULL, NULL))) goto cleanup; =20 if (openvzLoadDomains(driver) < 0) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 0cc288f36..4465ac862 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1202,7 +1202,7 @@ phypConnectOpen(virConnectPtr conn, goto failure; =20 if (!(phyp_driver->xmlopt =3D virDomainXMLOptionNew(&virPhypDriverDoma= inDefParserConfig, - NULL, NULL))) + NULL, NULL, NULL))) goto failure; =20 conn->privateData =3D phyp_driver; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 546dfd759..3af9a9601 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5024,7 +5024,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPComman= dPtr cmd, goto ignore; } =20 - if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL)) || + if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) || !(cmd->vm =3D virDomainObjNew(xmlopt))) goto cleanup; =20 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 19ddf787d..78f55c0e7 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -909,7 +909,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) virQEMUDriverDomainDefParserConfig.priv =3D driver; return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, - &virQEMUDriverDomainXMLNamespace); + &virQEMUDriverDomainXMLNamespace, + NULL); } =20 =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c8dc74813..35fd79de8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5816,6 +5816,7 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr drive= r, =20 if (!virDomainDefCheckABIStabilityFlags(migratableDefSrc, migratableDefDst, + driver->xmlopt, check_flags)) goto cleanup; =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cd513ff9f..f5f4a39c0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6130,7 +6130,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver, VIR_DOMAIN_XML_MIGRATABLE))) goto cleanup; =20 - if (!virDomainDefCheckABIStability(def, newdef_migr)) { + if (!virDomainDefCheckABIStability(def, newdef_migr, driver->xmlopt)) { virErrorPtr err =3D virSaveLastError(); =20 /* Due to a bug in older version of external snapshot creation @@ -6139,7 +6139,7 @@ qemuDomainSaveImageUpdateDef(virQEMUDriverPtr driver, * saved XML type, we need to check the ABI compatibility against * the user provided XML if the check against the migratable XML * fails. Snapshots created prior to v1.1.3 have this issue. */ - if (!virDomainDefCheckABIStability(def, newdef)) { + if (!virDomainDefCheckABIStability(def, newdef, driver->xmlopt)) { virSetError(err); virFreeError(err); goto cleanup; @@ -14583,7 +14583,8 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, qemuDomainObjSetAsyncJobMask(vm, QEMU_JOB_NONE); =20 if (redefine) { - if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap, + if (virDomainSnapshotRedefinePrep(driver->xmlopt, + domain, vm, &def, &snap, &update_current, flags) < 0) goto endjob; } else { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2db3f7ddf..a644e5ccf 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -414,7 +414,7 @@ testDriverNew(void) goto error; } =20 - if (!(ret->xmlopt =3D virDomainXMLOptionNew(NULL, NULL, &ns)) || + if (!(ret->xmlopt =3D virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) || !(ret->eventState =3D virObjectEventStateNew()) || !(ret->domains =3D virDomainObjListNew()) || !(ret->networks =3D virNetworkObjListNew())) @@ -6359,7 +6359,8 @@ testDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; =20 if (redefine) { - if (virDomainSnapshotRedefinePrep(domain, vm, &def, &snap, + if (virDomainSnapshotRedefinePrep(privconn->xmlopt, + domain, vm, &def, &snap, &update_current, flags) < 0) goto cleanup; } else { @@ -6635,7 +6636,8 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snaps= hot, if (virDomainObjIsActive(vm)) { /* Transitions 5, 6, 8, 9 */ /* Check for ABI compatibility. */ - if (!virDomainDefCheckABIStability(vm->def, config)) { + if (!virDomainDefCheckABIStability(vm->def, config, + privconn->xmlopt)) { virErrorPtr err =3D virGetLastError(); =20 if (!(flags & VIR_DOMAIN_SNAPSHOT_REVERT_FORCE)) { diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 03edc897c..58ab033c8 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -533,7 +533,7 @@ umlStateInitialize(bool privileged, goto out_of_memory; =20 if (!(uml_driver->xmlopt =3D virDomainXMLOptionNew(¨DriverDomainDef= ParserConfig, - &privcb, NULL))) + &privcb, NULL, NULL))) goto error; =20 if ((uml_driver->inotifyFD =3D inotify_init()) < 0) { diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index d6d363e45..c66939e01 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -142,7 +142,7 @@ vboxDriverObjNew(void) =20 if (!(driver->caps =3D vboxCapsInit()) || !(driver->xmlopt =3D virDomainXMLOptionNew(&vboxDomainDefParserCon= fig, - NULL, NULL))) + NULL, NULL, NULL))) goto cleanup; =20 return driver; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 685365833..9e369e67b 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -114,7 +114,7 @@ vmwareDomainXMLConfigInit(void) virDomainXMLPrivateDataCallbacks priv =3D { .alloc =3D vmwareDataAlloc= Func, .free =3D vmwareDataFreeFunc= }; =20 - return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL= ); + return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL= , NULL); } =20 static virDrvOpenStatus diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 31af2e9df..3289a2002 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -591,7 +591,7 @@ virDomainXMLOptionPtr virVMXDomainXMLConfInit(void) { return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL, - &virVMXDomainXMLNamespace); + &virVMXDomainXMLNamespace, NULL); } =20 char * diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 4d1408927..f81ee20ad 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -401,7 +401,7 @@ virDomainXMLOptionPtr xenDomainXMLConfInit(void) { return virDomainXMLOptionNew(&xenDomainDefParserConfig, - NULL, NULL); + NULL, NULL, NULL); } =20 =20 diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 37d1a6fd9..380c3a1de 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, } =20 if (!(privP->xmlopt =3D virDomainXMLOptionNew(&xenapiDomainDefParserCo= nfig, - NULL, NULL))) { + NULL, NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); goto error; diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 0b519a460..1adbcfef6 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -95,7 +95,7 @@ static int testCompareXMLToArgvFiles(const char *xmlfile, if (testSanitizeDef(vmdef) < 0) goto fail; =20 - if (!virDomainDefCheckABIStability(vmdef, vmdef)) { + if (!virDomainDefCheckABIStability(vmdef, vmdef, driver.xmlopt)) { VIR_TEST_DEBUG("ABI stability check failed on %s", xmlfile); goto fail; } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 426959857..4c5b80011 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -463,7 +463,7 @@ testCompareXMLToArgv(const void *data) if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0) goto cleanup; =20 - if (!virDomainDefCheckABIStability(vm->def, vm->def)) { + if (!virDomainDefCheckABIStability(vm->def, vm->def, driver.xmlopt)) { VIR_TEST_DEBUG("ABI stability check failed on %s", xml); goto cleanup; } diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 107509b31..5dfc45d7d 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -57,7 +57,7 @@ testCompareFiles(const char *xml, const char *sexpr) tty, vncport, caps, xmlopt))) goto fail; =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } diff --git a/tests/testutils.c b/tests/testutils.c index 817fffa04..4fb2338bb 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit= (void) { return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig, &virTestGenericPrivateDataCallbacks, - NULL); + NULL, NULL); } =20 =20 @@ -1169,7 +1169,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomain= XMLOptionPtr xmlopt, goto out; } =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { VIR_TEST_DEBUG("ABI stability check failed on %s", infile); result =3D TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_STABILITY; goto out; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 4eedbac2b..00385dfa7 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -81,7 +81,7 @@ testCompareFiles(const char *vmx, const char *xml) if (!(def =3D virVMXParseConfig(&ctx, xmlopt, caps, vmxData))) goto cleanup; =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", vmx); goto cleanup; } diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 05f7c2042..3fe42988d 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -97,7 +97,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) goto fail; } =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index aa3845bf0..345223ffe 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -67,7 +67,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index fddccf029..0ba8a765b 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -31,7 +31,7 @@ testCompareFiles(const char *xml, const char *sexpr) VIR_DOMAIN_DEF_PARSE_INACTIVE))) goto fail; =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto fail; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 71c4cb9dc..13f53e7d2 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -82,7 +82,7 @@ testCompareFiles(const char *xml, const char *vmx, int vi= rtualHW_version) if (def =3D=3D NULL) goto failure; =20 - if (!virDomainDefCheckABIStability(def, def)) { + if (!virDomainDefCheckABIStability(def, def, xmlopt)) { fprintf(stderr, "ABI stability check failed on %s", xml); goto failure; } --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun Apr 28 20:04:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495637285120758.0888219852743; Wed, 24 May 2017 07:48:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CDC1E7D50A; Wed, 24 May 2017 14:47:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9592485DB5; Wed, 24 May 2017 14:47:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 22BC24A48E; Wed, 24 May 2017 14:47:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4OEkm5g022462 for ; Wed, 24 May 2017 10:46:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DA8B7F8CD; Wed, 24 May 2017 14:46:48 +0000 (UTC) Received: from moe.brq.redhat.com (dhcp129-131.brq.redhat.com [10.34.129.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2379E7F8D1 for ; Wed, 24 May 2017 14:46:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CDC1E7D50A Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CDC1E7D50A From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 24 May 2017 16:45:57 +0200 Message-Id: <42dcb84fe44240b4e2e36525f01cebbf4e87af8d.1495637025.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/3] virQEMUDriverDomainABIStability: Check for memoryBacking X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 24 May 2017 14:48:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1450349 Problem is, qemu fails to load guest memory image if these attribute change on migration/restore from an image. Signed-off-by: Michal Privoznik --- src/libvirt_private.syms | 6 ++++++ src/qemu/qemu_conf.c | 2 +- src/qemu/qemu_domain.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 1 + 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index d361454d5..a3ed2ad5b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -404,11 +404,15 @@ virDomainLockFailureTypeFromString; virDomainLockFailureTypeToString; virDomainMemballoonModelTypeFromString; virDomainMemballoonModelTypeToString; +virDomainMemoryAllocationTypeFromString; +virDomainMemoryAllocationTypeToString; virDomainMemoryDefFree; virDomainMemoryFindByDef; virDomainMemoryFindInactiveByDef; virDomainMemoryInsert; virDomainMemoryRemove; +virDomainMemorySourceTypeFromString; +virDomainMemorySourceTypeToString; virDomainNetAppendIPAddress; virDomainNetDefClear; virDomainNetDefFormat; @@ -690,6 +694,8 @@ virNodeDeviceEventUpdateNew; =20 =20 # conf/numa_conf.h +virDomainMemoryAccessTypeFromString; +virDomainMemoryAccessTypeToString; virDomainNumaCheckABIStability; virDomainNumaEquals; virDomainNumaFree; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 78f55c0e7..d8b88386d 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -910,7 +910,7 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace, - NULL); + &virQEMUDriverDomainABIStability); } =20 =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 35fd79de8..c1ff8ca8a 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5797,6 +5797,46 @@ qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr dr= iver, } =20 =20 +static bool +qemuDomainABIStabilityCheck(const virDomainDef *src, + const virDomainDef *dst) +{ + if (src->mem.source !=3D dst->mem.source) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target memoryBacking source '%s' doesn't " + "match source memoryBacking source'%s'"), + virDomainMemorySourceTypeToString(dst->mem.source), + virDomainMemorySourceTypeToString(src->mem.source)); + return false; + } + + if (src->mem.access !=3D dst->mem.access) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target memoryBacking access '%s' doesn't " + "match access memoryBacking access'%s'"), + virDomainMemoryAccessTypeToString(dst->mem.access), + virDomainMemoryAccessTypeToString(src->mem.access)); + return false; + } + + if (src->mem.allocation !=3D dst->mem.allocation) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target memoryBacking allocation '%s' doesn't " + "match allocation memoryBacking allocation'%s'"), + virDomainMemoryAllocationTypeToString(dst->mem.allo= cation), + virDomainMemoryAllocationTypeToString(src->mem.allo= cation)); + return false; + } + + return true; +} + + +virDomainABIStability virQEMUDriverDomainABIStability =3D { + .domain =3D qemuDomainABIStabilityCheck, +}; + + bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, virDomainDefPtr src, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index aebd91ad3..829f7746e 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -636,6 +636,7 @@ void qemuDomainCleanupRun(virQEMUDriverPtr driver, extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks; extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace; extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig; +extern virDomainABIStability virQEMUDriverDomainABIStability; =20 int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver, virDomainObjPtr vm, int asyncJob); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list