[PATCH V4 1/5] Add public API virDomainSendSysrq

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

 



Add public API virDomainSendSysrq for sending SysRequest key.

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 include/libvirt/libvirt-domain.h |  3 +++
 src/driver-hypervisor.h          |  4 ++++
 src/libvirt-domain.c             | 39 +++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  5 +++++
 4 files changed, 51 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 0b1a2d6..a762034 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -3527,6 +3527,9 @@ int virDomainGetFSInfo(virDomainPtr dom,
                        virDomainFSInfoPtr **info,
                        unsigned int flags);
 
+/* virDomainSendSysrq */
+int virDomainSendSysrq(virDomainPtr dom, char key, unsigned int flags);
+
 int virDomainGetTime(virDomainPtr dom,
                      long long *seconds,
                      unsigned int *nseconds,
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 9f26b13..d260d29 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1170,6 +1170,9 @@ typedef int
                         unsigned int cellCount,
                         unsigned int flags);
 
+typedef int
+(*virDrvDomainSendSysrq)(virDomainPtr dom, char key, unsigned int flags);
+
 
 typedef struct _virHypervisorDriver virHypervisorDriver;
 typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -1396,6 +1399,7 @@ struct _virHypervisorDriver {
     virDrvConnectGetAllDomainStats connectGetAllDomainStats;
     virDrvNodeAllocPages nodeAllocPages;
     virDrvDomainGetFSInfo domainGetFSInfo;
+    virDrvDomainSendSysrq domainSendSysrq;
 };
 
 
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 6ec68aa..83ece45 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -11201,3 +11201,42 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
         VIR_FREE(info->devAlias[i]);
     VIR_FREE(info->devAlias);
 }
+
+
+/**
+ * virDomainSendSysrq:
+ * @domain:    pointer to domain object, or NULL for Domain0
+ * @key:    SysRq key, like h, c, ...
+ * @flags:  extra flags; not used yet, so callers should always pass 0
+ *
+ * Send SysRq key to the guest.
+ *
+ * Returns 0 in case of success, -1 in case of failure.
+ */
+int
+virDomainSendSysrq(virDomainPtr domain, char key, unsigned int flags)
+{
+    virConnectPtr conn;
+    VIR_DOMAIN_DEBUG(domain, "key=%c, flags=%x", key, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (conn->driver->domainSendSysrq) {
+        int ret;
+        ret = conn->driver->domainSendSysrq(domain, key, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index e4c2df1..5d4999a 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -690,4 +690,9 @@ LIBVIRT_1.2.11 {
         virDomainGetFSInfo;
 } LIBVIRT_1.2.9;
 
+LIBVIRT_1.2.12 {
+    global:
+        virDomainSendSysrq;
+} LIBVIRT_1.2.11;
+
 # .... define new API here using predicted next version number ....
-- 
1.8.4.5

--
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]