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

Michal Privoznik mprivozn at redhat.com
Tue Sep 20 11:34:27 UTC 2011


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>
---
 include/libvirt/libvirt.h.in |    1 +
 src/qemu/qemu_driver.c       |    8 +++++++-
 tools/virsh.c                |    3 +++
 3 files changed, 11 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 e2f428f..22576a8 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,11 @@ cleanup:
     if (event)
         qemuDomainEventQueue(driver, event);
     qemuDriverUnlock(driver);
+
+    if ((ret == 0) && (flags & VIR_DUMP_REBOOT)) {
+        qemuDomainReboot(dom, 0);
+    }
+
     return ret;
 }
 
diff --git a/tools/virsh.c b/tools/virsh.c
index d575425..74f6a79 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2840,6 +2840,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}
@@ -2869,6 +2870,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);
-- 
1.7.3.4




More information about the libvir-list mailing list