]> xenbits.xensource.com Git - libvirt.git/commitdiff
PHYP: Adding reboot domain function
authorEduardo Otubo <otubo@linux.vnet.ibm.com>
Tue, 19 Apr 2011 15:34:08 +0000 (12:34 -0300)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 21 Apr 2011 06:25:33 +0000 (08:25 +0200)
Adding reboot <domain> function for pHyp driver.

src/phyp/phyp_driver.c

index bb0e0ac6d532b6af3937594427a943caffcac4f3..ebd4a8adb3ef24290669f26243e19f1591e11060 100644 (file)
@@ -3383,6 +3383,39 @@ cleanup:
     return result;
 }
 
+static int
+phypDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
+{
+    int result = -1;
+    ConnectionData *connection_data = dom->conn->networkPrivateData;
+    virConnectPtr conn = dom->conn;
+    LIBSSH2_SESSION *session = connection_data->session;
+    phyp_driverPtr phyp_driver = conn->privateData;
+    int system_type = phyp_driver->system_type;
+    char *managed_system = phyp_driver->managed_system;
+    int exit_status = 0;
+    char *ret = NULL;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+    virBufferAddLit(&buf, "chsysstate");
+    if (system_type == HMC)
+        virBufferVSprintf(&buf, " -m %s", managed_system);
+    virBufferVSprintf(&buf,
+                      " -r lpar -o shutdown --id %d --immed --restart",
+                      dom->id);
+    ret = phypExecBuffer(session, &buf, &exit_status, dom->conn, false);
+
+    if (exit_status < 0)
+        goto cleanup;
+
+    result = 0;
+
+  cleanup:
+    VIR_FREE(ret);
+
+    return result;
+}
+
 static int
 phypDomainShutdown(virDomainPtr dom)
 {
@@ -3707,7 +3740,7 @@ static virDriver phypDriver = {
     NULL,                       /* domainSuspend */
     phypDomainResume,           /* domainResume */
     phypDomainShutdown,         /* domainShutdown */
-    NULL,                       /* domainReboot */
+    phypDomainReboot,           /* domainReboot */
     phypDomainDestroy,          /* domainDestroy */
     NULL,                       /* domainGetOSType */
     NULL,                       /* domainGetMaxMemory */