[libvirt] [RFC PATCH 2/3] qemu: vfio-ap device support

Boris Fiuczynski posted 3 patches 5 years, 11 months ago
There is a newer version of this series
[libvirt] [RFC PATCH 2/3] qemu: vfio-ap device support
Posted by Boris Fiuczynski 5 years, 11 months ago
Adjusting domain format documentation, adding device address
support and adding command line generation for vfio-ap.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
 docs/formatdomain.html.in      | 3 ++-
 docs/schemas/domaincommon.rng  | 1 +
 src/qemu/qemu_command.c        | 8 ++++++++
 src/qemu/qemu_domain_address.c | 4 ++++
 src/util/virmdev.c             | 3 ++-
 src/util/virmdev.h             | 1 +
 6 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8189959773..269741a690 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4616,8 +4616,9 @@
           <dd>For mediated devices (<span class="since">Since 3.2.0</span>)
           the <code>model</code> attribute specifies the device API which
           determines how the host's vfio driver will expose the device to the
-          guest. Currently, <code>model='vfio-pci'</code> and
+          guest. Currently, <code>model='vfio-pci'</code>,
           <code>model='vfio-ccw'</code> (<span class="since">Since 4.4.0</span>)
+          and <code>model='vfio-ap'</code> (<span class="since">Since 4.9.0</span>)
           is supported. <a href="drvnodedev.html#MDEV">MDEV</a> section
           provides more information about mediated devices as well as how to
           create mediated devices on the host.
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 099a949cf8..b9ac5df479 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4618,6 +4618,7 @@
       <choice>
         <value>vfio-pci</value>
         <value>vfio-ccw</value>
+        <value>vfio-ap</value>
       </choice>
     </attribute>
     <optional>
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d77cf8c2d6..83569d70ab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5476,6 +5476,14 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
                     return -1;
                 }
                 break;
+            case VIR_MDEV_MODEL_TYPE_VFIO_AP:
+                if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("VFIO AP device assignment is not "
+                                     "supported by this version of QEMU"));
+                    return -1;
+                }
+                break;
             case VIR_MDEV_MODEL_TYPE_LAST:
             default:
                 virReportEnumRangeError(virMediatedDeviceModelType,
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 8a8764cff5..24dd7c1a58 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -294,6 +294,10 @@ qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
             subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
             def->hostdevs[i]->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
             def->hostdevs[i]->info->type = type;
+
+        if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
+            subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP)
+            def->hostdevs[i]->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
     }
 }
 
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 10a2b08337..3e11e38802 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
 
 VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
               "vfio-pci",
-              "vfio-ccw")
+              "vfio-ccw",
+              "vfio-ap")
 
 static virClassPtr virMediatedDeviceListClass;
 
diff --git a/src/util/virmdev.h b/src/util/virmdev.h
index 7c93c4d390..c856ff5bdb 100644
--- a/src/util/virmdev.h
+++ b/src/util/virmdev.h
@@ -27,6 +27,7 @@
 typedef enum {
     VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
     VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
+    VIR_MDEV_MODEL_TYPE_VFIO_AP  = 2,
 
     VIR_MDEV_MODEL_TYPE_LAST
 } virMediatedDeviceModelType;
-- 
2.17.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 2/3] qemu: vfio-ap device support
Posted by Bjoern Walk 5 years, 11 months ago
Boris Fiuczynski <fiuczy@linux.ibm.com> [2018-10-08, 06:25PM +0200]:
> Adjusting domain format documentation, adding device address
> support and adding command line generation for vfio-ap.
> 
> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> ---
>  docs/formatdomain.html.in      | 3 ++-
>  docs/schemas/domaincommon.rng  | 1 +
>  src/qemu/qemu_command.c        | 8 ++++++++
>  src/qemu/qemu_domain_address.c | 4 ++++
>  src/util/virmdev.c             | 3 ++-
>  src/util/virmdev.h             | 1 +
>  6 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 8189959773..269741a690 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -4616,8 +4616,9 @@
>            <dd>For mediated devices (<span class="since">Since 3.2.0</span>)
>            the <code>model</code> attribute specifies the device API which
>            determines how the host's vfio driver will expose the device to the
> -          guest. Currently, <code>model='vfio-pci'</code> and
> +          guest. Currently, <code>model='vfio-pci'</code>,
>            <code>model='vfio-ccw'</code> (<span class="since">Since 4.4.0</span>)
> +          and <code>model='vfio-ap'</code> (<span class="since">Since 4.9.0</span>)
>            is supported. <a href="drvnodedev.html#MDEV">MDEV</a> section
>            provides more information about mediated devices as well as how to
>            create mediated devices on the host.

