From nobody Thu May 15 21:27:42 2025 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.zohomail.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 1506012418746452.55925034535755; Thu, 21 Sep 2017 09:46:58 -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 8162DC07F989; Thu, 21 Sep 2017 16:46:57 +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 26E376FDA1; Thu, 21 Sep 2017 16:46:57 +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 D23871855943; Thu, 21 Sep 2017 16:46:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8LG16P9030251 for ; Thu, 21 Sep 2017 12:01:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C2CD503AF; Thu, 21 Sep 2017 16:01:06 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 036C060BE2 for ; Thu, 21 Sep 2017 16:01:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8162DC07F989 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Michal Privoznik To: libvir-list@redhat.com Date: Thu, 21 Sep 2017 18:00:51 +0200 Message-Id: <4dec5931ac7fa93a8437a9e8ae616a2a716805d7.1506005021.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 7/7] conf: Format device alias into inactive XML too 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.31]); Thu, 21 Sep 2017 16:46:58 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Now that we are generating the device aliases at the define time, we might as well format them into inactive XML. Signed-off-by: Michal Privoznik --- I've trimmed out all the test/ XML changes. I've generated them using: tests $ VIR_TEST_REGENERATE_OUTPUT=3D1 ./test With the changes in this patch would be ~1MB in size. If interested regener= ate them on your own. Alternatively, you can find them at my github. src/conf/domain_conf.c | 7 +- tests/qemuxml2xmltest.c | 63 ++++++++++- 489 files changed, 7417 insertions(+), 1623 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 653357531..ae38bae47 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5770,10 +5770,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 virBufferAddLit(buf, "/>\n"); } - if (info->alias && - !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { + + if (info->alias) virBufferAsprintf(buf, "\n", info->alias); - } =20 if (info->mastertype =3D=3D VIR_DOMAIN_CONTROLLER_MASTER_USB) { virBufferAsprintf(buf, "\n", @@ -6333,7 +6332,7 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { if (alias =3D=3D NULL && - !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) && + !(flags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) && virXMLNodeNameEqual(cur, "alias")) { alias =3D cur; } else if (address =3D=3D NULL && diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 4b2fbd990..c9afafe14 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -13,11 +13,16 @@ #ifdef WITH_QEMU =20 # include "internal.h" +# include "qemu/qemu_alias.h" # include "qemu/qemu_domain_address.h" # include "qemu/qemu_domain.h" # include "testutilsqemu.h" # include "virstring.h" =20 +# define __QEMU_CAPSPRIV_H_ALLOW__ +# include "qemu/qemu_capspriv.h" +# undef __QEMU_CAPSPRIV_H_ALLOW__ + # define VIR_FROM_THIS VIR_FROM_NONE =20 static virQEMUDriver driver; @@ -38,6 +43,25 @@ struct testInfo { virQEMUCapsPtr qemuCaps; }; =20 + +static int +testUpdateQEMUCaps(virDomainDefPtr def, + virQEMUCapsPtr qemuCaps) +{ + virQEMUCapsSetArch(qemuCaps, def->os.arch); + + virQEMUCapsInitQMPBasicArch(qemuCaps); + + /* We need to pretend QEMU 2.0.0 is in use so that pSeries guests + * will get the correct alias assigned to their buses. + * See virQEMUCapsHasPCIMultiBus() */ + virQEMUCapsSetVersion(qemuCaps, 2000000); + + return 0; +} + + + static int qemuXML2XMLActivePreFormatCallback(virDomainDefPtr def, const void *opaque) @@ -48,6 +72,19 @@ qemuXML2XMLActivePreFormatCallback(virDomainDefPtr def, if (!info->activeVcpus) info->activeVcpus =3D virDomainDefGetOnlineVcpumap(def); =20 + /* Update capabilities according to domain definition, + * just like we're doing in qemuxml2argvtest. */ + testUpdateQEMUCaps(def, info->qemuCaps); + + /* Forcibly regenerate device aliases. They are generated in + * virDomainDefParseFile(), however, qemuCaps are filled out + * just partially therefore the generated aliases might be + * wrong. It's only after testUpdateQEMUCaps() call that we + * have full set of caps. However, we can't move the call any + * sooner because it needs vm->def. */ + if (qemuAssignDeviceAliases(def, info->qemuCaps, true) < 0) + return -1; + return 0; } =20 @@ -64,6 +101,29 @@ testXML2XMLActive(const void *opaque) } =20 =20 +static int +qemuXML2XMLInactivePreFormatCallback(virDomainDefPtr def, + const void *opaque) +{ + struct testInfo *info =3D (struct testInfo *) opaque; + + /* Update capabilities according to domain definition, + * just like we're doing in qemuxml2argvtest. */ + testUpdateQEMUCaps(def, info->qemuCaps); + + /* Forcibly regenerate device aliases. They are generated in + * virDomainDefParseFile(), however, qemuCaps are filled out + * just partially therefore the generated aliases might be + * wrong. It's only after testUpdateQEMUCaps() call that we + * have full set of caps. However, we can't move the call any + * sooner because it needs vm->def. */ + if (qemuAssignDeviceAliases(def, info->qemuCaps, true) < 0) + return -1; + + return 0; +} + + static int testXML2XMLInactive(const void *opaque) { @@ -71,7 +131,8 @@ testXML2XMLInactive(const void *opaque) =20 return testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, info->in= Name, info->outInactiveName, false, - NULL, opaque, 0, + qemuXML2XMLInactivePreFormatCallback, + opaque, 0, TEST_COMPARE_DOM_XML2XML_RESULT_SUCC= ESS); } =20 --=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list