<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 20, 2016 at 12:05 AM, Laine Stump <span dir="ltr"><<a href="mailto:laine@laine.org" target="_blank">laine@laine.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 05/18/2016 05:35 PM, Shivaprasad G Bhat wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The hostdevices are the only devices which have dependencies<br>
outside of themselves such that, other functions of the PCI<br>
card should also have been detached from host driver before<br>
attempting the hotplug.<br>
</blockquote>
<br></span>
Are you saying that all the functions on a host device must be detached from their host driver, even if you're only assigning one or another of them to the guest?<span class=""><br>
<br></span></blockquote><div>Yes. All devices from same iommu group should be detached from the host. Here, I hope the Card is independent. Otherwise, many cards can also</div><div>belong to same iommu group. In such case, manual the nodedev-detach for other card functions is necessary.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
This patch moves the detach to the beginning of the hotplug<br>
so that the following patch can detach all funtions first before<br>
attempting to hotplug any.<br>
<br>
We need not move the detach for net devices using SRIOV as<br>
all SRIOV devices are single function devices.<br>
</blockquote>
<br>
<br></span>
I'm not sure why that makes any difference. In any case, you should detach all the devices that are going to be assigned, then assign them all, with the one going to function 0 being last.</blockquote><div><br></div><div>There will be only function zero. So I felt its not necessary. Are you saying different SRIOV functions(all with function zero) be hotplugged as</div><div>different functions of single card in guest ? In that case, we would need to do that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Signed-off-by: Shivaprasad G Bhat <<a href="mailto:sbhat@linux.vnet.ibm.com" target="_blank">sbhat@linux.vnet.ibm.com</a>><br>
---<br>
  src/qemu/qemu_driver.c  |   13 ++++++++++++-<br>
  src/qemu/qemu_hotplug.c |   18 +++++++++---------<br>
  2 files changed, 21 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c<br>
index 37d970e..9cff397 100644<br>
--- a/src/qemu/qemu_driver.c<br>
+++ b/src/qemu/qemu_driver.c<br>
@@ -8273,8 +8273,13 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,<br>
                                           VIR_DOMAIN_DEVICE_ACTION_ATTACH) < 0)<br>
              goto endjob;<br>
  -        if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, dom)) < 0)<br>
+        if (dev_copy->type == VIR_DOMAIN_DEVICE_HOSTDEV &&<br>
+            dev_copy->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&<br>
+            qemuDomainAttachPCIHostDevicePrepare(driver,vm->def, dev_copy->data.hostdev, qemuCaps) < 0)<br>
              goto endjob;<br>
+<br>
+        if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, dom)) < 0)<br>
+            goto undoprepare;<br>
          /*<br>
           * update domain status forcibly because the domain status may be<br>
           * changed even if we failed to attach the device. For example,<br>
@@ -8309,6 +8314,12 @@ static int qemuDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,<br>
      virObjectUnref(cfg);<br>
      virNWFilterUnlockFilterUpdates();<br>
      return ret;<br>
+<br>
+  undoprepare:<br>
+    if (dev_copy->type == VIR_DOMAIN_DEVICE_HOSTDEV &&<br>
+        dev_copy->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)<br>
+        qemuHostdevReAttachPCIDevices(driver, vm->def->name, &dev_copy->data.hostdev, 1);<br>
+    goto endjob;<br>
  }<br>
    static int qemuDomainAttachDevice(virDomainPtr dom, const char *xml)<br>
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c<br>
index a2bcd89..bdfbafe 100644<br>
--- a/src/qemu/qemu_hotplug.c<br>
+++ b/src/qemu/qemu_hotplug.c<br>
@@ -899,6 +899,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,<br>
      actualType = virDomainNetGetActualType(net);<br>
        if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {<br>
+        virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);<br>
          /* This is really a "smart hostdev", so it should be attached<br>
           * as a hostdev (the hostdev code will reach over into the<br>
           * netdev-specific code as appropriate), then also added to<br>
@@ -907,8 +908,14 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,<br>
           * qemuDomainAttachHostDevice uses a connection to resolve<br>
           * a SCSI hostdev secret, which is not this case, so pass NULL.<br>
           */<br>
-        ret = qemuDomainAttachHostDevice(NULL, driver, vm,<br>
-                                         virDomainNetGetActualHostdev(net));<br>
+        if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def,<br>
+                                                 hostdev, priv->qemuCaps) < 0)<br>
+            goto cleanup;<br>
+<br>
+        ret = qemuDomainAttachHostDevice(NULL, driver, vm, hostdev);<br>
+        if (!ret)<br>
+            qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);<br>
+<br>
          goto cleanup;<br>
      }<br>
  @@ -1248,10 +1255,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,<br>
      if (VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1) < 0)<br>
          return -1;<br>
  -    if (qemuDomainAttachPCIHostDevicePrepare(driver, vm->def,<br>
-                                             hostdev, priv->qemuCaps) < 0)<br>
-        return -1;<br>
-<br>
      backend = hostdev->source.subsys.u.pci.backend;<br>
        /* Temporarily add the hostdev to the domain definition. This is needed<br>
@@ -1330,13 +1333,10 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,<br>
      if (releaseaddr)<br>
          qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL);<br>
  -    qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);<br>
-<br>
      VIR_FREE(devstr);<br>
      VIR_FREE(configfd_name);<br>
      VIR_FORCE_CLOSE(configfd);<br>
  - cleanup:<br>
      return -1;<br>
  }<br>
  <br>
--<br>
libvir-list mailing list<br>
<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/libvir-list</a><br>
<br>
</blockquote>
<br>
</div></div></blockquote></div><br></div></div>