Maybe it is time to explain what the models actually are? Or is this not
in the scope of libvirt's documentation?

> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
> index 099a949cf8..b9ac5df479 100644
> --- a/docs/schemas/domaincommon.rng
> +++ b/docs/schemas/domaincommon.rng
> @@ -4618,6 +4618,7 @@
>        <choice>
>          <value>vfio-pci</value>
>          <value>vfio-ccw</value>
> +        <value>vfio-ap</value>
>        </choice>
>      </attribute>
>      <optional>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index d77cf8c2d6..83569d70ab 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -5476,6 +5476,14 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
>                      return -1;
>                  }
>                  break;
> +            case VIR_MDEV_MODEL_TYPE_VFIO_AP:
> +                if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) {
> +                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                                   _("VFIO AP device assignment is not "
> +                                     "supported by this version of QEMU"));
> +                    return -1;
> +                }
> +                break;
>              case VIR_MDEV_MODEL_TYPE_LAST:
>              default:
>                  virReportEnumRangeError(virMediatedDeviceModelType,
> diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
> index 8a8764cff5..24dd7c1a58 100644
> --- a/src/qemu/qemu_domain_address.c
> +++ b/src/qemu/qemu_domain_address.c
> @@ -294,6 +294,10 @@ qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
>              subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>              def->hostdevs[i]->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
>              def->hostdevs[i]->info->type = type;
> +
> +        if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
> +            subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP)
> +            def->hostdevs[i]->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
>      }
>  }
>  
> diff --git a/src/util/virmdev.c b/src/util/virmdev.c
> index 10a2b08337..3e11e38802 100644
> --- a/src/util/virmdev.c
> +++ b/src/util/virmdev.c
> @@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
>  
>  VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
>                "vfio-pci",
> -              "vfio-ccw")
> +              "vfio-ccw",
> +              "vfio-ap")
>  
>  static virClassPtr virMediatedDeviceListClass;
>  
> diff --git a/src/util/virmdev.h b/src/util/virmdev.h
> index 7c93c4d390..c856ff5bdb 100644
> --- a/src/util/virmdev.h
> +++ b/src/util/virmdev.h
> @@ -27,6 +27,7 @@
>  typedef enum {
>      VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
>      VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
> +    VIR_MDEV_MODEL_TYPE_VFIO_AP  = 2,
>  
>      VIR_MDEV_MODEL_TYPE_LAST
>  } virMediatedDeviceModelType;
> -- 
> 2.17.0
> 

