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

[libvirt] [PATCH 3/8] UndefineFlags: Implement the public API



---
 src/libvirt.c |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 7e70caa..eeb25a5 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -6381,7 +6381,8 @@ error:
  * Returns 0 in case of success, -1 in case of error
  */
 int
-virDomainUndefine(virDomainPtr domain) {
+virDomainUndefine(virDomainPtr domain)
+{
     virConnectPtr conn;
 
     VIR_DOMAIN_DEBUG(domain);
@@ -6415,6 +6416,56 @@ error:
 }
 
 /**
+ * virDomainUndefineWithFlags:
+ * @domain: pointer to a defined domain
+ * @flags: bitwise-or of supported virDomainUndefineFlags
+ *
+ * Undefine a domain but does not stop it if it is running
+ *
+ * If VIR_DOMAIN_UNDEFINE_MANAGED_STATE is specified, the domain
+ * managed state file will be removed along with domain undefine
+ * process, the entire domain undefine process will fail if
+ * it fails on removing the managed state file.
+ *
+ * Returns 0 in case of success, -1 in case of error
+ */
+int
+virDomainUndefineWithFlags(virDomainPtr domain,
+                           unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "flags=%x", flags);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+    conn = domain->conn;
+    if (conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->domainUndefineWithFlags) {
+        int ret;
+        ret = conn->driver->domainUndefineWithFlags (domain, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+/**
  * virConnectNumOfDefinedDomains:
  * @conn: pointer to the hypervisor connection
  *
-- 
1.7.6


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