Signed-off-by: Xu He Jie <xuhj(a)linux.vnet.ibm.com>
---
tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 8 ++++++++
2 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 807324b..a7d0559 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3192,6 +3192,51 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
}
/*
+ * "reset" command
+ */
+static const vshCmdInfo info_reset[] = {
+ {"help", N_("reset a domain immediately without any guest OS
shutdown")},
+ {"desc",
+ N_("Reset the target domain immediately without any guest OS shutdown. "
+ "That emulates the power reset of a button on a machine, i.e. "
+ "All hardware see the RST line set and reinitialize their "
+ "internal state.\n"
+ "\n"
+ " Note that the risk of data loss caused by reset without "
+ "guest os shutdown.")},
+ {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 is being reseted\n"), name);
+ } else {
+ vshError(ctl, _("Failed to reset domain %s"), name);
+ ret = false;
+ }
+
+ virDomainFree(dom);
+ return ret;
+}
+
+/*
* "destroy" command
*/
static const vshCmdInfo info_destroy[] = {
@@ -13665,6 +13710,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},
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 614b5a3..2192600 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -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 of a button on a machine, i.e.
+All hardware see the RST line set and reinitialize their internal state.
+
+B<Note>: Reset without any guest OS shutdown cause the risk of data loss.
+
=item B<restore> I<state-file> [I<--bypass-cache>] [I<--xml>
B<file>]
[{I<--running> | I<--paused>}]
--
1.7.4.1