Looks good.

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 2/3] qemu: vfio-ap device support
Posted by Boris Fiuczynski 5 years, 11 months ago
On 10/9/18 7:08 AM, Bjoern Walk wrote:
> Boris Fiuczynski <fiuczy@linux.ibm.com> [2018-10-08, 06:25PM +0200]:
>> Adjusting domain format documentation, adding device address
>> support and adding command line generation for vfio-ap.
>>
>> Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>> ---
>>   docs/formatdomain.html.in      | 3 ++-
>>   docs/schemas/domaincommon.rng  | 1 +
>>   src/qemu/qemu_command.c        | 8 ++++++++
>>   src/qemu/qemu_domain_address.c | 4 ++++
>>   src/util/virmdev.c             | 3 ++-
>>   src/util/virmdev.h             | 1 +
>>   6 files changed, 18 insertions(+), 2 deletions(-)
>>
>> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
>> index 8189959773..269741a690 100644
>> --- a/docs/formatdomain.html.in
>> +++ b/docs/formatdomain.html.in
>> @@ -4616,8 +4616,9 @@
>>             <dd>For mediated devices (<span class="since">Since 3.2.0</span>)
>>             the <code>model</code> attribute specifies the device API which
>>             determines how the host's vfio driver will expose the device to the
>> -          guest. Currently, <code>model='vfio-pci'</code> and
>> +          guest. Currently, <code>model='vfio-pci'</code>,
>>             <code>model='vfio-ccw'</code> (<span class="since">Since 4.4.0</span>)
>> +          and <code>model='vfio-ap'</code> (<span class="since">Since 4.9.0</span>)
>>             is supported. <a href="drvnodedev.html#MDEV">MDEV</a> section
>>             provides more information about mediated devices as well as how to
>>             create mediated devices on the host.
> 
> Maybe it is time to explain what the models actually are? Or is this not
> in the scope of libvirt's documentation?
I am not sure what the libvirt policy regarding the documentation is. 
Therefore it would be good if some familiar with it could answer this 
question.
I just stuck to the style of the already supported vfio models.

> 
>> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
>> index 099a949cf8..b9ac5df479 100644
>> --- a/docs/schemas/domaincommon.rng
>> +++ b/docs/schemas/domaincommon.rng
>> @@ -4618,6 +4618,7 @@
>>         <choice>
>>           <value>vfio-pci</value>
>>           <value>vfio-ccw</value>
>> +        <value>vfio-ap</value>
>>         </choice>
>>       </attribute>
>>       <optional>
>> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
>> index d77cf8c2d6..83569d70ab 100644
>> --- a/src/qemu/qemu_command.c
>> +++ b/src/qemu/qemu_command.c
>> @@ -5476,6 +5476,14 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
>>                       return -1;
>>                   }
>>                   break;
>> +            case VIR_MDEV_MODEL_TYPE_VFIO_AP:
>> +                if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_AP)) {
>> +                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>> +                                   _("VFIO AP device assignment is not "
>> +                                     "supported by this version of QEMU"));
>> +                    return -1;
>> +                }
>> +                break;
>>               case VIR_MDEV_MODEL_TYPE_LAST:
>>               default:
>>                   virReportEnumRangeError(virMediatedDeviceModelType,
>> diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
>> index 8a8764cff5..24dd7c1a58 100644
>> --- a/src/qemu/qemu_domain_address.c
>> +++ b/src/qemu/qemu_domain_address.c
>> @@ -294,6 +294,10 @@ qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
>>               subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>               def->hostdevs[i]->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
>>               def->hostdevs[i]->info->type = type;
>> +
>> +        if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
>> +            subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_AP)
>> +            def->hostdevs[i]->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE;
>>       }
>>   }
>>   
>> diff --git a/src/util/virmdev.c b/src/util/virmdev.c
>> index 10a2b08337..3e11e38802 100644
>> --- a/src/util/virmdev.c
>> +++ b/src/util/virmdev.c
>> @@ -48,7 +48,8 @@ struct _virMediatedDeviceList {
>>   
>>   VIR_ENUM_IMPL(virMediatedDeviceModel, VIR_MDEV_MODEL_TYPE_LAST,
>>                 "vfio-pci",
>> -              "vfio-ccw")
>> +              "vfio-ccw",
>> +              "vfio-ap")
>>   
>>   static virClassPtr virMediatedDeviceListClass;
>>   
>> diff --git a/src/util/virmdev.h b/src/util/virmdev.h
>> index 7c93c4d390..c856ff5bdb 100644
>> --- a/src/util/virmdev.h
>> +++ b/src/util/virmdev.h
>> @@ -27,6 +27,7 @@
>>   typedef enum {
>>       VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
>>       VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
>> +    VIR_MDEV_MODEL_TYPE_VFIO_AP  = 2,
>>   
>>       VIR_MDEV_MODEL_TYPE_LAST
>>   } virMediatedDeviceModelType;
>> -- 
>> 2.17.0
>>
> 
> Looks good.
> 
> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
> 
Thanks for the review.


-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list