[libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests

Xiao Feng Ren posted 13 patches 7 years, 8 months ago
There is a newer version of this series
[libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Xiao Feng Ren 7 years, 8 months ago
From: Yi Min Zhao <zyimin@linux.ibm.com>

This commit adds hotplug support for PCI devices on S390 guests.
There's no need to implement hot unplug for zPCI as QEMU implements
an unplug callback which will unplug both PCI and zPCI device in a
cascaded way.
Currently, the following PCI devices are supported:
  virtio-blk-pci
  virtio-net-pci
  virtio-rng-pci
  virtio-input-host-pci
  virtio-keyboard-pci
  virtio-mouse-pci
  virtio-tablet-pci
  vfio-pci
  Shmem device
  SCSIVhost device

Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
---
 src/qemu/qemu_hotplug.c | 175 +++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 158 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b35594be5f..c64b4fa722 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -193,6 +193,84 @@ qemuDomainDelDiskSrcTLSObject(virQEMUDriverPtr driver,
 }
 
 
+static int
+qemuDomainAttachZPCIDevice(qemuMonitorPtr mon,
+                           virDomainDeviceInfoPtr info)
+{
+    int ret = -1;
+    char *devstr_zpci = NULL;
+
+    if (!(devstr_zpci = qemuBuildZPCIDevStr(info)))
+        goto cleanup;
+
+    if (qemuMonitorAddDevice(mon, devstr_zpci) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(devstr_zpci);
+    return ret;
+}
+
+
+static int
+qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
+                           virDomainDeviceInfoPtr info)
+{
+    char *zpciAlias = NULL;
+    int ret = -1;
+
+    if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci->zpciuid) < 0)
+        goto cleanup;
+
+    if (qemuMonitorDelDevice(mon, zpciAlias) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(zpciAlias);
+    return ret;
+}
+
+
+static int
+qemuDomainAttachExtensionDevice(qemuMonitorPtr mon,
+                                 virDomainDeviceInfoPtr info,
+                                 virQEMUCapsPtr qemuCaps)
+{
+    if (qemuCheckDeviceIsZPCI(info)) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("This QEMU doesn't support zpci devices"));
+            return -1;
+        }
+        return qemuDomainAttachZPCIDevice(mon, info);
+    }
+
+    return 0;
+}
+
+
+static int
+qemuDomainDetachExtensionDevice(qemuMonitorPtr mon,
+                                 virDomainDeviceInfoPtr info,
+                                 virQEMUCapsPtr qemuCaps)
+{
+    if (qemuCheckDeviceIsZPCI(info)) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("This QEMU doesn't support zpci devices"));
+            return -1;
+        }
+        return qemuDomainDetachZPCIDevice(mon, info);
+    }
+
+    return 0;
+}
+
+
 static int
 qemuHotplugWaitForTrayEject(virQEMUDriverPtr driver,
                             virDomainObjPtr vm,
@@ -521,9 +599,16 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver,
         goto exit_monitor;
     driveAdded = true;
 
-    if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+    if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info,
+                                         priv->qemuCaps) < 0)
         goto exit_monitor;
 
+    if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &disk->info,
+                                                      priv->qemuCaps));
+        goto exit_monitor;
+    }
+
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         ret = -2;
         goto error;
@@ -1088,17 +1173,19 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
     }
 
     if (qemuDomainIsS390CCW(vm->def) &&
-        virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
-        net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
-        if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
-            goto cleanup;
-        if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
-                                      !net->info.addr.ccw.assigned) < 0)
+        net->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+        if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CCW)) {
+            net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW;
+            if (!(ccwaddrs = qemuDomainCCWAddrSetCreateFromDomain(vm->def)))
+                goto cleanup;
+            if (virDomainCCWAddressAssign(&net->info, ccwaddrs,
+                                          !net->info.addr.ccw.assigned) < 0)
+                goto cleanup;
+        } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("virtio-s390 net device cannot be hotplugged."));
             goto cleanup;
-    } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_VIRTIO_S390)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("virtio-s390 net device cannot be hotplugged."));
-        goto cleanup;
+        }
     } else if (qemuDomainEnsurePCIAddress(vm, &dev, driver) < 0) {
         goto cleanup;
     }
