Re: [libvirt] [RFC] support memory reserved feature and optimize mlock guest memory propose
Il 05/03/2014 09:01, Zhanghailiang ha scritto: Hi all: Currently, we use cgroup(memory) to support memory QoS on KVM platform, and use mlock on qemu to support memory reserved. The mlock seems to be not appropriate. Now qemu mlock memory in the main thread, which would lock iothread (qemu_mutex_lock_iothread), if the memory size is large, that will consume lots of time. It means whenever we want to set a new 'mlock', the VM would be blocked for a while. I'm not sure I understand how the mlock-ed memory is used. Are you using a custom malloc, for example with g_mem_set_vtable? Paolo Hi Paolo: Thanks for your reply. As you know qemu has an option -mlock, I think it has some problems. If we set -realtime mlock=on, then qemu will mlockall vm's memory, It is a very time consuming action, and it will block the libvirt api until it finished. so I think it is better to do 'mlock' asynchronously, the flow chart can be described like below. Is it ok? Flow chart: main funciton qmp command set_ram_minguarantee | | | | create mlock thread change value of lock_ram_size | | | | |--thread wait-wake up mlock thread || || || |---mlock(lock_ram_zie) zhanghailiang -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC] support memory reserved feature and optimize mlock guest memory propose
Il 06/03/2014 09:06, Zhanghailiang ha scritto: Il 05/03/2014 09:01, Zhanghailiang ha scritto: Hi all: Currently, we use cgroup(memory) to support memory QoS on KVM platform, and use mlock on qemu to support memory reserved. The mlock seems to be not appropriate. Now qemu mlock memory in the main thread, which would lock iothread (qemu_mutex_lock_iothread), if the memory size is large, that will consume lots of time. It means whenever we want to set a new 'mlock', the VM would be blocked for a while. I'm not sure I understand how the mlock-ed memory is used. Are you using a custom malloc, for example with g_mem_set_vtable? Paolo Hi Paolo: Thanks for your reply. As you know qemu has an option -mlock, I think it has some problems. If we set -realtime mlock=on, then qemu will mlockall vm's memory, It is a very time consuming action, and it will block the libvirt api until it finished. so I think it is better to do 'mlock' asynchronously, the flow chart can be described like below. Is an asynchronous mlock valid for all workloads? Until the mlock finishes, there is no guarantee that the guest will have real-time--friendly response to memory allocation. Is it ok? Flow chart: main funciton qmp command set_ram_minguarantee | | | | create mlock thread change value of lock_ram_size | | | | |--thread wait-wake up mlock thread || || || |---mlock(lock_ram_zie) Also, I'm not sure what the arguments to mlock are. How do you find the address range to pass to mlock? Paolo -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] datatypes: Fix comments
On 03/04/2014 03:58 AM, Michael Chapman wrote: - As of commit 2ff4c137, all virGet*() functions in datatypes.c always return pointers to new objects. Objects are not cached in a per-connection hashtable. - As of commit 46ec5f85, the conn.lock mutex does not need to be held when calling any vir*Dispose() function in datatypes.c (via virObjectUnref()). I've split out this part and pushed it. - Add comments for virGetStream(), virStreamDispose(), virGetDomainSnapshot(), virDomainSnapshotDispose(). Signed-off-by: Michael Chapman m...@very.puzzling.org --- src/datatypes.c | 174 1 file changed, 99 insertions(+), 75 deletions(-) diff --git a/src/datatypes.c b/src/datatypes.c index 73f17e7..aafa54b 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -96,9 +96,8 @@ VIR_ONCE_GLOBAL_INIT(virDataTypes) /** * virGetConnect: * - * Allocates a new hypervisor connection structure - * - * Returns a new pointer or NULL in case of error. + * Allocates and returns a pointer to a new hypervisor connection object. + * Returns NULL on error. As someone pointed out to me in person, 'Returns' is a special keyword for our API docs builder script. Even if we aren't building docs out of this file, it would be nice to stick to that style. Jan signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] Cache result of QEMU capabilities extraction
On Wed, Mar 05, 2014 at 05:53:48PM -0700, Eric Blake wrote: On 03/05/2014 10:53 AM, Daniel P. Berrange wrote: Extracting capabilities from QEMU takes a notable amount of time when all QEMU binaries are installed. Each system emulator needs about 200-300ms multiplied by 26 binaries == ~5-8 seconds. This change causes the QEMU driver to save an XML file containing the content of the virQEMUCaps object instance in the cache dir eg /var/cache/libvirt/qemu/capabilities/$SHA256(binarypath).xml or $HOME/.cache/libvirt/qemu/cache/capabilities/$SHA256(binarypath).xml We attempt to load this and only if it fails, do we fallback to probing the QEMU binary. The timestamp of the file is compared to the timestamp of the QEMU binary and discarded if the QEMU binary is newer. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- src/qemu/qemu_capabilities.c | 412 ++- src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_driver.c | 1 + 3 files changed, 407 insertions(+), 8 deletions(-) @@ -44,6 +45,7 @@ #include unistd.h #include sys/wait.h #include stdarg.h +#include utime.h utime.h (and the utime() function) is deprecated by POSIX and therefore no longer portable because it corrupts sub-second timestamps. Better is to use gnulib's utimensat (or futimens). But what timestamps do we actually have to munge? + +ut.actime = qemuCaps-mtime; +ut.modtime = qemuCaps-mtime; +if (utime(filename, ut) 0) { +virReportSystemError(errno, + _(Failed to set mtime on '%s' for '%s'), + filename, qemuCaps-binary); Why not just store the qemu binary timestamp in the XML, rather than playing games with the mtime of the xml file? I wanted to be able to detect out of date cache files without having to go through parsing them. 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
Re: [libvirt] [PATCH v2 0/5] Expose FSFreeze/FSThaw within the guest as API
On Wed, Mar 05, 2014 at 02:52:49PM -0500, Tomoki Sekiyama wrote: Hello, This is patchset v2 to add FSFreeze/FSThaw API for custom disk snapshotting. Patch 1 in your series hasn't arrived in my inbox, nor is it visible in the mail archves... 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
Re: [libvirt] [PATCH 3/4] Cache result of QEMU capabilities extraction
On Wed, Mar 05, 2014 at 09:40:34PM +0100, Guido Günther wrote: Hi Daniel, On Wed, Mar 05, 2014 at 05:53:53PM +, Daniel P. Berrange wrote: [..snip..] +/* Discard if cache is older that QEMU binary */ +/* XXX must also compare to libvirtd timestamp */ +if (sb.st_mtime qemuCaps-mtime) { I think looking at the mtime isn't sufficent here. Tools like dpkg set the mtime to the time the package was built at not the installation time so we might end up updating qemu but still having an mtime older than the time the xml was created (same holds for downgrades to older qemu versions) or are we simply requiring distributors to clean the cache upon package upgrades (which would mandate using a trigger)? NB the existing code already has the flaw you speak of - we cache the capabilities in memory currently and only invalidate when mtime is outdated. Maybe we need to actually calculate the binaries checksum not only the pathname? We could then simply just wipe alle checksums upon libvirt upgrades to get rid of old entries. Checksumming the binary content is reasonably heavyweight, but we could just use ctime like Eric suggests 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
[libvirt] [PATCH v5 3/3] allow virsh dump --memory-only specify dump format
This patch is used to add --compress and [--compression-format] string to virsh dump --memory-only. And virsh dump --memory-only is going be implemented by new virDomainCoreDumpWithFormat API. Signed-off-by: Qiao Nuohan qiaonuo...@cn.fujitsu.com --- tools/virsh-domain.c | 45 - 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2e3f0ed..70613e5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4486,6 +4486,14 @@ static const vshCmdOptDef opts_dump[] = { .type = VSH_OT_BOOL, .help = N_(dump domain's memory only) }, +{.name = compress, + .type = VSH_OT_BOOL, + .help = N_(make qemu dump domain's memory in kdump-compressed format) +}, +{.name = compression-format, + .type = VSH_OT_DATA, + .help = N_(specify the compression format of kdump-compressed format) +}, {.name = NULL} }; @@ -4501,6 +4509,9 @@ doDump(void *opaque) const char *name = NULL; const char *to = NULL; unsigned int flags = 0; +bool optCompress; +const char *compression_format = NULL; +unsigned int memory_dump_format = VIR_DUMP_FORMAT_RAW; sigemptyset(sigmask); sigaddset(sigmask, SIGINT); @@ -4524,7 +4535,39 @@ doDump(void *opaque) if (vshCommandOptBool(cmd, memory-only)) flags |= VIR_DUMP_MEMORY_ONLY; -if (virDomainCoreDump(dom, to, flags) 0) { +optCompress = vshCommandOptBool(cmd, compress); +if (optCompress !(flags VIR_DUMP_MEMORY_ONLY)) { +vshError(ctl, %s, + _(compress flag cannot be set without memory-only flag)); +goto out; +} + +if (vshCommandOptString(cmd, compression-format, compression_format)) { +if (!optCompress) { +vshError(ctl, %s, + _(compression-format cannot be set without compress + flag)); +goto out; +} + +if (STREQ(compression_format, zlib)) +memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB; +else if (STREQ(compression_format, lzo)) +memory_dump_format = VIR_DUMP_FORMAT_KDUMP_LZO; +else if (STREQ(compression_format, snappy)) +memory_dump_format = VIR_DUMP_FORMAT_KDUMP_SNAPPY; +else { +vshError(ctl, _(compression format '%s' is not supported, +expecting 'zlib', 'lzo' or 'snappy'.), + compression_format); +goto out; +} +} else { +if (optCompress) +memory_dump_format = VIR_DUMP_FORMAT_KDUMP_ZLIB; +} + +if (virDomainCoreDumpWithFormat(dom, to, memory_dump_format, flags) 0) { vshError(ctl, _(Failed to core dump domain %s to %s), name, to); goto out; } -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v5 0/3] support dumping guest memory in compressed format
dumping guest's memroy is introduced without compression supported, and this is a freature regression of 'virsh dump --memory-only'. This patchset is used to add support in libvirt side to make qemu dump guest's memory in kdump-compressed format and please refer the following address to see implementation of the qemu side, the lastest version of qemu side is v9(ready for being queued). http://lists.nongnu.org/archive/html/qemu-devel/2014-02/msg03016.html ChangLog: Changes from v4 to v5: 1. modify some restriction check Changes from v3 to v4: 1. dropping patch add dump_memory_format in qemu.conf 2. fix to follow some conventions Changes from v2 to v3: 1. address Jiri Denemark's comment about adding a new public API instead of changing an old one. Changes from v1 to v2: 1. address Daniel P. Berrange's comment about using a new parameter to replace flags like VIR_DUMP_COMPRESS_ZLIB. qiaonuohan (3): add new virDomainCoreDumpWithFormat API add qemu support to virDomainCoreDumpWithFormat API allow virsh dump --memory-only specify dump format include/libvirt/libvirt.h.in | 31 ++ src/driver.h | 7 src/libvirt.c| 97 src/libvirt_public.syms | 5 +++ src/qemu/qemu_driver.c | 49 ++ 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 +- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 15 ++- src/remote_protocol-structs | 7 src/test/test_driver.c | 20 +++-- tests/qemumonitorjsontest.c | 2 +- tools/virsh-domain.c | 45 +++- 15 files changed, 275 insertions(+), 21 deletions(-) -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v5 1/3] add new virDomainCoreDumpWithFormat API
--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 virDomainCoreDumpWithFormat API, so that the format in which qemu dump domain's memory can be specified. Signed-off-by: Qiao Nuohan qiaonuo...@cn.fujitsu.com --- include/libvirt/libvirt.h.in | 31 ++ src/driver.h | 7 src/libvirt.c| 97 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 | 20 +++-- 8 files changed, 179 insertions(+), 4 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..12d64ab 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -1180,6 +1180,29 @@ typedef enum { VIR_DUMP_MEMORY_ONLY = (1 4), /* use dump-guest-memory */ } virDomainCoreDumpFlags; +/** + * virDomainCoreDumpFormat: + * + * Values for specifying different formats of domain core dumps. + */ +typedef enum { +VIR_DUMP_FORMAT_RAW, /* dump guest memory in raw format */ +VIR_DUMP_FORMAT_KDUMP_ZLIB, /* dump guest memory in kdump-compressed + format, with zlib-compressed */ +VIR_DUMP_FORMAT_KDUMP_LZO,/* dump guest memory in kdump-compressed + format, with lzo-compressed */ +VIR_DUMP_FORMAT_KDUMP_SNAPPY, /* dump guest memory in kdump-compressed + format, with snappy-compressed */ +#ifdef VIR_ENUM_SENTINELS +VIR_DUMP_FORMAT_LAST +/* + * NB: this enum value will increase over time as new events are + * added to the libvirt API. It reflects the last state supported + * by this version of the libvirt API. + */ +#endif +} virDomainCoreDumpFormat; + /* Domain migration flags. */ typedef enum { VIR_MIGRATE_LIVE = (1 0), /* live migration */ @@ -1731,6 +1754,14 @@ int virDomainCoreDump (virDomainPtr domain, unsigned int flags); /* + * Domain core dump with format specified + */ +int virDomainCoreDumpWithFormat (virDomainPtr domain, + const char *to, + unsigned int dumpformat, + unsigned int flags); + +/* * Screenshot of current domain console */ char * virDomainScreenshot (virDomainPtr domain, diff --git a/src/driver.h b/src/driver.h index fbfaac4..d613f64 100644 --- a/src/driver.h +++ b/src/driver.h @@ -306,6 +306,12 @@ typedef int const char *to, unsigned int flags); +typedef int +(*virDrvDomainCoreDumpWithFormat)(virDomainPtr domain, + const char *to, + unsigned int dumpformat, + unsigned int flags); + typedef char * (*virDrvDomainScreenshot)(virDomainPtr domain, virStreamPtr stream, @@ -1200,6 +1206,7 @@ struct _virDriver { virDrvDomainSaveImageGetXMLDesc domainSaveImageGetXMLDesc; virDrvDomainSaveImageDefineXML domainSaveImageDefineXML; virDrvDomainCoreDump domainCoreDump; +virDrvDomainCoreDumpWithFormat domainCoreDumpWithFormat; virDrvDomainScreenshot domainScreenshot; virDrvDomainSetVcpus domainSetVcpus; virDrvDomainSetVcpusFlags domainSetVcpusFlags; diff --git a/src/libvirt.c b/src/libvirt.c index dcf6b53..77bf44f 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -2999,6 +2999,103 @@ error: return -1; } +/** + * virDomainCoreDumpWithFormat: + * @domain: a domain object + * @to: path for the core file + * @dumpformat: format of domain memory's dump + * @flags: bitwise-OR of virDomainCoreDumpFlags + * + * This method will dump the core of a domain on a given file for analysis. + * Note that for remote Xen Daemon the file path will be interpreted in + * the remote host. Hypervisors may require the user to manually ensure + * proper permissions on the file named by @to. + * + * If @flags includes VIR_DUMP_MEMORY_ONLY and dumpformat is set, libvirt + * will ask qemu dump domain's memory in kdump-compressed format. + * + * If @flags includes VIR_DUMP_CRASH, then leave the guest shut off with + * 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. + * VIR_DUMP_RESET flag forces reset of the quest after dump. + * The above three flags are mutually exclusive. + * + * Additionally, if @flags
[libvirt] [PATCH v5 2/3] add qemu support to virDomainCoreDumpWithFormat API
This patch makes qemu driver supprot virDomainCoreDumpWithFormat API. --- src/qemu/qemu_driver.c | 49 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, 52 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index c9a865e..2a56157 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 = NULL; /* Create an empty file with appropriate ownership. */ if (dump_flags VIR_DUMP_BYPASS_CACHE) { @@ -3452,8 +3455,25 @@ doCoreDump(virQEMUDriverPtr driver, goto cleanup; if (dump_flags VIR_DUMP_MEMORY_ONLY) { -ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP); +if (dumpformat == VIR_DUMP_FORMAT_RAW) +memory_dump_format = elf; +else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_ZLIB) +memory_dump_format = kdump-zlib; +else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_LZO) +memory_dump_format = kdump-lzo; +else if (dumpformat == VIR_DUMP_FORMAT_KDUMP_SNAPPY) +memory_dump_format = kdump-snappy; +else { +virReportError(VIR_ERR_INVALID_ARG, + _(unknown dumpformat '%d'), dumpformat); +} +ret = qemuDumpToFd(driver, vm, fd, QEMU_ASYNC_JOB_DUMP, + memory_dump_format); } else { +if (dumpformat != VIR_DUMP_FORMAT_RAW) +virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s, + _(kdump-compressed format is only work with guest + memory dump)); ret = qemuMigrationToFile(driver, vm, fd, 0, path, qemuCompressProgramName(compress), false, QEMU_ASYNC_JOB_DUMP); @@ -3515,8 +3535,9 @@ cleanup: return ret; } -static int qemuDomainCoreDump(virDomainPtr dom, +static int qemuDomainCoreDumpWithFormat(virDomainPtr dom, const char *path, + unsigned int dumpformat, unsigned int flags) { virQEMUDriverPtr driver = dom-conn-privateData; @@ -3533,7 +3554,7 @@ static int qemuDomainCoreDump(virDomainPtr dom, if (!(vm = qemuDomObjFromDomain(dom))) return -1; -if (virDomainCoreDumpEnsureACL(dom-conn, vm-def) 0) +if (virDomainCoreDumpWithFormatEnsureACL(dom-conn, vm-def) 0) goto cleanup; if (qemuDomainObjBeginAsyncJob(driver, vm, @@ -3565,7 +3586,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 +3641,13 @@ cleanup: return ret; } +static int qemuDomainCoreDump(virDomainPtr dom, + const char *path, + unsigned int flags) +{ +return qemuDomainCoreDumpWithFormat(dom, path, VIR_DUMP_FORMAT_RAW, flags); +} + static char * qemuDomainScreenshot(virDomainPtr dom, virStreamPtr st, @@ -3742,7 +3771,8 @@ static void processWatchdogEvent(virQEMUDriverPtr driver, virDomainObjPtr vm, in flags |= cfg-autoDumpBypassCache ? VIR_DUMP_BYPASS_CACHE: 0; ret = doCoreDump(driver, vm, dumpfile, - getCompressionType(driver), flags); + getCompressionType(driver), flags, +
Re: [libvirt] [Qemu-devel] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx
Amos Kong ak...@redhat.com writes: vm_config_groups[] only contains part of the options which have argument, and all options which have no argument aren't added to vm_config_groups[]. Current query-command-line-options only checks options from vm_config_groups[], so some options will be lost. We have macro in qemu-options.hx to generate a table that contains all the options. This patch tries to query options from the table. Then we won't lose the legacy options that weren't added to vm_config_groups[] (eg: -vnc, -smbios). The options that have no argument will also be returned (eg: -enable-fips) Some options that have argument have a NULL desc list, some options don't have argument, and parameters is mandatory in the past. So we add a new field argument to present if the option takes unspecified arguments. This patch also fixes options to match their actual command-line spelling rather than an alternate name associated with the option table in use by the command. Signed-off-by: Amos Kong ak...@redhat.com --- qapi-schema.json | 8 ++-- qemu-options.h | 10 ++ util/qemu-config.c | 44 ++-- vl.c | 15 --- 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 193e7e4..4ab0d16 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4070,12 +4070,16 @@ # # @option: option name # -# @parameters: an array of @CommandLineParameterInfo +# @parameters: array of @CommandLineParameterInfo, possibly empty +# @argument: @optional present if the @parameters array is empty. If +#true, then the option takes unspecified arguments, if +#false, then the option is merely a boolean flag (since 2.0) Suggest if false, then the option takes no argument. I'd call it something like 'unspecified-parameters' to emphasize the connection with parameters. # # Since 1.5 ## { 'type': 'CommandLineOptionInfo', - 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } } + 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'], +'*argument': 'bool' } } ## # @query-command-line-options: diff --git a/qemu-options.h b/qemu-options.h index 89a009e..8a515e0 100644 --- a/qemu-options.h +++ b/qemu-options.h @@ -25,6 +25,8 @@ * THE SOFTWARE. */ +#include sysemu/arch_init.h + Why do you need this header? If you need it, you should #include within the multiple-inclusion guard! #ifndef _QEMU_OPTIONS_H_ #define _QEMU_OPTIONS_H_ @@ -33,4 +35,12 @@ enum { #include qemu-options-wrapper.h }; +typedef struct QEMUOption { +const char *name; +int flags; +int index; +uint32_t arch_mask; +} QEMUOption; + +extern const QEMUOption qemu_options[]; #endif diff --git a/util/qemu-config.c b/util/qemu-config.c index d2facfd..2f89b92 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -6,6 +6,16 @@ #include hw/qdev.h #include qapi/error.h #include qmp-commands.h +#include qemu-options.h + +#define HAS_ARG 0x0001 + +const QEMUOption qemu_options[] = { +{ h, 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, +#define QEMU_OPTIONS_GENERATE_OPTIONS +#include qemu-options-wrapper.h +{ NULL }, +}; static QemuOptsList *vm_config_groups[32]; static QemuOptsList *drive_config_groups[4]; @@ -78,6 +88,17 @@ static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc) return param_list; } +static int get_group_index(const char *name) +{ +int i; + +for (i = 0; vm_config_groups[i] != NULL; i++) { +if (!strcmp(vm_config_groups[i]-name, name)) { +return i; +} +} +return -1; +} /* remove repeated entry from the info list */ static void cleanup_infolist(CommandLineParameterInfoList *head) { @@ -139,15 +160,26 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, CommandLineOptionInfo *info; int i; -for (i = 0; vm_config_groups[i] != NULL; i++) { -if (!has_option || !strcmp(option, vm_config_groups[i]-name)) { +for (i = 0; qemu_options[i].name; i++) { +if (!has_option || !strcmp(option, qemu_options[i].name)) { info = g_malloc0(sizeof(*info)); -info-option = g_strdup(vm_config_groups[i]-name); -if (!strcmp(drive, vm_config_groups[i]-name)) { +info-option = g_strdup(qemu_options[i].name); + +int idx = get_group_index(qemu_options[i].name); Style nit: declaration after statement. Suggest to declare it together with i above, as int i, idx;. + +if (qemu_options[i].flags) { +info-argument = true; +} The existing code using flags tests flags HAS_ARG, see lookup_opt()). Suggest to stick to that for consistency. Please move the assigment next to the assignment to
[libvirt] [PATCH] spec: Let translations be properly updated
Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo file to be regenerated even if a corresponding po/*.po file is newer. By removing the stamp-po file, all *.gmo files are properly updated if required. This allows downstreams to provide patches that update translations. Signed-off-by: Jiri Denemark jdene...@redhat.com --- libvirt.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 014fe5d..23374e7 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1421,6 +1421,7 @@ driver autoreconf -if %endif +rm -f po/stamp-po %configure %{?_without_xen} \ %{?_without_qemu} \ %{?_without_openvz} \ -- 1.9.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] spec: Let translations be properly updated
On 03/06/2014 04:06 AM, Jiri Denemark wrote: Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo file to be regenerated even if a corresponding po/*.po file is newer. By removing the stamp-po file, all *.gmo files are properly updated if required. This allows downstreams to provide patches that update translations. Signed-off-by: Jiri Denemark jdene...@redhat.com --- libvirt.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 014fe5d..23374e7 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1421,6 +1421,7 @@ driver autoreconf -if %endif I think you need to guard this: %if 0%{?enable_autotools} +rm -f po/stamp-po %endif %configure %{?_without_xen} \ %{?_without_qemu} \ %{?_without_openvz} \ since regeneration of .po files only occurs if autotools are re-run. When building an rpm from a stock tarball, you do NOT want to require gettext to be present - it is only when you are applying downstream patches that a .po file will ever be newer to require the regeneration of translations. ACK with the conditional added -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Release of libvirt-1.2.2
On 03/06/2014 12:02 AM, Jason Helfman wrote: On Sun, Mar 2, 2014 at 7:26 AM, Daniel Veillard veill...@redhat.com wrote: As planned I have tagged libvirt-1.2.2 in git and it seem the git tree finally updated despite the horrible network I get in china ATM, the tarballs may finally arrive at some time too at the usual place after working around the local infrastructure flaws... : ftp://libvirt.org/libvirt/ I am also pushing a libvirt-python-1.2.2 update at: ftp://libvirt.org/libvirt/libvirt/ I get this breakage on libvirt 1.2.2 for FreeBSD. gmake[3]: *** No rule to make target `test_libvirt_lockd.aug', needed by `all-am'. Stop. Any ideas? Known bug: https://bugzilla.redhat.com/show_bug.cgi?id=1071777 -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] spec: Let translations be properly updated
On Thu, Mar 06, 2014 at 06:20:37 -0700, Eric Blake wrote: On 03/06/2014 04:06 AM, Jiri Denemark wrote: Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo file to be regenerated even if a corresponding po/*.po file is newer. By removing the stamp-po file, all *.gmo files are properly updated if required. This allows downstreams to provide patches that update translations. Signed-off-by: Jiri Denemark jdene...@redhat.com --- libvirt.spec.in | 1 + 1 file changed, 1 insertion(+) diff --git a/libvirt.spec.in b/libvirt.spec.in index 014fe5d..23374e7 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1421,6 +1421,7 @@ driver autoreconf -if %endif I think you need to guard this: %if 0%{?enable_autotools} +rm -f po/stamp-po %endif I don't think so. %configure %{?_without_xen} \ %{?_without_qemu} \ %{?_without_openvz} \ since regeneration of .po files only occurs if autotools are re-run. If additional patches just update *.po and other source files without touching Makefile.am and configure.ac, there's no need to re-run autotools while we still want to regenerate gmo files from the updated po files. When building an rpm from a stock tarball, you do NOT want to require gettext to be present - it is only when you are applying downstream patches that a .po file will ever be newer to require the regeneration of translations. gettext is an unconditional BuildRequires in libvirt.spec so we always require it to be present (unlike gettext-devel which is only required if enable_autotools is 1). And msgfmt used for generating gmo files from po files is present in gettext package. And the Makefile from gettext is clever enough not to regenerate gmo files if their corresponding po files were not updated even if stamp-po is missing. That said, I don't really understand why stamp-po exists at all :-) Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] spec: Let translations be properly updated
On 03/06/2014 06:37 AM, Jiri Denemark wrote: On Thu, Mar 06, 2014 at 06:20:37 -0700, Eric Blake wrote: On 03/06/2014 04:06 AM, Jiri Denemark wrote: Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo file to be regenerated even if a corresponding po/*.po file is newer. By removing the stamp-po file, all *.gmo files are properly updated if required. This allows downstreams to provide patches that update translations. I think you need to guard this: %if 0%{?enable_autotools} +rm -f po/stamp-po %endif I don't think so. gettext is an unconditional BuildRequires in libvirt.spec so we always require it to be present (unlike gettext-devel which is only required if enable_autotools is 1). And msgfmt used for generating gmo files from po files is present in gettext package. Fair enough. ACK to your patch as-is, then. And the Makefile from gettext is clever enough not to regenerate gmo files if their corresponding po files were not updated even if stamp-po is missing. That said, I don't really understand why stamp-po exists at all :-) It exists for incremental development - so that 'make' doesn't rebuild .gmo files for every source change. I don't know why automake packages it in the tarball, but that's a question for automake people (I'm not as familiar with automake internals as I am with autoconf). -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] virDomainShutdown() API failed with error '-1'
Hi Team, We are calling virDomainShutdown() API for shutting the VM. Sometime we see, this API is failing because of 'unknown' reason. It took almost 15 secs to bringdown the VM and at last failed. And the domain goes into shut off state. You can find the time stamp in below log. Could you please let us know in which case this API can fail, how to fix/debug this issue ? We are running 1.0.2 libvirtd version. === 20.53.48.532818176: Shuting down domain... 20.54.03.539286528: Failure of libvirt library call: Code: internal error Context: None Message: An error occurred, but the cause is unknown Level: ERROR 20.54.03.539291392: virDomainShutdown() call returned error -1 for CP—3 === [host:/var/log/libvirt/qemu]$ virsh list --all IdName State -CP--3 shut off === [host:/var/log/libvirt/qemu]$ [host:/var/log/libvirt/qemu]$ libvirtd --version libvirtd (libvirt) 1.0.2 [host:/var/log/libvirt/qemu]$ Regards Ritesh Sharma -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2] qemu: Reject unsupported tuning in session mode
On Wed, Mar 05, 2014 at 06:12:41AM -0700, Eric Blake wrote: On 03/05/2014 03:37 AM, Martin Kletzander wrote: On Tue, Mar 04, 2014 at 02:04:05PM -0700, Eric Blake wrote: On 03/04/2014 07:15 AM, Martin Kletzander wrote: When domain is started with setting that cannot be done, i.e. those that require cgroups, there is no error reported and it succeeds without any message whatsoever. When setting with API, virsh, an error is reported, but only due to the fact that no cgroups are mounted (priv-cgroup == NULL). Given the above it seems reasonable to reject such unsupported settings. I can understand failing the Set commands if we can't change things; but since we have a fallback for the Get command even for an offline domain, shouldn't we stick to returning the defaults rather than erroring out? If that's really needed, I'll rework it that way (even though it'll probably need to get changed back when user cgroups will be user-editable), but until then, could we make the error reported now: $ virsh -c qemu:///session schedinfo dummy Scheduler : Unknown error: Requested operation is not valid: cgroup CPU controller is not mounted changed into: $ virsh -c qemu:///session schedinfo dummy Scheduler : Unknown error: Operation not supported: CPU tuning is not available in session mode // I should've added that info into the commit message, I just forgot. Indeed, trading one error for another nicer one is always safe - and mentioning it in the commit message highlights that it is an improvement (we aren't causing an error on any situation where we used to pass). ACK to this patch, then. I added the info into the commit message and pushed, thanks for the review. Martin signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] fixup
[To be squashed in the previous commit] I've found two more places where shareSpecified should be checked and added a test. --- src/parallels/parallels_driver.c | 1 + src/vmx/vmx.c | 2 +- .../qemuxml2argv-cputune-zero-shares.args | 5 .../qemuxml2argv-cputune-zero-shares.xml | 35 ++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmltest.c| 1 + 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 33260ef..f0c7762 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -2053,6 +2053,7 @@ parallelsApplyChanges(virConnectPtr conn, virDomainObjPtr dom, virDomainDefPtr n } if (old-cputune.shares != new-cputune.shares || +old-cputune.sharesSpecified != new-cputune.sharesSpecified || old-cputune.period != new-cputune.period || old-cputune.quota != new-cputune.quota || old-cputune.nvcpupin != new-cputune.nvcpupin) { diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 75dcdc6..281aae4 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3176,7 +3176,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe } /* def:cputune.shares - vmx:sched.cpu.shares */ -if (def-cputune.shares 0) { +if (def-cputune.sharesSpecified) { /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */ if (def-cputune.shares == def-vcpus * 500) { virBufferAddLit(buffer, sched.cpu.shares = \low\\n); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args new file mode 100644 index 000..bc6d241 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 -S -M pc -m 214 -smp 2 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ +-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml new file mode 100644 index 000..d597054 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml @@ -0,0 +1,35 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory + vcpu placement='static'2/vcpu + cputune +shares0/shares +period100/period +quota-1/quota +vcpupin vcpu='0' cpuset='0'/ +vcpupin vcpu='1' cpuset='1'/ +emulatorpin cpuset='1'/ + /cputune + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='usb' index='0'/ +controller type='ide' index='0'/ +controller type='pci' index='0' model='pci-root'/ +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5d6a64b..bedfbb1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1163,6 +1163,7 @@ mymain(void) DO_TEST(blkiotune, QEMU_CAPS_NAME); DO_TEST(blkiotune-device, QEMU_CAPS_NAME); DO_TEST(cputune, QEMU_CAPS_NAME); +DO_TEST(cputune-zero-shares, QEMU_CAPS_NAME); DO_TEST(numatune-memory, NONE); DO_TEST(numatune-auto-nodeset-invalid, NONE); DO_TEST(numad, NONE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8e8fe71..9a16289 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -260,6 +260,7 @@ mymain(void) DO_TEST(blkiotune); DO_TEST(blkiotune-device); DO_TEST(cputune); +DO_TEST(cputune-zero-shares); DO_TEST(smp); DO_TEST(lease); -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/9] conf: eliminate hardcoded indent from all xml
Many of the domain xml format functions (including all of the device format functions) had hard-coded spaces, which made for incorrect indentation when those functions were called in a different context (for example, commit 2122cf39 added interface XML into the document provided to a network hook script, and in this case it should have been indented by 2 spaces, but was instead indented by 6 spaces). In that patch I mentioned doing a followup patch to make the device xml formatters more consistent. After doing that patch, it felt incomplete to not give the same treatment to the entire directory. The one downside to this series is that it may create merge conflicts during backports, but fortunately the conflicts should all be fairly easy to resolve. Laine Stump (9): conf: eliminate hardcoded indent from domain xml conf: eliminate hardcoded indent from domain snapshot xml conf: eliminate hardcoded indent from network xml conf: eliminate outmoded/odd indent method from interface xml conf: eliminate hardcoded indentation in nwfilter xml conf: eliminate hardcoded indentation in capabilities xml conf: eliminate hardcoded indentation in node device xml conf: eliminate hardcoded indent in volume/pool xml conf: eliminate hardcoded indentation in all remaining xml src/conf/capabilities.c | 183 ++- src/conf/cpu_conf.c | 11 +- src/conf/domain_conf.c | 599 +++ src/conf/interface_conf.c| 137 src/conf/netdev_bandwidth_conf.c | 6 +- src/conf/netdev_vlan_conf.c | 6 +- src/conf/netdev_vport_profile_conf.c | 6 +- src/conf/network_conf.c | 8 +- src/conf/node_device_conf.c | 207 ++-- src/conf/nwfilter_conf.c | 94 ++ src/conf/nwfilter_params.c | 6 +- src/conf/secret_conf.c | 20 +- src/conf/snapshot_conf.c | 48 +-- src/conf/storage_conf.c | 174 +- src/conf/storage_encryption_conf.c | 6 +- 15 files changed, 811 insertions(+), 700 deletions(-) -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] fixup
On Thu, Mar 06, 2014 at 03:46:42PM +0100, Ján Tomko wrote: [To be squashed in the previous commit] I've found two more places where shareSpecified should be checked and added a test. And you can find another one in qemuBuildCommandLine(), see commit 45ad1adb4a5ae5ce46287c570e87abab6ffe62d6 ;-) Martin --- src/parallels/parallels_driver.c | 1 + src/vmx/vmx.c | 2 +- .../qemuxml2argv-cputune-zero-shares.args | 5 .../qemuxml2argv-cputune-zero-shares.xml | 35 ++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmltest.c| 1 + 6 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 33260ef..f0c7762 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -2053,6 +2053,7 @@ parallelsApplyChanges(virConnectPtr conn, virDomainObjPtr dom, virDomainDefPtr n } if (old-cputune.shares != new-cputune.shares || +old-cputune.sharesSpecified != new-cputune.sharesSpecified || old-cputune.period != new-cputune.period || old-cputune.quota != new-cputune.quota || old-cputune.nvcpupin != new-cputune.nvcpupin) { diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 75dcdc6..281aae4 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3176,7 +3176,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe } /* def:cputune.shares - vmx:sched.cpu.shares */ -if (def-cputune.shares 0) { +if (def-cputune.sharesSpecified) { /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.SharesInfo.Level.html */ if (def-cputune.shares == def-vcpus * 500) { virBufferAddLit(buffer, sched.cpu.shares = \low\\n); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args new file mode 100644 index 000..bc6d241 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 -S -M pc -m 214 -smp 2 -nographic \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ +-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml new file mode 100644 index 000..d597054 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune-zero-shares.xml @@ -0,0 +1,35 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory + vcpu placement='static'2/vcpu + cputune +shares0/shares +period100/period +quota-1/quota +vcpupin vcpu='0' cpuset='0'/ +vcpupin vcpu='1' cpuset='1'/ +emulatorpin cpuset='1'/ + /cputune + os +type arch='i686' machine='pc'hvm/type +boot dev='hd'/ + /os + clock offset='utc'/ + on_poweroffdestroy/on_poweroff + on_rebootrestart/on_reboot + on_crashdestroy/on_crash + devices +emulator/usr/bin/qemu/emulator +disk type='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='usb' index='0'/ +controller type='ide' index='0'/ +controller type='pci' index='0' model='pci-root'/ +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5d6a64b..bedfbb1 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1163,6 +1163,7 @@ mymain(void) DO_TEST(blkiotune, QEMU_CAPS_NAME); DO_TEST(blkiotune-device, QEMU_CAPS_NAME); DO_TEST(cputune, QEMU_CAPS_NAME); +DO_TEST(cputune-zero-shares, QEMU_CAPS_NAME); DO_TEST(numatune-memory, NONE); DO_TEST(numatune-auto-nodeset-invalid, NONE); DO_TEST(numad, NONE); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8e8fe71..9a16289 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -260,6 +260,7 @@ mymain(void) DO_TEST(blkiotune); DO_TEST(blkiotune-device); DO_TEST(cputune); +DO_TEST(cputune-zero-shares); DO_TEST(smp); DO_TEST(lease); -- 1.8.3.2 -- libvir-list mailing list libvir-list@redhat.com
[libvirt] [PATCH v2 1/5] Introduce virDomainFSFreeze() and virDomainFSThaw() public API
These will freeze and thaw filesystems within guest. The APIs take flags arguments which are currently not used, for future extensions. Signed-off-by: Tomoki Sekiyama tomoki.sekiy...@hds.com --- include/libvirt/libvirt.h.in |6 src/driver.h | 10 ++ src/libvirt.c| 70 ++ src/libvirt_public.syms |5 +++ 4 files changed, 91 insertions(+) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..22f373b 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -5245,6 +5245,12 @@ int virDomainFSTrim(virDomainPtr dom, unsigned long long minimum, unsigned int flags); +int virDomainFSFreeze(virDomainPtr dom, + unsigned int flags); + +int virDomainFSThaw(virDomainPtr dom, +unsigned int flags); + /** * virSchedParameterType: * diff --git a/src/driver.h b/src/driver.h index fbfaac4..7e6aec0 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1130,6 +1130,14 @@ typedef int unsigned int flags, int cancelled); +typedef int +(*virDrvDomainFSFreeze)(virDomainPtr dom, +unsigned int flags); + +typedef int +(*virDrvDomainFSThaw)(virDomainPtr dom, + unsigned int flags); + typedef struct _virDriver virDriver; typedef virDriver *virDriverPtr; @@ -1341,6 +1349,8 @@ struct _virDriver { virDrvDomainMigrateFinish3Params domainMigrateFinish3Params; virDrvDomainMigrateConfirm3Params domainMigrateConfirm3Params; virDrvConnectGetCPUModelNames connectGetCPUModelNames; +virDrvDomainFSFreeze domainFSFreeze; +virDrvDomainFSThaw domainFSThaw; }; diff --git a/src/libvirt.c b/src/libvirt.c index a385935..84c9783 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -20552,3 +20552,73 @@ error: virDispatchError(dom-conn); return -1; } + +/** + * virDomainFSFreeze: + * @dom: a domain object + * @flags: extra flags, not used yet, so callers should always pass 0 + * + * Freeze filesystems within the guest (hence guest agent may be + * required depending on hypervisor used). + * + * Returns 0 on success, -1 otherwise. + */ +int +virDomainFSFreeze(virDomainPtr dom, + unsigned int flags) +{ +VIR_DOMAIN_DEBUG(dom, flags=%x, flags); + +virResetLastError(); + +virCheckDomainReturn(dom, -1); +virCheckReadOnlyGoto(dom-conn-flags, error); + +if (dom-conn-driver-domainFSFreeze) { +int ret = dom-conn-driver-domainFSFreeze(dom, flags); +if (ret 0) +goto error; +return ret; +} + +virReportUnsupportedError(); + +error: +virDispatchError(dom-conn); +return -1; +} + +/** + * virDomainFSThaw: + * @dom: a domain object + * @flags: extra flags, not used yet, so callers should always pass 0 + * + * Thaw the frozen filesystems within the guest (hence guest agent + * may be required depending on hypervisor used). + * + * Returns 0 on success, -1 otherwise. + */ +int +virDomainFSThaw(virDomainPtr dom, +unsigned int flags) +{ +VIR_DOMAIN_DEBUG(dom, flags=%x, flags); + +virResetLastError(); + +virCheckDomainReturn(dom, -1); +virCheckReadOnlyGoto(dom-conn-flags, error); + +if (dom-conn-driver-domainFSThaw) { +int ret = dom-conn-driver-domainFSThaw(dom, flags); +if (ret 0) +goto error; +return ret; +} + +virReportUnsupportedError(); + +error: +virDispatchError(dom-conn); +return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 6ed6ce6..9e49a9d 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -645,5 +645,10 @@ LIBVIRT_1.2.1 { virConnectNetworkEventDeregisterAny; } LIBVIRT_1.1.3; +LIBVIRT_1.2.3 { +global: +virDomainFSFreeze; +virDomainFSThaw; +} LIBVIRT_1.2.1; # define new API here using predicted next version number -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/9] conf: eliminate hardcoded indent from network xml
This was very simple, since the only place that had hardcoded indentation was a few items in the network status xml. --- src/conf/network_conf.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index bac0465..1d5781e 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2806,17 +2806,17 @@ virNetworkObjFormat(virNetworkObjPtr net, goto no_memory; virBufferAddLit(buf, networkstatus\n); -virBufferAsprintf(buf, class_id bitmap='%s'/\n, class_id); -virBufferAsprintf(buf, floor sum='%llu'/\n, net-floor_sum); +virBufferAdjustIndent(buf, 2); +virBufferAsprintf(buf, class_id bitmap='%s'/\n, class_id); +virBufferAsprintf(buf, floor sum='%llu'/\n, net-floor_sum); VIR_FREE(class_id); for (i = 0; i VIR_NETWORK_TAINT_LAST; i++) { if (net-taint (1 i)) -virBufferAsprintf(buf, taint flag='%s'/\n, +virBufferAsprintf(buf, taint flag='%s'/\n, virNetworkTaintTypeToString(i)); } -virBufferAdjustIndent(buf, 2); if (virNetworkDefFormatBuf(buf, net-def, flags) 0) goto error; -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/9] conf: eliminate hardcoded indent from domain snapshot xml
All leading spaces in domain snapshot xml format functions have been replaced with appropriate calls to virBufferAdjustIndent(). This will make it easier to call other similarly fixed format functions (e.g. domain device format functions). --- src/conf/snapshot_conf.c | 48 +++- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f2ad980..d70d176 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -615,7 +615,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, if (!disk-name) return; -virBufferEscapeString(buf, disk name='%s', disk-name); +virBufferEscapeString(buf, disk name='%s', disk-name); if (disk-snapshot 0) virBufferAsprintf(buf, snapshot='%s', virDomainSnapshotLocationTypeToString(disk-snapshot)); @@ -626,11 +626,11 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, } virBufferAsprintf(buf, type='%s'\n, virDomainDiskTypeToString(type)); +virBufferAdjustIndent(buf, 2); if (disk-format 0) -virBufferEscapeString(buf, driver type='%s'/\n, +virBufferEscapeString(buf, driver type='%s'/\n, virStorageFileFormatTypeToString(disk-format)); -virBufferAdjustIndent(buf, 6); virDomainDiskSourceDefFormatInternal(buf, type, disk-file, @@ -640,8 +640,8 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, disk-hosts, 0, NULL, NULL, 0); -virBufferAdjustIndent(buf, -6); -virBufferAddLit(buf, /disk\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /disk\n); } char *virDomainSnapshotDefFormat(const char *domain_uuid, @@ -658,45 +658,51 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, flags |= VIR_DOMAIN_XML_INACTIVE; virBufferAddLit(buf, domainsnapshot\n); -virBufferEscapeString(buf, name%s/name\n, def-name); +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, name%s/name\n, def-name); if (def-description) -virBufferEscapeString(buf, description%s/description\n, +virBufferEscapeString(buf, description%s/description\n, def-description); -virBufferAsprintf(buf, state%s/state\n, +virBufferAsprintf(buf, state%s/state\n, virDomainSnapshotStateTypeToString(def-state)); if (def-parent) { -virBufferAddLit(buf, parent\n); -virBufferEscapeString(buf, name%s/name\n, def-parent); -virBufferAddLit(buf, /parent\n); +virBufferAddLit(buf, parent\n); +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, name%s/name\n, def-parent); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /parent\n); } -virBufferAsprintf(buf, creationTime%lld/creationTime\n, +virBufferAsprintf(buf, creationTime%lld/creationTime\n, def-creationTime); if (def-memory) { -virBufferAsprintf(buf, memory snapshot='%s', +virBufferAsprintf(buf, memory snapshot='%s', virDomainSnapshotLocationTypeToString(def-memory)); virBufferEscapeString(buf, file='%s', def-file); virBufferAddLit(buf, /\n); } if (def-ndisks) { -virBufferAddLit(buf, disks\n); +virBufferAddLit(buf, disks\n); +virBufferAdjustIndent(buf, 2); for (i = 0; i def-ndisks; i++) virDomainSnapshotDiskDefFormat(buf, def-disks[i]); -virBufferAddLit(buf, /disks\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /disks\n); } if (def-dom) { -virBufferAdjustIndent(buf, 2); if (virDomainDefFormatInternal(def-dom, flags, buf) 0) { virBufferFreeAndReset(buf); return NULL; } -virBufferAdjustIndent(buf, -2); } else if (domain_uuid) { -virBufferAddLit(buf, domain\n); -virBufferAsprintf(buf, uuid%s/uuid\n, domain_uuid); -virBufferAddLit(buf, /domain\n); +virBufferAddLit(buf, domain\n); +virBufferAdjustIndent(buf, 2); +virBufferAsprintf(buf, uuid%s/uuid\n, domain_uuid); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /domain\n); } if (internal) -virBufferAsprintf(buf, active%d/active\n, def-current); +virBufferAsprintf(buf, active%d/active\n, def-current); +virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /domainsnapshot\n); if (virBufferError(buf)) { -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/9] conf: eliminate hardcoded indentation in nwfilter xml
This file was using multiple virBuffers, inserting the contents of buf3 into buf2, then inserting the contents of buf2 into buf1, rather than the more conventional method of just passing around a single virBufferPtr and streaming everything into that single buffer. This was unnecessary, and also made it more difficult to make indentation relative, because when you insert a string into a buffer, the indentation of the buffer is only applied once at the beginning of the string, *not* each time a newline is encountered in the string. --- src/conf/nwfilter_conf.c | 94 ++ src/conf/nwfilter_params.c | 6 ++- 2 files changed, 32 insertions(+), 68 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 52e1c06..588261c 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2,7 +2,7 @@ * nwfilter_conf.c: network filter XML processing * (derived from storage_conf.c) * - * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * Copyright (C) 2010-2011 IBM Corporation @@ -3215,7 +3215,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, enum virNWFilterEntryItemFlags flags = item-flags; if ((flags NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) { if (!typeShown) { -virBufferAsprintf(buf, %s, type); +virBufferAsprintf(buf, %s, type); typeShown = true; neverShown = false; } @@ -3326,95 +3326,59 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, if (neverShown) virBufferAsprintf(buf, - %s/\n, type); + %s/\n, type); err_exit: return; } -static char * -virNWFilterRuleDefFormat(virNWFilterRuleDefPtr def) +static int +virNWFilterRuleDefFormat(virBufferPtr buf, virNWFilterRuleDefPtr def) { size_t i; -virBuffer buf = VIR_BUFFER_INITIALIZER; -virBuffer buf2 = VIR_BUFFER_INITIALIZER; -char *data; +bool subelement = false; -virBufferAsprintf(buf, rule action='%s' direction='%s' priority='%d', +virBufferAsprintf(buf, rule action='%s' direction='%s' priority='%d', virNWFilterRuleActionTypeToString(def-action), virNWFilterRuleDirectionTypeToString(def-tt), def-priority); if ((def-flags RULE_FLAG_NO_STATEMATCH)) -virBufferAddLit(buf, statematch='false'); +virBufferAddLit(buf, statematch='false'); +virBufferAdjustIndent(buf, 2); i = 0; while (virAttr[i].id) { if (virAttr[i].prtclType == def-prtclType) { -virNWFilterRuleDefDetailsFormat(buf2, +if (!subelement) +virBufferAddLit(buf, \n); +virNWFilterRuleDefDetailsFormat(buf, virAttr[i].id, virAttr[i].att, def); +subelement = true; break; } i++; } -if (virBufferError(buf2)) -goto no_memory; - -data = virBufferContentAndReset(buf2); - -if (data) { -virBufferAddLit(buf, \n); -virBufferAsprintf(buf, %s /rule\n, data); -VIR_FREE(data); -} else -virBufferAddLit(buf, /\n); - -if (virBufferError(buf)) -goto no_memory; - -return virBufferContentAndReset(buf); - -no_memory: -virReportOOMError(); -virBufferFreeAndReset(buf); -virBufferFreeAndReset(buf2); - -return NULL; -} - - -static char * -virNWFilterIncludeDefFormat(virNWFilterIncludeDefPtr inc) -{ -virBuffer buf = VIR_BUFFER_INITIALIZER; - -virBufferAdjustIndent(buf, 2); -if (virNWFilterFormatParamAttributes(buf, inc-params, - inc-filterref) 0) { -virBufferFreeAndReset(buf); -return NULL; -} -virBufferAdjustIndent(buf, -2); -if (virBufferError(buf)) { -virReportOOMError(); -virBufferFreeAndReset(buf); -return NULL; -} - -return virBufferContentAndReset(buf); +virBufferAdjustIndent(buf, -2); +if (subelement) +virBufferAddLit(buf, /rule\n); +else +virBufferAddLit(buf, /\n); +return 0; } -static char * -virNWFilterEntryFormat(virNWFilterEntryPtr entry) +static int +virNWFilterEntryFormat(virBufferPtr buf, virNWFilterEntryPtr entry) { if (entry-rule) -return virNWFilterRuleDefFormat(entry-rule); -return virNWFilterIncludeDefFormat(entry-include); +return virNWFilterRuleDefFormat(buf, entry-rule); +return virNWFilterFormatParamAttributes(buf, entry-include-params, +entry-include-filterref); } @@ -3424,7 +3388,6 @@ virNWFilterDefFormat(const virNWFilterDef *def)
[libvirt] [PATCH 8/9] conf: eliminate hardcoded indent in volume/pool xml
Again completely mechanical, but a lot of lines. --- src/conf/storage_conf.c| 174 + src/conf/storage_encryption_conf.c | 6 +- 2 files changed, 105 insertions(+), 75 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index e4232e9..2f195b6 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1,7 +1,7 @@ /* * storage_conf.c: config handling for storage driver * - * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -1074,10 +1074,12 @@ virStoragePoolSourceFormat(virBufferPtr buf, size_t i, j; char uuid[VIR_UUID_STRING_BUFLEN]; -virBufferAddLit(buf, source\n); +virBufferAddLit(buf, source\n); +virBufferAdjustIndent(buf, 2); + if ((options-flags VIR_STORAGE_POOL_SOURCE_HOST) src-nhost) { for (i = 0; i src-nhost; i++) { -virBufferEscapeString(buf, host name='%s', +virBufferEscapeString(buf, host name='%s', src-hosts[i].name); if (src-hosts[i].port) virBufferAsprintf(buf, port='%d', src-hosts[i].port); @@ -1089,28 +1091,30 @@ virStoragePoolSourceFormat(virBufferPtr buf, src-ndevice) { for (i = 0; i src-ndevice; i++) { if (src-devices[i].nfreeExtent) { -virBufferEscapeString(buf, device path='%s'\n, +virBufferEscapeString(buf, device path='%s'\n, src-devices[i].path); +virBufferAdjustIndent(buf, 2); for (j = 0; j src-devices[i].nfreeExtent; j++) { -virBufferAsprintf(buf, freeExtent start='%llu' end='%llu'/\n, +virBufferAsprintf(buf, freeExtent start='%llu' end='%llu'/\n, src-devices[i].freeExtents[j].start, src-devices[i].freeExtents[j].end); } -virBufferAddLit(buf, /device\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /device\n); } else { -virBufferEscapeString(buf, device path='%s'/\n, +virBufferEscapeString(buf, device path='%s'/\n, src-devices[i].path); } } } if (options-flags VIR_STORAGE_POOL_SOURCE_DIR) -virBufferEscapeString(buf, dir path='%s'/\n, src-dir); +virBufferEscapeString(buf, dir path='%s'/\n, src-dir); if ((options-flags VIR_STORAGE_POOL_SOURCE_ADAPTER)) { if (src-adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST || src-adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) -virBufferAsprintf(buf, adapter type='%s', +virBufferAsprintf(buf, adapter type='%s', virStoragePoolSourceAdapterTypeTypeToString(src-adapter.type)); if (src-adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { @@ -1126,14 +1130,16 @@ virStoragePoolSourceFormat(virBufferPtr buf, } if (options-flags VIR_STORAGE_POOL_SOURCE_NAME) -virBufferEscapeString(buf, name%s/name\n, src-name); +virBufferEscapeString(buf, name%s/name\n, src-name); if ((options-flags VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) src-initiator.iqn) { -virBufferAddLit(buf, initiator\n); -virBufferEscapeString(buf, iqn name='%s'/\n, +virBufferAddLit(buf, initiator\n); +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, iqn name='%s'/\n, src-initiator.iqn); -virBufferAddLit(buf, /initiator\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /initiator\n); } if (options-formatToString) { @@ -1144,19 +1150,20 @@ virStoragePoolSourceFormat(virBufferPtr buf, src-format); return -1; } -virBufferAsprintf(buf, format type='%s'/\n, format); +virBufferAsprintf(buf, format type='%s'/\n, format); } if (src-authType == VIR_STORAGE_POOL_AUTH_CHAP || src-authType == VIR_STORAGE_POOL_AUTH_CEPHX) { -virBufferAsprintf(buf, auth type='%s' , +virBufferAsprintf(buf, auth type='%s' , virStoragePoolAuthTypeTypeToString(src-authType)); virBufferEscapeString(buf, username='%s'\n, (src-authType == VIR_STORAGE_POOL_AUTH_CHAP ? src-auth.chap.username : src-auth.cephx.username)); +virBufferAdjustIndent(buf, 2); -virBufferAddLit(buf, secret); +
[libvirt] [PATCH 4/9] conf: eliminate outmoded/odd indent method from interface xml
These format functions needed the ability to be indented by an arbitrary amount, but were written before the introduction of virBufferAdjustIndent(). They instead used the much more clunky method of adding a level arg to every format function, and padding with spaces using the %*s printf format specifier (giving it the level, and , which has the effect of adding level spaces to the output). While eliminating the hardcoded indentation in other xml, I decided it was finally time to also modernize the interface formatter code to make it more consistent. --- src/conf/interface_conf.c | 137 ++ 1 file changed, 64 insertions(+), 73 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 8053307..65ab2fa 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1,7 +1,7 @@ /* * interface_conf.c: interfaces XML handling * - * Copyright (C) 2006-2010, 2013 Red Hat, Inc. + * Copyright (C) 2006-2010, 2013, 2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,8 +41,7 @@ VIR_ENUM_IMPL(virInterface, static virInterfaceDefPtr virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType); static int -virInterfaceDefDevFormat(virBufferPtr buf, - const virInterfaceDef *def, int level); +virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def); static void virInterfaceIpDefFree(virInterfaceIpDefPtr def) { @@ -857,13 +856,12 @@ virInterfaceDefPtr virInterfaceDefParseFile(const char *filename) } static int -virInterfaceBridgeDefFormat(virBufferPtr buf, -const virInterfaceDef *def, int level) +virInterfaceBridgeDefFormat(virBufferPtr buf, const virInterfaceDef *def) { size_t i; int ret = 0; -virBufferAsprintf(buf, %*s bridge, level*2, ); +virBufferAddLit(buf, bridge); if (def-data.bridge.stp == 1) virBufferAddLit(buf, stp='on'); else if (def-data.bridge.stp == 0) @@ -871,25 +869,25 @@ virInterfaceBridgeDefFormat(virBufferPtr buf, if (def-data.bridge.delay != NULL) virBufferAsprintf(buf, delay='%s', def-data.bridge.delay); virBufferAddLit(buf, \n); +virBufferAdjustIndent(buf, 2); for (i = 0; i def-data.bridge.nbItf; i++) { -if (virInterfaceDefDevFormat(buf, - def-data.bridge.itf[i], level+2) 0) +if (virInterfaceDefDevFormat(buf, def-data.bridge.itf[i]) 0) ret = -1; } -virBufferAsprintf(buf, %*s /bridge\n, level*2, ); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /bridge\n); return ret; } static int -virInterfaceBondDefFormat(virBufferPtr buf, - const virInterfaceDef *def, int level) +virInterfaceBondDefFormat(virBufferPtr buf, const virInterfaceDef *def) { size_t i; int ret = 0; -virBufferAsprintf(buf, %*s bond, level*2, ); +virBufferAddLit(buf, bond); if (def-data.bond.mode == VIR_INTERFACE_BOND_BALRR) virBufferAddLit(buf, mode='balance-rr'); else if (def-data.bond.mode == VIR_INTERFACE_BOND_ABACKUP) @@ -905,10 +903,11 @@ virInterfaceBondDefFormat(virBufferPtr buf, else if (def-data.bond.mode == VIR_INTERFACE_BOND_BALALB) virBufferAddLit(buf, mode='balance-alb'); virBufferAddLit(buf, \n); +virBufferAdjustIndent(buf, 2); if (def-data.bond.monit == VIR_INTERFACE_BOND_MONIT_MII) { -virBufferAsprintf(buf, %*smiimon freq='%d', - level*2, , def-data.bond.frequency); +virBufferAsprintf(buf, miimon freq='%d', + def-data.bond.frequency); if (def-data.bond.downdelay 0) virBufferAsprintf(buf, downdelay='%d', def-data.bond.downdelay); if (def-data.bond.updelay 0) @@ -924,8 +923,7 @@ virInterfaceBondDefFormat(virBufferPtr buf, %s, _(bond arp monitoring has no target)); return -1; } -virBufferAsprintf(buf, %*sarpmon interval='%d' target='%s', - level*2, , +virBufferAsprintf(buf, arpmon interval='%d' target='%s', def-data.bond.interval, def-data.bond.target); if (def-data.bond.validate == VIR_INTERFACE_BOND_ARP_ACTIVE) virBufferAddLit(buf, validate='active'); @@ -936,17 +934,17 @@ virInterfaceBondDefFormat(virBufferPtr buf, virBufferAddLit(buf, /\n); } for (i = 0; i def-data.bond.nbItf; i++) { -if (virInterfaceDefDevFormat(buf, def-data.bond.itf[i], level+2) 0) +if (virInterfaceDefDevFormat(buf, def-data.bond.itf[i]) 0) ret = -1; } -virBufferAsprintf(buf, %*s /bond\n, level*2, ); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /bond\n); return ret; } static
[libvirt] [PATCH 9/9] conf: eliminate hardcoded indentation in all remaining xml
These last files had such a small change count I just put them into a single patch. --- src/conf/cpu_conf.c | 11 ++- src/conf/netdev_bandwidth_conf.c | 6 -- src/conf/netdev_vlan_conf.c | 6 -- src/conf/netdev_vport_profile_conf.c | 6 -- src/conf/secret_conf.c | 20 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 3d015f2..4b982c9 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -1,7 +1,7 @@ /* * cpu_conf.c: CPU XML handling * - * Copyright (C) 2009-2013 Red Hat, Inc. + * Copyright (C) 2009-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -541,12 +541,11 @@ virCPUDefFormatBufFull(virBufferPtr buf, } } virBufferAddLit(buf, \n); +virBufferAdjustIndent(buf, 2); if (def-arch) -virBufferAsprintf(buf, arch%s/arch\n, +virBufferAsprintf(buf, arch%s/arch\n, virArchToString(def-arch)); - -virBufferAdjustIndent(buf, 2); if (virCPUDefFormatBuf(buf, def, flags) 0) return -1; virBufferAdjustIndent(buf, -2); @@ -645,12 +644,14 @@ virCPUDefFormatBuf(virBufferPtr buf, if (def-ncells) { virBufferAddLit(buf, numa\n); +virBufferAdjustIndent(buf, 2); for (i = 0; i def-ncells; i++) { -virBufferAddLit(buf, cell); +virBufferAddLit(buf, cell); virBufferAsprintf(buf, cpus='%s', def-cells[i].cpustr); virBufferAsprintf(buf, memory='%d', def-cells[i].mem); virBufferAddLit(buf, /\n); } +virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /numa\n); } return 0; diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_conf.c index da14909..ed02704 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 Red Hat, Inc. + * Copyright (C) 2009-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -214,7 +214,7 @@ virNetDevBandwidthRateFormat(virNetDevBandwidthRatePtr def, return 0; if (def-average || def-floor) { -virBufferAsprintf(buf, %s, elem_name); +virBufferAsprintf(buf, %s, elem_name); if (def-average) virBufferAsprintf(buf, average='%llu', def-average); @@ -257,9 +257,11 @@ virNetDevBandwidthFormat(virNetDevBandwidthPtr def, virBufferPtr buf) } virBufferAddLit(buf, bandwidth\n); +virBufferAdjustIndent(buf, 2); if (virNetDevBandwidthRateFormat(def-in, buf, inbound) 0 || virNetDevBandwidthRateFormat(def-out, buf, outbound) 0) goto cleanup; +virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /bandwidth\n); ret = 0; diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c index dbe203e..e5196d5 100644 --- a/src/conf/netdev_vlan_conf.c +++ b/src/conf/netdev_vlan_conf.c @@ -154,6 +154,7 @@ virNetDevVlanFormat(const virNetDevVlan *def, virBufferPtr buf) } virBufferAsprintf(buf, vlan%s\n, def-trunk ? trunk='yes' : ); +virBufferAdjustIndent(buf, 2); for (i = 0; i def-nTags; i++) { if (def-nativeMode != VIR_NATIVE_VLAN_MODE_DEFAULT def-nativeTag == def-tag[i]) { @@ -163,12 +164,13 @@ virNetDevVlanFormat(const virNetDevVlan *def, virBufferPtr buf) virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(Bad value for nativeMode)); } -virBufferAsprintf(buf, tag id='%u' nativeMode='%s'/\n, +virBufferAsprintf(buf, tag id='%u' nativeMode='%s'/\n, def-tag[i], mode); } else { -virBufferAsprintf(buf, tag id='%u'/\n, def-tag[i]); +virBufferAsprintf(buf, tag id='%u'/\n, def-tag[i]); } } +virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /vlan\n); return 0; } diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c index 8d403c4..c7d2ab1 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 Red Hat, Inc. + * Copyright (C) 2009-2014 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -232,7 +232,8 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr virtPort, virNetDevVPortTypeToString(type)); } } -virBufferAddLit(buf, parameters); +virBufferAdjustIndent(buf, 2); +virBufferAddLit(buf, parameters); if (virtPort-managerID_specified
[libvirt] [PATCH 7/9] conf: eliminate hardcoded indentation in node device xml
Completely mechanical changes, but there were a lot of lines so I made it a separate patch. --- src/conf/node_device_conf.c | 207 1 file changed, 112 insertions(+), 95 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index ea85cff..65ee4b3 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1,7 +1,7 @@ /* * node_device_conf.c: config handling for node devices * - * Copyright (C) 2009-2013 Red Hat, Inc. + * Copyright (C) 2009-2014 Red Hat, Inc. * Copyright (C) 2008 Virtual Iron Software, Inc. * Copyright (C) 2008 David F. Lively * @@ -235,70 +235,77 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDef *def) size_t i = 0; virBufferAddLit(buf, device\n); -virBufferEscapeString(buf, name%s/name\n, def-name); -virBufferEscapeString(buf, path%s/path\n, def-sysfs_path); -if (def-parent) { -virBufferEscapeString(buf, parent%s/parent\n, def-parent); -} +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, name%s/name\n, def-name); +virBufferEscapeString(buf, path%s/path\n, def-sysfs_path); +if (def-parent) +virBufferEscapeString(buf, parent%s/parent\n, def-parent); if (def-driver) { -virBufferAddLit(buf, driver\n); -virBufferEscapeString(buf, name%s/name\n, def-driver); -virBufferAddLit(buf, /driver\n); +virBufferAddLit(buf, driver\n); +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, name%s/name\n, def-driver); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /driver\n); } for (caps = def-caps; caps; caps = caps-next) { char uuidstr[VIR_UUID_STRING_BUFLEN]; union _virNodeDevCapData *data = caps-data; -virBufferAsprintf(buf, capability type='%s'\n, +virBufferAsprintf(buf, capability type='%s'\n, virNodeDevCapTypeToString(caps-type)); +virBufferAdjustIndent(buf, 2); switch (caps-type) { case VIR_NODE_DEV_CAP_SYSTEM: if (data-system.product_name) -virBufferEscapeString(buf, product%s/product\n, +virBufferEscapeString(buf, product%s/product\n, data-system.product_name); -virBufferAddLit(buf, hardware\n); +virBufferAddLit(buf, hardware\n); +virBufferAdjustIndent(buf, 2); if (data-system.hardware.vendor_name) -virBufferEscapeString(buf, vendor%s/vendor\n, +virBufferEscapeString(buf, vendor%s/vendor\n, data-system.hardware.vendor_name); if (data-system.hardware.version) -virBufferEscapeString(buf, version%s/version\n, +virBufferEscapeString(buf, version%s/version\n, data-system.hardware.version); if (data-system.hardware.serial) -virBufferEscapeString(buf, serial%s/serial\n, +virBufferEscapeString(buf, serial%s/serial\n, data-system.hardware.serial); virUUIDFormat(data-system.hardware.uuid, uuidstr); -virBufferAsprintf(buf, uuid%s/uuid\n, uuidstr); -virBufferAddLit(buf, /hardware\n); -virBufferAddLit(buf, firmware\n); +virBufferAsprintf(buf, uuid%s/uuid\n, uuidstr); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /hardware\n); + +virBufferAddLit(buf, firmware\n); +virBufferAdjustIndent(buf, 2); if (data-system.firmware.vendor_name) -virBufferEscapeString(buf, vendor%s/vendor\n, +virBufferEscapeString(buf, vendor%s/vendor\n, data-system.firmware.vendor_name); if (data-system.firmware.version) -virBufferEscapeString(buf, version%s/version\n, +virBufferEscapeString(buf, version%s/version\n, data-system.firmware.version); if (data-system.firmware.release_date) -virBufferEscapeString(buf, - release_date%s/release_date\n, +virBufferEscapeString(buf, release_date%s/release_date\n, data-system.firmware.release_date); -virBufferAddLit(buf, /firmware\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /firmware\n); break; case VIR_NODE_DEV_CAP_PCI_DEV: -virBufferAsprintf(buf, domain%d/domain\n, +virBufferAsprintf(buf, domain%d/domain\n, data-pci_dev.domain); -virBufferAsprintf(buf,
[libvirt] [PATCH 6/9] conf: eliminate hardcoded indentation in capabilities xml
There were a lot of changes here, but all very mechanical. For some reason, the virBufferPtr had been named xml instead of buf in this file, so since the indentation changing touched almost every line using the buffer, I took this chance to change its name for buf for consistency with every other file. --- src/conf/capabilities.c | 183 +++- 1 file changed, 103 insertions(+), 80 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index c1c4ab8..3022b45 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1,7 +1,7 @@ /* * capabilities.c: hypervisor capabilities * - * Copyright (C) 2006-2008, 2010-2011, 2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -745,7 +745,7 @@ virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, } static int -virCapabilitiesFormatNUMATopology(virBufferPtr xml, +virCapabilitiesFormatNUMATopology(virBufferPtr buf, size_t ncells, virCapsHostNUMACellPtr *cells) { @@ -753,21 +753,23 @@ virCapabilitiesFormatNUMATopology(virBufferPtr xml, size_t j; char *siblings; -virBufferAddLit(xml, topology\n); -virBufferAsprintf(xml, cells num='%zu'\n, ncells); +virBufferAddLit(buf, topology\n); +virBufferAdjustIndent(buf, 2); +virBufferAsprintf(buf, cells num='%zu'\n, ncells); +virBufferAdjustIndent(buf, 2); for (i = 0; i ncells; i++) { -virBufferAsprintf(xml, cell id='%d'\n, cells[i]-num); +virBufferAsprintf(buf, cell id='%d'\n, cells[i]-num); +virBufferAdjustIndent(buf, 2); /* Print out the numacell memory total if it is available */ if (cells[i]-mem) -virBufferAsprintf(xml, -memory unit='KiB'%llu/memory\n, +virBufferAsprintf(buf, memory unit='KiB'%llu/memory\n, cells[i]-mem); -virBufferAsprintf(xml, cpus num='%d'\n, cells[i]-ncpus); +virBufferAsprintf(buf, cpus num='%d'\n, cells[i]-ncpus); +virBufferAdjustIndent(buf, 2); for (j = 0; j cells[i]-ncpus; j++) { -virBufferAsprintf(xml, cpu id='%d', - cells[i]-cpus[j].id); +virBufferAsprintf(buf, cpu id='%d', cells[i]-cpus[j].id); if (cells[i]-cpus[j].siblings) { if (!(siblings = virBitmapFormat(cells[i]-cpus[j].siblings))) { @@ -775,22 +777,24 @@ virCapabilitiesFormatNUMATopology(virBufferPtr xml, return -1; } -virBufferAsprintf(xml, +virBufferAsprintf(buf, socket_id='%d' core_id='%d' siblings='%s', cells[i]-cpus[j].socket_id, cells[i]-cpus[j].core_id, siblings); VIR_FREE(siblings); } -virBufferAddLit(xml, /\n); +virBufferAddLit(buf, /\n); } - -virBufferAddLit(xml, /cpus\n); -virBufferAddLit(xml, /cell\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /cpus\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /cell\n); } -virBufferAddLit(xml, /cells\n); -virBufferAddLit(xml, /topology\n); - +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /cells\n); +virBufferAdjustIndent(buf, -2); +virBufferAddLit(buf, /topology\n); return 0; } @@ -805,142 +809,160 @@ virCapabilitiesFormatNUMATopology(virBufferPtr xml, char * virCapabilitiesFormatXML(virCapsPtr caps) { -virBuffer xml = VIR_BUFFER_INITIALIZER; +virBuffer buf = VIR_BUFFER_INITIALIZER; size_t i, j, k; char host_uuid[VIR_UUID_STRING_BUFLEN]; -virBufferAddLit(xml, capabilities\n\n); -virBufferAddLit(xml, host\n); +virBufferAddLit(buf, capabilities\n\n); +virBufferAdjustIndent(buf, 2); +virBufferAddLit(buf, host\n); +virBufferAdjustIndent(buf, 2); if (virUUIDIsValid(caps-host.host_uuid)) { virUUIDFormat(caps-host.host_uuid, host_uuid); -virBufferAsprintf(xml, uuid%s/uuid\n, host_uuid); +virBufferAsprintf(buf, uuid%s/uuid\n, host_uuid); } -virBufferAddLit(xml, cpu\n); +virBufferAddLit(buf, cpu\n); +virBufferAdjustIndent(buf, 2); + if (caps-host.arch) -virBufferAsprintf(xml, arch%s/arch\n, +virBufferAsprintf(buf, arch%s/arch\n, virArchToString(caps-host.arch)); - if (caps-host.nfeatures) { -virBufferAddLit(xml, features\n); +virBufferAddLit(buf, features\n); +virBufferAdjustIndent(buf,
[libvirt] [PATCH v2 1/5] Introduce virDomainFSFreeze() and virDomainFSThaw() public API
These will freeze and thaw filesystems within guest. The APIs take flags arguments which are currently not used, for future extensions. Signed-off-by: Tomoki Sekiyama tomoki.sekiy...@hds.com --- include/libvirt/libvirt.h.in |6 src/driver.h | 10 ++ src/libvirt.c| 70 ++ src/libvirt_public.syms |5 +++ 4 files changed, 91 insertions(+) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 295d551..22f373b 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -5245,6 +5245,12 @@ int virDomainFSTrim(virDomainPtr dom, unsigned long long minimum, unsigned int flags); +int virDomainFSFreeze(virDomainPtr dom, + unsigned int flags); + +int virDomainFSThaw(virDomainPtr dom, +unsigned int flags); + /** * virSchedParameterType: * diff --git a/src/driver.h b/src/driver.h index fbfaac4..7e6aec0 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1130,6 +1130,14 @@ typedef int unsigned int flags, int cancelled); +typedef int +(*virDrvDomainFSFreeze)(virDomainPtr dom, +unsigned int flags); + +typedef int +(*virDrvDomainFSThaw)(virDomainPtr dom, + unsigned int flags); + typedef struct _virDriver virDriver; typedef virDriver *virDriverPtr; @@ -1341,6 +1349,8 @@ struct _virDriver { virDrvDomainMigrateFinish3Params domainMigrateFinish3Params; virDrvDomainMigrateConfirm3Params domainMigrateConfirm3Params; virDrvConnectGetCPUModelNames connectGetCPUModelNames; +virDrvDomainFSFreeze domainFSFreeze; +virDrvDomainFSThaw domainFSThaw; }; diff --git a/src/libvirt.c b/src/libvirt.c index a385935..84c9783 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -20552,3 +20552,73 @@ error: virDispatchError(dom-conn); return -1; } + +/** + * virDomainFSFreeze: + * @dom: a domain object + * @flags: extra flags, not used yet, so callers should always pass 0 + * + * Freeze filesystems within the guest (hence guest agent may be + * required depending on hypervisor used). + * + * Returns 0 on success, -1 otherwise. + */ +int +virDomainFSFreeze(virDomainPtr dom, + unsigned int flags) +{ +VIR_DOMAIN_DEBUG(dom, flags=%x, flags); + +virResetLastError(); + +virCheckDomainReturn(dom, -1); +virCheckReadOnlyGoto(dom-conn-flags, error); + +if (dom-conn-driver-domainFSFreeze) { +int ret = dom-conn-driver-domainFSFreeze(dom, flags); +if (ret 0) +goto error; +return ret; +} + +virReportUnsupportedError(); + +error: +virDispatchError(dom-conn); +return -1; +} + +/** + * virDomainFSThaw: + * @dom: a domain object + * @flags: extra flags, not used yet, so callers should always pass 0 + * + * Thaw the frozen filesystems within the guest (hence guest agent + * may be required depending on hypervisor used). + * + * Returns 0 on success, -1 otherwise. + */ +int +virDomainFSThaw(virDomainPtr dom, +unsigned int flags) +{ +VIR_DOMAIN_DEBUG(dom, flags=%x, flags); + +virResetLastError(); + +virCheckDomainReturn(dom, -1); +virCheckReadOnlyGoto(dom-conn-flags, error); + +if (dom-conn-driver-domainFSThaw) { +int ret = dom-conn-driver-domainFSThaw(dom, flags); +if (ret 0) +goto error; +return ret; +} + +virReportUnsupportedError(); + +error: +virDispatchError(dom-conn); +return -1; +} diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 6ed6ce6..9e49a9d 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -645,5 +645,10 @@ LIBVIRT_1.2.1 { virConnectNetworkEventDeregisterAny; } LIBVIRT_1.1.3; +LIBVIRT_1.2.3 { +global: +virDomainFSFreeze; +virDomainFSThaw; +} LIBVIRT_1.2.1; # define new API here using predicted next version number -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 0/5] Expose FSFreeze/FSThaw within the guest as API
On 3/6/14 4:32 , Daniel P. Berrange berra...@redhat.com wrote: On Wed, Mar 05, 2014 at 02:52:49PM -0500, Tomoki Sekiyama wrote: Hello, This is patchset v2 to add FSFreeze/FSThaw API for custom disk snapshotting. Patch 1 in your series hasn't arrived in my inbox, nor is it visible in the mail archves... I'm sorry, it looks like the smtp server's spam filter dislike patch 1/5 by some reason (Although I received bcc-ed in my inbox...) I sent it again and this should be in the thread now. Sorry for confusion. Regards, Tomoki Sekiyama 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
[libvirt] [PATCH] libvirt-tck: Update hook syntax for libvirt 0.9.0+
Starting with libvirt 0.9.0+, hook scripts can be called from several new locations. These locations must also be reflected in the expected logs of the hook tests. The final test in 052-domain-hook.t intentionally produces a failed start, which should show the first stage in the startup hook process, followed by all the stages in the destroy process. In addition to the above changes, libvirtd init scripts can return daemon status in several different ways (due to distribution differences, sysvinit vs. systemd, etc). This patch allows for 'running|active', and 'stopped|unused|inactive' responses which the hook tests rely on. --- lib/Sys/Virt/TCK/Hooks.pm | 17 - scripts/hooks/051-daemon-hook.t | 2 +- scripts/hooks/052-domain-hook.t | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm index 75f98e9..2ae2c2a 100644 --- a/lib/Sys/Virt/TCK/Hooks.pm +++ b/lib/Sys/Virt/TCK/Hooks.pm @@ -73,10 +73,10 @@ sub libvirtd_status { my $status = `service libvirtd status`; my $_ = $status; -if (/running/) { -$self-{libvirtd_status} = 'running'; -} elsif (/stopped/) { +if (/stopped|unused|inactive/) { $self-{libvirtd_status} = 'stopped'; +} elsif (/running|active/) { +$self-{libvirtd_status} = 'running'; } return $self; @@ -146,13 +146,20 @@ sub expect_log { } elsif ($self-{type} eq 'qemu' or $self-{type} eq 'lxc') { if ($domain_state eq Sys::Virt::Domain::STATE_RUNNING) { if ($action eq 'destroy') { - $expect_log = $hook $domain_name stopped end -; +$expect_log = $hook $domain_name stopped end -\n. + $hook $domain_name release end -; } else { die hooks testing doesn't support $action running domain; } } elsif ($domain_state eq Sys::Virt::Domain::STATE_SHUTOFF) { if ($action eq 'start') { - $expect_log = $hook $domain_name start begin -; +$expect_log = $hook $domain_name prepare begin -\n. + $hook $domain_name start begin -\n. + $hook $domain_name started begin -; +} elsif ($action eq 'failstart') { +$expect_log = $hook $domain_name prepare begin -\n. + $hook $domain_name stopped end -\n. + $hook $domain_name release end -; } else { die hooks testing doesn't support $action shutoff domain; } diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index d9cfb3a..165cf4e 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -85,7 +85,7 @@ SKIP: { ok($hook-compare_log(), $hook-{name} is invoked correctly while $hook-{action} libvirtd); diag check if libvirtd is stopped; -ok(`service libvirtd status` =~ /stopped/, libvirtd is stopped); +ok(`service libvirtd status` =~ /stopped|unused|inactive/, libvirtd is stopped); # start libvirtd $hook-action('start'); diff --git a/scripts/hooks/052-domain-hook.t b/scripts/hooks/052-domain-hook.t index e3b55ec..90b8a48 100644 --- a/scripts/hooks/052-domain-hook.t +++ b/scripts/hooks/052-domain-hook.t @@ -90,7 +90,7 @@ SKIP: { ok(-f $hook-{name}, $hook-{name} is invoked); my $actual_log_data = slurp($hook-{log_name}); -diag acutal log: $hook-{log_name} '$actual_log_data'; +diag actual log: $hook-{log_name} '$actual_log_data'; diag expect log:\n $hook-{expect_log}; @@ -147,7 +147,7 @@ SKIP: { $hook-domain_name($domain_name); $hook-domain_state($domain_state); -$hook-action('start'); +$hook-action('failstart'); $hook-expect_log(); diag start $domain_name; @@ -170,7 +170,7 @@ SKIP: { diag expect log:\n $hook-{expect_log}; diag check if the actual log is same with expected log; -ok($hook-compare_log, $hook-{name} is invoked correctly while start $domain_name); +ok($hook-compare_log, $hook-{name} is invoked correctly while failing to start $domain_name); # undefine domain diag undefine $domain_name; -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] libvirt-tck: Ignore SIGPIPE in 051-daemon-hook.t
This test completes successfully, but results in a return code of 141 due to a broken pipe when restarting libvirtd. This patch just masks the SIGPIPE and undefines $tck to avoid the 141 return code. If there is a way to reestablish the tck connection after the restart, that would be a better solution. --- scripts/hooks/051-daemon-hook.t | 5 + 1 file changed, 5 insertions(+) diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index 165cf4e..a6c3d03 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -163,5 +163,10 @@ SKIP: { ok(`service libvirtd status` =~ /running/, libvirtd is running); $hook-cleanup(); + +# Restarting libvirtd broke the tck connection, so ignore sigpipe and +# undefine $tck to avoid a return code of 141 +$SIG{PIPE} = 'IGNORE'; +undef $tck; }; -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/9] conf: eliminate hardcoded indent from domain xml
On 03/06/2014 08:24 AM, Laine Stump wrote: Many of the domain xml format functions (including all of the device format functions) had hard-coded spaces, which made for incorrect indentation when those functions were called in a different context (for example, commit 2122cf39 added interface XML into the document provided to a network hook script, and in this case it should have been indented by 2 spaces, but was instead indented by 6 spaces). To make it possible to insert a properly indented device anywhere into an XML document, this patch removes hardcoded spaces from the formatting functions, and calls virBufferAdjustIndent() at appropriate places instead. (a regex search of domain_conf.c was done to assure that all occurrences of hardcoded spaces were removed). virDomainDiskSourceDefFormatInternal() is also called from snapshot_conf.c, so two virBufferAdjustIndent() calls were temporarily added around that call - those functions will have hardcoded spaces removed in a separate patch. This could cause some conflicts when backporting future changes to the formatting functions to older branches, but fortunately the changes are almost all trivial, so conflict resolution will be obvious. --- src/conf/domain_conf.c | 599 ++- src/conf/snapshot_conf.c | 4 +- 2 files changed, 336 insertions(+), 267 deletions(-) @@ -14671,8 +14671,10 @@ virSecurityDeviceLabelDefFormat(virBufferPtr buf, if (def-label) { virBufferAddLit(buf, \n); -virBufferEscapeString(buf, label%s/label\n, +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, label%s/label\n, def-label); +virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, /seclabel\n); For small hunks like this where all the context is local, this just adds lines of code. I'm almost of the opinion that it's easier to have each function start with no indent, and any strings it prints locally are correctly indented (allowing leading whitespace), while any helper functions it calls are surrounded by AdjustIndent (since the helper function also prints at a local top level). } else { virBufferAddLit(buf, /\n); @@ -14684,14 +14686,16 @@ static int virDomainLeaseDefFormat(virBufferPtr buf, virDomainLeaseDefPtr def) { -virBufferAddLit(buf, lease\n); -virBufferEscapeString(buf, lockspace%s/lockspace\n, def-lockspace); -virBufferEscapeString(buf, key%s/key\n, def-key); -virBufferEscapeString(buf, target path='%s', def-path); +virBufferAddLit(buf, lease\n); That is, changes like this are good (this is the first print of the function, so it should be done as if at the top level)... +virBufferAdjustIndent(buf, 2); +virBufferEscapeString(buf, lockspace%s/lockspace\n, def-lockspace); +virBufferEscapeString(buf, key%s/key\n, def-key); +virBufferEscapeString(buf, target path='%s', def-path); ...while all these are local so usingwould be just as easy to follow. On the other hand, your argument of consistency (that it is easier to grep for ' ' violations) is mechanically testable, while my idea of local indentation is not. So I can live with your patch. The clincher is that our testsuite validates that we didn't break any output :) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/9] conf: eliminate hardcoded indent from domain snapshot xml
On 03/06/2014 08:24 AM, Laine Stump wrote: All leading spaces in domain snapshot xml format functions have been replaced with appropriate calls to virBufferAdjustIndent(). This will make it easier to call other similarly fixed format functions (e.g. domain device format functions). --- src/conf/snapshot_conf.c | 48 +++- 1 file changed, 27 insertions(+), 21 deletions(-) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] libvirt-tck: prefer kvm if multiple domain types exist
When matching capabilities of a guest, if multiple domain types exist (for example, 'qemu' and 'kvm') the order in which they are returned can change. To avoid unpredictable test results, this patch prefers kvm if that domain type exists. If not, the behavior matches what existed before, and the first domain type is returned. --- lib/Sys/Virt/TCK.pm | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index b2c16e7..56547c6 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -502,7 +502,17 @@ sub match_kernel { my @domains = $caps-guest_domain_types($i); next unless int(@domains); - return ($domains[0], +# Prefer kvm if multiple domain types are returned +my $domain; +if (int(@domains) gt 1) { +for (my $j = 0 ; $j int(@domains) ; $j++) { +$domain = kvm if ($domains[$j] eq kvm); +} +} +# If kvm was not found, default to the first one +$domain = $domains[0] if (!defined($domain)); + +return ($domain, $caps-guest_domain_emulator($i, $domains[0]), $caps-guest_domain_loader($i, $domains[0])); } -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/9] conf: eliminate hardcoded indent from network xml
On 03/06/2014 08:24 AM, Laine Stump wrote: This was very simple, since the only place that had hardcoded indentation was a few items in the network status xml. --- src/conf/network_conf.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/9] conf: eliminate outmoded/odd indent method from interface xml
On 03/06/2014 08:24 AM, Laine Stump wrote: These format functions needed the ability to be indented by an arbitrary amount, but were written before the introduction of virBufferAdjustIndent(). They instead used the much more clunky method of adding a level arg to every format function, and padding with spaces using the %*s printf format specifier (giving it the level, and , which has the effect of adding level spaces to the output). While eliminating the hardcoded indentation in other xml, I decided it was finally time to also modernize the interface formatter code to make it more consistent. --- src/conf/interface_conf.c | 137 ++ 1 file changed, 64 insertions(+), 73 deletions(-) About time! diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 8053307..65ab2fa 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1,7 +1,7 @@ /* * interface_conf.c: interfaces XML handling * - * Copyright (C) 2006-2010, 2013 Red Hat, Inc. + * Copyright (C) 2006-2010, 2013, 2014 Red Hat, Inc. Per git log, Red Hat people touched this file in 2011 and 2012, so you could simplify this to 2006-2014. ACK. Again, it's nice that 'make check' has tests of our generated output files, so that we cover most (if not all) of these changes to prove that the output is unchanged. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/9] conf: eliminate hardcoded indentation in nwfilter xml
On 03/06/2014 08:24 AM, Laine Stump wrote: This file was using multiple virBuffers, inserting the contents of buf3 into buf2, then inserting the contents of buf2 into buf1, rather than the more conventional method of just passing around a single virBufferPtr and streaming everything into that single buffer. This was unnecessary, and also made it more difficult to make indentation relative, because when you insert a string into a buffer, the indentation of the buffer is only applied once at the beginning of the string, *not* each time a newline is encountered in the string. --- src/conf/nwfilter_conf.c | 94 ++ src/conf/nwfilter_params.c | 6 ++- 2 files changed, 32 insertions(+), 68 deletions(-) ACK. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 6/9] conf: eliminate hardcoded indentation in capabilities xml
On 03/06/2014 08:24 AM, Laine Stump wrote: There were a lot of changes here, but all very mechanical. For some reason, the virBufferPtr had been named xml instead of buf in this file, so since the indentation changing touched almost every line using the buffer, I took this chance to change its name for buf for consistency with every other file. --- src/conf/capabilities.c | 183 +++- 1 file changed, 103 insertions(+), 80 deletions(-) ACK -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 7/9] conf: eliminate hardcoded indentation in node device xml
On 03/06/2014 08:24 AM, Laine Stump wrote: Completely mechanical changes, but there were a lot of lines so I made it a separate patch. --- src/conf/node_device_conf.c | 207 1 file changed, 112 insertions(+), 95 deletions(-) ACK -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 8/9] conf: eliminate hardcoded indent in volume/pool xml
On 03/06/2014 08:24 AM, Laine Stump wrote: Again completely mechanical, but a lot of lines. --- src/conf/storage_conf.c| 174 + src/conf/storage_encryption_conf.c | 6 +- 2 files changed, 105 insertions(+), 75 deletions(-) ACK -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 9/9] conf: eliminate hardcoded indentation in all remaining xml
On 03/06/2014 08:24 AM, Laine Stump wrote: These last files had such a small change count I just put them into a single patch. --- src/conf/cpu_conf.c | 11 ++- src/conf/netdev_bandwidth_conf.c | 6 -- src/conf/netdev_vlan_conf.c | 6 -- src/conf/netdev_vport_profile_conf.c | 6 -- src/conf/secret_conf.c | 20 5 files changed, 30 insertions(+), 19 deletions(-) ACK -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/9] conf: eliminate hardcoded indent from all xml
On 03/06/2014 08:24 AM, Laine Stump wrote: [0/9 in the subject line] Many of the domain xml format functions (including all of the device format functions) had hard-coded spaces, which made for incorrect indentation when those functions were called in a different context (for example, commit 2122cf39 added interface XML into the document provided to a network hook script, and in this case it should have been indented by 2 spaces, but was instead indented by 6 spaces). In that patch I mentioned doing a followup patch to make the device xml formatters more consistent. After doing that patch, it felt incomplete to not give the same treatment to the entire directory. The one downside to this series is that it may create merge conflicts during backports, but fortunately the conflicts should all be fairly easy to resolve. Missing from this series: qemuDomainObjPrivateXMLFormat in qemu_domain.c qemuMigrationCookieGraphicsXMLFormat in qemu_migration.c probably others. Also, it would be a good idea to add a syntax check to cfg.mk. I'd suggest a rule something like: sc_forbid_manual_xml_indent: @prohibit='virBuffer.* +' \ halt='use virBufferIndent when indenting xml' \ $(_sc_search_regexp) As I mentioned in the real 1/9, using local indentation is more compact than using virBufferIndent, but makes it harder to enforce - so if we go with your patches, a syntax check rule that enforces things will make it so we don't slip into old habits. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] spec: Let translations be properly updated
On Thu, Mar 06, 2014 at 06:57:14 -0700, Eric Blake wrote: On 03/06/2014 06:37 AM, Jiri Denemark wrote: On Thu, Mar 06, 2014 at 06:20:37 -0700, Eric Blake wrote: On 03/06/2014 04:06 AM, Jiri Denemark wrote: Libvirt tarball contains po/stamp-po file which prevents any po/*.gmo file to be regenerated even if a corresponding po/*.po file is newer. By removing the stamp-po file, all *.gmo files are properly updated if required. This allows downstreams to provide patches that update translations. I think you need to guard this: %if 0%{?enable_autotools} +rm -f po/stamp-po %endif I don't think so. gettext is an unconditional BuildRequires in libvirt.spec so we always require it to be present (unlike gettext-devel which is only required if enable_autotools is 1). And msgfmt used for generating gmo files from po files is present in gettext package. Fair enough. ACK to your patch as-is, then. OK, pushed. Thanks, Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx
On 03/05/2014 07:36 PM, Amos Kong wrote: vm_config_groups[] only contains part of the options which have argument, and all options which have no argument aren't added to vm_config_groups[]. Current query-command-line-options only checks options from vm_config_groups[], so some options will be lost. We have macro in qemu-options.hx to generate a table that contains all the options. This patch tries to query options from the table. Then we won't lose the legacy options that weren't added to vm_config_groups[] (eg: -vnc, -smbios). The options that have no argument will also be returned (eg: -enable-fips) Some options that have argument have a NULL desc list, some options don't have argument, and parameters is mandatory in the past. So we add a new field argument to present if the option takes unspecified arguments. I like Markus' suggestion of naming the new field 'unspecified-parameters' rather than 'argument'. This patch also fixes options to match their actual command-line spelling rather than an alternate name associated with the option table in use by the command. Should we independently patch hw/acpi/core.c to rename qemu_acpi_opts from acpi to acpitable to match the command line option? Same for vl.c and qemu_boot_opts from boot-opts to boot? Same for vl.c and qemu_smp_opts from smp-opts to smp? Those were the obvious mismatches I found where the command line was spelled differently than the vm_config_groups entry. This is a bug fix patch, so let's shoot to get it into 2.0. Signed-off-by: Amos Kong ak...@redhat.com --- qapi-schema.json | 8 ++-- qemu-options.h | 10 ++ util/qemu-config.c | 44 ++-- vl.c | 15 --- 4 files changed, 54 insertions(+), 23 deletions(-) +++ b/util/qemu-config.c @@ -6,6 +6,16 @@ #include hw/qdev.h #include qapi/error.h #include qmp-commands.h +#include qemu-options.h + +#define HAS_ARG 0x0001 Hmm, we are now duplicating this macro between here and vl.c. I'd prefer it gets hoisted into the .h file, so that it doesn't get out of sync between the two clients. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] libvirt-tck: 052-domain-hook.t - reload after hook cleanup
Reload libvirtd after hook testing has completed. Otherwise, libvirtd is still expecting hook test scripts to exist. --- scripts/hooks/052-domain-hook.t | 4 1 file changed, 4 insertions(+) diff --git a/scripts/hooks/052-domain-hook.t b/scripts/hooks/052-domain-hook.t index 90b8a48..d1070b5 100644 --- a/scripts/hooks/052-domain-hook.t +++ b/scripts/hooks/052-domain-hook.t @@ -180,4 +180,8 @@ SKIP: { Sys::Virt::Error::ERR_NO_DOMAIN); $hook-cleanup(); + +diag reload libvirtd after hook cleanup; +$hook-action('reload'); +$hook-service_libvirtd(); }; -- 1.8.4.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Release of libvirt-1.2.2
On Thu, Mar 6, 2014 at 5:22 AM, Eric Blake ebl...@redhat.com wrote: On 03/06/2014 12:02 AM, Jason Helfman wrote: On Sun, Mar 2, 2014 at 7:26 AM, Daniel Veillard veill...@redhat.com wrote: As planned I have tagged libvirt-1.2.2 in git and it seem the git tree finally updated despite the horrible network I get in china ATM, the tarballs may finally arrive at some time too at the usual place after working around the local infrastructure flaws... : ftp://libvirt.org/libvirt/ I am also pushing a libvirt-python-1.2.2 update at: ftp://libvirt.org/libvirt/libvirt/ I get this breakage on libvirt 1.2.2 for FreeBSD. gmake[3]: *** No rule to make target `test_libvirt_lockd.aug', needed by `all-am'. Stop. Any ideas? Known bug: https://bugzilla.redhat.com/show_bug.cgi?id=1071777 -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org This works for build, but fails on install phase. https://redports.org/buildarchive/20140306201300-37125/ -jgh -- Jason Helfman | FreeBSD Committer j...@freebsd.org | http://people.freebsd.org/~jgh | The Power to Serve -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] qemu: don't munge user input during block commit
While investigating https://bugzilla.redhat.com/show_bug.cgi?id=1061827 I noticed that we pass user input unscathed for block-pull, but always pass a canonical absolute name through for block-commit. [Note that we probably _ought_ to validate that the user's request for block-pull actually matches the backing chain, the way we already do for block-commit - but that's a separate issue. Further note that the ability to pass user input through unscathed allows backdoors such as specifying a backing image that is a network URI such as a gluster disk, instead of forcing things to the local file system; which is an area still under active investigation on whether libvirt needs to behave differently for network disks.] Since qemu may write the name that the user passed in as the backing file, a user may have a reason to want a relative file name passed through to qemu, and always munging things to absolute prevents that. Put another way, if you have the backing chain: [A] - [B(back=./A)] - [C(back=./B)] and commit B into A (virsh blockcommit $dom vda --base A --top B), the metadata of C will have to be re-written. But should it be rewritten as [C(back=./A)] or as [C(back=/path/to/A)]? Still up in the air is whether qemu's decision should be based on whether B and/or C had relative paths, or on whether the --base and/or --top arguments to the command were relative paths; but if we always pass a canonical name, we've prevented the spelling of the command arguments from being part of the hueristics that qemu uses. I also audited the code, and verified that we never call qemuMonitorBlockCommit() with a NULL base, either before or after the change to qemu_driver.c. * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Preserve user's spelling, since absolute vs. relative matters to qemu. * src/qemu/qemu_monitor.h (qemuMonitorBlockCommit): Base is never null. * src/qemu/qemu_monitor.c (qemuMonitorBlockCommit): Likewise. * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockCommit): Likewise. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockCommit): Likewise. Signed-off-by: Eric Blake ebl...@redhat.com --- I was _hoping_ that this would solve the mentioned bugzilla. But even with this applied, qemu still ended up writing an absolute backing file name into the active file in the backing chain, so that bug has been reassigned back to qemu - it probably has to do with the fact that libvirt always spawns qemu with -drive pointing to an absolute name, which is unrelated to what this patch fixes. Therefore, I'm a little bit hesitant to apply this patch, but wanted to post it for review anyway. src/qemu/qemu_driver.c | 11 --- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 2 +- src/qemu/qemu_monitor_json.h | 5 +++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 9aad2dc..31adf78 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -15383,10 +15383,15 @@ qemuDomainBlockCommit(virDomainPtr dom, const char *path, const char *base, VIR_DISK_CHAIN_READ_WRITE) 0)) goto endjob; -/* Start the commit operation. */ +/* Start the commit operation. Pass the user's original spelling, + * if any, through to qemu, since qemu behaves differently + * depending on whether the input was specified as relative or + * absolute (that is, our absolute top_canon may do the wrong + * thing if the user specified a name). */ qemuDomainObjEnterMonitor(driver, vm); -ret = qemuMonitorBlockCommit(priv-mon, device, top_canon, base_canon, - bandwidth); +ret = qemuMonitorBlockCommit(priv-mon, device, + top ? top : top_canon, + base ? base : base_canon, bandwidth); qemuDomainObjExitMonitor(driver, vm); endjob: diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index a2769db..e4707b7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1,7 +1,7 @@ /* * qemu_monitor.c: interaction with QEMU monitor console * - * Copyright (C) 2006-2013 Red Hat, Inc. + * Copyright (C) 2006-2014 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -3188,7 +3188,7 @@ qemuMonitorBlockCommit(qemuMonitorPtr mon, const char *device, unsigned long long speed; VIR_DEBUG(mon=%p, device=%s, top=%s, base=%s, bandwidth=%ld, - mon, device, NULLSTR(top), NULLSTR(base), bandwidth); + mon, device, top, base, bandwidth); /* Convert bandwidth MiB to bytes - unfortunately the JSON QMP protocol is * limited to LLONG_MAX also for unsigned values */ diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index eabf000..7bb465b 100644 --- a/src/qemu/qemu_monitor.h +++
Re: [libvirt] Looking for project ideas and mentors for Google Summer of Code 2014
-Original Message- From: kvm-ow...@vger.kernel.org [mailto:kvm-ow...@vger.kernel.org] On Behalf Of Stefan Hajnoczi Sent: Friday, February 14, 2014 7:58 AM To: Cedric Bosdonnat Cc: Jan Kiszka; qemu-devel; kvm; libvir-list@redhat.com; Kevin Wolf; Peter Maydell; Peter Crosthwaite; Max Reitz; Anthony Liguori; Paolo Bonzini; Andreas Färber; Richard Henderson Subject: Re: [libvirt] Looking for project ideas and mentors for Google Summer of Code 2014 On Fri, Feb 14, 2014 at 03:22:04PM +0100, Cedric Bosdonnat wrote: On Fri, 2014-02-14 at 09:16 +0100, Jan Kiszka wrote: I need to submit our organization application (including our project ideas) on Friday. Hope it's not too late: just added the VT-d emulation proposal. It's not too late. Ideas page must be ready when students will discover the list of accepted organizations on Monday 24th. I'm not GSoc admin here, but on LibreOffice ;) The project ideas list is linked from the organization application form and Google folks have mentioned messy/incomplete project ideas lists when giving feedback to orgs that were not accepted. This is why it's worth having the project ideas list ready. But Cedric is right that we can still add project ideas later. I set the hard deadline at March 10th when students begin applying. Stefan There are only a few days left before the hard deadline (March 10th) but I wanted to mention one possible project which I think is worth considering: Integration of Libvirt and CRIU to allow live-migration (and snapshots?) for containers In [1] you can find more details about the reasons why this feature would make sense together with a first analysis by Daniel about what to consider for the design. I am not applying as a student and I am not offering myself as a mentor (I do not qualify as a mentor), I Just wanted to point out a possible interesting (and challenging) project. I am afraid it would be too challenging for a 12 weeks projects, but I'll let you decide that. Having said that, I would be happy to help with the testing and reviews if needed. /Chris [1] http://www.redhat.com/archives/libvir-list/2013-November/msg00055.html -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [bug-report] libvirtd can't be connected by using the master branch with lots of VMs
bug address: https://bugzilla.redhat.com/show_bug.cgi?id=1066801 I can reproduce it at master/v1.2.1-maint/v1.1.4-maint/v1.1.3.4 release branches everytime, but cann't reproduce it at v1.2.1,so I believe this bug is imported by the maintain patches after v1.2.1 release. Steps to Reproduce: 1.create many VMs(40 in my env) on the host 2.kill -9 `pid of libvirtd` 3.start libvirtd by using service libvirt-bin start Actual results: virsh version/list command is hung there without any responses Expected results: virsh version/list return the correct things Additional info: if there are few VMs(1 vm in my env), the virsh version command is OK Thanks in advance! 2014-03-07 Wangpan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Python-libvirt in a virtual environment.
I installed libvirt 1.2 tarball and then I use pip install libvirt-python inside virtual env.. it worked.. thanks -Sijo On Thu, Mar 6, 2014 at 12:02 PM, Roman Bogorodskiy bogorods...@gmail.comwrote: Sijo Jose wrote: @Michel using virtualenv we can create an isolated environment in the system. Just go through - http://docs.python-guide.org/en/latest/dev/virtualenvs/ @Eric I'm using Ubuntu, and I was able to install and use libvirt using sudo apt-get install python-libvirt but its not available in tg2 virtual environment. Moreover if you try to install in the virtualenv using the sudo apt-get install python-libvirt, it would say the package is been already installed. apt-get operates with system-level packages, so there's no difference if you run it from virtualenv or not. I think you have two options: - Install python-libvirt and create virtualenv with --system-site-packages [1] so it pulls system python-libvirt - Activate virtualenv and install python-libvirt using pip 1: http://virtualenv.readthedocs.org/en/latest/virtualenv.html#the-system-site-packages-option Roman Bogorodskiy -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v5 2/2] query-command-line-options: query all the options in qemu-options.hx
vm_config_groups[] only contains part of the options which have parameters, and all options which have no parameter aren't added to vm_config_groups[]. Current query-command-line-options only checks options from vm_config_groups[], so some options will be lost. We have macro in qemu-options.hx to generate a table that contains all the options. This patch tries to query options from the table. Then we won't lose the legacy options that weren't added to vm_config_groups[] (eg: -vnc, -smbios). The options that have no parameter will also be returned (eg: -enable-fips) Some options that have parameters have a NULL desc list, some options don't have parameters, and parameters is mandatory in the past. So we add a new field unspecified-parameters to present if the option takes unspecified parameters. This patch also fixes options to match their actual command-line spelling rather than an alternate name associated with the option table in use by the command. Signed-off-by: Amos Kong ak...@redhat.com --- qapi-schema.json | 9 +++-- qemu-options.h | 12 util/qemu-config.c | 43 --- vl.c | 19 ++- 4 files changed, 57 insertions(+), 26 deletions(-) diff --git a/qapi-schema.json b/qapi-schema.json index 193e7e4..fb7ca1b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4070,12 +4070,17 @@ # # @option: option name # -# @parameters: an array of @CommandLineParameterInfo +# @parameters: array of @CommandLineParameterInfo, possibly empty +# @unspecified-parameters: @optional present if the @parameters array is empty. +# If true, then the option takes unspecified +# parameters, if false, then the option takes no +# parameter (since 2.0) # # Since 1.5 ## { 'type': 'CommandLineOptionInfo', - 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'] } } + 'data': { 'option': 'str', 'parameters': ['CommandLineParameterInfo'], +'*unspecified-parameters': 'bool' } } ## # @query-command-line-options: diff --git a/qemu-options.h b/qemu-options.h index 89a009e..4024487 100644 --- a/qemu-options.h +++ b/qemu-options.h @@ -28,9 +28,21 @@ #ifndef _QEMU_OPTIONS_H_ #define _QEMU_OPTIONS_H_ +#include sysemu/arch_init.h + enum { #define QEMU_OPTIONS_GENERATE_ENUM #include qemu-options-wrapper.h }; +#define HAS_ARG 0x0001 + +typedef struct QEMUOption { +const char *name; +int flags; +int index; +uint32_t arch_mask; +} QEMUOption; + +extern const QEMUOption qemu_options[]; #endif diff --git a/util/qemu-config.c b/util/qemu-config.c index d2facfd..ea8a419 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -6,6 +6,14 @@ #include hw/qdev.h #include qapi/error.h #include qmp-commands.h +#include qemu-options.h + +const QEMUOption qemu_options[] = { +{ h, 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, +#define QEMU_OPTIONS_GENERATE_OPTIONS +#include qemu-options-wrapper.h +{ NULL }, +}; static QemuOptsList *vm_config_groups[32]; static QemuOptsList *drive_config_groups[4]; @@ -78,6 +86,17 @@ static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc) return param_list; } +static int get_group_index(const char *name) +{ +int i; + +for (i = 0; vm_config_groups[i] != NULL; i++) { +if (!strcmp(vm_config_groups[i]-name, name)) { +return i; +} +} +return -1; +} /* remove repeated entry from the info list */ static void cleanup_infolist(CommandLineParameterInfoList *head) { @@ -137,17 +156,25 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, { CommandLineOptionInfoList *conf_list = NULL, *entry; CommandLineOptionInfo *info; -int i; +int i, idx; -for (i = 0; vm_config_groups[i] != NULL; i++) { -if (!has_option || !strcmp(option, vm_config_groups[i]-name)) { +for (i = 0; qemu_options[i].name; i++) { +if (!has_option || !strcmp(option, qemu_options[i].name)) { info = g_malloc0(sizeof(*info)); -info-option = g_strdup(vm_config_groups[i]-name); -if (!strcmp(drive, vm_config_groups[i]-name)) { +info-option = g_strdup(qemu_options[i].name); + +idx = get_group_index(qemu_options[i].name); + +if (!strcmp(drive, qemu_options[i].name)) { info-parameters = get_drive_infolist(); -} else { +} else if (idx = 0) { info-parameters = -get_param_infolist(vm_config_groups[i]-desc); +get_param_infolist(vm_config_groups[idx]-desc); +} + +if (!info-parameters) { +info-has_unspecified_parameters = true; +info-unspecified_parameters = qemu_options[i].flags HAS_ARG; } entry = g_malloc0(sizeof(*entry));
[libvirt] [PATCH v5 0/2] fix query-command-line-options
This patchset fixed some issues of query-command-line-options: * some new options that haven't argument can't be queried. (eg: -enable-fips) * some legacy options that have argument can't be queried. (eg: -vnc display) More discussion: http://marc.info/?l=qemu-develm=139081830416684w=2 V2: remove duplicate option tables, update schema (eric) V3: fix typo in commitlog and export qemu_options talbe (eric) V4: avoid the duplicate static table (eric) V5: rename new field, other fix (markus) Thanks for your review! Amos Kong (2): qmp: rename query_option_descs() to get_param_infolist() query-command-line-options: query all the options in qemu-options.hx qapi-schema.json | 9 +++-- qemu-options.h | 12 util/qemu-config.c | 49 +++-- vl.c | 19 ++- 4 files changed, 60 insertions(+), 29 deletions(-) -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v4 2/2] query-command-line-options: query all the options in qemu-options.hx
On Thu, Mar 06, 2014 at 02:23:15PM -0700, Eric Blake wrote: On 03/05/2014 07:36 PM, Amos Kong wrote: vm_config_groups[] only contains part of the options which have argument, and all options which have no argument aren't added to vm_config_groups[]. Current query-command-line-options only checks options from vm_config_groups[], so some options will be lost. We have macro in qemu-options.hx to generate a table that contains all the options. This patch tries to query options from the table. Then we won't lose the legacy options that weren't added to vm_config_groups[] (eg: -vnc, -smbios). The options that have no argument will also be returned (eg: -enable-fips) Some options that have argument have a NULL desc list, some options don't have argument, and parameters is mandatory in the past. So we add a new field argument to present if the option takes unspecified arguments. I like Markus' suggestion of naming the new field 'unspecified-parameters' rather than 'argument'. This patch also fixes options to match their actual command-line spelling rather than an alternate name associated with the option table in use by the command. Should we independently patch hw/acpi/core.c to rename qemu_acpi_opts from acpi to acpitable to match the command line option? Same for vl.c and qemu_boot_opts from boot-opts to boot? Same for vl.c and qemu_smp_opts from smp-opts to smp? Yes, we should. Those were the obvious mismatches I found where the command line was spelled differently than the vm_config_groups entry. This is a bug fix patch, so let's shoot to get it into 2.0. Signed-off-by: Amos Kong ak...@redhat.com --- qapi-schema.json | 8 ++-- qemu-options.h | 10 ++ util/qemu-config.c | 44 ++-- vl.c | 15 --- 4 files changed, 54 insertions(+), 23 deletions(-) +++ b/util/qemu-config.c @@ -6,6 +6,16 @@ #include hw/qdev.h #include qapi/error.h #include qmp-commands.h +#include qemu-options.h + +#define HAS_ARG 0x0001 Hmm, we are now duplicating this macro between here and vl.c. I'd prefer it gets hoisted into the .h file, so that it doesn't get out of sync between the two clients. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org -- Amos. pgpW0Dh3JP7Kf.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v5 1/2] qmp: rename query_option_descs() to get_param_infolist()
Signed-off-by: Amos Kong ak...@redhat.com Reviewed-by: Eric Blake ebl...@redhat.com --- util/qemu-config.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util/qemu-config.c b/util/qemu-config.c index f610101..d2facfd 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -39,7 +39,7 @@ QemuOptsList *qemu_find_opts(const char *group) return ret; } -static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc) +static CommandLineParameterInfoList *get_param_infolist(const QemuOptDesc *desc) { CommandLineParameterInfoList *param_list = NULL, *entry; CommandLineParameterInfo *info; @@ -120,9 +120,9 @@ static CommandLineParameterInfoList *get_drive_infolist(void) for (i = 0; drive_config_groups[i] != NULL; i++) { if (!head) { -head = query_option_descs(drive_config_groups[i]-desc); +head = get_param_infolist(drive_config_groups[i]-desc); } else { -cur = query_option_descs(drive_config_groups[i]-desc); +cur = get_param_infolist(drive_config_groups[i]-desc); connect_infolist(head, cur); } } @@ -147,7 +147,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option, info-parameters = get_drive_infolist(); } else { info-parameters = -query_option_descs(vm_config_groups[i]-desc); +get_param_infolist(vm_config_groups[i]-desc); } entry = g_malloc0(sizeof(*entry)); entry-value = info; -- 1.8.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list