[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 4/7] hypervisor api: implement RPC calls for virNodeDeviceDetachFlags



This requires a custom function for remoteNodeDeviceDetachFlags,
because it is named *NodeDevice, but it goes through the hypervisor
driver rather than nodedevice driver, and so it uses privateData
instead of nodeDevicePrivateData. (It has to go through the hypervisor
driver, because that is the driver that nows about the backend drivers
that will perform the pci device assignment).
---
 src/remote/remote_driver.c   | 34 +++++++++++++++++++++++++++++++++-
 src/remote/remote_protocol.x | 15 +++++++++++++--
 src/remote_protocol-structs  |  6 ++++++
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index ee7a2a4..f66304c 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2,7 +2,7 @@
  * remote_driver.c: driver to provide access to libvirtd running
  *   on a remote machine
  *
- * 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
@@ -3405,6 +3405,37 @@ done:
 }
 
 static int
+remoteNodeDeviceDetachFlags(virNodeDevicePtr dev,
+                            const char *driverName,
+                            unsigned int flags)
+{
+    int rv = -1;
+    remote_node_device_detach_flags_args args;
+    /* This method is unusual in that it uses the HV driver, not the
+     * devMon driver hence its use of privateData, instead of
+     * nodeDevicePrivateData
+     */
+    struct private_data *priv = dev->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    args.name = dev->name;
+    args.driverName = driverName ? (char**)&driverName : NULL;
+    args.flags = flags;
+
+    if (call(dev->conn, priv, 0, REMOTE_PROC_NODE_DEVICE_DETACH_FLAGS,
+             (xdrproc_t) xdr_remote_node_device_detach_flags_args,
+             (char *) &args, (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        goto done;
+
+    rv = 0;
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+static int
 remoteNodeDeviceReAttach(virNodeDevicePtr dev)
 {
     int rv = -1;
@@ -6225,6 +6256,7 @@ static virDriver remote_driver = {
     .domainMigratePrepare2 = remoteDomainMigratePrepare2, /* 0.5.0 */
     .domainMigrateFinish2 = remoteDomainMigrateFinish2, /* 0.5.0 */
     .nodeDeviceDettach = remoteNodeDeviceDettach, /* 0.6.1 */
+    .nodeDeviceDetachFlags = remoteNodeDeviceDetachFlags, /* 1.0.5 */
     .nodeDeviceReAttach = remoteNodeDeviceReAttach, /* 0.6.1 */
     .nodeDeviceReset = remoteNodeDeviceReset, /* 0.6.1 */
     .domainMigratePrepareTunnel = remoteDomainMigratePrepareTunnel, /* 0.7.2 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 486d640..512ba2e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3,7 +3,7 @@
  *   remote_internal driver and libvirtd.  This protocol is
  *   internal and may change at any time.
  *
- * Copyright (C) 2006-2012 Red Hat, Inc.
+ * Copyright (C) 2006-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
@@ -1900,6 +1900,12 @@ struct remote_node_device_dettach_args {
     remote_nonnull_string name;
 };
 
+struct remote_node_device_detach_flags_args {
+    remote_nonnull_string name;
+    remote_string driverName;
+    unsigned int flags;
+};
+
 struct remote_node_device_re_attach_args {
     remote_nonnull_string name;
 };
@@ -4423,6 +4429,11 @@ enum remote_procedure {
     /**
      * @generate: both
      */
-    REMOTE_PROC_DOMAIN_MIGRATE_SET_COMPRESSION_CACHE = 300
+    REMOTE_PROC_DOMAIN_MIGRATE_SET_COMPRESSION_CACHE = 300,
+
+    /**
+     * @generate: server
+     */
+    REMOTE_PROC_NODE_DEVICE_DETACH_FLAGS = 301
 
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 11a53a2..ea38ea2 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1440,6 +1440,11 @@ struct remote_node_device_list_caps_ret {
 struct remote_node_device_dettach_args {
         remote_nonnull_string      name;
 };
+struct remote_node_device_detach_flags_args {
+        remote_nonnull_string      name;
+        remote_string              driverName;
+        u_int                      flags;
+};
 struct remote_node_device_re_attach_args {
         remote_nonnull_string      name;
 };
@@ -2488,4 +2493,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_GET_JOB_STATS = 298,
         REMOTE_PROC_DOMAIN_MIGRATE_GET_COMPRESSION_CACHE = 299,
         REMOTE_PROC_DOMAIN_MIGRATE_SET_COMPRESSION_CACHE = 300,
+        REMOTE_PROC_NODE_DEVICE_DETACH_FLAGS = 301,
 };
-- 
1.7.11.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]