[libvirt] [PATCH v3 1/4] add new virDomainMemoryDump API

Daniel P. Berrange berrange at redhat.com
Thu Feb 27 14:43:53 UTC 2014


On Thu, Feb 27, 2014 at 03:56:42PM +0800, qiaonuohan wrote:
> --memory-only option is introduced without compression supported. Therefore,
> this is a freature regression of virsh dump. Now qemu has support dumping memory
> in kdump-compressed format. This patch is adding new virDomainMemoryDump API,
> so that the format in which qemu dump domain's memory can be specified.
> 
> Signed-off-by: Qiao Nuohan <qiaonuohan at cn.fujitsu.com>_
> ---
>  include/libvirt/libvirt.h.in | 21 ++++++++++
>  src/access/viraccessperm.c   |  2 +-
>  src/access/viraccessperm.h   |  6 +++
>  src/driver.h                 |  7 ++++
>  src/libvirt.c                | 95 ++++++++++++++++++++++++++++++++++++++++++++
>  src/libvirt_public.syms      |  5 +++
>  src/remote/remote_driver.c   |  1 +
>  src/remote/remote_protocol.x | 15 ++++++-
>  src/remote_protocol-structs  |  7 ++++
>  src/test/test_driver.c       | 17 +++++++-
>  10 files changed, 172 insertions(+), 4 deletions(-)
> 
> diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
> index 295d551..ab6efca 100644
> --- a/include/libvirt/libvirt.h.in
> +++ b/include/libvirt/libvirt.h.in
> @@ -1180,6 +1180,19 @@ typedef enum {
>      VIR_DUMP_MEMORY_ONLY  = (1 << 4), /* use dump-guest-memory */
>  } virDomainCoreDumpFlags;
>  
> +/* Domain memory dump's format */
> +typedef enum {
> +    VIR_MEMORY_DUMP_COMPRESS_ZLIB   = 1, /* dump guest memory in
> +                                            kdump-compressed format, with
> +                                            zlib-compressed */
> +    VIR_MEMORY_DUMP_COMPRESS_LZO    = 2, /* dump guest memory in
> +                                            kdump-compressed format, with
> +                                            lzo-compressed */
> +    VIR_MEMORY_DUMP_COMPRESS_SNAPPY = 3, /* dump guest memory in
> +                                            kdump-compressed format, with
> +                                            snappy-compressed */
> +} virMemoryDumpFormat;

s/virMemoryDumpFormat/virDomainCoreDumpFormat/

No need to assign values to each entry here since this
is a plain enum, not bitflags.

Also  s/MEMORY_COMPRESS/DOMAIN_CORE_FORMAT/ for every member

And add  VIR_MEMORY_DUMP_FORMAT_RAW  for the non-compressed
format, which probably ought to be the default (ie first).

> +
>  /* Domain migration flags. */
>  typedef enum {
>      VIR_MIGRATE_LIVE              = (1 << 0), /* live migration */
> @@ -1731,6 +1744,14 @@ int                     virDomainCoreDump       (virDomainPtr domain,
>                                                   unsigned int flags);
>  
>  /*
> + * Domain core dump
> + */
> +int                     virDomainMemoryDump     (virDomainPtr domain,
> +                                                 const char *to,
> +                                                 unsigned int flags,
> +                                                 unsigned int dumpformat);

Convention is that the 'flags' parameter should always be the very last
one.

The name would be better as virDomainCoreDumpWithFormat IMHO to
show it is an extension of virDomainCoreDump.

> diff --git a/src/access/viraccessperm.h b/src/access/viraccessperm.h
> index 6d14f05..2537fbf 100644
> --- a/src/access/viraccessperm.h
> +++ b/src/access/viraccessperm.h
> @@ -205,6 +205,12 @@ typedef enum {
>      VIR_ACCESS_PERM_DOMAIN_CORE_DUMP, /* Dump guest core */
>  
>      /**
> +     * @desc: Dump domain's memory only
> +     * @message: Dumping domain's memory requires authorization
> +     */
> +    VIR_ACCESS_PERM_DOMAIN_MEMORY_DUMP, /* Dump guest's memory only */
> +
> +    /**

There's no point in inventing a new permission - the same permission
as the existing API is more than OK.


> +/**
> + * virDomainMemoryDump:
> + * @domain: a domain object
> + * @to: path for the core file
> + * @flags: bitwise-OR of virDomainCoreDumpFlags
> + * @dumpformat: format of domain memory's dump
> + *
> + * This method will only dump the memory of a domain on a given file for
> + * analysis, so @flag must includes VIR_DUMP_MEMORY_ONLY.

This restricton seems rather dubious. This new method's functionality
should be a super-set of virDomainCoreDump - ie everything that the
old method could do, should be possible in the new method. All we
do is add the ability to choose between formats.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list