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

[libvirt] [PATCH v4 1/2] virDomainCoreDump: Introduce VIR_DUMP_RESET flag



This flag is intended to allow user to do so called system reset
after dump, instead of sending ACPI reboot event.
---
 include/libvirt/libvirt.h.in |    1 +
 src/libvirt.c                |   15 ++++++++++++++-
 tools/virsh.c                |    3 +++
 tools/virsh.pod              |    4 +++-
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..fc82e13 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_RESET        = (1 << 3), /* reset domain after dump finishes */
 } virDomainCoreDumpFlags;
 
 /* Domain migration flags. */
diff --git a/src/libvirt.c b/src/libvirt.c
index 8f94b11..f8be566 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2784,7 +2784,8 @@ error:
  * a crashed state after the dump completes.  If @flags includes
  * VIR_DUMP_LIVE, then make the core dump while continuing to allow
  * the guest to run; otherwise, the guest is suspended during the dump.
- * The above two flags are mutually exclusive.
+ * VIR_DUMP_RESET flag forces reset of the quest after dump.
+ * The above three flags are mutually exclusive.
  *
  * Additionally, if @flags includes VIR_DUMP_BYPASS_CACHE, then libvirt
  * will attempt to bypass the file system cache while creating the file,
@@ -2823,6 +2824,18 @@ virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)
         goto error;
     }
 
+    if ((flags & VIR_DUMP_CRASH) && (flags & VIR_DUMP_RESET)) {
+        virLibDomainError(VIR_ERR_INVALID_ARG,
+                         _("crash and reset flags are mutually exclusive"));
+        goto error;
+    }
+
+    if ((flags & VIR_DUMP_LIVE) && (flags & VIR_DUMP_RESET)) {
+        virLibDomainError(VIR_ERR_INVALID_ARG,
+                          _("live and reset flags are mutually exclusive"));
+        goto error;
+    }
+
     if (conn->driver->domainCoreDump) {
         int ret;
         char *absolute_to;
diff --git a/tools/virsh.c b/tools/virsh.c
index 7b0533d..b860d1a 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")},
+    {"reset", VSH_OT_BOOL, 0, N_("reset 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, "reset"))
+        flags |= VIR_DUMP_RESET;
 
     if (virDomainCoreDump(dom, to, flags) < 0) {
         vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 43ed1ea..fc735f7 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -629,13 +629,15 @@ Convert the file I<xml> in domain XML format to the native guest
 configuration format named by I<format>.
 
 =item B<dump> I<domain-id> I<corefilepath> [I<--live>] [I<--crash>]
-[I<--bypass-cache>]
+[I<--bypass-cache>] [I<--reset>]
 
 Dumps the core of a domain to a file for analysis.
 If I<--live> is specified, the domain continues to run until the core
 dump is complete, rather than pausing up front.
 If I<--crash> is specified, the domain is halted with a crashed status,
 rather than merely left in a paused state.
+If I<--reset> is specified, the domain is reset after successful dump.
+Note, these three switches are mutually exclusive.
 If I<--bypass-cache> is specified, the save will avoid the file system
 cache, although this may slow down the operation.
 
-- 
1.7.3.4


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