From nobody Sun Feb 8 19:25:35 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1713367194357427.78096936870793; Wed, 17 Apr 2024 08:19:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4C9271C3F; Wed, 17 Apr 2024 11:19:53 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1C6781BF5; Wed, 17 Apr 2024 11:17:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FEE11B69; Wed, 17 Apr 2024 11:17:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 777231B88 for ; Wed, 17 Apr 2024 11:17:31 -0400 (EDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-422-oEVaGj7TMna3-dkveqkQqQ-1; Wed, 17 Apr 2024 11:17:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC7A9963B23; Wed, 17 Apr 2024 15:17:27 +0000 (UTC) Received: from colepc.home (unknown [10.22.34.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B161C06666; Wed, 17 Apr 2024 15:17:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: oEVaGj7TMna3-dkveqkQqQ-1 From: Cole Robinson To: devel@lists.libvirt.org Subject: [PATCH v4 3/3] conf: nodedev: Fill active_config at XML parse time Date: Wed, 17 Apr 2024 11:17:23 -0400 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: P3PNENII4GG2IL2KAJPWEOMPPXRYOYSY X-Message-ID-Hash: P3PNENII4GG2IL2KAJPWEOMPPXRYOYSY X-MailFrom: crobinso@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Michal Privoznik , fiuczy@linux.ibm.com, Cole Robinson X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1713367195185100001 Commit v10.0.0-265-ge67bca23e4 added a `active_config` and `defined_config` to nodedev mdev internal XML handling. `defined_config` can be filled at XML parse time, but `active_config` must be filled in by nodedev driver. This wasn't implemented for the test driver however, which caused virt-manager test suite regressions. Example before: ``` $ virsh --connect test:///home/crobinso/src/virt-manager/tests/data/testdri= ver/testdriver.xml nodedev-dumpxml mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110 mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110 /sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110 css_0_0_0023 ``` Example after: ``` $ virsh --connect test:///home/crobinso/src/virt-manager/tests/data/testdri= ver/testdriver.xml nodedev-dumpxml mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110 mdev_8e37ee90_2b51_45e3_9b25_bf8283c03110 /sys/devices/css0/0.0.0023/8e37ee90-2b51-45e3-9b25-bf8283c03110 css_0_0_0023 ``` Simplest solution is to fill in `active_config` at XML define time as well. The real node_device driver already takes care to free any `active_config` when it live updates this info, so we are safe there. This also lets us drop the test suite logic to duplicate this data. Signed-off-by: Cole Robinson --- src/conf/node_device_conf.c | 5 ++++- tests/nodedevxml2xmltest.c | 15 --------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 5cfbd6a7eb..f381ea128c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2222,6 +2222,7 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, _("missing type id attribute for '%1$s'"), def->nam= e); return -1; } + mdev->active_config.type =3D g_strdup(mdev->defined_config.type); =20 if ((uuidstr =3D virXPathString("string(./uuid[1])", ctxt))) { unsigned char uuidbuf[VIR_UUID_BUFLEN]; @@ -2248,8 +2249,10 @@ virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, if ((nattrs =3D virXPathNodeSet("./attr", ctxt, &attrs)) < 0) return -1; =20 - for (i =3D 0; i < nattrs; i++) + for (i =3D 0; i < nattrs; i++) { virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], &mdev->defined_= config); + virNodeDevCapMdevAttributeParseXML(ctxt, attrs[i], &mdev->active_c= onfig); + } =20 return 0; } diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index e918922672..d2663a8d68 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -24,7 +24,6 @@ testCompareXMLToXMLFiles(const char *xml, const char *out= file, unsigned int flag int ret =3D -1; virNodeDeviceDef *dev =3D NULL; virNodeDevCapsDef *caps; - size_t i; =20 if (virTestLoadFile(xml, &xmlData) < 0) goto fail; @@ -52,20 +51,6 @@ testCompareXMLToXMLFiles(const char *xml, const char *ou= tfile, unsigned int flag data->storage.logical_block_siz= e; } } - - if (caps->data.type =3D=3D VIR_NODE_DEV_CAP_MDEV && - !(flags & VIR_NODE_DEVICE_XML_INACTIVE)) { - data->mdev.active_config.type =3D g_strdup(data->mdev.defined_= config.type); - for (i =3D 0; i < data->mdev.defined_config.nattributes; i++) { - g_autoptr(virMediatedDeviceAttr) attr =3D g_new0(virMediat= edDeviceAttr, 1); - - attr->name =3D g_strdup(data->mdev.defined_config.attribut= es[i]->name); - attr->value =3D g_strdup(data->mdev.defined_config.attribu= tes[i]->value); - VIR_APPEND_ELEMENT(data->mdev.active_config.attributes, - data->mdev.active_config.nattributes, - attr); - } - } } =20 if (!(actual =3D virNodeDeviceDefFormat(dev, flags))) --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org