[RFC v2: vf-token 4/7] conf: vf-token parsing and formatting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



XML parsing and formatting of vf-token attribute

Signed-off-by: Vivek Kashyap <vivek.kashyap@xxxxxxxxxxxxxxx>
---
 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);
 }
 
 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
+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);
+
 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>
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 553b01b8c0..0726ae6622 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3137,6 +3137,7 @@ virPCIHeaderTypeToString;
 virPCIIsVirtualFunction;
 virPCIStubDriverTypeFromString;
 virPCIStubDriverTypeToString;
+virPCIVFIOTokenIDIsPresent;
 virPCIVirtualFunctionListFree;
 virZPCIDeviceAddressIsIncomplete;
 virZPCIDeviceAddressIsPresent;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index baacde4c14..2aca144e85 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2313,6 +2313,13 @@ virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddress *addr)
 }
 
 
+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 f080fceb97..2d49bbd53f 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -279,6 +279,9 @@ int virPCIDeviceAddressParse(char *address, virPCIDeviceAddress *bdf);
 bool virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr);
 bool virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddress *addr);
 
+bool virPCIVFIOTokenIDIsPresent(const virPCIDeviceToken *token);
+bool virDeviceExtensionIsPresent(const virPCIDeviceAddress *pci);
+
 int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
                                  int pfNetDevIdx,
                                  char **pfname,
-- 
2.25.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux