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

Re: [libvirt] [PATCH v2] qemu: Allow domain reboot after core dump



On 09/21/2011 02:47 PM, Michal Privoznik wrote:
This patch introduces possibility to reboot domain after core dump
finishes. The new flag VIR_DUMP_REBOOT was added to
virDomainCoreDumpFlags. The new functionality is accessible via virsh
too: virsh dump --reboot<domain>
---
diff to v1:
-check for success of reboot
  include/libvirt/libvirt.h.in |    1 +
  src/qemu/qemu_driver.c       |    9 ++++++++-
  tools/virsh.c                |    3 +++
  3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..8c41f5a 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -748,6 +748,7 @@ typedef enum {
      VIR_DUMP_CRASH        = (1<<  0), /* crash after dump */
      VIR_DUMP_LIVE         = (1<<  1), /* live dump */
      VIR_DUMP_BYPASS_CACHE = (1<<  2), /* avoid file system cache pollution */
+    VIR_DUMP_REBOOT       = (1<<  3), /* reboot domain after dump finishes */
  } virDomainCoreDumpFlags;

  /* Domain migration flags. */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f4ee4c3..f040384 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3104,7 +3104,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
      int ret = -1;
      virDomainEventPtr event = NULL;

-    virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH | VIR_DUMP_BYPASS_CACHE, -1);
+    virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH |
+                  VIR_DUMP_BYPASS_CACHE | VIR_DUMP_REBOOT, -1);

      qemuDriverLock(driver);
      vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -3189,6 +3190,12 @@ cleanup:
      if (event)
          qemuDomainEventQueue(driver, event);
      qemuDriverUnlock(driver);
+
+    if ((ret == 0)&&  (flags&  VIR_DUMP_REBOOT)&&
+        (qemuDomainReboot(dom, 0)<  0)) {
+        ret = -1;
+    }
+
      return ret;
  }

diff --git a/tools/virsh.c b/tools/virsh.c
index 371346a..deadb4e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2899,6 +2899,7 @@ static const vshCmdOptDef opts_dump[] = {
      {"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")},
      {"bypass-cache", VSH_OT_BOOL, 0,
       N_("avoid file system cache when saving")},
+    {"reboot", VSH_OT_BOOL, 0, N_("reboot the domain after core dump")},
      {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
      {"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")},
      {NULL, 0, 0, NULL}
@@ -2928,6 +2929,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
          flags |= VIR_DUMP_CRASH;
      if (vshCommandOptBool(cmd, "bypass-cache"))
          flags |= VIR_DUMP_BYPASS_CACHE;
+    if (vshCommandOptBool(cmd, "reboot"))
+        flags |= VIR_DUMP_REBOOT;

      if (virDomainCoreDump(dom, to, flags)<  0) {
          vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
I met some error like below when I test virsh command virsh dump -reboot:

virsh # start kvm-one
Domain kvm-one started

virsh # dump --reboot kvm-one /home/lei/dumpcore
error: Failed to core dump domain kvm-one to /home/lei/dumpcore
error: Unable to read from monitor: Connection reset by peer

virsh # list
 Id Name                 State
----------------------------------

virsh #

After dump --reboot, my domain shutdown unexpectedly.
Did I miss anything?

--
Lei


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