[PATCH 1/4] api: Add new public api for 'reset'

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

 



Add new public api for 'reset'.
It can reset domain immediately without any guest shutdown.

Signed-off-by: Xu He Jie <xuhj@xxxxxxxxxxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |    2 +
 src/driver.h                 |    3 ++
 src/libvirt.c                |   44 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    5 ++++
 4 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..3d60023 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1031,6 +1031,8 @@ virDomainPtr            virDomainLookupByUUIDString     (virConnectPtr conn,
 int                     virDomainShutdown       (virDomainPtr domain);
 int                     virDomainReboot         (virDomainPtr domain,
                                                  unsigned int flags);
+int                     virDomainReset          (virDomainPtr domain);
+
 int                     virDomainDestroy        (virDomainPtr domain);
 int                     virDomainDestroyFlags   (virDomainPtr domain,
                                                  unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index 3792003..fd0d3a1 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -124,6 +124,8 @@ typedef int
         (*virDrvDomainReboot)		(virDomainPtr domain,
                                          unsigned int flags);
 typedef int
+        (*virDrvDomainReset)        (virDomainPtr domain);
+typedef int
         (*virDrvDomainDestroy)		(virDomainPtr domain);
 typedef int
         (*virDrvDomainDestroyFlags) (virDomainPtr domain,
@@ -755,6 +757,7 @@ struct _virDriver {
     virDrvDomainResume		domainResume;
     virDrvDomainShutdown		domainShutdown;
     virDrvDomainReboot		domainReboot;
+    virDrvDomainReset       domainReset;
     virDrvDomainDestroy		domainDestroy;
     virDrvDomainDestroyFlags    domainDestroyFlags;
     virDrvDomainGetOSType		domainGetOSType;
diff --git a/src/libvirt.c b/src/libvirt.c
index 8f94b11..3c5cd5e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3017,6 +3017,50 @@ error:
 }
 
 /**
+ * virDomainReset:
+ * @domain: a domain object
+ *
+ * Reset a domain immediately without any guest shutdown
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virDomainReset(virDomainPtr domain)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
+        virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+        virDispatchError(NULL);
+        return -1;
+    }
+    if (domain->conn->flags & VIR_CONNECT_RO) {
+        virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+        goto error;
+    }
+
+    conn = domain->conn;
+
+    if (conn->driver->domainReset) {
+        int ret;
+        ret = conn->driver->domainReset (domain);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(domain->conn);
+    return -1;
+}
+
+/**
  * virDomainGetName:
  * @domain: a domain object
  *
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 8a6d55a..dffa33f 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -489,4 +489,9 @@ LIBVIRT_0.9.5 {
         virDomainSnapshotGetName;
 } LIBVIRT_0.9.4;
 
+LIBVIRT_0.9.7 {
+    global:
+        virDomainReset;
+} LIBVIRT_0.9.5;
+
 # .... define new API here using predicted next version number ....
-- 
1.7.4.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]