From nobody Sun Feb 8 18:30: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=linux.intel.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1702914236177320.9616714335857; Mon, 18 Dec 2023 07:43:56 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 139921BC6; Mon, 18 Dec 2023 10:43:54 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8AC121BD4; Mon, 18 Dec 2023 10:37:15 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 26D2A1A77; Mon, 18 Dec 2023 10:36:32 -0500 (EST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 D185A197E for ; Mon, 18 Dec 2023 10:36:29 -0500 (EST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 07:35:28 -0800 Received: from vivk-mobl.amr.corp.intel.com ([10.215.113.98]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2023 07:35:26 -0800 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="2614127" X-IronPort-AV: E=Sophos;i="6.04,286,1695711600"; d="scan'208";a="2614127" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10928"; a="899009112" X-IronPort-AV: E=Sophos;i="6.04,286,1695711600"; d="scan'208";a="899009112" From: Vivek Kashyap To: devel@lists.libvirt.org, ciara.loftus@intel.com Subject: [vf-token 4/8] conf: XML parsing and formatting of vf-token Date: Mon, 18 Dec 2023 21:05:05 +0530 Message-Id: <20231218153509.1285-5-vivek.kashyap@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218153509.1285-1-vivek.kashyap@linux.intel.com> References: <20231218153509.1285-1-vivek.kashyap@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: PD7NZ6WG75NC5N2CUFM2VFFYAH4P5U52 X-Message-ID-Hash: PD7NZ6WG75NC5N2CUFM2VFFYAH4P5U52 X-MailFrom: vivek.kashyap@linux.intel.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 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: 1702914237963100001 This patch introduces new XML parser/formatter functions for parsing the vf-token Signed-off-by: Vivek Kashyap Signed-off-by: Ciara Loftus --- src/conf/device_conf.c | 49 ++++++++++++++++++++++++++++++++++------ src/conf/domain_conf.c | 8 +++++++ src/libvirt_private.syms | 1 + src/util/virpci.c | 7 ++++++ src/util/virpci.h | 2 ++ 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index f3d977f2b7..f490aeef9a 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -70,6 +70,21 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node, return 0; } =20 + +static int +virPCIDeviceTokenParseXML(xmlNodePtr node, + virPCIDeviceAddress *addr) +{ + if (virXMLPropUUID(node, "uuid", VIR_XML_PROP_NONE, + addr->token.uuid) < 0) + return -1; + + addr->token.isSet =3D 1; + + return 0; +} + + void virDomainDeviceInfoClear(virDomainDeviceInfo *info) { @@ -200,6 +215,7 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, virPCIDeviceAddress *addr) { xmlNodePtr zpci; + xmlNodePtr token; =20 memset(addr, 0, sizeof(*addr)); =20 @@ -231,6 +247,11 @@ virPCIDeviceAddressParseXML(xmlNodePtr node, return -1; } =20 + if ((token =3D virXMLNodeGetSubelement(node, "vf-token"))) { + if (virPCIDeviceTokenParseXML(token, addr) < 0) + return -1; + } + return 0; } =20 @@ -239,13 +260,27 @@ virPCIDeviceAddressFormat(virBuffer *buf, virPCIDeviceAddress addr, bool includeTypeInAddr) { - virBufferAsprintf(buf, "
\n", - includeTypeInAddr ? "type=3D'pci' " : "", - addr.domain, - addr.bus, - addr.slot, - addr.function); + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) tokenBuf =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer *tb =3D NULL; + + virBufferAsprintf(&attrBuf, " %sdomain=3D'0x%04x' bus=3D'0x%02x' " + "slot=3D'0x%02x' function=3D'0x%d'", + includeTypeInAddr ? "type=3D'pci' " : "", + addr.domain, + addr.bus, + addr.slot, + addr.function); + + if (virPCIVFIOTokenIDIsPresent(&addr.token)) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virBufferAsprintf(&tokenBuf, "\n", + virUUIDFormat(addr.token.uuid, uuidstr)); + tb =3D &tokenBuf; + } + + virXMLFormatElement(buf, "address", &attrBuf, tb); } =20 int diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 22ad43e1d7..8bda81815a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5403,6 +5403,14 @@ virDomainDeviceInfoFormat(virBuffer *buf, info->addr.pci.zpci.uid.value, info->addr.pci.zpci.fid.value); } + + if (virPCIVFIOTokenIDIsPresent(&info->addr.pci.token)) { + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virBufferAsprintf(&childBuf, "\n", + virUUIDFormat(info->addr.pci.token.uuid, + uuidstr)); + } break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 31c0f169c3..b2bc26c323 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3138,6 +3138,7 @@ virPCIHeaderTypeToString; virPCIIsVirtualFunction; virPCIStubDriverTypeFromString; virPCIStubDriverTypeToString; +virPCIVFIOTokenIDIsPresent; virPCIVirtualFunctionListFree; virZPCIDeviceAddressIsIncomplete; virZPCIDeviceAddressIsPresent; diff --git a/src/util/virpci.c b/src/util/virpci.c index afce7b52b7..0a9ae7a881 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2314,6 +2314,13 @@ virZPCIDeviceAddressIsPresent(const virZPCIDeviceAdd= ress *addr) } =20 =20 +bool +virPCIVFIOTokenIDIsPresent(const virPCIDeviceToken *token) +{ + return token->isSet; +} + + void virPCIVirtualFunctionListFree(virPCIVirtualFunctionList *list) { diff --git a/src/util/virpci.h b/src/util/virpci.h index da32c2f4d2..8510752e84 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -271,6 +271,8 @@ int virPCIDeviceAddressParse(char *address, virPCIDevic= eAddress *bdf); bool virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr); bool virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddress *addr); =20 +bool virPCIVFIOTokenIDIsPresent(const virPCIDeviceToken *token); + int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path, int pfNetDevIdx, char **pfname, --=20 2.33.8 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org