On Wed, Nov 29, 2023 at 21:07:24 -0700, Vivek Kashyap wrote:
XML parsing and formatting of vf-token attribute
Signed-off-by: Vivek Kashyap <vivek.kashyap(a)linux.intel.com>
---
src/conf/device_conf.c | 32 ++++++++++++++++++++++++++++++--
src/conf/device_conf.h | 3 +++
src/conf/domain_conf.c | 8 ++++++++
src/conf/schemas/basictypes.rng | 7 +++++++
src/libvirt_private.syms | 1 +
src/util/virpci.c | 7 +++++++
src/util/virpci.h | 3 +++
7 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index f3d977f2b7..f365e98bfd 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -188,11 +188,20 @@ virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo
*info)
virZPCIDeviceAddressIsIncomplete(&info->addr.pci.zpci);
}
+bool
+virDeviceExtensionIsPresent(const virPCIDeviceAddress *pci)
+{
+ return (((pci->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
+ virZPCIDeviceAddressIsPresent(&pci->zpci)) ||
+ ((pci->extFlags & VIR_PCI_ADDRESS_EXTENSION_VFTOKEN) &&
+ pci->token.isSet));
+}
+
bool
virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info)
{
- return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
- virZPCIDeviceAddressIsPresent(&info->addr.pci.zpci);
+ return (info->addr.pci.extFlags != VIR_PCI_ADDRESS_EXTENSION_NONE) &&
+ virDeviceExtensionIsPresent(&info->addr.pci);
}
Fixes to coding style requested before:
https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/4...
were not addressed. Note that reviews aren't an easy task an thus not
addressing all feedback may deter reviewers from a timely look at your
next postings.
int
@@ -200,6 +209,7 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddress *addr)
{
xmlNodePtr zpci;
+ xmlNodePtr token;
memset(addr, 0, sizeof(*addr));
@@ -231,6 +241,11 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
return -1;
}
+ if ((token = virXMLNodeGetSubelement(node, "vf-token"))) {
+ if (virPCIDeviceTokenParseXML(token, addr) < 0)
+ return -1;
+ }
+
return 0;
}
@@ -248,6 +263,19 @@ virPCIDeviceAddressFormat(virBuffer *buf,
addr.function);
}
+int
No need to export this function, as it's used just in this file. Place
it properly and make it static.
+virPCIDeviceTokenParseXML(xmlNodePtr node,
+ virPCIDeviceAddress *addr)
+{
+ if (virXMLPropUUID(node, "uuid", VIR_XML_PROP_NONE,
+ addr->token.uuid) < 0)
+ return -1;
+
+ addr->token.isSet = 1;
+
+ return 0;
+}
+
int
virCCWDeviceAddressParseXML(xmlNodePtr node,
virCCWDeviceAddress *addr)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index a83377417a..a37ee29b88 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -188,6 +188,9 @@ bool virDeviceInfoPCIAddressExtensionIsPresent(const
virDomainDeviceInfo *info);
int virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddress *addr);
+int virPCIDeviceTokenParseXML(xmlNodePtr node,
+ virPCIDeviceAddress *addr);
+
Drop this hunk.
void virPCIDeviceAddressFormat(virBuffer *buf,
virPCIDeviceAddress addr,
bool includeTypeInAddr);
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, "<vf-token
uuid='%s'/>\n",
+ virUUIDFormat(info->addr.pci.token.uuid,
+ uuidstr));
+ }
break;
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.rng
index 26eb538077..bbb7484430 100644
--- a/src/conf/schemas/basictypes.rng
+++ b/src/conf/schemas/basictypes.rng
@@ -121,6 +121,13 @@
<ref name="virOnOff"/>
</attribute>
</optional>
+ <optional>
+ <element name="vf-token">
+ <attribute name="uuid">
+ <ref name="UUID"/>
+ </attribute>
+ </element>
+ </optional>
</define>
<define name="zpciaddress">
<optional>
And move the documentation from the last patch to this one.