]> xenbits.xensource.com Git - libvirt.git/commitdiff
xen: implement virNodeDeviceDetachFlags backend
authorLaine Stump <laine@laine.org>
Wed, 24 Apr 2013 18:06:42 +0000 (14:06 -0400)
committerLaine Stump <laine@laine.org>
Fri, 26 Apr 2013 01:28:43 +0000 (21:28 -0400)
This was the only hypervisor driver other than qemu that implemented
virNodeDeviceDettach. It doesn't currently support multiple pci device
assignment driver backends, but it is simple to plug in this new API,
which will make it easier for Xen people to fill it in later when they
decide to support VFIO (or whatever other) device assignment. Also it
means that management applications will have the same API available to
them for both hypervisors on any given version of libvirt.

The only acceptable value for driverName in this case is NULL, since
there is no alternate, and I'm not willing to pick a name for the
default driver used by Xen.

src/xen/xen_driver.c

index a6990cfb3afef60c720664ddd45eb063588c0c72..8971d4cc72a541962d6623387b0bdb138282021c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * xen_driver.c: Unified Xen driver.
  *
- * Copyright (C) 2007-2012 Red Hat, Inc.
+ * Copyright (C) 2007-2013 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -2133,12 +2133,16 @@ out:
 }
 
 static int
-xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
+xenUnifiedNodeDeviceDetachFlags(virNodeDevicePtr dev,
+                                const char *driverName,
+                                unsigned int flags)
 {
     virPCIDevicePtr pci;
     unsigned domain, bus, slot, function;
     int ret = -1;
 
+    virCheckFlags(0, -1);
+
     if (xenUnifiedNodeDeviceGetPciInfo(dev, &domain, &bus, &slot, &function) < 0)
         return -1;
 
@@ -2146,7 +2150,15 @@ xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
     if (!pci)
         return -1;
 
-    if (virPCIDeviceDetach(pci, NULL, NULL, "pciback") < 0)
+    if (!driverName) {
+        virPCIDeviceSetStubDriver(pci, "pciback");
+    } else {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("unknown driver name '%s'"), driverName);
+        goto out;
+    }
+
+    if (virPCIDeviceDetach(pci, NULL, NULL, NULL) < 0)
         goto out;
 
     ret = 0;
@@ -2155,6 +2167,12 @@ out:
     return ret;
 }
 
+static int
+xenUnifiedNodeDeviceDettach(virNodeDevicePtr dev)
+{
+    return xenUnifiedNodeDeviceDetachFlags(dev, NULL, 0);
+}
+
 static int
 xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
 {
@@ -2405,6 +2423,7 @@ static virDriver xenUnifiedDriver = {
     .connectDomainEventRegister = xenUnifiedConnectDomainEventRegister, /* 0.5.0 */
     .connectDomainEventDeregister = xenUnifiedConnectDomainEventDeregister, /* 0.5.0 */
     .nodeDeviceDettach = xenUnifiedNodeDeviceDettach, /* 0.6.1 */
+    .nodeDeviceDetachFlags = xenUnifiedNodeDeviceDetachFlags, /* 1.0.5 */
     .nodeDeviceReAttach = xenUnifiedNodeDeviceReAttach, /* 0.6.1 */
     .nodeDeviceReset = xenUnifiedNodeDeviceReset, /* 0.6.1 */
     .connectIsEncrypted = xenUnifiedConnectIsEncrypted, /* 0.7.3 */