提交 1fb7af40 编写于 作者: P Paolo Bonzini 提交者: Daniel Veillard

add --live support to "virsh dump"

This is trivial for QEMU since you just have to not stop the vm before
starting the dump.  And for Xen, you just pass the flag down to xend.

* include/libvirt/libvirt.h.in (virDomainCoreDumpFlags): Add VIR_DUMP_LIVE.
* src/qemu/qemu_driver.c (qemudDomainCoreDump): Support live dumping.
* src/xen/xend_internal.c (xenDaemonDomainCoreDump): Support live dumping.
* tools/virsh.c (opts_dump): Add --live. (cmdDump): Map it to VIR_DUMP_LIVE.
上级 b927aed8
...@@ -337,6 +337,7 @@ typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr; ...@@ -337,6 +337,7 @@ typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;
/* Domain core dump flags. */ /* Domain core dump flags. */
typedef enum { typedef enum {
VIR_DUMP_CRASH = (1 << 0), /* crash after dump */ VIR_DUMP_CRASH = (1 << 0), /* crash after dump */
VIR_DUMP_LIVE = (1 << 1), /* live dump */
} virDomainCoreDumpFlags; } virDomainCoreDumpFlags;
/* Domain migration flags. */ /* Domain migration flags. */
......
...@@ -3856,15 +3856,14 @@ static int qemudDomainCoreDump(virDomainPtr dom, ...@@ -3856,15 +3856,14 @@ static int qemudDomainCoreDump(virDomainPtr dom,
driver->securityDriver->domainSetSavedStateLabel(dom->conn, vm, path) == -1) driver->securityDriver->domainSetSavedStateLabel(dom->conn, vm, path) == -1)
goto endjob; goto endjob;
/* Migrate will always stop the VM, so once we support live dumping /* Migrate will always stop the VM, so the resume condition is
the resume condition will stay the same, independent of whether independent of whether the stop command is issued. */
the stop command is issued. */
resume = (vm->state == VIR_DOMAIN_RUNNING); resume = (vm->state == VIR_DOMAIN_RUNNING);
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
/* Pause domain for non-live dump */ /* Pause domain for non-live dump */
if (vm->state == VIR_DOMAIN_RUNNING) { if (!(flags & VIR_DUMP_LIVE) && vm->state == VIR_DOMAIN_RUNNING) {
qemuDomainObjEnterMonitor(vm); qemuDomainObjEnterMonitor(vm);
if (qemuMonitorStopCPUs(priv->mon) < 0) { if (qemuMonitorStopCPUs(priv->mon) < 0) {
qemuDomainObjExitMonitor(vm); qemuDomainObjExitMonitor(vm);
......
...@@ -3255,6 +3255,7 @@ xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename, ...@@ -3255,6 +3255,7 @@ xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
return xend_op(domain->conn, domain->name, return xend_op(domain->conn, domain->name,
"op", "dump", "file", filename, "live", "0", "op", "dump", "file", filename, "live", "0",
"live", (flags & VIR_DUMP_LIVE ? "1" : "0"),
"crash", (flags & VIR_DUMP_CRASH ? "1" : "0"), "crash", (flags & VIR_DUMP_CRASH ? "1" : "0"),
NULL); NULL);
} }
......
...@@ -1431,6 +1431,7 @@ static const vshCmdInfo info_dump[] = { ...@@ -1431,6 +1431,7 @@ static const vshCmdInfo info_dump[] = {
}; };
static const vshCmdOptDef opts_dump[] = { static const vshCmdOptDef opts_dump[] = {
{"live", VSH_OT_BOOL, 0, gettext_noop("perform a live core dump if supported")},
{"crash", VSH_OT_BOOL, 0, gettext_noop("crash the domain after core dump")}, {"crash", VSH_OT_BOOL, 0, gettext_noop("crash the domain after core dump")},
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")}, {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("where to dump the core")}, {"file", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("where to dump the core")},
...@@ -1455,6 +1456,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) ...@@ -1455,6 +1456,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return FALSE; return FALSE;
if (vshCommandOptBool (cmd, "live"))
flags |= VIR_DUMP_LIVE;
if (vshCommandOptBool (cmd, "crash")) if (vshCommandOptBool (cmd, "crash"))
flags |= VIR_DUMP_CRASH; flags |= VIR_DUMP_CRASH;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册