[PATCH 4/4] virsh: Add 'reset' command for virsh

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

 



Signed-off-by: Xu He Jie <xuhj@xxxxxxxxxxxxxxxxxx>
---
 tools/virsh.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 13be03b..13b10cd 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3188,6 +3188,44 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd)
 }
 
 /*
+ * "reset" command
+ */
+static const vshCmdInfo info_reset[] = {
+    {"help", N_("reset a domain")},
+    {"desc", N_("Reset the target domain immediately without any guest 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) {
+        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[] = {
@@ -13574,6 +13612,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},
-- 
1.7.4.1

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