[PATCH vf-token 5/8] qemu: Introduce validation for vf-token

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

 



Introduce a validation function for vf-token support in qemu and
generate vf-token device attribute in qemu command line

Signed-off-by: Vivek Kashyap <vivek.kashyap@xxxxxxxxxxxxxxx>
---
 src/qemu/qemu_command.c  |  8 ++++++++
 src/qemu/qemu_validate.c | 20 ++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 54fb8220e8..0e81a3ed73 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4706,6 +4706,7 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
     virDomainNetTeamingInfo *teaming;
     g_autofree char *host = virPCIDeviceAddressAsString(&pcisrc->addr);
     const char *failover_pair_id = NULL;
+    g_autofree char *token = NULL;
 
     /* caller has to assign proper passthrough backend type */
     switch (pcisrc->backend) {
@@ -4732,9 +4733,16 @@ qemuBuildPCIHostdevDevProps(const virDomainDef *def,
         teaming->persistent)
         failover_pair_id = teaming->persistent;
 
+    if ((dev->info->pciAddrExtFlags & VIR_PCI_ADDRESS_EXTENSION_VFTOKEN) &&
+        pcisrc->addr.token.isSet) {
+        token = g_new0(char, VIR_UUID_STRING_BUFLEN);
+        virUUIDFormat(pcisrc->addr.token.uuid, token);
+    }
+
     if (virJSONValueObjectAdd(&props,
                               "s:driver", "vfio-pci",
                               "s:host", host,
+                              "S:vf-token", token,
                               "s:id", dev->info->alias,
                               "p:bootindex", dev->info->effectiveBootIndex,
                               "S:failover_pair_id", failover_pair_id,
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index e475ad035e..13114ca3d1 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1364,6 +1364,24 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfo *info,
 }
 
 
+static int
+qemuValidateDomainDeviceDefVFTokenId(virDomainDeviceInfo *info,
+                                     virQEMUCaps *qemuCaps)
+{
+    virPCIDeviceToken *vftoken = &info->addr.pci.token;
+
+    if (virPCIVFIOTokenIDIsPresent(vftoken) &&
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VFIO_VFTOKEN)) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                       "%s",
+                       _("This QEMU binary doesn't support vf token ids"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 qemuValidateDomainDeviceDefAddressDrive(virDomainDeviceInfo *info,
                                         const virDomainDef *def,
@@ -1483,6 +1501,8 @@ qemuValidateDomainDeviceDefAddress(const virDomainDeviceDef *dev,
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
         if (qemuValidateDomainDeviceDefZPCIAddress(info, qemuCaps) < 0)
             return -1;
+         if (qemuValidateDomainDeviceDefVFTokenId(info, qemuCaps) < 0)
+            return -1;
         break;
 
     case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
-- 
2.33.8
_______________________________________________
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