On Thu, Feb 27, 2014 at 03:56:43PM +0800, qiaonuohan wrote: > This patch makes use of the QEMU guest agent to implement the > virDomainMemoryDump API.
Unless I'm missing something this doesn't appear to involve the QEMU guest agent, at least not from libvirt's POV. This code is using the QEMU monitor APIs. > Signed-off-by: Qiao Nuohan <qiaonuo...@cn.fujitsu.com> > --- > src/qemu/qemu_driver.c | 42 ++++++++++++++++++++++++++++++++---------- > src/qemu/qemu_monitor.c | 7 ++++--- > src/qemu/qemu_monitor.h | 3 ++- > src/qemu/qemu_monitor_json.c | 4 +++- > src/qemu/qemu_monitor_json.h | 3 ++- > tests/qemumonitorjsontest.c | 2 +- > 6 files changed, 44 insertions(+), 17 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index c9a865e..e063a42 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -3391,7 +3391,8 @@ cleanup: > } > > static int qemuDumpToFd(virQEMUDriverPtr driver, virDomainObjPtr vm, > - int fd, enum qemuDomainAsyncJob asyncJob) > + int fd, enum qemuDomainAsyncJob asyncJob, > + const char* memory_dump_format) > { > qemuDomainObjPrivatePtr priv = vm->privateData; > int ret = -1; > @@ -3411,7 +3412,7 @@ static int qemuDumpToFd(virQEMUDriverPtr driver, > virDomainObjPtr vm, > if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) > return -1; > > - ret = qemuMonitorDumpToFd(priv->mon, fd); > + ret = qemuMonitorDumpToFd(priv->mon, fd, memory_dump_format); > qemuDomainObjExitMonitor(driver, vm); > > return ret; > @@ -3422,13 +3423,15 @@ doCoreDump(virQEMUDriverPtr driver, > virDomainObjPtr vm, > const char *path, > virQEMUSaveFormat compress, > - unsigned int dump_flags) > + unsigned int dump_flags, > + unsigned int dumpformat) > { > int fd = -1; > int ret = -1; > virFileWrapperFdPtr wrapperFd = NULL; > int directFlag = 0; > unsigned int flags = VIR_FILE_WRAPPER_NON_BLOCKING; > + const char *memory_dump_format; > > /* Create an empty file with appropriate ownership. */ > if (dump_flags & VIR_DUMP_BYPASS_CACHE) { > @@ -3452,7 +3455,16 @@ doCoreDump(virQEMUDriverPtr driver, > goto cleanup; > > if (dump_flags & VIR_DUMP_MEMORY_ONLY) { > - ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP); > + if (dumpformat == VIR_MEMORY_DUMP_COMPRESS_ZLIB) > + memory_dump_format = "kdump-zlib"; > + else if (dumpformat == VIR_MEMORY_DUMP_COMPRESS_LZO) > + memory_dump_format = "kdump-lzo"; > + else if (dumpformat == VIR_MEMORY_DUMP_COMPRESS_SNAPPY) > + memory_dump_format = "kdump-snappy"; > + else > + memory_dump_format = "elf"; There should be an explicit check for the ELF format, and the use virReportError(VIR_ERR_INVALID_ARG) if the user supplied a format we don't know about. > + ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, > + memory_dump_format); > } else { > ret = qemuMigrationToFile(driver, vm, fd, 0, path, > qemuCompressProgramName(compress), false, > @@ -3515,9 +3527,10 @@ cleanup: > return ret; > } > > -static int qemuDomainCoreDump(virDomainPtr dom, > +static int qemuDomainMemoryDump(virDomainPtr dom, > const char *path, > - unsigned int flags) > + unsigned int flags, > + unsigned int dumpformat) > { > virQEMUDriverPtr driver = dom->conn->privateData; > virDomainObjPtr vm; > @@ -3533,7 +3546,7 @@ static int qemuDomainCoreDump(virDomainPtr dom, > if (!(vm = qemuDomObjFromDomain(dom))) > return -1; > > - if (virDomainCoreDumpEnsureACL(dom->conn, vm->def) < 0) > + if (virDomainMemoryDumpEnsureACL(dom->conn, vm->def) < 0) > goto cleanup; > > if (qemuDomainObjBeginAsyncJob(driver, vm, > @@ -3565,7 +3578,8 @@ static int qemuDomainCoreDump(virDomainPtr dom, > } > } > > - ret = doCoreDump(driver, vm, path, getCompressionType(driver), flags); > + ret = doCoreDump(driver, vm, path, getCompressionType(driver), flags, > + dumpformat); > if (ret < 0) > goto endjob; > > @@ -3619,6 +3633,13 @@ cleanup: > return ret; > } > > +static int qemuDomainCoreDump(virDomainPtr dom, > + const char *path, > + unsigned int flags) > +{ > + return qemuDomainMemoryDump(dom, path, flags, 0); > +} This should use a enum constant from the public header rather than 0 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 :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list