@@ -1158,7 +1245,17 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
         goto try_remove;
 
     qemuDomainObjEnterMonitor(driver, vm);
+
+    if (qemuDomainAttachExtensionDevice(priv->mon, &net->info,
+                                         priv->qemuCaps) < 0) {
+        ignore_value(qemuDomainObjExitMonitor(driver, vm));
+        virDomainAuditNet(vm, NULL, net, "attach", false);
+        goto try_remove;
+    }
+
     if (qemuMonitorAddDevice(priv->mon, nicstr) < 0) {
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &net->info,
+                                                      priv->qemuCaps));
         ignore_value(qemuDomainObjExitMonitor(driver, vm));
         virDomainAuditNet(vm, NULL, net, "attach", false);
         goto try_remove;
@@ -1374,8 +1471,17 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
         goto error;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
-                                     configfd, configfd_name);
+
+    if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info,
+                                                priv->qemuCaps)) < 0)
+        goto exit_monitor;
+
+    if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr,
+                                          configfd, configfd_name)) < 0)
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info,
+                                                      priv->qemuCaps));
+
+ exit_monitor:
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto error;
 
@@ -2052,8 +2158,15 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
         goto exit_monitor;
     objAdded = true;
 
-    if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+    if (qemuDomainAttachExtensionDevice(priv->mon, &rng->info,
+                                         priv->qemuCaps) < 0)
+        goto exit_monitor;
+
+    if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &rng->info,
+                                                      priv->qemuCaps));
         goto exit_monitor;
+    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         releaseaddr = false;
@@ -2555,8 +2668,18 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
 
     qemuDomainObjEnterMonitor(driver, vm);
 
-    ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, vhostfd, vhostfdName);
+    if ((ret = qemuDomainAttachExtensionDevice(priv->mon, hostdev->info,
+                                                priv->qemuCaps)) < 0)
+        goto exit_monitor;
+
+    if ((ret = qemuMonitorAddDeviceWithFd(priv->mon, devstr, vhostfd,
+                                          vhostfdName)) < 0) {
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, hostdev->info,
+                                                      priv->qemuCaps));
+        goto exit_monitor;
+    }
 
+ exit_monitor:
     if (qemuDomainObjExitMonitor(driver, vm) < 0 || ret < 0)
         goto audit;
 
@@ -2800,8 +2923,15 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
 
     release_backing = true;
 
-    if (qemuMonitorAddDevice(priv->mon, shmstr) < 0)
+    if (qemuDomainAttachExtensionDevice(priv->mon, &shmem->info,
+                                         priv->qemuCaps) < 0)
+        goto exit_monitor;
+
+    if (qemuMonitorAddDevice(priv->mon, shmstr) < 0) {
+        ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &shmem->info,
+                                                      priv->qemuCaps));
         goto exit_monitor;
+    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         release_address = false;
@@ -2974,8 +3104,19 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
         goto cleanup;
 
     qemuDomainObjEnterMonitor(driver, vm);
