From nobody Thu May 15 21:07:19 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 1506007379469461.8883632034813; Thu, 21 Sep 2017 08:22:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 289C781240; Thu, 21 Sep 2017 15:22:58 +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 F1BCC5E1CA; Thu, 21 Sep 2017 15:22: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 A96603FA57; Thu, 21 Sep 2017 15:22:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8LEleW9014719 for ; Thu, 21 Sep 2017 10:47:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id D93CA60178; Thu, 21 Sep 2017 14:47:40 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 61385600C2 for ; Thu, 21 Sep 2017 14:47:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 289C781240 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.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 16:47:10 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 6/7] qemu: Assign device aliases at define time 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 15:22:58 +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=3D1434451 Users might want to uniquely identify devices even before the domain is started. Therefore we must generate device aliases right at the define time. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 24 ++++++++++++++++++= ++++ tests/qemuxml2argvtest.c | 9 ++++++++ .../qemuxml2xmlout-channel-virtio-state-active.xml | 20 +++++++++++++++--- .../qemuxml2xmlout-disk-active-commit.xml | 16 ++++++++++++--- .../qemuxml2xmlout-disk-backing-chains-active.xml | 19 ++++++++++++++--- .../qemuxml2xmlout-disk-mirror-active.xml | 19 ++++++++++++++--- .../qemuxml2xmlout-disk-mirror-old.xml | 19 ++++++++++++++--- .../qemuxml2xmlout-seclabel-static-labelskip.xml | 16 ++++++++++++--- 8 files changed, 124 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ee6641847..15fd88dcc 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3936,6 +3936,29 @@ qemuDomainDefAssignAddresses(virDomainDef *def, } =20 =20 +static int +qemuDomainDefAssignAliases(virDomainDef *def, + virCapsPtr caps ATTRIBUTE_UNUSED, + unsigned int parseFlags ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED, + void *parseOpaque) +{ + /* Note that qemuCaps may be NULL when this function is called. This + * function shall not fail in that case. It will be re-run on VM start= up + * with the capabilities populated. */ + virQEMUCapsPtr qemuCaps =3D parseOpaque; + + /* Skip address assignment if @qemuCaps is not present. In such case d= evices + * which are automatically added may be missing. Additionally @qemuCap= s should + * only be missing when reloading configs, thus aliases were already + * assigned. */ + if (!qemuCaps) + return 1; + + return qemuAssignDeviceAliases(def, qemuCaps, true); +} + + static int qemuDomainPostParseDataAlloc(const virDomainDef *def, virCapsPtr caps ATTRIBUTE_UNUSED, @@ -3969,6 +3992,7 @@ virDomainDefParserConfig virQEMUDriverDomainDefParser= Config =3D { .devicesPostParseCallback =3D qemuDomainDeviceDefPostParse, .domainPostParseCallback =3D qemuDomainDefPostParse, .assignAddressesCallback =3D qemuDomainDefAssignAddresses, + .assignAliasesCallback =3D qemuDomainDefAssignAliases, .domainValidateCallback =3D qemuDomainDefValidate, .deviceValidateCallback =3D qemuDomainDeviceDefValidate, =20 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 70be0c32d..5c2a45fd3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -485,6 +485,15 @@ testCompareXMLToArgv(const void *data) if (testUpdateQEMUCaps(info, vm, driver.caps) < 0) goto cleanup; =20 + /* 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(vm->def, info->qemuCaps, true) < 0) + goto cleanup; + log =3D virTestLogContentAndReset(); VIR_FREE(log); virResetLastError(); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-state-a= ctive.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-state-ac= tive.xml index 8cddbeff7..326e285cb 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-state-active.x= ml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-state-active.x= ml @@ -18,33 +18,47 @@ +
+
+
+
- + + + +
+
+
- - + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml= b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml index cc26af109..f63e8c3b7 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-active-commit.xml @@ -27,18 +27,28 @@ +
+
+
- - - + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-ac= tive.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-acti= ve.xml index 83d47df56..5abe21270 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-backing-chains-active.xml @@ -25,6 +25,7 @@ +
@@ -58,6 +59,7 @@ +
@@ -67,6 +69,7 @@ +
@@ -85,6 +88,7 @@ +
@@ -92,15 +96,24 @@ +
+
- - - + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml= b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml index c1e8a33ec..ebe6e4471 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-active.xml @@ -21,6 +21,7 @@ +
@@ -28,6 +29,7 @@ +
@@ -38,6 +40,7 @@ +
@@ -48,18 +51,28 @@ +
+
+
- - - + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml b/= tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml index e390bc02f..451737621 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml @@ -21,6 +21,7 @@ +
@@ -28,6 +29,7 @@ +
@@ -38,24 +40,35 @@ +
+
+
+
- - - + + + + + + + + + +
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labels= kip.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip= .xml index d37b950cb..8ea5a29d7 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-static-labelskip.xml @@ -20,18 +20,28 @@ +
+
+
- - - + + + + + + + + + +
--=20 2.13.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list