[PATCH V2 5/5] xen: add .domainSendSysrq method

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

 



Support .domainSendSysrq in xen driver.

Signed-off-by: Chunyan Liu <cyliu@xxxxxxxx>
---
 src/xen/xen_driver.c    | 19 +++++++++++++++++++
 src/xen/xend_internal.c | 20 ++++++++++++++++++++
 src/xen/xend_internal.h |  2 ++
 3 files changed, 41 insertions(+)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index c9f4159..e2b01cf 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -2738,6 +2738,24 @@ xenUnifiedNodeSuspendForDuration(virConnectPtr conn,
     return nodeSuspendForDuration(target, duration, flags);
 }
 
+static int
+xenUnifiedDomainSendSysrq(virDomainPtr dom, const char *key)
+{
+    int ret = -1;
+    virDomainDefPtr def = NULL;
+
+    if (!(def = xenGetDomainDefForDom(dom)))
+        goto cleanup;
+
+    if (virDomainSendSysrqEnsureACL(dom->conn, def) < 0)
+        goto cleanup;
+
+    ret = xenDaemonDomainSysrq(dom->conn, def, key);
+
+ cleanup:
+    virDomainDefFree(def);
+    return ret;
+}
 
 /*----- Register with libvirt.c, and initialize Xen drivers. -----*/
 
@@ -2836,6 +2854,7 @@ static virHypervisorDriver xenUnifiedDriver = {
     .nodeSuspendForDuration = xenUnifiedNodeSuspendForDuration, /* 0.9.8 */
     .nodeGetMemoryParameters = xenUnifiedNodeGetMemoryParameters, /* 0.10.2 */
     .nodeSetMemoryParameters = xenUnifiedNodeSetMemoryParameters, /* 0.10.2 */
+    .domainSendSysrq = xenUnifiedDomainSendSysrq, /* 1.2.11 */
 };
 
 /**
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index b233b6b..62b6e31 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -3300,6 +3300,26 @@ xenDaemonDomainBlockPeek(virConnectPtr conn,
     return ret;
 }
 
+/*
+ * xenDaemonDomainSysrq:
+ *  <at> conn: the connection object
+ *  <at> def: the domain to destroy
+ *
+ * Send a sysrq to a domain.
+ *
+ * Returns 0 in case of success, -1 (with errno) in case of error.
+ */
+int
+xenDaemonDomainSysrq(virConnectPtr conn, virDomainDefPtr def, const char *key)
+{
+    if (def->id < 0) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       _("Domain %s isn't running."), def->name);
+        return -1;
+    }
+
+    return xend_op(conn, def->name, "op", "sysrq", "key", key, NULL);
+}
 
 /**
  * virDomainXMLDevID:
diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
index 814330d..26ab5e3 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -213,5 +213,7 @@ int xenDaemonSetSchedulerParameters(virConnectPtr conn,
                                     virDomainDefPtr def,
                                     virTypedParameterPtr params,
                                     int nparams);
+int xenDaemonDomainSysrq(virConnectPtr conn, virDomainDefPtr def,
+                         const char *key);
 
 #endif /* __XEND_INTERNAL_H_ */
-- 
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]