-    if (qemuMonitorAddDevice(priv->mon, devstr) < 0)
+
+    if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO) {
+        if (qemuDomainAttachExtensionDevice(priv->mon, &input->info,
+                                             priv->qemuCaps) < 0)
+            goto exit_monitor;
+    }
+
+    if (qemuMonitorAddDevice(priv->mon, devstr) < 0) {
+        if (input->bus == VIR_DOMAIN_INPUT_BUS_VIRTIO)
+            ignore_value(qemuDomainDetachExtensionDevice(priv->mon, &input->info,
+                                                          priv->qemuCaps));
         goto exit_monitor;
+    }
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0) {
         releaseaddr = false;
-- 
2.16.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Cornelia Huck 7 years, 8 months ago
On Thu, 24 May 2018 14:24:32 +0200
Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:

> From: Yi Min Zhao <zyimin@linux.ibm.com>
> 
> This commit adds hotplug support for PCI devices on S390 guests.
> There's no need to implement hot unplug for zPCI as QEMU implements
> an unplug callback which will unplug both PCI and zPCI device in a
> cascaded way.
> Currently, the following PCI devices are supported:
>   virtio-blk-pci
>   virtio-net-pci
>   virtio-rng-pci
>   virtio-input-host-pci
>   virtio-keyboard-pci
>   virtio-mouse-pci
>   virtio-tablet-pci
>   vfio-pci
>   Shmem device
>   SCSIVhost device

Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?

> 
> Signed-off-by: Yi Min Zhao <zyimin@linux.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
> Reviewed-by: Stefan Zimmermann <stzi@linux.ibm.com>
> Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
> ---
>  src/qemu/qemu_hotplug.c | 175 +++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 158 insertions(+), 17 deletions(-)

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Bjoern Walk 7 years, 8 months ago
Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:
> On Thu, 24 May 2018 14:24:32 +0200
> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
> 
> > From: Yi Min Zhao <zyimin@linux.ibm.com>
> > 
> > This commit adds hotplug support for PCI devices on S390 guests.
> > There's no need to implement hot unplug for zPCI as QEMU implements
> > an unplug callback which will unplug both PCI and zPCI device in a
> > cascaded way.
> > Currently, the following PCI devices are supported:
> >   virtio-blk-pci
> >   virtio-net-pci
> >   virtio-rng-pci
> >   virtio-input-host-pci
> >   virtio-keyboard-pci
> >   virtio-mouse-pci
> >   virtio-tablet-pci
> >   vfio-pci
> >   Shmem device
> >   SCSIVhost device
> 
> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?

I guess it's just any device that libvirt actually supports hotplug for,
with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Xiao Feng Ren 7 years, 8 months ago

On 5/25/2018 6:22 PM, Bjoern Walk wrote:
> Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:
>> On Thu, 24 May 2018 14:24:32 +0200
>> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>>
>>> From: Yi Min Zhao <zyimin@linux.ibm.com>
>>>
>>> This commit adds hotplug support for PCI devices on S390 guests.
>>> There's no need to implement hot unplug for zPCI as QEMU implements
>>> an unplug callback which will unplug both PCI and zPCI device in a
>>> cascaded way.
>>> Currently, the following PCI devices are supported:
>>>    virtio-blk-pci
>>>    virtio-net-pci
>>>    virtio-rng-pci
>>>    virtio-input-host-pci
>>>    virtio-keyboard-pci
>>>    virtio-mouse-pci
>>>    virtio-tablet-pci
>>>    vfio-pci
>>>    Shmem device
>>>    SCSIVhost device
>> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?
> I guess it's just any device that libvirt actually supports hotplug for,
> with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.

The list should be the devices that support MSI-X and have realized the 
hotplug in qemu,
we support the hotplug for them in the libvirt.  So the list will be 
updated to:

   virtio-blk-pci
   virtio-net-pci
   virtio-input-host-pci
   virtio-keyboard-pci
   virtio-mouse-pci
   virtio-tablet-pci
   vfio-pci
   SCSIVhost device

As the model of Shmem is not support in qemu, the rng device doesn't 
support MSI-X.  So remove them.


In addition, the bug found need to be fixed for the hotplug of tablet, 
in the virDomainDeviceIsUSB()
if ((t == VIR_DOMAIN_DEVICE_DISK &&
          dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) ||
         (t == VIR_DOMAIN_DEVICE_INPUT &&
          dev->data.input->type == VIR_DOMAIN_INPUT_BUS_USB) ||  
---------->dev->data.input->bus == VIR_DOMAIN_INPUT_BUS_USB
         (t == VIR_DOMAIN_DEVICE_HOSTDEV &&
I will send the fix if this bug is agreed.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Cornelia Huck 7 years, 8 months ago
On Mon, 28 May 2018 16:26:57 +0800
Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:

> On 5/25/2018 6:22 PM, Bjoern Walk wrote:
> > Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:  
> >> On Thu, 24 May 2018 14:24:32 +0200
> >> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
> >>  
> >>> From: Yi Min Zhao <zyimin@linux.ibm.com>
> >>>
> >>> This commit adds hotplug support for PCI devices on S390 guests.
> >>> There's no need to implement hot unplug for zPCI as QEMU implements
> >>> an unplug callback which will unplug both PCI and zPCI device in a
> >>> cascaded way.
> >>> Currently, the following PCI devices are supported:
> >>>    virtio-blk-pci
> >>>    virtio-net-pci
> >>>    virtio-rng-pci
> >>>    virtio-input-host-pci
> >>>    virtio-keyboard-pci
> >>>    virtio-mouse-pci
> >>>    virtio-tablet-pci
> >>>    vfio-pci
> >>>    Shmem device
> >>>    SCSIVhost device  
> >> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?  
> > I guess it's just any device that libvirt actually supports hotplug for,
> > with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.  
> 
> The list should be the devices that support MSI-X and have realized the 
> hotplug in qemu,
> we support the hotplug for them in the libvirt.  So the list will be 
> updated to:
> 
>    virtio-blk-pci
>    virtio-net-pci
>    virtio-input-host-pci
>    virtio-keyboard-pci
>    virtio-mouse-pci
>    virtio-tablet-pci
>    vfio-pci
>    SCSIVhost device

Ok, that makes sense.

I also checked that libvirt only allows setting the vectors property
for virtio-serial and shmem (vectors == 0 turns msi-x off), so that
should be fine.

> 
> As the model of Shmem is not support in qemu, the rng device doesn't 
> support MSI-X.  So remove them.

So, should qemu add support for msi-x with virtio-rng-pci in the
future, we'd want to update libvirt as well, correct?

> 
> 
> In addition, the bug found need to be fixed for the hotplug of tablet, 
> in the virDomainDeviceIsUSB()
> if ((t == VIR_DOMAIN_DEVICE_DISK &&
>           dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) ||
>          (t == VIR_DOMAIN_DEVICE_INPUT &&
>           dev->data.input->type == VIR_DOMAIN_INPUT_BUS_USB) ||  
> ---------->dev->data.input->bus == VIR_DOMAIN_INPUT_BUS_USB  
>          (t == VIR_DOMAIN_DEVICE_HOSTDEV &&
> I will send the fix if this bug is agreed.
> 


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Yi Min Zhao 7 years, 8 months ago

在 2018/5/29 下午5:04, Cornelia Huck 写道:
> On Mon, 28 May 2018 16:26:57 +0800
> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>
>> On 5/25/2018 6:22 PM, Bjoern Walk wrote:
>>> Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:
>>>> On Thu, 24 May 2018 14:24:32 +0200
>>>> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>>>>   
>>>>> From: Yi Min Zhao <zyimin@linux.ibm.com>
>>>>>
>>>>> This commit adds hotplug support for PCI devices on S390 guests.
>>>>> There's no need to implement hot unplug for zPCI as QEMU implements
>>>>> an unplug callback which will unplug both PCI and zPCI device in a
>>>>> cascaded way.
>>>>> Currently, the following PCI devices are supported:
>>>>>     virtio-blk-pci
>>>>>     virtio-net-pci
>>>>>     virtio-rng-pci
>>>>>     virtio-input-host-pci
>>>>>     virtio-keyboard-pci
>>>>>     virtio-mouse-pci
>>>>>     virtio-tablet-pci
>>>>>     vfio-pci
>>>>>     Shmem device
>>>>>     SCSIVhost device
>>>> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?
>>> I guess it's just any device that libvirt actually supports hotplug for,
>>> with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.
>> The list should be the devices that support MSI-X and have realized the
>> hotplug in qemu,
>> we support the hotplug for them in the libvirt.  So the list will be
>> updated to:
>>
>>     virtio-blk-pci
>>     virtio-net-pci
>>     virtio-input-host-pci
>>     virtio-keyboard-pci
>>     virtio-mouse-pci
>>     virtio-tablet-pci
>>     vfio-pci
>>     SCSIVhost device
> Ok, that makes sense.
>
> I also checked that libvirt only allows setting the vectors property
> for virtio-serial and shmem (vectors == 0 turns msi-x off), so that
> should be fine.

Thanks for your check!
>
>> As the model of Shmem is not support in qemu, the rng device doesn't
>> support MSI-X.  So remove them.
> So, should qemu add support for msi-x with virtio-rng-pci in the
> future, we'd want to update libvirt as well, correct?
This is a little bit hard to answer. Our patch adds the code calling the 
function which is to
attach zpci address in rng attachment function. As the logic in libvirt, 
zpci could be generated
for rng device. But it actually can't be supported in s390 qemu binary. 
If it is being plugged,
the error should be reported.

Thus, if we remove the attachement code for zpci in 
qemuDomainAttachRNGDevice(),
we should update libvirt when rng supports msix in qemu. If we keep it 
here, then update for libvirt
is not needed.
>
>>
>> In addition, the bug found need to be fixed for the hotplug of tablet,
>> in the virDomainDeviceIsUSB()
>> if ((t == VIR_DOMAIN_DEVICE_DISK &&
>>            dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) ||
>>           (t == VIR_DOMAIN_DEVICE_INPUT &&
>>            dev->data.input->type == VIR_DOMAIN_INPUT_BUS_USB) ||
>> ---------->dev->data.input->bus == VIR_DOMAIN_INPUT_BUS_USB
>>           (t == VIR_DOMAIN_DEVICE_HOSTDEV &&
>> I will send the fix if this bug is agreed.
>>
>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Cornelia Huck 7 years, 8 months ago
On Fri, 1 Jun 2018 12:43:09 +0800
Yi Min Zhao <zyimin@linux.ibm.com> wrote:

> 在 2018/5/29 下午5:04, Cornelia Huck 写道:
> > On Mon, 28 May 2018 16:26:57 +0800
> > Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:

> >> As the model of Shmem is not support in qemu, the rng device doesn't
> >> support MSI-X.  So remove them.  
> > So, should qemu add support for msi-x with virtio-rng-pci in the
> > future, we'd want to update libvirt as well, correct?  
> This is a little bit hard to answer. Our patch adds the code calling the 
> function which is to
> attach zpci address in rng attachment function. As the logic in libvirt, 
> zpci could be generated
> for rng device. But it actually can't be supported in s390 qemu binary. 
> If it is being plugged,
> the error should be reported.
> 
> Thus, if we remove the attachement code for zpci in 
> qemuDomainAttachRNGDevice(),
> we should update libvirt when rng supports msix in qemu. If we keep it 
> here, then update for libvirt
> is not needed.

General question to the libvirt folks: is it better to just assume that
qemu can handle a device and deal with failure if it turns out that it
doesn't work after all, or to proactively fence off devices we assume
to not work? [Making virtio-rng-pci use msi-x in qemu does not look too
hard to do.]

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Yi Min Zhao 7 years, 8 months ago

在 2018/5/29 下午5:04, Cornelia Huck 写道:
> On Mon, 28 May 2018 16:26:57 +0800
> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>
>> On 5/25/2018 6:22 PM, Bjoern Walk wrote:
>>> Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:
>>>> On Thu, 24 May 2018 14:24:32 +0200
>>>> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>>>>   
>>>>> From: Yi Min Zhao <zyimin@linux.ibm.com>
>>>>>
>>>>> This commit adds hotplug support for PCI devices on S390 guests.
>>>>> There's no need to implement hot unplug for zPCI as QEMU implements
>>>>> an unplug callback which will unplug both PCI and zPCI device in a
>>>>> cascaded way.
>>>>> Currently, the following PCI devices are supported:
>>>>>     virtio-blk-pci
>>>>>     virtio-net-pci
>>>>>     virtio-rng-pci
>>>>>     virtio-input-host-pci
>>>>>     virtio-keyboard-pci
>>>>>     virtio-mouse-pci
>>>>>     virtio-tablet-pci
>>>>>     vfio-pci
>>>>>     Shmem device
>>>>>     SCSIVhost device
>>>> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?
>>> I guess it's just any device that libvirt actually supports hotplug for,
>>> with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.
>> The list should be the devices that support MSI-X and have realized the
>> hotplug in qemu,
>> we support the hotplug for them in the libvirt.  So the list will be
>> updated to:
>>
>>     virtio-blk-pci
>>     virtio-net-pci
>>     virtio-input-host-pci
>>     virtio-keyboard-pci
>>     virtio-mouse-pci
>>     virtio-tablet-pci
>>     vfio-pci
>>     SCSIVhost device
> Ok, that makes sense.
>
> I also checked that libvirt only allows setting the vectors property
> for virtio-serial and shmem (vectors == 0 turns msi-x off), so that
> should be fine.
>
>> As the model of Shmem is not support in qemu, the rng device doesn't
>> support MSI-X.  So remove them.
> So, should qemu add support for msi-x with virtio-rng-pci in the
> future, we'd want to update libvirt as well, correct?
>
>>
>> In addition, the bug found need to be fixed for the hotplug of tablet,
>> in the virDomainDeviceIsUSB()
>> if ((t == VIR_DOMAIN_DEVICE_DISK &&
>>            dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) ||
>>           (t == VIR_DOMAIN_DEVICE_INPUT &&
>>            dev->data.input->type == VIR_DOMAIN_INPUT_BUS_USB) ||
>> ---------->dev->data.input->bus == VIR_DOMAIN_INPUT_BUS_USB
>>           (t == VIR_DOMAIN_DEVICE_HOSTDEV &&
>> I will send the fix if this bug is agreed.
>>
>
I have not received my response mail until now....What's wrong?

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/13] qemu: Add hotpluging support for PCI devices on S390 guests
Posted by Laine Stump 7 years, 8 months ago
On 05/29/2018 05:04 AM, Cornelia Huck wrote:
> On Mon, 28 May 2018 16:26:57 +0800
> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>
>> On 5/25/2018 6:22 PM, Bjoern Walk wrote:
>>> Cornelia Huck <cohuck@redhat.com> [2018-05-24, 06:25PM +0200]:  
>>>> On Thu, 24 May 2018 14:24:32 +0200
>>>> Xiao Feng Ren <renxiaof@linux.vnet.ibm.com> wrote:
>>>>  
>>>>> From: Yi Min Zhao <zyimin@linux.ibm.com>
>>>>>
>>>>> This commit adds hotplug support for PCI devices on S390 guests.
>>>>> There's no need to implement hot unplug for zPCI as QEMU implements
>>>>> an unplug callback which will unplug both PCI and zPCI device in a
>>>>> cascaded way.
>>>>> Currently, the following PCI devices are supported:
>>>>>    virtio-blk-pci
>>>>>    virtio-net-pci
>>>>>    virtio-rng-pci
>>>>>    virtio-input-host-pci
>>>>>    virtio-keyboard-pci
>>>>>    virtio-mouse-pci
>>>>>    virtio-tablet-pci
>>>>>    vfio-pci
>>>>>    Shmem device
>>>>>    SCSIVhost device  
>>>> Hm, how did you arrive at this list? Is it 'anything that uses msi-x'?  
>>> I guess it's just any device that libvirt actually supports hotplug for,
>>> with a few exceptions (cf. patch 3 and 6). Not familiar wuth msi-x.  

Note that, lacking specific information to the contrary, libvirt should
be assuming that every device supports hotplug and should attempt to
hotplug the device when requested. If the device can't be hotplugged,
then qemu will return an error, and libvirt will fail the operation
accordingly. (No, this doesn't match libvirt behavior - hotplug for some
devices simply isn't implemented, but it should be.)

>> The list should be the devices that support MSI-X and have realized the 
>> hotplug in qemu,
>> we support the hotplug for them in the libvirt.  So the list will be 
>> updated to:
>>
>>    virtio-blk-pci
>>    virtio-net-pci
>>    virtio-input-host-pci
>>    virtio-keyboard-pci
>>    virtio-mouse-pci
>>    virtio-tablet-pci
>>    vfio-pci
>>    SCSIVhost device
> Ok, that makes sense.
>
> I also checked that libvirt only allows setting the vectors property
> for virtio-serial and shmem (vectors == 0 turns msi-x off), so that
> should be fine.
>
>> As the model of Shmem is not support in qemu, the rng device doesn't 
>> support MSI-X.  So remove them.
> So, should qemu add support for msi-x with virtio-rng-pci in the
> future, we'd want to update libvirt as well, correct?
>
>>
>> In addition, the bug found need to be fixed for the hotplug of tablet, 
>> in the virDomainDeviceIsUSB()
>> if ((t == VIR_DOMAIN_DEVICE_DISK &&
>>           dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_USB) ||
>>          (t == VIR_DOMAIN_DEVICE_INPUT &&
>>           dev->data.input->type == VIR_DOMAIN_INPUT_BUS_USB) ||  
>> ---------->dev->data.input->bus == VIR_DOMAIN_INPUT_BUS_USB  
>>          (t == VIR_DOMAIN_DEVICE_HOSTDEV &&
>> I will send the fix if this bug is agreed.
>>
>
> --
> 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