[libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation

Boris Fiuczynski posted 8 patches 7 years ago
[libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by Boris Fiuczynski 7 years ago
From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>

Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
devices such that CCW address will be generated.

Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
---
 docs/schemas/domaincommon.rng  |  5 ++++-
 src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
 src/util/virmdev.c             |  3 ++-
 src/util/virmdev.h             |  1 +
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 0a6b29b..bea2bc0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4478,7 +4478,10 @@
       <value>mdev</value>
     </attribute>
     <attribute name="model">
-      <value>vfio-pci</value>
+      <choice>
+        <value>vfio-pci</value>
+        <value>vfio-ccw</value>
+      </choice>
     </attribute>
     <element name="source">
       <ref name="mdevaddress"/>
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 50f815c..be0424d 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -282,6 +282,23 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
 
 
 static void
+qemuDomainPrimeVfioDeviceAddresses(virDomainDefPtr def,
+                                      virDomainDeviceAddressType type)
+{
+    size_t i;
+
+    for (i = 0; i < def->nhostdevs; i++) {
+        virDomainHostdevSubsysPtr subsys = &def->hostdevs[i]->source.subsys;
+
+        if (virHostdevIsMdevDevice(def->hostdevs[i]) &&
+            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;
+    }
+}
+
+
+static void
 qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def,
                                      virDomainDeviceAddressType type)
 {
@@ -397,6 +414,9 @@ qemuDomainAssignS390Addresses(virDomainDefPtr def,
 
     if (qemuDomainIsS390CCW(def) &&
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCW)) {
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW))
+            qemuDomainPrimeVfioDeviceAddresses(
+                def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
         qemuDomainPrimeVirtioDeviceAddresses(
             def, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW);
 
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 536ddbe..6c51388 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-pci",
+              "vfio-ccw")
 
 static virClassPtr virMediatedDeviceListClass;
 
diff --git a/src/util/virmdev.h b/src/util/virmdev.h
index 01ab02e..cfda2ca 100644
--- a/src/util/virmdev.h
+++ b/src/util/virmdev.h
@@ -25,6 +25,7 @@
 
 typedef enum {
     VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
+    VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
 
     VIR_MDEV_MODEL_TYPE_LAST
 } virMediatedDeviceModelType;
-- 
2.9.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by John Ferlan 7 years ago

On 05/07/2018 10:41 AM, Boris Fiuczynski wrote:
> From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
> 
> Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
> devices such that CCW address will be generated.
> 
> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
> ---
>  docs/schemas/domaincommon.rng  |  5 ++++-
>  src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
>  src/util/virmdev.c             |  3 ++-
>  src/util/virmdev.h             |  1 +
>  4 files changed, 27 insertions(+), 2 deletions(-)
> 

Looking at all places using VIR_MDEV_MODEL_TYPE_VFIO_PCI - should this
patch make a change to virDomainHostdevDefPostParse to do something
similar - that is:

       if (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
            dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
... error message
      }

?

Let me know... I think it should and can add it before pushing...

Reviewed-by: John Ferlan <jferlan@redhat.com>

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by Boris Fiuczynski 6 years, 12 months ago
On 05/10/2018 10:52 PM, John Ferlan wrote:
> 
> 
> On 05/07/2018 10:41 AM, Boris Fiuczynski wrote:
>> From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>
>> Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
>> devices such that CCW address will be generated.
>>
>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
>> ---
>>   docs/schemas/domaincommon.rng  |  5 ++++-
>>   src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
>>   src/util/virmdev.c             |  3 ++-
>>   src/util/virmdev.h             |  1 +
>>   4 files changed, 27 insertions(+), 2 deletions(-)
>>
> 
> Looking at all places using VIR_MDEV_MODEL_TYPE_VFIO_PCI - should this
> patch make a change to virDomainHostdevDefPostParse to do something
> similar - that is:
> 
>         if (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
> ... error message
>        }
> 
> ?
> 
> Let me know... I think it should and can add it before pushing...
You are correct. Good catch!
How about fixing it like this?
         if ((model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
             dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) ||
             (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
             dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("Unsupported address type '%s' with mediated "
                              "device model '%s'"),
 
virDomainDeviceAddressTypeToString(dev->info->type),
                            virMediatedDeviceModelTypeToString(model));
             return -1;
         }



Besides that I just saw that the indention of the second parameter of 
method qemuDomainPrimeVfioDeviceAddresses is off by three blanks.

> 
> Reviewed-by: John Ferlan <jferlan@redhat.com>
> 
> John
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
> 


-- 
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
Re: [libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by John Ferlan 6 years, 12 months ago

On 05/14/2018 03:43 AM, Boris Fiuczynski wrote:
> On 05/10/2018 10:52 PM, John Ferlan wrote:
>>
>>
>> On 05/07/2018 10:41 AM, Boris Fiuczynski wrote:
>>> From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>>
>>> Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
>>> devices such that CCW address will be generated.
>>>
>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
>>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>>> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
>>> ---
>>>   docs/schemas/domaincommon.rng  |  5 ++++-
>>>   src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
>>>   src/util/virmdev.c             |  3 ++-
>>>   src/util/virmdev.h             |  1 +
>>>   4 files changed, 27 insertions(+), 2 deletions(-)
>>>
>>
>> Looking at all places using VIR_MDEV_MODEL_TYPE_VFIO_PCI - should this
>> patch make a change to virDomainHostdevDefPostParse to do something
>> similar - that is:
>>
>>         if (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
>> ... error message
>>        }
>>
>> ?
>>
>> Let me know... I think it should and can add it before pushing...
> You are correct. Good catch!
> How about fixing it like this?
>         if ((model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
>             dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) ||
>             (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>             dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
>             virReportError(VIR_ERR_XML_ERROR,
>                            _("Unsupported address type '%s' with mediated "
>                              "device model '%s'"),
> 
> virDomainDeviceAddressTypeToString(dev->info->type),
>                            virMediatedDeviceModelTypeToString(model));
>             return -1;
>         }
> 

OK - added that...

> 
> 
> Besides that I just saw that the indention of the second parameter of
> method qemuDomainPrimeVfioDeviceAddresses is off by three blanks.
> 

ah true - adjusted that.

I've merged with the latest top of tree and have pushed... So much flux
in the capabilities lately...

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by Boris Fiuczynski 6 years, 12 months ago
On 05/14/2018 06:30 PM, John Ferlan wrote:
> 
> 
> On 05/14/2018 03:43 AM, Boris Fiuczynski wrote:
>> On 05/10/2018 10:52 PM, John Ferlan wrote:
>>>
>>>
>>> On 05/07/2018 10:41 AM, Boris Fiuczynski wrote:
>>>> From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>>>
>>>> Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
>>>> devices such that CCW address will be generated.
>>>>
>>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>>> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
>>>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>>>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>>>> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
>>>> ---
>>>>    docs/schemas/domaincommon.rng  |  5 ++++-
>>>>    src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
>>>>    src/util/virmdev.c             |  3 ++-
>>>>    src/util/virmdev.h             |  1 +
>>>>    4 files changed, 27 insertions(+), 2 deletions(-)
>>>>
>>>
>>> Looking at all places using VIR_MDEV_MODEL_TYPE_VFIO_PCI - should this
>>> patch make a change to virDomainHostdevDefPostParse to do something
>>> similar - that is:
>>>
>>>          if (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>>               dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
>>> ... error message
>>>         }
>>>
>>> ?
>>>
>>> Let me know... I think it should and can add it before pushing...
>> You are correct. Good catch!
>> How about fixing it like this?
>>          if ((model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
>>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) ||
>>              (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
>>              virReportError(VIR_ERR_XML_ERROR,
>>                             _("Unsupported address type '%s' with mediated "
>>                               "device model '%s'"),
>>
>> virDomainDeviceAddressTypeToString(dev->info->type),
>>                             virMediatedDeviceModelTypeToString(model));
>>              return -1;
>>          }
>>
> 
> OK - added that...
> 
>>
>>
>> Besides that I just saw that the indention of the second parameter of
>> method qemuDomainPrimeVfioDeviceAddresses is off by three blanks.
>>
> 
> ah true - adjusted that.
> 
> I've merged with the latest top of tree and have pushed... So much flux
> in the capabilities lately...
> 
> John
You are correct that lots of changes happened in the capabilities.
Thanks for merging the changes and pushing the series!


-- 
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
Re: [libvirt] [PATCH v2 4/8] qemu: vfio-ccw device address generation
Posted by Shalini Chellathurai Saroja 6 years, 12 months ago

On 05/14/2018 06:30 PM, John Ferlan wrote:
>
> On 05/14/2018 03:43 AM, Boris Fiuczynski wrote:
>> On 05/10/2018 10:52 PM, John Ferlan wrote:
>>>
>>> On 05/07/2018 10:41 AM, Boris Fiuczynski wrote:
>>>> From: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>>>
>>>> Introduces the vfio-ccw model for mediated devices and prime vfio-ccw
>>>> devices such that CCW address will be generated.
>>>>
>>>> Signed-off-by: Shalini Chellathurai Saroja <shalini@linux.vnet.ibm.com>
>>>> Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
>>>> Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
>>>> Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
>>>> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
>>>> ---
>>>>    docs/schemas/domaincommon.rng  |  5 ++++-
>>>>    src/qemu/qemu_domain_address.c | 20 ++++++++++++++++++++
>>>>    src/util/virmdev.c             |  3 ++-
>>>>    src/util/virmdev.h             |  1 +
>>>>    4 files changed, 27 insertions(+), 2 deletions(-)
>>>>
>>> Looking at all places using VIR_MDEV_MODEL_TYPE_VFIO_PCI - should this
>>> patch make a change to virDomainHostdevDefPostParse to do something
>>> similar - that is:
>>>
>>>          if (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>>               dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
>>> ... error message
>>>         }
>>>
>>> ?
>>>
>>> Let me know... I think it should and can add it before pushing...
>> You are correct. Good catch!
>> How about fixing it like this?
>>          if ((model == VIR_MDEV_MODEL_TYPE_VFIO_PCI &&
>>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) ||
>>              (model == VIR_MDEV_MODEL_TYPE_VFIO_CCW &&
>>              dev->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)) {
>>              virReportError(VIR_ERR_XML_ERROR,
>>                             _("Unsupported address type '%s' with mediated "
>>                               "device model '%s'"),
>>
>> virDomainDeviceAddressTypeToString(dev->info->type),
>>                             virMediatedDeviceModelTypeToString(model));
>>              return -1;
>>          }
>>
> OK - added that...
>
>>
>> Besides that I just saw that the indention of the second parameter of
>> method qemuDomainPrimeVfioDeviceAddresses is off by three blanks.
>>
> ah true - adjusted that.
>
> I've merged with the latest top of tree and have pushed... So much flux
> in the capabilities lately...

Thank you :-).

>
> John
>
> --
> 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