[libvirt] [PATCH 2/2] add --live support to "virsh dump"

Daniel Veillard veillard at redhat.com
Mon Nov 30 10:22:54 UTC 2009


On Mon, Nov 30, 2009 at 10:11:11AM +0100, Paolo Bonzini wrote:
> This is trivial for QEMU since you just have to not stop the vm before
> starting the dump.
> 
> In Xen it is buggy, so I chose to not support it.

  And for the test driver there ain't any difference anyway ...

> * src/qemu/qemu_driver.c (qemudDomainCoreDump): Support live dumping.
> ---
>  include/libvirt/libvirt.h.in |    1 +
>  src/qemu/qemu_driver.c       |    7 +++----
>  tools/virsh.c                |    3 +++
>  3 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index c04b552..b4a7ef1 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -337,6 +337,7 @@ typedef virDomainInterfaceStatsStruct *virDomainInterfaceStatsPtr;
>  /* Domain core dump flags. */
>  typedef enum {
>      VIR_DUMP_CRASH   = (1 << 0), /* crash after dump */
> +    VIR_DUMP_LIVE    = (1 << 1), /* live dump */
>  } virDomainCoreDumpFlags;
>  
>  /* Domain migration flags. */
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 8e80144..7de3c45 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -3597,15 +3597,14 @@ static int qemudDomainCoreDump(virDomainPtr dom,
>          driver->securityDriver->domainSetSavedStateLabel(dom->conn, vm, path) == -1)
>          goto endjob;
>  
> -    /* Migrate will always stop the VM, so once we support live dumping
> -       the resume condition will stay the same, independent of whether
> -       the stop command is issued.  */
> +    /* Migrate will always stop the VM, so the resume condition is
> +       independent of whether the stop command is issued.  */
>      resume = (vm->state == VIR_DOMAIN_RUNNING);
>  
>      qemuDomainObjPrivatePtr priv = vm->privateData;
>  
>      /* Pause domain for non-live dump */
> -    if (vm->state == VIR_DOMAIN_RUNNING) {
> +    if (!(flags & VIR_DUMP_LIVE) && vm->state == VIR_DOMAIN_RUNNING) {
>          qemuDomainObjEnterMonitor(vm);
>          if (qemuMonitorStopCPUs(priv->mon) < 0) {
>              qemuDomainObjExitMonitor(vm);
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 65eaa3b..fcbd4e6 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -1431,6 +1431,7 @@ static const vshCmdInfo info_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")},
>      {"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")},
> @@ -1455,6 +1456,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
>      if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
>          return FALSE;
>  
> +    if (vshCommandOptBool (cmd, "live"))
> +        flags |= VIR_DUMP_LIVE;
>      if (vshCommandOptBool (cmd, "crash"))
>          flags |= VIR_DUMP_CRASH;
>  

  Looks fine to me too, depends on previous being applied, ACK !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list