]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Add 'reset' command for virsh
authorXu He Jie <xuhj@linux.vnet.ibm.com>
Thu, 29 Sep 2011 08:57:12 +0000 (16:57 +0800)
committerEric Blake <eblake@redhat.com>
Thu, 29 Sep 2011 13:04:14 +0000 (07:04 -0600)
Signed-off-by: Xu He Jie <xuhj@linux.vnet.ibm.com>
tools/virsh.c
tools/virsh.pod

index 807324b71c2c73711ea52ca857d1b84ac497b114..1909dce20ed416fa216934f624e9fcddfe8a8dd7 100644 (file)
@@ -3191,6 +3191,44 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
     return ret;
 }
 
+/*
+ * "reset" command
+ */
+static const vshCmdInfo info_reset[] = {
+    {"help", N_("reset a domain")},
+    {"desc", N_("Reset the target domain as if by power button")},
+    {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_reset[] = {
+    {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
+    {NULL, 0, 0, NULL}
+};
+
+static bool
+cmdReset(vshControl *ctl, const vshCmd *cmd)
+{
+    virDomainPtr dom;
+    bool ret = true;
+    const char *name;
+
+    if (!vshConnectionUsability(ctl, ctl->conn))
+        return false;
+
+    if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
+        return false;
+
+    if (virDomainReset(dom, 0) == 0) {
+        vshPrint(ctl, _("Domain %s was reset\n"), name);
+    } else {
+        vshError(ctl, _("Failed to reset domain %s"), name);
+        ret = false;
+    }
+
+    virDomainFree(dom);
+    return ret;
+}
+
 /*
  * "destroy" command
  */
@@ -13665,6 +13703,7 @@ static const vshCmdDef domManagementCmds[] = {
     {"migrate-getspeed", cmdMigrateGetMaxSpeed,
      opts_migrate_getspeed, info_migrate_getspeed, 0},
     {"reboot", cmdReboot, opts_reboot, info_reboot, 0},
+    {"reset", cmdReset, opts_reset, info_reset, 0},
     {"restore", cmdRestore, opts_restore, info_restore, 0},
     {"resume", cmdResume, opts_resume, info_resume, 0},
     {"save", cmdSave, opts_save, info_save, 0},
index 614b5a3e86d7d7fb8960585343ea7c34beefd69f..be81afc47024c1cd2ef912f1e39c68ae1fa54786 100644 (file)
@@ -790,6 +790,14 @@ domain actually reboots.
 The exact behavior of a domain when it reboots is set by the
 I<on_reboot> parameter in the domain's XML definition.
 
+=item B<reset> I<domain-id>
+
+Reset a domain immediately without any guest shutdown. B<reset>
+emulates the power reset button on a machine, where all guest
+hardware sees the RST line set and reinitializes internal state.
+
+B<Note>: Reset without any guest OS shutdown risks data loss.
+
 =item B<restore> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
 [{I<--running> | I<--paused>}]