]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: fix hot add/remove VF from a pool
authorChunyan Liu <cyliu@suse.com>
Mon, 21 Mar 2016 08:11:40 +0000 (16:11 +0800)
committerJim Fehlig <jfehlig@suse.com>
Mon, 28 Mar 2016 16:18:39 +0000 (10:18 -0600)
For those VF allocated from a network pool, we need to set its backend
to be VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN so that later work can be
correct.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
src/libxl/libxl_driver.c

index cc7f2246355b98607c8e70617ffc5208e7913dae..cfc45552f0babe25b1a2ecb1878bb0e1624e0f6e 100644 (file)
@@ -3145,13 +3145,23 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driver,
     }
 
     if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+        virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
+        virDomainHostdevSubsysPCIPtr pcisrc = &hostdev->source.subsys.u.pci;
+
+        /* For those just allocated from a network pool whose backend is
+         * still VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT, we need to set
+         * backend correctly.
+         */
+        if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+            hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+            pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
+
         /* This is really a "smart hostdev", so it should be attached
          * as a hostdev (the hostdev code will reach over into the
          * netdev-specific code as appropriate), then also added to
          * the nets list (see out:) if successful.
          */
-        ret = libxlDomainAttachHostDevice(driver, vm,
-                                          virDomainNetGetActualHostdev(net));
+        ret = libxlDomainAttachHostDevice(driver, vm, hostdev);
         goto cleanup;
     }