<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    yes, the patch can work, when I execute virsh dump --reboot
    <domain> <file><br>
    <br>
    and the type of file is: QEMU's suspend to disk image<br>
    <br>
    but the guest does not reboot. The guest does nothing.<br>
    <br>
    but I try  virsh shutdown <domain>,  the guest Ubuntu OS pop
    up a dialog box with four options: Shut Down, Restart, Suspend and
    HIbernate.<br>
    <br>
    -------- 原始信息 --------
    <blockquote cite="mid:4E797262.2080102@linux.vnet.ibm.com"
      type="cite">
      <table class="moz-email-headers-table" border="0" cellpadding="0"
        cellspacing="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">主题: </th>
            <td>[libvirt] [PATCH] qemu: Allow domain reboot after core
              dump</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">日期: </th>
            <td>Tue, 20 Sep 2011 13:34:27 +0200</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">发件人: </th>
            <td>Michal Privoznik <a moz-do-not-send="true"
                class="moz-txt-link-rfc2396E"
                href="mailto:mprivozn@redhat.com"><mprivozn@redhat.com></a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">收件人: </th>
            <td><a moz-do-not-send="true"
                class="moz-txt-link-abbreviated"
                href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <pre>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

--
libvir-list mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:libvir-list@redhat.com">libvir-list@redhat.com</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://www.redhat.com/mailman/listinfo/libvir-list">https://www.redhat.com/mailman/listinfo/libvir-list</a>

</pre>
    </blockquote>
  </body>
</html>