[libvirt] [PATCH v3 05/15] conf: Add post parse code for mdevs to virDomainHostdevDefPostParse

Erik Skultety posted 15 patches 8 years, 10 months ago
There is a newer version of this series
[libvirt] [PATCH v3 05/15] conf: Add post parse code for mdevs to virDomainHostdevDefPostParse
Posted by Erik Skultety 8 years, 10 months ago
We need to make sure that if user explicitly provides a guest address
for a mdev device, the address type will be matching the device API
supported on that specific mediated device and error out with an
incorrect XML message.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 src/conf/domain_conf.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 77201925ce..1a8f1b2f8a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4252,6 +4252,23 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
             }
         }
         break;
+    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
+        int model = dev->source.subsys.u.mdev.model;
+
+        if (dev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+            return 0;
+
+        if (model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
+            dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("Unsupported address type '%s' with mediated "
+                             "device model '%s'"),
+                           virDomainDeviceAddressTypeToString(dev->info->type),
+                           virMediatedDeviceModelTypeToString(model));
+            return -1;
+        }
+    }
+
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
-- 
2.12.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 05/15] conf: Add post parse code for mdevs to virDomainHostdevDefPostParse
Posted by Pavel Hrdina 8 years, 10 months ago
On Thu, Mar 16, 2017 at 01:21:09PM +0100, Erik Skultety wrote:
> We need to make sure that if user explicitly provides a guest address
> for a mdev device, the address type will be matching the device API
> supported on that specific mediated device and error out with an
> incorrect XML message.
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/conf/domain_conf.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

This should be squashed into the previous patch to keep the domain_conf
changes together.

Pavel

> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 77201925ce..1a8f1b2f8a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -4252,6 +4252,23 @@ virDomainHostdevDefPostParse(virDomainHostdevDefPtr dev,
>              }
>          }
>          break;
> +    case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: {
> +        int model = dev->source.subsys.u.mdev.model;
> +
> +        if (dev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
> +            return 0;
> +
> +        if (model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
> +            dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
> +            virReportError(VIR_ERR_XML_ERROR,
> +                           _("Unsupported address type '%s' with mediated "
> +                             "device model '%s'"),
> +                           virDomainDeviceAddressTypeToString(dev->info->type),
> +                           virMediatedDeviceModelTypeToString(model));
> +            return -1;
> +        }
> +    }
> +
>      case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
>      case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
>      case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
> -- 
> 2.12.0
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list