[libvirt] [PATCH v3 1/3] Add new parameters for blkiotune
Add --config, --live and --current for command blkiotune --- tools/virsh.c | 26 +++--- tools/virsh.pod |7 +++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..d458b92 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -3343,6 +3343,9 @@ static const vshCmdOptDef opts_blkiotune[] = { {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, {weight, VSH_OT_INT, VSH_OFLAG_NONE, N_(IO Weight in range [100, 1000])}, +{config, VSH_OT_BOOL, 0, N_(affect next boot)}, +{live, VSH_OT_BOOL, 0, N_(affect running domain)}, +{current, VSH_OT_BOOL, 0, N_(affect current domain)}, {NULL, 0, 0, NULL} }; @@ -3355,6 +3358,23 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) unsigned int i = 0; virTypedParameterPtr params = NULL, temp = NULL; bool ret = false; +unsigned int flags = 0; +int current = vshCommandOptBool(cmd, current); +int config = vshCommandOptBool(cmd, config); +int live = vshCommandOptBool(cmd, live); + +if (current) { +if (live || config) { +vshError(ctl, %s, _(--current must be specified exclusively)); +return false; +} +flags = VIR_DOMAIN_AFFECT_CURRENT; +} else { +if (config) +flags |= VIR_DOMAIN_AFFECT_CONFIG; +if (live) +flags |= VIR_DOMAIN_AFFECT_LIVE; +} if (!vshConnectionUsability(ctl, ctl-conn)) return false; @@ -3379,7 +3399,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) if (nparams == 0) { /* get the number of blkio parameters */ -if (virDomainGetBlkioParameters(dom, NULL, nparams, 0) != 0) { +if (virDomainGetBlkioParameters(dom, NULL, nparams, flags) != 0) { vshError(ctl, %s, _(Unable to get number of blkio parameters)); goto cleanup; @@ -3393,7 +3413,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) /* now go get all the blkio parameters */ params = vshCalloc(ctl, nparams, sizeof(*params)); -if (virDomainGetBlkioParameters(dom, params, nparams, 0) != 0) { +if (virDomainGetBlkioParameters(dom, params, nparams, flags) != 0) { vshError(ctl, %s, _(Unable to get blkio parameters)); goto cleanup; } @@ -3445,7 +3465,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) weight = 0; } } -if (virDomainSetBlkioParameters(dom, params, nparams, 0) != 0) +if (virDomainSetBlkioParameters(dom, params, nparams, flags) != 0) vshError(ctl, %s, _(Unable to change blkio parameters)); else ret = true; diff --git a/tools/virsh.pod b/tools/virsh.pod index 7ed3003..9c53203 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -697,6 +697,13 @@ value are kilobytes (i.e. blocks of 1024 bytes). Display or set the blkio parameters. QEMU/KVM supports I--weight. I--weight is in range [100, 1000]. +If I--live is specified, affect a running guest. +If I--config is specified, affect the next boot of a persistent guest. +If I--current is specified, affect the current guest state. +Both I--live and I--current flags may be given, but I--current is +exclusive. If no flag is specified, behavior is different depending +on hypervisor. + =item Bsetvcpus Idomain-id Icount optional I--maximum I--config I--live -- 1.7.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 0/3] add support for changing blkio parameters for inactive domains
This series enables user to change blkio parameters for inactive domains from virsh command line. CHANGES: v2-v3: - based on new macros VIR_DOMAIN_AFFECT_XXX Hu Tao (3): Add new parameters for blkiotune update qemuDomainGetBlkioParameters to use flags Update qemuDomainSetBlkioParameters to use flags src/qemu/qemu_driver.c | 250 ++-- tools/virsh.c | 26 +- tools/virsh.pod|7 ++ 3 files changed, 206 insertions(+), 77 deletions(-) -- 1.7.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 2/3] update qemuDomainGetBlkioParameters to use flags
--- src/qemu/qemu_driver.c | 124 +--- 1 files changed, 86 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2957467..8ebb7d4 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4824,18 +4824,16 @@ static int qemuDomainGetBlkioParameters(virDomainPtr dom, int i; virCgroupPtr group = NULL; virDomainObjPtr vm = NULL; +virDomainDefPtr persistentDef = NULL; unsigned int val; int ret = -1; int rc; +bool isActive; -virCheckFlags(0, -1); +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); qemuDriverLock(driver); -if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) { -qemuReportError(VIR_ERR_NO_SUPPORT, _(blkio cgroup isn't mounted)); -goto cleanup; -} - vm = virDomainFindByUUID(driver-domains, dom-uuid); if (vm == NULL) { @@ -4844,12 +4842,6 @@ static int qemuDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } -if (!virDomainObjIsActive(vm)) { -qemuReportError(VIR_ERR_OPERATION_INVALID, -%s, _(domain is not running)); -goto cleanup; -} - if ((*nparams) == 0) { /* Current number of blkio parameters supported by cgroups */ *nparams = QEMU_NB_BLKIO_PARAM; @@ -4863,37 +4855,93 @@ static int qemuDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } -if (virCgroupForDomain(driver-cgroup, vm-def-name, group, 0) != 0) { -qemuReportError(VIR_ERR_INTERNAL_ERROR, -_(cannot find cgroup for domain %s), vm-def-name); -goto cleanup; +isActive = virDomainObjIsActive(vm); + +if (flags == VIR_DOMAIN_AFFECT_CURRENT) { +if (isActive) +flags = VIR_DOMAIN_AFFECT_LIVE; +else +flags = VIR_DOMAIN_AFFECT_CONFIG; } -for (i = 0; i *nparams; i++) { -virTypedParameterPtr param = params[i]; -val = 0; -param-value.ui = 0; -param-type = VIR_TYPED_PARAM_UINT; +if (flags VIR_DOMAIN_AFFECT_LIVE) { +if (!isActive) { +qemuReportError(VIR_ERR_OPERATION_INVALID, +%s, _(domain is not running)); +goto cleanup; +} -switch (i) { -case 0: /* fill blkio weight here */ -rc = virCgroupGetBlkioWeight(group, val); -if (rc != 0) { -virReportSystemError(-rc, %s, - _(unable to get blkio weight)); -goto cleanup; -} -if (virStrcpyStatic(param-field, VIR_DOMAIN_BLKIO_WEIGHT) == NULL) { -qemuReportError(VIR_ERR_INTERNAL_ERROR, -%s, _(Field blkio weight too long for destination)); -goto cleanup; +if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) { +qemuReportError(VIR_ERR_NO_SUPPORT, _(blkio cgroup isn't mounted)); +goto cleanup; +} + +if (virCgroupForDomain(driver-cgroup, vm-def-name, group, 0) != 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +_(cannot find cgroup for domain %s), vm-def-name); +goto cleanup; +} +} + +if (flags VIR_DOMAIN_AFFECT_CONFIG) { +if (!vm-persistent) { +qemuReportError(VIR_ERR_OPERATION_INVALID, %s, +_(cannot change persistent config of a transient domain)); +goto cleanup; +} +if (!(persistentDef = virDomainObjGetPersistentDef(driver-caps, vm))) +goto cleanup; +} + +if (flags VIR_DOMAIN_AFFECT_LIVE) { +for (i = 0; i *nparams; i++) { +virTypedParameterPtr param = params[i]; +val = 0; +param-value.ui = 0; +param-type = VIR_TYPED_PARAM_UINT; + +switch (i) { +case 0: /* fill blkio weight here */ +rc = virCgroupGetBlkioWeight(group, val); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to get blkio weight)); +goto cleanup; +} +if (virStrcpyStatic(param-field, VIR_DOMAIN_BLKIO_WEIGHT) == NULL) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +%s, _(Field blkio weight too long for destination)); +goto cleanup; +} +param-value.ui = val; +break; + +default: +break; +/* should not hit here */ } -param-value.ui = val; -break; +} +} else if (flags VIR_DOMAIN_AFFECT_CONFIG) { +for (i = 0; i *nparams;
[libvirt] [PATCH v3 3/3] Update qemuDomainSetBlkioParameters to use flags
--- src/qemu/qemu_driver.c | 126 ++-- 1 files changed, 90 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8ebb7d4..fb2f63a 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4745,14 +4745,13 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom, int i; virCgroupPtr group = NULL; virDomainObjPtr vm = NULL; +virDomainDefPtr persistentDef = NULL; int ret = -1; +bool isActive; -virCheckFlags(0, -1); +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); qemuDriverLock(driver); -if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) { -qemuReportError(VIR_ERR_NO_SUPPORT, _(blkio cgroup isn't mounted)); -goto cleanup; -} vm = virDomainFindByUUID(driver-domains, dom-uuid); @@ -4762,49 +4761,104 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom, goto cleanup; } -if (!virDomainObjIsActive(vm)) { -qemuReportError(VIR_ERR_OPERATION_INVALID, -%s, _(domain is not running)); -goto cleanup; +isActive = virDomainObjIsActive(vm); + +if (flags == VIR_DOMAIN_AFFECT_CURRENT) { +if (isActive) +flags = VIR_DOMAIN_AFFECT_LIVE; +else +flags = VIR_DOMAIN_AFFECT_CONFIG; } -if (virCgroupForDomain(driver-cgroup, vm-def-name, group, 0) != 0) { -qemuReportError(VIR_ERR_INTERNAL_ERROR, -_(cannot find cgroup for domain %s), vm-def-name); -goto cleanup; +if (flags VIR_DOMAIN_AFFECT_LIVE) { +if (!isActive) { +qemuReportError(VIR_ERR_OPERATION_INVALID, +%s, _(domain is not running)); +goto cleanup; +} + +if (!qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) { +qemuReportError(VIR_ERR_NO_SUPPORT, _(blkio cgroup isn't mounted)); +goto cleanup; +} + +if (virCgroupForDomain(driver-cgroup, vm-def-name, group, 0) != 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, +_(cannot find cgroup for domain %s), vm-def-name); +goto cleanup; +} +} + +if (flags VIR_DOMAIN_AFFECT_CONFIG) { +if (!vm-persistent) { +qemuReportError(VIR_ERR_OPERATION_INVALID, %s, +_(cannot change persistent config of a transient domain)); +goto cleanup; +} +if (!(persistentDef = virDomainObjGetPersistentDef(driver-caps, vm))) +goto cleanup; } ret = 0; -for (i = 0; i nparams; i++) { -virTypedParameterPtr param = params[i]; +if (flags VIR_DOMAIN_AFFECT_LIVE) { +for (i = 0; i nparams; i++) { +virTypedParameterPtr param = params[i]; -if (STREQ(param-field, VIR_DOMAIN_BLKIO_WEIGHT)) { -int rc; -if (param-type != VIR_TYPED_PARAM_UINT) { -qemuReportError(VIR_ERR_INVALID_ARG, %s, -_(invalid type for blkio weight tunable, expected a 'unsigned int')); -ret = -1; -continue; -} +if (STREQ(param-field, VIR_DOMAIN_BLKIO_WEIGHT)) { +int rc; +if (param-type != VIR_TYPED_PARAM_UINT) { +qemuReportError(VIR_ERR_INVALID_ARG, %s, +_(invalid type for blkio weight tunable, expected a 'unsigned int')); +ret = -1; +continue; +} -if (params[i].value.ui 1000 || params[i].value.ui 100) { -qemuReportError(VIR_ERR_INVALID_ARG, %s, -_(out of blkio weight range.)); +if (params[i].value.ui 1000 || params[i].value.ui 100) { +qemuReportError(VIR_ERR_INVALID_ARG, %s, +_(out of blkio weight range.)); +ret = -1; +continue; +} + +rc = virCgroupSetBlkioWeight(group, params[i].value.ui); +if (rc != 0) { +virReportSystemError(-rc, %s, + _(unable to set blkio weight tunable)); +ret = -1; +} +} else { +qemuReportError(VIR_ERR_INVALID_ARG, +_(Parameter `%s' not supported), param-field); ret = -1; -continue; } +} +} else if (flags VIR_DOMAIN_AFFECT_CONFIG) { +for (i = 0; i nparams; i++) { +virTypedParameterPtr param = params[i]; -rc = virCgroupSetBlkioWeight(group, params[i].value.ui); -if (rc != 0) { -
[libvirt] [PATCH] esx: Remove duplicated invalid-argument checks
Those checks are already performed at the public API level. --- src/esx/esx_driver.c | 10 -- src/esx/esx_storage_driver.c |5 - 2 files changed, 0 insertions(+), 15 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 500dc52..a5b96a9 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1479,11 +1479,6 @@ esxListDomains(virConnectPtr conn, int *ids, int maxids) esxVI_VirtualMachinePowerState powerState; int count = 0; -if (ids == NULL || maxids 0) { -ESX_ERROR(VIR_ERR_INVALID_ARG, %s, _(Invalid argument)); -return -1; -} - if (maxids == 0) { return 0; } @@ -2895,11 +2890,6 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames) int count = 0; int i; -if (names == NULL || maxnames 0) { -ESX_ERROR(VIR_ERR_INVALID_ARG, %s, _(Invalid argument)); -return -1; -} - if (maxnames == 0) { return 0; } diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 6461917..c7fc992 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -167,11 +167,6 @@ esxListStoragePools(virConnectPtr conn, char **const names, int maxnames) int count = 0; int i; -if (names == NULL || maxnames 0) { -ESX_ERROR(VIR_ERR_INVALID_ARG, %s, _(Invalid argument)); -return -1; -} - if (maxnames == 0) { return 0; } -- 1.7.0.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Avoid virGetVersion failure on specific driver support configurations
2011/6/6 Eric Blake ebl...@redhat.com: On 06/06/2011 05:59 AM, Matthias Bolte wrote: When virConnectGetType is called on a remote connection then the remote driver returns the type of the underlying driver on the server side, for example QEMU. Then virGetVersion compares hvType to a set of strings that depend on configure options and returns LIBVIR_VERSION_NUMBER in most cases. Now this fails in case libvirt on the client side is just compiled with the remote driver enabled only and the server side has the actual driver such as the QEMU driver. Conditional ACK, with docs fixed: * Provides information on up to two versions: @libVer is the version of the We now provide only one version. * library and will always be set unless an error occurs, in which case an - * error code will be returned. If @typeVer is not NULL it will be set to the - * version of the hypervisor @type against which the library was compiled. - * If @type is NULL, Xen is assumed, if @type is unknown or not - * available, an error code will be returned and @typeVer will be 0. + * error code will be returned. If @typeVer is not NULL it should have been be been be + * set to the version of the hypervisor @type against which the library was + * compiled. Due to a design problem this doesn't work as intented. Therefore, intended + * this function is only usefull to obtain the local library version number via useful + * @libVer. To get the version of the running hypervisor use the + * virConnectGetVersion function instead. To get the libvirt library version + * used by a connection use the virConnectGetLibVersion instead. I'm thinking this looks better: * virGetVersion: * @libVer: return value for the library version (OUT) * @type: ignored; pass NULL * @typeVer: pass NULL; for historical purposes duplicates @libVer if * non-NULL * * Provides version information. @libVer is the version of the * library and will always be set unless an error occurs, in which case * an error code will be returned. @typeVer exists for historical * compatibility; if it is not NULL it will duplicate @libVer (it was * originally intended to return hypervisor information based on @type, * but due to the design of remote clients this is not reliable). To * get the version of the running hypervisor use the * virConnectGetVersion function instead. To get the libvirt library * version used by a connection use the virConnectGetLibVersion instead. Yes, much better, thanks :) Pushed with improved documentation. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] USB 2.0 support in qemu
Hi, Recently USB 2.0 support was merged into upstream qemu, I guess libvirt and virt-manager needs some bits to support this ... The docs/usb2.txt file in the qemu source tree carries some information on how to use it, and also some hints for USB pass-through. The most recent version (not yet merged upstream) can be found here: http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt?h=usb.15 If there are any questions feel free to ask. cheers, Gerd -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Use VIR_USE_CPU instead of new wheel
On 06/03/2011 10:47 PM, Eric Blake wrote: On 06/02/2011 03:45 AM, Osier Yang wrote: * src/libxl/libxl_driver.c * src/qemu/qemu_process.c --- src/libxl/libxl_driver.c |7 ++- src/qemu/qemu_process.c | 13 ++--- 2 files changed, 4 insertions(+), 16 deletions(-) ACK. Trivial cleanup, so safe for 0.9.2. for (i = 0; i VIR_DOMAIN_CPUMASK_LEN; ++i) { -if (cpumask[i]) { -pos = i / 8; -cpumap[pos] |= 1 (i % 8); -} +if (cpumask[i]) +VIR_USE_CPU(cpumap, i); } Thanks, applied Regards Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Add doc for video element
On 06/03/2011 10:44 PM, Eric Blake wrote: On 06/02/2011 03:45 AM, Osier Yang wrote: For backwards compatability, if novideo is set but there is a s/compatability/compatibility/ graphics tag, then we add a defaultvideo according to the guest type. Add docs to tell the user about this to not make them confused. Especially if they remove the video (such as via virsh edit), it will be surprised for them to see the video element is still in domain XML. --- docs/formatdomain.html.in |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f8baffd..455f4dd 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1868,7 +1868,12 @@ qemu-kvm -net nic,model=? /dev/null dtcodevideo/code/dt dd Thecodevideo/code element is the a container for describing -video devices. +video devices. NB, for backwards compatability, if nocodevideo/code When reading, I generally find that NB doesn't add much to the conversation. Also, this has a typo. How about: s/NB, for backwards compatability,/For backwards compatibility,/ +is set but there is acodegraphics/code in domain xml, then libvirt +will add a defaultcodevideo/code according to the guest type, e.g. +For a guest of type kvm, the defaultcodevideo/code for it is: s/type, e.g. For/type. For/ ACK with those nits fixed, and since it is doc-only, pushing prior to 0.9.2 is desirable. Thanks, pushed with the nits fixed, though late for 0.9.2, :-) Regards Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 05/10 V2] [PATCH 05/13] send-key: Defining the public API
Add public virDomainSendKey() and enum libvirt_keycode_set for the @codeset. Python version of virDomainSendKey() has not been implemented yet, it will be done soon. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- include/libvirt/libvirt.h.in |7 +++ include/libvirt/virtkeys.h | 22 ++ python/generator.py |1 + src/libvirt_public.syms |5 + 4 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 include/libvirt/virtkeys.h diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index df213f1..94da205 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2673,6 +2673,13 @@ typedef struct _virTypedParameter virMemoryParameter; */ typedef virMemoryParameter *virMemoryParameterPtr; +int virDomainSendKey(virDomainPtr domain, + unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + unsigned int nkeycodes, + unsigned int flags); + #ifdef __cplusplus } #endif diff --git a/include/libvirt/virtkeys.h b/include/libvirt/virtkeys.h new file mode 100644 index 000..854594a --- /dev/null +++ b/include/libvirt/virtkeys.h @@ -0,0 +1,22 @@ +#ifndef _LIBVIRT_VIRTKEYS_H +#define _LIBVIRT_VIRTKEYS_H + +/* + * Copyright (c) 2011 Lai Jiangshan + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + */ + +enum libvirt_keycode_set { +LIBVIRT_KEYCODE_LINUX = 0, +LIBVIRT_KEYCODE_XT = 1, +LIBVIRT_KEYCODE_ATSET1 = 2, +LIBVIRT_KEYCODE_ATSET2 = 3, +LIBVIRT_KEYCODE_ATSET3 = 4, +}; + +#define MAX_SEND_KEY 16 + +#endif diff --git a/python/generator.py b/python/generator.py index 7c38fdd..57373f0 100755 --- a/python/generator.py +++ b/python/generator.py @@ -356,6 +356,7 @@ skip_impl = ( 'virNodeDeviceListCaps', 'virConnectBaselineCPU', 'virDomainRevertToSnapshot', +'virDomainSendKey', ) diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 4d4299a..ddfed44 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -450,4 +450,9 @@ LIBVIRT_0.9.2 { virInterfaceChangeRollback; } LIBVIRT_0.9.0; +LIBVIRT_0.9.3 { +global: +virDomainSendKey; +} LIBVIRT_0.9.2; + # define new API here using predicted next version number -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 02/10 V2] improve the iteration of VSH_OT_ARGV options
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- tools/virsh.c | 47 --- 1 files changed, 24 insertions(+), 23 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 61eb11e..638029c 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -280,7 +280,27 @@ static int vshCommandOptULongLong(const vshCmd *cmd, const char *name, unsigned long long *value) ATTRIBUTE_NONNULL(3) ATTRIBUTE_RETURN_CHECK; static bool vshCommandOptBool(const vshCmd *cmd, const char *name); -static char *vshCommandOptArgv(const vshCmd *cmd, int count); + +/* + * Iterate all the argv arguments. + * + * Requires that a VSH_OT_ARGV option be last in the + * list of supported options in CMD-def-opts. + */ +static inline const vshCmdOpt *__variable_arg(const vshCmdOpt *opt) +{ +while (opt) { + if (opt-def opt-def-type == VSH_OT_ARGV) + break; + opt = opt-next; +} + +return opt; +} + +#define for_each_variable_arg(cmd, opt) \ +for (opt = __variable_arg(cmd-opts); opt; opt = __variable_arg(opt-next)) + #define VSH_BYID (1 1) #define VSH_BYUUID (1 2) @@ -10341,6 +10361,7 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd) bool shell = false; bool xml = false; int count = 0; +const vshCmdOpt *opt; char *arg; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -10349,10 +10370,11 @@ cmdEcho (vshControl *ctl ATTRIBUTE_UNUSED, const vshCmd *cmd) if (vshCommandOptBool(cmd, xml)) xml = true; -while ((arg = vshCommandOptArgv(cmd, count)) != NULL) { +for_each_variable_arg(cmd, opt) { bool close_quote = false; char *q; +arg = opt-data; if (count) virBufferAddChar(buf, ' '); /* Add outer '' only if arg included shell metacharacters. */ @@ -11803,27 +11825,6 @@ vshCommandOptBool(const vshCmd *cmd, const char *name) return vshCommandOpt(cmd, name) != NULL; } -/* - * Returns the COUNT argv argument, or NULL after last argument. - * - * Requires that a VSH_OT_ARGV option with the name be last in the - * list of supported options in CMD-def-opts. - */ -static char * -vshCommandOptArgv(const vshCmd *cmd, int count) -{ -vshCmdOpt *opt = cmd-opts; - -while (opt) { -if (opt-def opt-def-type == VSH_OT_ARGV) { -if (count-- == 0) -return opt-data; -} -opt = opt-next; -} -return NULL; -} - /* Determine whether CMD-opts includes an option with name OPTNAME. If not, give a diagnostic and return false. If so, return true. */ -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 00/10 V2] Add support for send keys to guest
Add API virDomainSendKey() and virsh send-key command. PATCH 01~04 prepare PATCH 05~10 Add support for send keys to guest Python version of virDomainSendKey() has not been implemented yet, it will be done soon. Some usage-improvment patches will be sent later(after these 10 are applied) these usage-improvment patches does not touch any APIs nor change the behaviors: support KEY_XXX names for the linux keycode for virsh command(auto detect), translate keycodes between different codesets, ...etc. Lai Jiangshan (10): allow name for VSH_OT_ARGV options improve the iteration of VSH_OT_ARGV options add VSH_OFLAG_REQ_OPT options remote generator: Handle (unsigned) int arrays send-key: Defining the public API send-key: Defining the internal API send-key: Implementing the public API send-key: Implementing the remote protocol send-key: Expose the new API in virsh qemu:send-key: Implement the driver methods daemon/remote_generator.pl | 17 include/libvirt/libvirt.h.in |7 ++ include/libvirt/virtkeys.h | 22 + python/generator.py |1 + src/driver.h |8 ++ src/libvirt.c| 63 +++ src/libvirt_public.syms |5 + src/qemu/qemu_driver.c | 50 src/qemu/qemu_monitor.c | 27 +++ src/qemu/qemu_monitor.h |6 ++ src/qemu/qemu_monitor_json.c | 15 src/qemu/qemu_monitor_json.h |5 + src/qemu/qemu_monitor_text.c | 47 +++ src/qemu/qemu_monitor_text.h |5 + src/remote/remote_driver.c |1 + src/remote/remote_protocol.x | 16 - src/remote_protocol-structs | 11 +++ tools/virsh.c| 175 +++--- tools/virsh.pod |4 + 19 files changed, 455 insertions(+), 30 deletions(-) create mode 100644 include/libvirt/virtkeys.h -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 04/10 V2] remote generator: Handle (unsigned) int arrays
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- daemon/remote_generator.pl | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 632972c..532fe63 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -407,6 +407,13 @@ elsif ($opt_b) { } push(@args_list, args-$2.$2_len); +} elsif ($args_member =~ m/^(?:unsigned )?int (\S+)\S+;/) { +if (! @args_list) { +push(@args_list, conn); +} + +push(@args_list, args-$1.$1_val); +push(@args_list, args-$1.$1_len); } elsif ($args_member =~ m/^remote_typed_param (\S+)(\S+);/) { push(@vars_list, virTypedParameterPtr $1 = NULL); push(@vars_list, int n$1); @@ -985,6 +992,16 @@ elsif ($opt_k) { push(@setters_list, args.$arg_name.${arg_name}_val = (char *)$arg_name;); push(@setters_list, args.$arg_name.${arg_name}_len = ${arg_name}len;); push(@args_check_list, { name = \$arg_name\, arg = ${arg_name}len, limit = $limit }); +} elsif ($args_member =~ m/^((?:unsigned )?int) (\S+)(\S+);/) { +my $type_name = $1; +my $arg_name = $2; +my $limit = $3; + +push(@args_list, ${type_name} *$arg_name); +push(@args_list, unsigned int ${arg_name}len); +push(@setters_list, args.$arg_name.${arg_name}_val = $arg_name;); +push(@setters_list, args.$arg_name.${arg_name}_len = ${arg_name}len;); +push(@args_check_list, { name = \$arg_name\, arg = ${arg_name}len, limit = $limit }); } elsif ($args_member =~ m/^remote_typed_param (\S+)(\S+);/) { push(@args_list, virTypedParameterPtr $1); push(@args_list, int n$1); -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 09/10 V2] send-key: Expose the new API in virsh
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- tools/virsh.c | 102 +++ tools/virsh.pod |4 ++ 2 files changed, 106 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d13c12b..7b5847f 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -33,6 +33,8 @@ #include signal.h #include poll.h +#include libvirt/virtkeys.h + #include libxml/parser.h #include libxml/tree.h #include libxml/xpath.h @@ -3182,6 +3184,105 @@ cmdInjectNMI(vshControl *ctl, const vshCmd *cmd) } /* + * send-key command + */ +static const vshCmdInfo info_send_key[] = { +{help, N_(Send keycodes to the guest)}, +{desc, N_(Send keycodes to the guest, the keycodes must be integers\n +Examples:\n\n +virsh # send-key domain 37 18 21\n +virsh # send-key domain --holdtime 1000 0x15 18 0xf\n +)}, +{NULL, NULL} +}; + +static const vshCmdOptDef opts_send_key[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{codeset, VSH_OT_STRING, VSH_OFLAG_REQ_OPT, N_(the codeset of keycodes, default:linux)}, +{holdtime, VSH_OT_INT, VSH_OFLAG_REQ_OPT, + N_(the time (in millsecond) how long the keys will be held)}, +{keycode, VSH_OT_ARGV, VSH_OFLAG_REQ, N_(the key code)}, +{NULL, 0, 0, NULL} +}; + +static int get_integer_keycode(const char *key_name) +{ +long val; +char *endptr; + +val = strtol(key_name, endptr, 0); +if (*endptr != '\0' || val 255 || val = 0) + return -1; + +return val; +} + +static bool +cmdSendKey(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom; +int ret = false; +const char *codeset_option; +int codeset; +int holdtime; +int count = 0; +const vshCmdOpt *opt; +int keycode; +unsigned int keycodes[MAX_SEND_KEY]; + +if (!vshConnectionUsability(ctl, ctl-conn)) +return false; + +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) +return false; + +if (vshCommandOptString(cmd, codeset, codeset_option) = 0) +codeset_option = default; + +if (vshCommandOptInt(cmd, holdtime, holdtime) = 0) +holdtime = 0; + +if (STREQ(codeset_option, default) || STREQ(codeset_option, linux)) { +codeset = LIBVIRT_KEYCODE_LINUX; +} else if (STREQ(codeset_option, xt)) { +codeset = LIBVIRT_KEYCODE_XT; +} else if (STREQ(codeset_option, atset1)) { +codeset = LIBVIRT_KEYCODE_ATSET1; +} else if (STREQ(codeset_option, atset2)) { +codeset = LIBVIRT_KEYCODE_ATSET2; +} else if (STREQ(codeset_option, atset3)) { +codeset = LIBVIRT_KEYCODE_ATSET3; +} else { +vshError(ctl, _(unknown codeset: '%s'), codeset_option); +goto free_domain; +} + +for_each_variable_arg(cmd, opt) { +if (count == MAX_SEND_KEY) { +vshError(ctl, _(too many keycode)); +goto free_domain; +} + +if ((keycode = get_integer_keycode(opt-data)) 0) +goto get_keycode; + +vshError(ctl, _(invalid keycode: '%s'), opt-data); +goto free_domain; + +get_keycode: +keycodes[count] = keycode; +count++; +} + +if (!(virDomainSendKey(dom, codeset, holdtime, keycodes, count, 0) 0)) +ret = true; + +free_domain: +virDomainFree(dom); +return ret; +} + +/* * setmemory command */ static const vshCmdInfo info_setmem[] = { @@ -11095,6 +11196,7 @@ static const vshCmdDef domManagementCmds[] = { {dumpxml, cmdDumpXML, opts_dumpxml, info_dumpxml, 0}, {edit, cmdEdit, opts_edit, info_edit, 0}, {inject-nmi, cmdInjectNMI, opts_inject_nmi, info_inject_nmi, 0}, +{send-key, cmdSendKey, opts_send_key, info_send_key}, {managedsave, cmdManagedSave, opts_managedsave, info_managedsave, 0}, {managedsave-remove, cmdManagedSaveRemove, opts_managedsaveremove, info_managedsaveremove, 0}, diff --git a/tools/virsh.pod b/tools/virsh.pod index 7ed3003..03b1418 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -296,6 +296,10 @@ scheduling by the hypervisor. Inject NMI to the guest +=item Bsend-key Idomain-id I--codeset Bcodeset I--holdtime Bholdtime Bkeycode... + +Send keys to the guest + =item Bshutdown The domain is in the process of shutting down, i.e. the guest operating system -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 06/10 V2] send-key: Defining the internal API
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- src/driver.h |8 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/driver.h b/src/driver.h index 5df798a..2e335a1 100644 --- a/src/driver.h +++ b/src/driver.h @@ -542,6 +542,13 @@ typedef int typedef int (*virDrvDomainInjectNMI)(virDomainPtr dom, unsigned int flags); +typedef int +(*virDrvDomainSendKey)(virDomainPtr dom, unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + unsigned int nkeycodes, + unsigned int flags); + typedef char * (*virDrvDomainMigrateBegin3) (virDomainPtr domain, @@ -749,6 +756,7 @@ struct _virDriver { virDrvDomainMigratePerform3domainMigratePerform3; virDrvDomainMigrateFinish3 domainMigrateFinish3; virDrvDomainMigrateConfirm3domainMigrateConfirm3; +virDrvDomainSendKey domainSendKey; }; typedef int -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 01/10 V2] allow name for VSH_OT_ARGV options
A name will improve the usege, example # virsh help echo NAME echo - echo arguments SYNOPSIS echo [--shell] [--xml] [string]... DESCRIPTION Echo back arguments, possibly with quoting. OPTIONS --shell escape for shell use --xmlescape for XML use string arguments to echo [string]... is added to SYNOPSIS. string arguments to echo is added to OPTIONS. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- tools/virsh.c | 19 +-- 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..61eb11e 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -126,7 +126,7 @@ typedef enum { VSH_OT_STRING, /* optional string option */ VSH_OT_INT, /* optional or mandatory int option */ VSH_OT_DATA, /* string data (as non-option) */ -VSH_OT_ARGV /* remaining arguments, opt-name should be */ +VSH_OT_ARGV /* remaining arguments */ } vshCmdOptType; /* @@ -10328,7 +10328,7 @@ static const vshCmdInfo info_echo[] = { static const vshCmdOptDef opts_echo[] = { {shell, VSH_OT_BOOL, 0, N_(escape for shell use)}, {xml, VSH_OT_BOOL, 0, N_(escape for XML use)}, -{, VSH_OT_ARGV, 0, N_(arguments to echo)}, +{string, VSH_OT_ARGV, 0, N_(arguments to echo)}, {NULL, 0, 0, NULL} }; @@ -11379,6 +11379,11 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, vshError(ctl, _(option --%s already seen), name); return NULL; } +if (opt-type == VSH_OT_ARGV) { +vshError(ctl, _(variable argument %s + should not be used with --%s), name, name); +return NULL; +} *opts_seen |= 1 i; return opt; } @@ -11427,7 +11432,7 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required, const vshCmdOptDef *opt = def-opts[i]; vshError(ctl, - opt-type == VSH_OT_DATA ? + opt-type == VSH_OT_DATA || opt-type == VSH_OT_ARGV ? _(command '%s' requires %s option) : _(command '%s' requires --%s option), def-name, opt-name); @@ -11535,7 +11540,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) break; case VSH_OT_ARGV: /* xgettext:c-format */ -fmt = _([string]...); +fmt = (opt-flag VSH_OFLAG_REQ) ? _(%s...) + : _([%s]...); break; default: assert(0); @@ -11575,7 +11581,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname) break; case VSH_OT_ARGV: /* Not really an option. */ -continue; +snprintf(buf, sizeof(buf), _(%s), opt-name); +break; default: assert(0); } @@ -13012,7 +13019,7 @@ vshReadlineOptionsGenerator(const char *text, int state) list_index++; -if (opt-type == VSH_OT_DATA) +if (opt-type == VSH_OT_DATA || opt-type == VSH_OT_ARGV) /* ignore non --option */ continue; -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 07/10] send-key: Implementing the public API
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- src/libvirt.c | 63 + 1 files changed, 63 insertions(+), 0 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index cbe1926..112f690 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -26,6 +26,8 @@ #include libxml/uri.h #include getpass.h +#include libvirt/virtkeys.h + #ifdef HAVE_WINSOCK2_H # include winsock2.h #endif @@ -6511,6 +6513,67 @@ error: } /** + * virDomainSendKey: + * @domain:pointer to domain object, or NULL for Domain0 + * @codeset: the code set of keycodes + * @holdtime: the time (in millsecond) how long the keys will be held + * @nkeycodes: number of keycodes + * @keycodes: array of keycodes + * @flags: the flags for controlling behavior, pass 0 for now + * + * Send key to the guest + * + * Returns 0 in case of success, -1 in case of failure. + */ + +int virDomainSendKey(virDomainPtr domain, + unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + unsigned int nkeycodes, + unsigned int flags) +{ +virConnectPtr conn; +VIR_DOMAIN_DEBUG(domain, codeset=%u,holdtime=%u,nkeycodes=%u,flags=%u, + codeset, holdtime, nkeycodes, flags); + +virResetLastError(); + +if (nkeycodes == 0 || nkeycodes MAX_SEND_KEY) { +virLibDomainError(VIR_ERR_OPERATION_INVALID, __FUNCTION__); +virDispatchError(NULL); +return -1; +} + +if (!VIR_IS_CONNECTED_DOMAIN(domain)) { +virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); +virDispatchError(NULL); +return -1; +} +if (domain-conn-flags VIR_CONNECT_RO) { +virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); +goto error; +} + +conn = domain-conn; + +if (conn-driver-domainSendKey) { +int ret; +ret = conn-driver-domainSendKey(domain, codeset, holdtime, + keycodes, nkeycodes, flags); +if (ret 0) +goto error; +return ret; +} + +virLibConnError (VIR_ERR_NO_SUPPORT, __FUNCTION__); + +error: +virDispatchError(domain-conn); +return -1; +} + +/** * virDomainSetVcpus: * @domain: pointer to domain object, or NULL for Domain0 * @nvcpus: the new number of virtual CPUs for this domain -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 08/10 V2] send-key: Implementing the remote protocol
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- src/remote/remote_driver.c |1 + src/remote/remote_protocol.x | 16 +++- src/remote_protocol-structs | 11 +++ 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8335a1a..f08a609 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6337,6 +6337,7 @@ static virDriver remote_driver = { .domainMigratePerform3 = remoteDomainMigratePerform3, /* 0.9.2 */ .domainMigrateFinish3 = remoteDomainMigrateFinish3, /* 0.9.2 */ .domainMigrateConfirm3 = remoteDomainMigrateConfirm3, /* 0.9.2 */ +.domainSendKey = remoteDomainSendKey, /* 0.9.3 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index c9b8cff..2126325 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -191,6 +191,11 @@ const REMOTE_SECRET_UUID_LIST_MAX = 16384; */ const REMOTE_CPU_BASELINE_MAX = 256; +/* + * Max number of sending keycodes. + */ +const REMOTE_SEND_KEY_MAX = 16; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; @@ -811,6 +816,14 @@ struct remote_domain_inject_nmi_args { unsigned int flags; }; +struct remote_domain_send_key_args { +remote_nonnull_domain dom; +unsigned int codeset; +unsigned int holdtime; +unsigned int keycodesREMOTE_SEND_KEY_MAX; +unsigned int flags; +}; + struct remote_domain_set_vcpus_args { remote_nonnull_domain dom; unsigned int nvcpus; @@ -2297,7 +2310,8 @@ enum remote_procedure { REMOTE_PROC_INTERFACE_CHANGE_COMMIT = 221, /* autogen autogen */ REMOTE_PROC_INTERFACE_CHANGE_ROLLBACK = 222, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS_FLAGS = 223, /* skipgen autogen */ -REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR = 224 /* skipgen skipgen */ +REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR = 224, /* skipgen skipgen */ +REMOTE_PROC_DOMAIN_SEND_KEY = 225 /* autogen autogen */ /* * Notice how the entries are grouped in sets of 10 ? diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 1d90dd5..dd70c24 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1550,3 +1550,14 @@ struct remote_message_header { u_int serial; remote_message_status status; }; + +struct remote_domain_send_key_args { +remote_nonnull_domain dom; +unsigned int codeset; +unsigned int holdtime; +struct { +unsigned int keycodes_len; +unsigned int * keycodes_val; +} keycodes; +unsigned int flags; +}; -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 10/10 V2] qemu:send-key: Implement the driver methods
Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- src/qemu/qemu_driver.c | 50 ++ src/qemu/qemu_monitor.c | 27 ++ src/qemu/qemu_monitor.h |6 + src/qemu/qemu_monitor_json.c | 15 src/qemu/qemu_monitor_json.h |5 src/qemu/qemu_monitor_text.c | 47 +++ src/qemu/qemu_monitor_text.h |5 7 files changed, 155 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2957467..1678deb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1764,6 +1764,55 @@ cleanup: return ret; } +static int qemuDomainSendKey(virDomainPtr domain, + unsigned int codeset, + unsigned int holdtime, + unsigned int *keycodes, + unsigned int nkeycodes, + unsigned int flags) +{ +struct qemud_driver *driver = domain-conn-privateData; +virDomainObjPtr vm = NULL; +int ret = -1; +qemuDomainObjPrivatePtr priv; + +virCheckFlags(0, -1); + +qemuDriverLock(driver); +vm = virDomainFindByUUID(driver-domains, domain-uuid); +if (!vm) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(domain-uuid, uuidstr); +qemuReportError(VIR_ERR_NO_DOMAIN, +_(no domain with matching uuid '%s'), uuidstr); +goto cleanup; +} + +if (!virDomainObjIsActive(vm)) { +qemuReportError(VIR_ERR_OPERATION_INVALID, +%s, _(domain is not running)); +goto cleanup; +} + +priv = vm-privateData; + +if (qemuDomainObjBeginJobWithDriver(driver, vm) 0) +goto cleanup; +qemuDomainObjEnterMonitorWithDriver(driver, vm); +ret = qemuMonitorSendKey(priv-mon, codeset, holdtime, nkeycodes, keycodes); +qemuDomainObjExitMonitorWithDriver(driver, vm); +if (qemuDomainObjEndJob(vm) == 0) { +vm = NULL; +goto cleanup; +} + +cleanup: +if (vm) +virDomainObjUnlock(vm); +qemuDriverUnlock(driver); +return ret; +} + static int qemudDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) { @@ -8092,6 +8141,7 @@ static virDriver qemuDriver = { .domainMigratePerform3 = qemuDomainMigratePerform3, /* 0.9.2 */ .domainMigrateFinish3 = qemuDomainMigrateFinish3, /* 0.9.2 */ .domainMigrateConfirm3 = qemuDomainMigrateConfirm3, /* 0.9.2 */ +.domainSendKey = qemuDomainSendKey, /* 0.9.2 */ }; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 26bb814..faab819 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -38,6 +38,8 @@ #include logging.h #include files.h +#include libvirt/virtkeys.h + #define VIR_FROM_THIS VIR_FROM_QEMU #define DEBUG_IO 0 @@ -2357,6 +2359,31 @@ int qemuMonitorInjectNMI(qemuMonitorPtr mon) return ret; } +int qemuMonitorSendKey(qemuMonitorPtr mon, + unsigned int codeset, + unsigned int holdtime, + unsigned int nkeycodes, + unsigned int *keycodes) +{ +int ret; + +VIR_DEBUG(mon=%p, codeset=%u, holdtime=%u, nkeycodes=%u, + mon, codeset, holdtime, nkeycodes); + +if (codeset != LIBVIRT_KEYCODE_XT) { +qemuReportError(VIR_ERR_NO_SUPPORT, +qemu monitor can not support the codeset: %d, +codeset); +return -1; +} + +if (mon-json) +ret = qemuMonitorJSONSendKey(mon, holdtime, nkeycodes, keycodes); +else +ret = qemuMonitorTextSendKey(mon, holdtime, nkeycodes, keycodes); +return ret; +} + int qemuMonitorScreendump(qemuMonitorPtr mon, const char *file) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 910865b..64a6320 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -441,6 +441,12 @@ int qemuMonitorInjectNMI(qemuMonitorPtr mon); int qemuMonitorScreendump(qemuMonitorPtr mon, const char *file); +int qemuMonitorSendKey(qemuMonitorPtr mon, + unsigned int codeset, + unsigned int holdtime, + unsigned int nkeycodes, + unsigned int *keycodes); + /** * When running two dd process and using redirection, we need a * shell that will not truncate files. These two strings serve that diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 75adf66..538e98f 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2619,6 +2619,21 @@ cleanup: return ret; } +int qemuMonitorJSONSendKey(qemuMonitorPtr mon, + unsigned int holdtime, + unsigned int nkeycodes, +
[libvirt] [PATCH 03/10 V2] add VSH_OFLAG_REQ_OPT options
A VSH_OFLAG_REQ_OPT option means --optionname is required when used. It will kill any ambiguity even !VSH_OFLAG_REQ option listed before VSH_OFLAG_REQ option if the !VSH_OFLAG_REQ option is a VSH_OFLAG_REQ_OPT option. It will help us use optional arguement with VSH_OT_ARGV argument. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- tools/virsh.c |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 638029c..d13c12b 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -152,6 +152,7 @@ enum { VSH_OFLAG_NONE = 0,/* without flags */ VSH_OFLAG_REQ = (1 0), /* option required */ VSH_OFLAG_EMPTY_OK = (1 1), /* empty string option allowed */ +VSH_OFLAG_REQ_OPT = (1 2), /* --optionname required */ }; /* dummy */ @@ -11375,6 +11376,12 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t* opts_need_arg, return -1; /* bool options can't be mandatory */ continue; } +if (opt-flag VSH_OFLAG_REQ_OPT) { +if (opt-flag VSH_OFLAG_REQ) +*opts_required |= 1 i; +continue; +} + *opts_need_arg |= 1 i; if (opt-flag VSH_OFLAG_REQ) { if (optional) -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] USB 2.0 support in qemu
On Tue, Jun 07, 2011 at 10:17:30AM +0200, Gerd Hoffmann wrote: Hi, Recently USB 2.0 support was merged into upstream qemu, I guess libvirt and virt-manager needs some bits to support this ... Yes, we'll need todo more modelling of USB controllers/hubs in the XML, and introduce a USB address type to specify device port numbers. 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 v2] qemu: Parse current balloon value returned by query_balloon
Qemu once supported following memory stats which will returned by query_balloon: stat_put(dict, actual, actual); stat_put(dict, mem_swapped_in, dev-stats[VIRTIO_BALLOON_S_SWAP_IN]); stat_put(dict, mem_swapped_out, dev-stats[VIRTIO_BALLOON_S_SWAP_OUT]); stat_put(dict, major_page_faults, dev-stats[VIRTIO_BALLOON_S_MAJFLT]); stat_put(dict, minor_page_faults, dev-stats[VIRTIO_BALLOON_S_MINFLT]); stat_put(dict, free_mem, dev-stats[VIRTIO_BALLOON_S_MEMFREE]); stat_put(dict, total_mem, dev-stats[VIRTIO_BALLOON_S_MEMTOT]); But it later disabled all the stats except actual by commit 07b0403dfc2b2ac179ae5b48105096cc2d03375a. libvirt doesn't parse actual, so user will always see a empty result with virsh dommemstat $domain. Even qemu haven't disabled the stats, we should support parsing actual. --- include/libvirt/libvirt.h.in |4 +++- src/libvirt.c|2 ++ src/qemu/qemu_monitor_json.c | 12 src/qemu/qemu_monitor_text.c |4 +++- tools/virsh.c|2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index df213f1..0930622 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -467,11 +467,13 @@ typedef enum { */ VIR_DOMAIN_MEMORY_STAT_AVAILABLE = 5, +/* Current balloon value (in KB). */ +VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON = 6, /* * The number of statistics supported by this version of the interface. * To add new statistics, add them to the enum and increase this value. */ -VIR_DOMAIN_MEMORY_STAT_NR = 6, +VIR_DOMAIN_MEMORY_STAT_NR = 7, } virDomainMemoryStatTags; typedef struct _virDomainMemoryStat virDomainMemoryStatStruct; diff --git a/src/libvirt.c b/src/libvirt.c index 18c4e08..08a7d4c 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -5737,6 +5737,8 @@ error: * The amount of memory which is not being used for any purpose (in kb). * VIR_DOMAIN_MEMORY_STAT_AVAILABLE: * The total amount of memory available to the domain's OS (in kb). + * VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON: + * Current balloon value (in kb). * * Returns: The number of stats provided or -1 in case of failure. */ diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 75adf66..2680b3c 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -1119,6 +1119,18 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon, goto cleanup; } +if (virJSONValueObjectHasKey(data, actual) (got nr_stats)) { +if (virJSONValueObjectGetNumberUlong(data, actual, mem) 0) { +qemuReportError(VIR_ERR_INTERNAL_ERROR, %s, +_(info balloon reply was missing balloon actual)); +ret = -1; +goto cleanup; +} +stats[got].tag = VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON; +stats[got].val = (mem/1024); +got++; +} + if (virJSONValueObjectHasKey(data, mem_swapped_in) (got nr_stats)) { if (virJSONValueObjectGetNumberUlong(data, mem_swapped_in, mem) 0) { qemuReportError(VIR_ERR_INTERNAL_ERROR, %s, diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 3b42e7a..d432027 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -549,7 +549,9 @@ static int qemuMonitorParseExtraBalloonInfo(char *text, parseMemoryStat(p, VIR_DOMAIN_MEMORY_STAT_UNUSED, ,free_mem=, stats[nr_stats_found]) || parseMemoryStat(p, VIR_DOMAIN_MEMORY_STAT_AVAILABLE, -,total_mem=, stats[nr_stats_found])) +,total_mem=, stats[nr_stats_found]) || +parseMemoryStat(p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, +,actual=, stats[nr_stats_found])) nr_stats_found++; /* Skip to the next label. When *p is ',' the last match attempt diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..17f6a22 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -1147,6 +1147,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) vshPrint (ctl, unused %llu\n, stats[i].val); if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_AVAILABLE) vshPrint (ctl, available %llu\n, stats[i].val); +if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON) +vshPrint (ctl, actual %llu\n, stats[i].val); } virDomainFree(dom); -- 1.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/7] check whether qemu supports multi function PCI device
At 06/03/2011 10:07 PM, Eric Blake Write: On 05/27/2011 04:19 AM, Wen Congyang wrote: qemu supports multi function PCI device after version 0.13.0. After ( 0.13.0) or at least (= 0.13.0)? at least. @@ -1024,6 +1026,9 @@ qemuCapsComputeCmdFlags(const char *help, */ if (version = 13000) qemuCapsSet(flags, QEMU_CAPS_MONITOR_JSON); + +if (version = 13000) +qemuCapsSet(flags, QEMU_CAPS_PCI_MULTIFUNCTION); This is a rather bad test. We should be avoiding version-based tests Yes, it is a bad test. But I do not find a better way. where possible, and instead favor -help parsing tests. Is there any device xxx where 'qemu -device xxx,?' will list multifunction? If so, No, for example: # /usr/local2/bin/qemu-system-x86_64 -device rtl8139,? rtl8139.mac=macaddr rtl8139.vlan=vlan rtl8139.netdev=netdev rtl8139.bootindex=int32 qemuCapsExtractDeviceStr is the better place to modify to probe for this capability. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] vcpupin: fix cpu affinity setting bug of qemu driver
On 06/07/2011 12:52 PM, Taku Izumi wrote: There is the case where cpu affinites for vcpu of qemu doesn't work correctly. For example, if only one vcpupin setting entry is provided and its setting is not for vcpu0, it doesn't work. # virsh dumpxml VM ... vcpu4/vcpu cputune vcpupin vcpu='3' cpuset='9-11'/ /cputune ... # virsh start VM Domain VM started # virsh vcpuinfo VM VCPU: 0 CPU:31 State: running CPU time: 2.5s CPU Affinity: VCPU: 1 CPU:12 State: running CPU time: 0.9s CPU Affinity: VCPU: 2 CPU:30 State: running CPU time: 1.5s CPU Affinity: VCPU: 3 CPU:13 State: running CPU time: 1.7s CPU Affinity: This patch fixes this problem. Signed-off-by: Taku Izumiizumi.t...@jp.fujitsu.com --- src/qemu/qemu_process.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) Index: libvirt/src/qemu/qemu_process.c === --- libvirt.orig/src/qemu/qemu_process.c +++ libvirt/src/qemu/qemu_process.c @@ -1194,7 +1194,7 @@ qemuProcessSetVcpuAffinites(virConnectPt virNodeInfo nodeinfo; pid_t vcpupid; unsigned char *cpumask; -int vcpu, cpumaplen, hostcpus, maxcpu; +int vcpu, cpumaplen, hostcpus, maxcpu, n; unsigned char *cpumap = NULL; int ret = -1; @@ -1223,14 +1223,12 @@ qemuProcessSetVcpuAffinites(virConnectPt return -1; } -for (vcpu = 0; vcpu def-cputune.nvcpupin; vcpu++) { -if (vcpu != def-cputune.vcpupin[vcpu]-vcpuid) -continue; Looks good to me, thanks for fixing it, ACK Regards Osier - +for (n = 0; n def-cputune.nvcpupin; n++) { int i; +vcpu = def-cputune.vcpupin[n]-vcpuid; memset(cpumap, 0, cpumaplen); -cpumask = (unsigned char *)def-cputune.vcpupin[vcpu]-cpumask; +cpumask = (unsigned char *)def-cputune.vcpupin[n]-cpumask; vcpupid = priv-vcpupids[vcpu]; /* Convert cpumask to bitmap here. */ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] xenapi: Improve error message on session failure
XenAPI session login can fail for a number of reasons, but currently no specific reason is displayed to the user, e.g.: virsh -c XenAPI://citrix-xen.example.com/ Enter username for citrix-xen.example.com: root Enter root's password for citrix-xen.example.com: error: authentication failed: (null) error: failed to connect to the hypervisor This patch displays the session error description on failure. --- src/xenapi/xenapi_driver.c | 20 ++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 6f64208..3fc35c6 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -166,7 +166,22 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS privP-session = xen_session_login_with_password(call_func, privP, username, password, xen_api_latest_version); -if (privP-session != NULL privP-session-ok) { +if (privP-session == NULL) { +/* From inspection of xen_session_login_with_password in + * libxenserver(Version 5.6.100-1), this appears not to be currently + * possible. The only way for this to be NULL would be on malloc + * failure, except that the code doesn't check for this and would + * segfault before returning. + * + * We don't assume the reason here for a failure in an external library. + */ +xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, + _(Failed to allocate xen session)); + +goto error; +} + +if (privP-session-ok) { conn-privateData = privP; VIR_FREE(username); @@ -175,7 +190,8 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS return VIR_DRV_OPEN_SUCCESS; } -xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, NULL); +xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, + *privP-session-error_description); error: VIR_FREE(username); -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] vbox: Support shared folders
Shared folders are handled as filesystems and can also be hotplugged. --- Currently this just maps shared folder to a filesystem element with type mount. The filesystem element has an accessmode attribute that is not useful for VirtualBox. Als the target element only has a dir attribute, but VirtualBox shares doen't support that, you can only give them a name. filesystem type='mount' accessmode='passthrough' source dir='/tmp'/ target dir='foobar'/ readonly/ /filesystem I wonder if we should add a shared folder type like this: filesystem type='sharedfolder' source dir='/tmp'/ target name='foobar'/ readonly/ /filesystem Or is this to specific to VirtualBox? VirtualBox 4.0 added the automount option that automatically mounts a shared folder in the guest. On Windows it is mounted to a free drive letter on Linux it's mounted to /media/prefix_shared-folder-name. The prefix is a global configuration option in VirtualBox. I wonder if and how to expose that in libvirt. Matthias docs/drvvbox.html.in |5 ++ src/vbox/vbox_tmpl.c | 140 ++ 2 files changed, 145 insertions(+), 0 deletions(-) diff --git a/docs/drvvbox.html.in b/docs/drvvbox.html.in index ef55757..1fcafde 100644 --- a/docs/drvvbox.html.in +++ b/docs/drvvbox.html.in @@ -61,6 +61,11 @@ vbox+ssh://u...@example.com/session (remote access, SSH tunnelled) lt;target dev='fda'/gt; lt;/diskgt; +lt;filesystem type='mount'gt; + lt;source dir='/home/user/stuff'/gt; + lt;target dir='my-shared-folder'/gt; +lt;/filesystemgt; + lt;!--BRIDGE--gt; lt;interface type='bridge'gt; lt;source bridge='eth0'/gt; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 2986f5a..13c324f 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2249,6 +2249,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, int flags) { /* Not supported by libvirt yet */ } else if (device == DeviceType_SharedFolder) { /* Not supported by libvirt yet */ +/* Can VirtualBox really boot from a shared folder? */ } } @@ -2752,6 +2753,67 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, int flags) { #endif /* VBOX_API_VERSION = 3001 */ +/* shared folders */ +vboxArray sharedFolders = VBOX_ARRAY_INITIALIZER; + +def-nfss = 0; + +vboxArrayGet(sharedFolders, machine, + machine-vtbl-GetSharedFolders); + +if (sharedFolders.count 0) { +if (VIR_ALLOC_N(def-fss, sharedFolders.count) 0) { +virReportOOMError(); +goto sharedFoldersCleanup; +} + +for (i = 0; i sharedFolders.count; i++) { +ISharedFolder *sharedFolder = sharedFolders.items[i]; +PRUnichar *nameUtf16 = NULL; +char *name = NULL; +PRUnichar *hostPathUtf16 = NULL; +char *hostPath = NULL; +PRBool writable = PR_FALSE; + +if (VIR_ALLOC(def-fss[i]) 0) { +virReportOOMError(); +goto sharedFoldersCleanup; +} + +def-fss[i]-type = VIR_DOMAIN_FS_TYPE_MOUNT; + +sharedFolder-vtbl-GetHostPath(sharedFolder, hostPathUtf16); +VBOX_UTF16_TO_UTF8(hostPathUtf16, hostPath); +def-fss[i]-src = strdup(hostPath); +VBOX_UTF8_FREE(hostPath); +VBOX_UTF16_FREE(hostPathUtf16); + +if (def-fss[i]-src == NULL) { +virReportOOMError(); +goto sharedFoldersCleanup; +} + +sharedFolder-vtbl-GetName(sharedFolder, nameUtf16); +VBOX_UTF16_TO_UTF8(nameUtf16, name); +def-fss[i]-dst = strdup(name); +VBOX_UTF8_FREE(name); +VBOX_UTF16_FREE(nameUtf16); + +if (def-fss[i]-dst == NULL) { +virReportOOMError(); +goto sharedFoldersCleanup; +} + +sharedFolder-vtbl-GetWritable(sharedFolder, writable); +def-fss[i]-readonly = !writable; + +++def-nfss; +} +} + +sharedFoldersCleanup: +vboxArrayRelease(sharedFolders); + /* dump network cards if present */ def-nnets = 0; /* Get which network cards are enabled */ @@ -4790,6 +4852,38 @@ vboxAttachUSB(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } } +static void +vboxAttachSharedFolder(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) +{ +int i; +PRUnichar
[libvirt] [PATCH] virsh: Expose virDomainMigrateSetMaxSpeed API to virsh
API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++ tools/virsh.pod |5 + 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..ab83ba9 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -4301,6 +4301,50 @@ done: } /* + * migrate-setspeed command + */ +static const vshCmdInfo info_migrate_setspeed[] = { +{help, N_(Set the maximum migration bandwidth)}, +{desc, N_(Set the maximum migration bandwidth (in Mbps) for a domain +which is being migrated to another host.)}, +{NULL, NULL} +}; + +static const vshCmdOptDef opts_migrate_setspeed[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{bandwidth, VSH_OT_INT, VSH_OFLAG_REQ, N_(migration bandwidth limit in Mbps)}, +{NULL, 0, 0, NULL} +}; + +static bool +cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom = NULL; +unsigned long bandwidth = 0; +bool ret = false; + +if (!vshConnectionUsability(ctl, ctl-conn)) +return false; + +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) +return false; + +if (vshCommandOptUL(cmd, bandwidth, bandwidth) 0) { +vshError(ctl, %s, _(migrate: Invalid bandwidth)); +goto done; +} + +if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) 0) +goto done; + +ret = true; + +done: +virDomainFree(dom); +return ret; +} + +/* * net-autostart command */ static const vshCmdInfo info_network_autostart[] = { @@ -11080,6 +11124,8 @@ static const vshCmdDef domManagementCmds[] = { {migrate, cmdMigrate, opts_migrate, info_migrate, 0}, {migrate-setmaxdowntime, cmdMigrateSetMaxDowntime, opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime, 0}, +{migrate-setspeed, cmdMigrateSetMaxSpeed, + opts_migrate_setspeed, info_migrate_setspeed, 0}, {reboot, cmdReboot, opts_reboot, info_reboot, 0}, {restore, cmdRestore, opts_restore, info_restore, 0}, {resume, cmdResume, opts_resume, info_resume, 0}, diff --git a/tools/virsh.pod b/tools/virsh.pod index 7ed3003..98adc90 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -542,6 +542,11 @@ Set maximum tolerable downtime for a domain which is being live-migrated to another host. The Idowntime is a number of milliseconds the guest is allowed to be down at the end of live migration. +=item Bmigrate-setspeed Idomain-id Ibandwidth + +Set the maximum migration bandwidth (in Mbps) for a domain which is being +migrated to another host. + =item Breboot Idomain-id Reboot a domain. This acts just as if the domain had the Breboot -- 1.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] test: Remove unused timeval
--- src/test/test_driver.c |7 --- 1 files changed, 0 insertions(+), 7 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2da24f1..68ab2fe 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -499,7 +499,6 @@ cleanup: static int testOpenDefault(virConnectPtr conn) { int u; -struct timeval tv; testConnPtr privconn; virDomainDefPtr domdef = NULL; virDomainObjPtr domobj = NULL; @@ -526,12 +525,6 @@ static int testOpenDefault(virConnectPtr conn) { testDriverLock(privconn); conn-privateData = privconn; -if (gettimeofday(tv, NULL) 0) { -virReportSystemError(errno, - %s, _(getting time of day)); -goto error; -} - if (virDomainObjListInit(privconn-domains) 0) goto error; -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] esx: Remove duplicated invalid-argument checks
On 06/07/2011 01:36 AM, Matthias Bolte wrote: Those checks are already performed at the public API level. --- src/esx/esx_driver.c | 10 -- src/esx/esx_storage_driver.c |5 - 2 files changed, 0 insertions(+), 15 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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] test: Remove unused timeval
On 06/07/2011 06:20 AM, Jiri Denemark wrote: --- src/test/test_driver.c |7 --- 1 files changed, 0 insertions(+), 7 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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] xenapi: Improve error message on session failure
On 06/07/2011 05:01 AM, Matthew Booth wrote: XenAPI session login can fail for a number of reasons, but currently no specific reason is displayed to the user, e.g.: virsh -c XenAPI://citrix-xen.example.com/ Enter username for citrix-xen.example.com: root Enter root's password for citrix-xen.example.com: error: authentication failed: (null) error: failed to connect to the hypervisor This patch displays the session error description on failure. --- src/xenapi/xenapi_driver.c | 20 ++-- 1 files changed, 18 insertions(+), 2 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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] virsh: Expose virDomainMigrateSetMaxSpeed API to virsh
On 06/07/2011 06:45 AM, Osier Yang wrote: API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++ tools/virsh.pod |5 + 2 files changed, 51 insertions(+), 0 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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 5/6] qemu: Implement virDomainGetControlInfo
--- src/qemu/qemu_domain.c |4 +++ src/qemu/qemu_domain.h |2 + src/qemu/qemu_driver.c | 61 +++ src/qemu/qemu_process.c |3 ++ 4 files changed, 70 insertions(+), 0 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 5f18ad3..06d2a5e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -609,6 +609,7 @@ void qemuDomainObjEnterMonitor(virDomainObjPtr obj) qemuMonitorLock(priv-mon); qemuMonitorRef(priv-mon); +virTimeMs(priv-monStart); virDomainObjUnlock(obj); } @@ -629,6 +630,7 @@ void qemuDomainObjExitMonitor(virDomainObjPtr obj) virDomainObjLock(obj); +priv-monStart = 0; if (refs == 0) { priv-mon = NULL; } @@ -650,6 +652,7 @@ void qemuDomainObjEnterMonitorWithDriver(struct qemud_driver *driver, qemuMonitorLock(priv-mon); qemuMonitorRef(priv-mon); +virTimeMs(priv-monStart); virDomainObjUnlock(obj); qemuDriverUnlock(driver); } @@ -674,6 +677,7 @@ void qemuDomainObjExitMonitorWithDriver(struct qemud_driver *driver, qemuDriverLock(driver); virDomainObjLock(obj); +priv-monStart = 0; if (refs == 0) { priv-mon = NULL; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index bacf5b5..3d041fc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -79,6 +79,8 @@ struct _qemuDomainObjPrivate { qemuMonitorPtr mon; virDomainChrSourceDefPtr monConfig; int monJSON; +bool monError; +unsigned long long monStart; bool gotShutdown; int nvcpupids; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 470573e..8328757 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1873,6 +1873,66 @@ cleanup: return ret; } +static int +qemuDomainGetControlInfo(virDomainPtr dom, + virDomainControlInfoPtr info, + unsigned int flags) +{ +struct qemud_driver *driver = dom-conn-privateData; +virDomainObjPtr vm; +qemuDomainObjPrivatePtr priv; +int ret = -1; + +virCheckFlags(0, -1); + +qemuDriverLock(driver); +vm = virDomainFindByUUID(driver-domains, dom-uuid); +qemuDriverUnlock(driver); + +if (!vm) { +char uuidstr[VIR_UUID_STRING_BUFLEN]; +virUUIDFormat(dom-uuid, uuidstr); +qemuReportError(VIR_ERR_NO_DOMAIN, +_(no domain with matching uuid '%s'), uuidstr); +goto cleanup; +} + +if (!virDomainObjIsActive(vm)) { +qemuReportError(VIR_ERR_OPERATION_INVALID, +%s, _(domain is not running)); +goto cleanup; +} + +priv = vm-privateData; + +memset(info, 0, sizeof(*info)); + +if (priv-monError) { +info-state = VIR_DOMAIN_CONTROL_ERROR; +} else if (priv-jobActive) { +if (!priv-monStart) { +info-state = VIR_DOMAIN_CONTROL_JOB; +if (virTimeMs(info-stateTime) 0) +goto cleanup; +info-stateTime -= priv-jobStart; +} else { +info-state = VIR_DOMAIN_CONTROL_OCCUPIED; +if (virTimeMs(info-stateTime) 0) +goto cleanup; +info-stateTime -= priv-monStart; +} +} else { +info-state = VIR_DOMAIN_CONTROL_OK; +} + +ret = 0; + +cleanup: +if (vm) +virDomainObjUnlock(vm); +return ret; +} + #define QEMUD_SAVE_MAGIC LibvirtQemudSave #define QEMUD_SAVE_VERSION 2 @@ -8001,6 +8061,7 @@ static virDriver qemuDriver = { .domainGetBlkioParameters = qemuDomainGetBlkioParameters, /* 0.9.0 */ .domainGetInfo = qemudDomainGetInfo, /* 0.2.0 */ .domainGetState = qemuDomainGetState, /* 0.9.2 */ +.domainGetControlInfo = qemuDomainGetControlInfo, /* 0.9.3 */ .domainSave = qemudDomainSave, /* 0.2.0 */ .domainRestore = qemuDomainRestore, /* 0.2.0 */ .domainCoreDump = qemudDomainCoreDump, /* 0.7.0 */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 40078e4..1790332 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -166,6 +166,7 @@ qemuProcessHandleMonitorError(qemuMonitorPtr mon ATTRIBUTE_UNUSED, qemuDriverLock(driver); virDomainObjLock(vm); +((qemuDomainObjPrivatePtr) vm-privateData)-monError = true; event = virDomainEventControlErrorNewFromObj(vm); if (event) qemuDomainEventQueue(driver, event); @@ -2255,6 +2256,8 @@ int qemuProcessStart(virConnectPtr conn, #endif priv-monJSON = 0; +priv-monError = false; +priv-monStart = 0; priv-gotShutdown = false; if ((ret = virFileDeletePid(driver-stateDir, vm-def-name)) != 0) { -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/6] Introduce virTimeMs for getting current time in ms
--- src/libvirt_private.syms |1 + src/util/util.c | 24 src/util/util.h |2 ++ 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e6ab870..2415a89 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1027,6 +1027,7 @@ virStrToLong_ul; virStrToLong_ull; virStrcpy; virStrncpy; +virTimeMs; virTimestamp; virVasprintf; diff --git a/src/util/util.c b/src/util/util.c index e221abe..d758cf9 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -3117,6 +3117,30 @@ virTimestamp(void) return timestamp; } +#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000)) + +/** + * virTimeMs: + * + * Get current time in milliseconds. + * + * Returns 0 on success, -1 on failure. + */ +int +virTimeMs(unsigned long long *ms) +{ +struct timeval now; + +if (gettimeofday(now, NULL) 0) { +virReportSystemError(errno, %s, + _(cannot get time of day)); +return -1; +} + +*ms = timeval_to_ms(now); +return 0; +} + #if HAVE_LIBDEVMAPPER_H bool virIsDevMapperDevice(const char *devname) diff --git a/src/util/util.h b/src/util/util.h index a1bcca0..273248a 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -286,6 +286,8 @@ int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL; char *virTimestamp(void); +int virTimeMs(unsigned long long *ms); + bool virIsDevMapperDevice(const char *devname) ATTRIBUTE_NONNULL(1); int virEmitXMLWarning(int fd, -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/6] Introduce virDomainGetControlInfo API
The API can be used to query current state of an interface to VMM used to control a domain. In QEMU world this translates into monitor connection and one can use the API, e.g., to check whether (and for how long) libvirtd is currently waiting for a reply from qemu process. Jiri Denemark (6): Introduce virTimeMs for getting current time in ms Use virTimeMs when appropriate Introduce virDomainGetControlInfo API Wire protocol and remote driver for virDomainGetControlInfo qemu: Implement virDomainGetControlInfo virsh: Add support for virDomainGetControlInfo daemon/remote_generator.pl | 20 +++--- include/libvirt/libvirt.h.in| 40 + python/generator.py |1 + python/libvirt-override-api.xml |6 +++ src/driver.h|5 +++ src/libvirt.c | 48 ++ src/libvirt_private.syms|1 + src/libvirt_public.syms |5 +++ src/qemu/qemu_domain.c | 28 ++- src/qemu/qemu_domain.h |2 + src/qemu/qemu_driver.c | 72 ++- src/qemu/qemu_migration.c | 31 +--- src/qemu/qemu_process.c |3 ++ src/remote/remote_driver.c |1 + src/remote/remote_protocol.x| 14 +++- src/remote_protocol-structs |9 + src/util/event_poll.c | 45 +--- src/util/util.c | 24 + src/util/util.h |2 + tools/virsh.c | 66 +++ tools/virsh.pod |7 21 files changed, 348 insertions(+), 82 deletions(-) -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/6] Introduce virDomainGetControlInfo API
The API can be used to query current state of an interface to VMM used to control a domain. In QEMU world this translates into monitor connection. --- include/libvirt/libvirt.h.in| 40 python/generator.py |1 + python/libvirt-override-api.xml |6 + src/driver.h|5 src/libvirt.c | 48 +++ src/libvirt_public.syms |5 6 files changed, 105 insertions(+), 0 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index df213f1..1454ca0 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -141,6 +141,43 @@ typedef enum { VIR_DOMAIN_CRASHED_UNKNOWN = 0, /* crashed for unknown reason */ } virDomainCrashedReason; + +/** + * virDomainControlState: + * + * Current state of a control interface to the domain. + */ +typedef enum { +VIR_DOMAIN_CONTROL_OK = 0, /* operational, ready to accept commands */ +VIR_DOMAIN_CONTROL_JOB = 1, /* background job is running (can be +monitored by virDomainGetJobInfo); only +limited set of commands may be allowed */ +VIR_DOMAIN_CONTROL_OCCUPIED = 2, /* occupied by a running command */ +VIR_DOMAIN_CONTROL_ERROR = 3,/* unusable, domain cannot be fully operated */ +} virDomainControlState; + +/** + * virDomainControlInfo: + * + * Structure filled in by virDomainGetControlInfo and providing details about + * current state of control interface to a domain. + */ +typedef struct _virDomainControlInfo virDomainControlInfo; +struct _virDomainControlInfo { +unsigned int state; /* control state, one of virDomainControlState */ +unsigned int details; /* state details, currently 0 */ +unsigned long long stateTime; /* for how long (in msec) control interface + has been in current state (except for OK + and ERROR states) */ +}; + +/** + * virDomainControlInfoPtr: + * + * Pointer to virDomainControlInfo structure. + */ +typedef virDomainControlInfo *virDomainControlInfoPtr; + /** * virDomainModificationImpact: * @@ -781,6 +818,9 @@ int virDomainGetState (virDomainPtr domain, int *state, int *reason, unsigned int flags); +int virDomainGetControlInfo (virDomainPtr domain, + virDomainControlInfoPtr info, + unsigned int flags); /* * Return scheduler type in effect 'sedf', 'credit', 'linux' diff --git a/python/generator.py b/python/generator.py index 7c38fdd..4e3e9fa 100755 --- a/python/generator.py +++ b/python/generator.py @@ -306,6 +306,7 @@ skip_impl = ( 'virGetLastError', 'virDomainGetInfo', 'virDomainGetState', +'virDomainGetControlInfo', 'virDomainGetBlockInfo', 'virDomainGetJobInfo', 'virNodeGetInfo', diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml index ec08e69..01207d6 100644 --- a/python/libvirt-override-api.xml +++ b/python/libvirt-override-api.xml @@ -54,6 +54,12 @@ arg name='domain' type='virDomainPtr' info='a domain object'/ arg name='flags' type='unsigned int' info='additional flags'/ /function +function name='virDomainGetControlInfo' file='python' + infoExtract details about current state of control interface to a domain./info + return type='int *' info='the list of information or None in case of error'/ + arg name='domain' type='virDomainPtr' info='a domain object'/ + arg name='flags' type='unsigned int' info='additional flags'/ +/function function name='virDomainGetBlockInfo' file='python' infoExtract information about a domain block device size/info return type='int *' info='the list of information or None in case of error'/ diff --git a/src/driver.h b/src/driver.h index 5df798a..ca49b08 100644 --- a/src/driver.h +++ b/src/driver.h @@ -171,6 +171,10 @@ typedef int int *reason, unsigned int flags); typedef int +(*virDrvDomainGetControlInfo) (virDomainPtr domain, + virDomainControlInfoPtr info, + unsigned int flags); +typedef int (*virDrvDomainSave)(virDomainPtr domain, const char *to); typedef int @@ -663,6 +667,7 @@ struct _virDriver { virDrvDomainGetBlkioParameters domainGetBlkioParameters; virDrvDomainGetInfodomainGetInfo; virDrvDomainGetState
[libvirt] [PATCH 2/6] Use virTimeMs when appropriate
--- src/qemu/qemu_domain.c| 24 src/qemu/qemu_driver.c| 11 ++- src/qemu/qemu_migration.c | 31 ++- src/util/event_poll.c | 45 - 4 files changed, 36 insertions(+), 75 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 332c09e..5f18ad3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -45,8 +45,6 @@ #define QEMU_NAMESPACE_HREF http://libvirt.org/schemas/domain/qemu/1.0; -#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000)) - static void qemuDomainEventDispatchFunc(virConnectPtr conn, virDomainEventPtr event, @@ -492,15 +490,12 @@ void qemuDomainSetNamespaceHooks(virCapsPtr caps) int qemuDomainObjBeginJob(virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj-privateData; -struct timeval now; +unsigned long long now; unsigned long long then; -if (gettimeofday(now, NULL) 0) { -virReportSystemError(errno, %s, - _(cannot get time of day)); +if (virTimeMs(now) 0) return -1; -} -then = timeval_to_ms(now) + QEMU_JOB_WAIT_TIME; +then = now + QEMU_JOB_WAIT_TIME; virDomainObjRef(obj); @@ -520,7 +515,7 @@ int qemuDomainObjBeginJob(virDomainObjPtr obj) priv-jobActive = QEMU_JOB_UNSPECIFIED; priv-jobSignals = 0; memset(priv-jobSignalsData, 0, sizeof(priv-jobSignalsData)); -priv-jobStart = timeval_to_ms(now); +priv-jobStart = now; memset(priv-jobInfo, 0, sizeof(priv-jobInfo)); return 0; @@ -536,15 +531,12 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, virDomainObjPtr obj) { qemuDomainObjPrivatePtr priv = obj-privateData; -struct timeval now; +unsigned long long now; unsigned long long then; -if (gettimeofday(now, NULL) 0) { -virReportSystemError(errno, %s, - _(cannot get time of day)); +if (virTimeMs(now) 0) return -1; -} -then = timeval_to_ms(now) + QEMU_JOB_WAIT_TIME; +then = now + QEMU_JOB_WAIT_TIME; virDomainObjRef(obj); qemuDriverUnlock(driver); @@ -568,7 +560,7 @@ int qemuDomainObjBeginJobWithDriver(struct qemud_driver *driver, priv-jobActive = QEMU_JOB_UNSPECIFIED; priv-jobSignals = 0; memset(priv-jobSignalsData, 0, sizeof(priv-jobSignalsData)); -priv-jobStart = timeval_to_ms(now); +priv-jobStart = now; memset(priv-jobInfo, 0, sizeof(priv-jobInfo)); virDomainObjUnlock(obj); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 2957467..470573e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -113,8 +113,6 @@ #define QEMU_NB_BLKIO_PARAM 1 -#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000)) - static void processWatchdogEvent(void *data, void *opaque); static int qemudShutdown(void); @@ -6843,8 +6841,6 @@ static int qemuDomainGetJobInfo(virDomainPtr dom, if (virDomainObjIsActive(vm)) { if (priv-jobActive) { -struct timeval now; - memcpy(info, priv-jobInfo, sizeof(*info)); /* Refresh elapsed time again just to ensure it @@ -6852,12 +6848,9 @@ static int qemuDomainGetJobInfo(virDomainPtr dom, * of incoming migration which we don't currently * monitor actively in the background thread */ -if (gettimeofday(now, NULL) 0) { -virReportSystemError(errno, %s, - _(cannot get time of day)); +if (virTimeMs(info-timeElapsed) 0) goto cleanup; -} -info-timeElapsed = timeval_to_ms(now) - priv-jobStart; +info-timeElapsed -= priv-jobStart; } else { memset(info, 0, sizeof(*info)); info-type = VIR_DOMAIN_JOB_NONE; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f7eaa1c..5d7494b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -46,8 +46,6 @@ #define VIR_FROM_THIS VIR_FROM_QEMU -#define timeval_to_ms(tv) (((tv).tv_sec * 1000ull) + ((tv).tv_usec / 1000)) - enum qemuMigrationCookieFlags { QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS, QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE, @@ -831,7 +829,6 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver, unsigned long long memProcessed; unsigned long long memRemaining; unsigned long long memTotal; -struct timeval now; if (!virDomainObjIsActive(vm)) { qemuReportError(VIR_ERR_INTERNAL_ERROR, _(%s: %s), @@ -852,13 +849,9 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver, return -1; } -if (gettimeofday(now, NULL) 0) { -priv-jobInfo.type =
[libvirt] [PATCH 6/6] virsh: Add support for virDomainGetControlInfo
--- tools/virsh.c | 66 +++ tools/virsh.pod |7 + 2 files changed, 73 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..2c81cf4 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -350,6 +350,7 @@ static void vshDebug(vshControl *ctl, int level, const char *format, ...) static int vshDomainState(vshControl *ctl, virDomainPtr dom, int *reason); static const char *vshDomainStateToString(int state); static const char *vshDomainStateReasonToString(int state, int reason); +static const char *vshDomainControlStateToString(int state); static const char *vshDomainVcpuStateToString(int state); static bool vshConnectionUsability(vshControl *ctl, virConnectPtr conn); @@ -976,6 +977,53 @@ cleanup: return ret; } +/* + * domcontrol command + */ +static const vshCmdInfo info_domcontrol[] = { +{help, N_(domain control interface state)}, +{desc, N_(Returns state of a control interface to the domain.)}, +{NULL, NULL} +}; + +static const vshCmdOptDef opts_domcontrol[] = { +{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)}, +{NULL, 0, 0, NULL} +}; + +static bool +cmdDomControl(vshControl *ctl, const vshCmd *cmd) +{ +virDomainPtr dom; +bool ret = true; +virDomainControlInfo info; + +if (!vshConnectionUsability(ctl, ctl-conn)) +return false; + +if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) +return false; + +if (virDomainGetControlInfo(dom, info, 0) 0) { +ret = false; +goto cleanup; +} + +if (info.state != VIR_DOMAIN_CONTROL_OK +info.state != VIR_DOMAIN_CONTROL_ERROR) { +vshPrint(ctl, %s (%0.3fs)\n, + _(vshDomainControlStateToString(info.state)), + info.stateTime / 1000.0); +} else { +vshPrint(ctl, %s\n, + _(vshDomainControlStateToString(info.state))); +} + +cleanup: +virDomainFree(dom); +return ret; +} + /* domblkstat command */ static const vshCmdInfo info_domblkstat[] = { @@ -11107,6 +11155,7 @@ static const vshCmdDef domManagementCmds[] = { static const vshCmdDef domMonitoringCmds[] = { {domblkinfo, cmdDomblkinfo, opts_domblkinfo, info_domblkinfo, 0}, {domblkstat, cmdDomblkstat, opts_domblkstat, info_domblkstat, 0}, +{domcontrol, cmdDomControl, opts_domcontrol, info_domcontrol, 0}, {domifstat, cmdDomIfstat, opts_domifstat, info_domifstat, 0}, {dominfo, cmdDominfo, opts_dominfo, info_dominfo, 0}, {dommemstat, cmdDomMemStat, opts_dommemstat, info_dommemstat, 0}, @@ -12621,6 +12670,23 @@ vshDomainStateReasonToString(int state, int reason) } static const char * +vshDomainControlStateToString(int state) +{ +switch ((virDomainControlState) state) { +case VIR_DOMAIN_CONTROL_OK: +return N_(ok); +case VIR_DOMAIN_CONTROL_JOB: +return N_(background job); +case VIR_DOMAIN_CONTROL_OCCUPIED: +return N_(occupied); +case VIR_DOMAIN_CONTROL_ERROR: +return N_(error); +} + +return N_(unknown); +} + +static const char * vshDomainVcpuStateToString(int state) { switch (state) { diff --git a/tools/virsh.pod b/tools/virsh.pod index 7ed3003..3f55422 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -437,6 +437,13 @@ Convert a domain Id (or UUID) to domain name Returns state about a domain. I--reason tells virsh to also print reason for the state. +=item Bdomcontrol Idomain-id + +Returns state of an interface to VMM used to control a domain. This +translates into monitor connection in QEMu world. For states other +than ok or error the command also prints number of seconds elapsed +since the control interface entered its current state. + =item Bdomxml-from-native Iformat Iconfig Convert the file Iconfig in the native guest configuration format -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 4/6] Wire protocol and remote driver for virDomainGetControlInfo
--- daemon/remote_generator.pl | 20 ++-- src/remote/remote_driver.c |1 + src/remote/remote_protocol.x | 14 +- src/remote_protocol-structs |9 + 4 files changed, 37 insertions(+), 7 deletions(-) diff --git a/daemon/remote_generator.pl b/daemon/remote_generator.pl index 632972c..8881d6c 100755 --- a/daemon/remote_generator.pl +++ b/daemon/remote_generator.pl @@ -668,9 +668,13 @@ elsif ($opt_b) { my $struct_name = $call-{ProcName}; $struct_name =~ s/Get//; -if ($call-{ProcName} eq DomainGetBlockInfo) { -# SPECIAL: virDomainGetBlockInfo has flags parameter after -# the struct parameter in its signature +if ($call-{ProcName} eq DomainGetBlockInfo || +$call-{ProcName} eq DomainGetControlInfo) { +# SPECIAL: virDomainGetBlockInfo and virDomainGetControlInfo +# have flags parameter after the struct parameter in +# its signature +# FIXME: this doesn't sound special at all; flags parameter is +#almost always the last one; anything else is special my $flags = pop(@args_list); push(@args_list, tmp); push(@args_list, $flags); @@ -1203,9 +1207,13 @@ elsif ($opt_k) { my $struct_name = $call-{ProcName}; $struct_name =~ s/Get//; -if ($call-{ProcName} eq DomainGetBlockInfo) { -# SPECIAL: virDomainGetBlockInfo has flags parameter after -# the struct parameter in its signature +if ($call-{ProcName} eq DomainGetBlockInfo || +$call-{ProcName} eq DomainGetControlInfo) { +# SPECIAL: virDomainGetBlockInfo and virDomainGetControlInfo +# have flags parameter after the struct parameter in +# its signature +# FIXME: this doesn't sound special at all; flags parameter is +#almost always the last one; anything else is special $last_arg = pop(@args_list); } diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8335a1a..f1c6674 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6251,6 +6251,7 @@ static virDriver remote_driver = { .domainGetBlkioParameters = remoteDomainGetBlkioParameters, /* 0.9.0 */ .domainGetInfo = remoteDomainGetInfo, /* 0.3.0 */ .domainGetState = remoteDomainGetState, /* 0.9.2 */ +.domainGetControlInfo = remoteDomainGetControlInfo, /* 0.9.3 */ .domainSave = remoteDomainSave, /* 0.3.0 */ .domainRestore = remoteDomainRestore, /* 0.3.0 */ .domainCoreDump = remoteDomainCoreDump, /* 0.3.0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index c9b8cff..7e8ad6d 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2035,6 +2035,17 @@ struct remote_domain_event_control_error_msg { remote_nonnull_domain dom; }; +struct remote_domain_get_control_info_args { +remote_nonnull_domain dom; +unsigned int flags; +}; + +struct remote_domain_get_control_info_ret { +unsigned int state; +unsigned int details; +unsigned hyper stateTime; +}; + /*- Protocol. -*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -2297,7 +2308,8 @@ enum remote_procedure { REMOTE_PROC_INTERFACE_CHANGE_COMMIT = 221, /* autogen autogen */ REMOTE_PROC_INTERFACE_CHANGE_ROLLBACK = 222, /* autogen autogen */ REMOTE_PROC_DOMAIN_GET_SCHEDULER_PARAMETERS_FLAGS = 223, /* skipgen autogen */ -REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR = 224 /* skipgen skipgen */ +REMOTE_PROC_DOMAIN_EVENT_CONTROL_ERROR = 224, /* skipgen skipgen */ +REMOTE_PROC_DOMAIN_GET_CONTROL_INFO = 225 /* autogen autogen */ /* * Notice how the entries are grouped in sets of 10 ? diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 1d90dd5..18511be 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -1542,6 +1542,15 @@ struct remote_domain_migrate_confirm3_args { struct remote_domain_event_control_error_msg { remote_nonnull_domain dom; }; +struct remote_domain_get_control_info_args { +remote_nonnull_domain dom; +u_int flags; +}; +struct remote_domain_get_control_info_ret { +u_int state; +u_int details; +uint64_t stateTime; +}; struct remote_message_header { u_int prog; u_int vers; -- 1.7.5.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] esx: Remove duplicated invalid-argument checks
2011/6/7 Eric Blake ebl...@redhat.com: On 06/07/2011 01:36 AM, Matthias Bolte wrote: Those checks are already performed at the public API level. --- src/esx/esx_driver.c | 10 -- src/esx/esx_storage_driver.c | 5 - 2 files changed, 0 insertions(+), 15 deletions(-) ACK. Thanks, pushed. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 01/12] build: detect Coverity 5.3.0
2011/6/6 Eric Blake ebl...@redhat.com: Coverity 5.3.0 still outputs lots of COVERITY_* variables, but no longer modifies COVERITY_BUILD_COMMAND in the environment. Pick one that seems likely to stay around. * configure.ac (STATIC_ANALYSIS): Detect newer Coverity. --- configure.ac | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 5307a1d..c9f09b9 100644 --- a/configure.ac +++ b/configure.ac @@ -2389,7 +2389,9 @@ cp -f COPYING.LIB COPYING # Detect when running under the clang static analyzer's scan-build driver # or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly. -test -n ${CCC_ANALYZER_ANALYSIS+set}$COVERITY_BUILD_COMMAND t=1 || t=0 +t=0 +test -n ${CCC_ANALYZER_ANALYSIS+set} t=1 +test -n $COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD t=1 AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t], [Define to 1 when performing static analysis.]) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 03/12] build: silence coverity false positive
2011/6/6 Eric Blake ebl...@redhat.com: Similar in nature to commit fd21ecfd, which shut up valgrind. sigaction is apparently a nasty interface for code analyzers. * src/util/util.c (virExecWithHook): Initialize entire var, since coverity gripes about the (unused and non-standard) sa_restorer. --- src/util/util.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/util/util.c b/src/util/util.c index e221abe..5672193 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -690,8 +690,8 @@ virExecWithHook(const char *const*argv, * so we need to temporarily block that again */ struct sigaction waxon, waxoff; + memset(waxoff, 0, sizeof(waxoff)); waxoff.sa_handler = SIG_IGN; - waxoff.sa_flags = 0; sigemptyset(waxoff.sa_mask); memset(waxon, 0, sizeof(waxon)); if (sigaction(SIGPIPE, waxoff, waxon) 0) { -- 1.7.4.4 ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 04/12] python: avoid unlikely sign extension bug
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. cpumap was allocated with a value of (unsigned short)*(int), which is an int computation, and then promotes to size_t. On a 64-bit platform, this fails if bit 32 of the product is set (because of sign extension giving a HUGE value to malloc), even though a naive programmer would assume that since the first value is unsigned, the product is also unsigned and at most 4GB would be allocated. Won't bite in practice (the product should never be that large), but worth using the right types to begin with, so that we are now computing (unsigned short)*(size_t). * python/libvirt-override.c (libvirt_virDomainGetVcpus): Use correct type. --- python/libvirt-override.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/python/libvirt-override.c b/python/libvirt-override.c index 763df00..974decb 100644 --- a/python/libvirt-override.c +++ b/python/libvirt-override.c @@ -414,7 +414,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED, virDomainInfo dominfo; virVcpuInfoPtr cpuinfo = NULL; unsigned char *cpumap = NULL; - int cpumaplen, i; + size_t cpumaplen, i; int i_retval; if (!PyArg_ParseTuple(args, (char *)O:virDomainGetVcpus, ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 02/12] storage: avoid mishandling backing store 2GB
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. The code was doing math on shifted unsigned char (which promotes to int), then promoting that to unsigned long during assignment to size. On 64-bit platforms, this risks sign extending values of size 2GiB. Bug present since commit 489fd3 (v0.6.0). I'm not sure if a specially-crafted bogus qcow2 image could exploit this, although it's probably not possible, since we were already checking for the computed results being within range of our fixed-size buffer. * src/util/storage_file.c (qcowXGetBackingStore): Avoid sign extension. --- src/util/storage_file.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/util/storage_file.c b/src/util/storage_file.c index 6b3b756..6749599 100644 --- a/src/util/storage_file.c +++ b/src/util/storage_file.c @@ -27,6 +27,7 @@ #include sys/stat.h #include unistd.h #include fcntl.h +#include stdint.h #ifdef __linux__ # if HAVE_LINUX_MAGIC_H # include linux/magic.h @@ -274,7 +275,7 @@ qcowXGetBackingStore(char **res, bool isQCow2) { unsigned long long offset; - unsigned long size; + uint32_t size; *res = NULL; if (format) Using unsigned int instead of uint32_t would also work and avoid stdint.h types that the libvirt codebase avoids. At any rate, ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Fix allocation of veth's to not skip an index
The algorithm for autoassigning vethXXX devices, was always skipping over the starting dev index when finding a free name for the guest device. This should only be done if the host device was autoallocated. * src/lxc/veth.c: Don't skip over veth indexes --- src/lxc/veth.c | 14 +- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lxc/veth.c b/src/lxc/veth.c index a00aa23..22dbed5 100644 --- a/src/lxc/veth.c +++ b/src/lxc/veth.c @@ -46,6 +46,7 @@ static int getFreeVethName(char **veth, int startDev) int devNum = startDev-1; char *path = NULL; +VIR_DEBUG(Find free from veth%d, startDev); do { VIR_FREE(path); ++devNum; @@ -53,6 +54,7 @@ static int getFreeVethName(char **veth, int startDev) virReportOOMError(); return -1; } +VIR_DEBUG(Probe %s, path); } while (virFileExists(path)); VIR_FREE(path); @@ -60,6 +62,7 @@ static int getFreeVethName(char **veth, int startDev) virReportOOMError(); return -1; } + return devNum; } @@ -98,18 +101,19 @@ int vethCreate(char** veth1, char** veth2) bool veth1_alloc = false; bool veth2_alloc = false; -VIR_DEBUG(veth1: %s veth2: %s, NULLSTR(*veth1), NULLSTR(*veth2)); +VIR_DEBUG(Host: %s guest: %s, NULLSTR(*veth1), NULLSTR(*veth2)); if (*veth1 == NULL) { if ((vethDev = getFreeVethName(veth1, vethDev)) 0) goto cleanup; -VIR_DEBUG(Assigned veth1: %s, *veth1); +VIR_DEBUG(Assigned host: %s, *veth1); veth1_alloc = true; +vethDev++; } argv[3] = *veth1; while (*veth2 == NULL) { -if ((vethDev = getFreeVethName(veth2, vethDev + 1)) 0) { +if ((vethDev = getFreeVethName(veth2, vethDev)) 0) { if (veth1_alloc) VIR_FREE(*veth1); goto cleanup; @@ -122,12 +126,12 @@ int vethCreate(char** veth1, char** veth2) continue; } -VIR_DEBUG(Assigned veth2: %s, *veth2); +VIR_DEBUG(Assigned guest: %s, *veth2); veth2_alloc = true; } argv[8] = *veth2; -VIR_DEBUG(veth1: %s veth2: %s, *veth1, *veth2); +VIR_DEBUG(Create Host: %s guest: %s, *veth1, *veth2); if (virRun(argv, NULL) 0) { if (veth1_alloc) VIR_FREE(*veth1); -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Add support for network filter code in LXC driver
The LXC driver networking uses veth device pairs. These can be easily hooked into the network filtering code. * src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter --- src/lxc/lxc_driver.c | 12 ++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8eb87a2..4d14466 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -52,7 +52,7 @@ #include hooks.h #include files.h #include fdstream.h - +#include domain_nwfilter.h #define VIR_FROM_THIS VIR_FROM_LXC @@ -1027,6 +1027,8 @@ static void lxcVmCleanup(lxc_driver_t *driver, vethDelete(vm-def-nets[i]-ifname); } +virDomainConfVMNWFilterTeardown(vm); + if (driver-cgroup virCgroupForDomain(driver-cgroup, vm-def-name, cgroup, 0) == 0) { virCgroupRemove(cgroup); @@ -1146,6 +1148,10 @@ static int lxcSetupInterfaces(virConnectPtr conn, if (vethInterfaceUpOrDown(parentVeth, 1) 0) goto error_exit; + +if (def-nets[i]-filter +virDomainConfNWFilterInstantiate(conn, def-nets[i]) 0) +goto error_exit; } rc = 0; @@ -1538,8 +1544,10 @@ cleanup: vethDelete(veths[i]); VIR_FREE(veths[i]); } -if (rc != 0) +if (rc != 0) { VIR_FORCE_CLOSE(priv-monitor); +virDomainConfVMNWFilterTeardown(vm); +} VIR_FORCE_CLOSE(parentTty); VIR_FREE(logfile); return rc; -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 05/12] debug: avoid null dereference on uuid lookup api
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. Commit a98d8f0d tried to make uuid debugging more robust, but missed some APIs. And on the APIs that it visited, the mere act of preparing the debug message ends up dereferencing uuid prior to the null check. Which means the APIs which are supposed to gracefully reject NULL arguments now end up with SIGSEGV. * src/libvirt.c (VIR_UUID_DEBUG): New macro. (virDomainLookupByUUID, virDomainLookupByUUIDString) (virNetworkLookupByUUID, virNetworkLookupByUUIDString) (virStoragePoolLookupByUUID, virStoragePoolLookupByUUIDString) (virSecretLookupByUUID, virSecretLookupByUUIDString) (virNWFilterLookupByUUID, virNWFilterLookupByUUIDString): Avoid null dereference. --- src/libvirt.c | 42 ++ 1 files changed, 26 insertions(+), 16 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 07/12] qemu: reorder checks for safety
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. All existing callers happen to be in range, so this isn't too serious. * src/qemu/qemu_cgroup.c (qemuCgroupControllerActive): Check bounds before dereference. --- src/qemu/qemu_cgroup.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index eba1e73..1298924 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -48,10 +48,10 @@ bool qemuCgroupControllerActive(struct qemud_driver *driver, { if (driver-cgroup == NULL) return false; - if (!virCgroupMounted(driver-cgroup, controller)) - return false; if (controller 0 || controller = VIR_CGROUP_CONTROLLER_LAST) return false; + if (!virCgroupMounted(driver-cgroup, controller)) + return false; if (driver-cgroupControllers (1 controller)) return true; return false; -- 1.7.4.4 ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 06/12] uuid: annotate non-null requirements
2011/6/6 Eric Blake ebl...@redhat.com: Coverity already saw through a NULL dereference without these annotations, and gcc is still too puny to do good NULL analysis. But clang still benefits (and is easier to run than coverity), not to mention that adding this bit of documentation to the code may help future developers remember the constraints. * src/util/uuid.h (virGetHostUUID, virUUIDFormat): Document restrictions, for improved static analysis. --- src/util/uuid.h | 8 +--- 1 files changed, 5 insertions(+), 3 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix allocation of veth's to not skip an index
On 06/07/2011 07:35 AM, Daniel P. Berrange wrote: The algorithm for autoassigning vethXXX devices, was always skipping over the starting dev index when finding a free name for the guest device. This should only be done if the host device was autoallocated. * src/lxc/veth.c: Don't skip over veth indexes --- src/lxc/veth.c | 14 +- 1 files changed, 9 insertions(+), 5 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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 08/12] secret: drop dead code
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. The only ways to get to the cleanup label were by an early abort (list still NULL) or after successfully transferring list to dest, so there is no list to clean up. * src/secret/secret_driver.c (loadSecrets): Kill dead code. --- src/secret/secret_driver.c | 8 +--- 1 files changed, 1 insertions(+), 7 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Add support for network filter code in LXC driver
On 06/07/2011 07:36 AM, Daniel P. Berrange wrote: The LXC driver networking uses veth device pairs. These can be easily hooked into the network filtering code. * src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter --- src/lxc/lxc_driver.c | 12 ++-- 1 files changed, 10 insertions(+), 2 deletions(-) ACK. -- Eric Blake ebl...@redhat.com+1-801-349-2682 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 10/12] build: silence coverity false positives
2011/6/6 Eric Blake ebl...@redhat.com: Coverity complained about these intentional fallthrough cases, but not about other cases that were explicitly marked with nice comments. For some reason, Coverity doesn't seem smart enough to parse the up-front English comment in virsh about intentional fallthrough :) * tools/virsh.c (cmdVolSize): Mark fallthrough in a more typical fashion. * src/conf/nwfilter_conf.c (virNWFilterRuleDefDetailsFormat) (virNWFilterRuleDetailsParse): Mark explicit fallthrough. --- src/conf/nwfilter_conf.c | 4 tools/virsh.c | 3 +++ 2 files changed, 7 insertions(+), 0 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 11/12] qemu: add missing break statement
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. Bug introduced in commit 9d73efd (v0.8.8). * src/qemu/qemu_hotplug.c (qemuDomainChangeGraphics): Don't report error on success. ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 12/12] build: break some long lines
2011/6/6 Eric Blake ebl...@redhat.com: As long as I was already touching the function... * src/qemu/qemu_hotplug.c (qemuDomainChangeGraphics): Line wrap. --- src/qemu/qemu_hotplug.c | 46 ++ 1 files changed, 30 insertions(+), 16 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 13/12] daemon: plug memory leak
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. Commit ef21beda was incomplete; it solved a leak one one path, but not on the other. * daemon/libvirtd.c (qemudSetLogging): Avoid leak on success. --- How embarrassing that I was just barely fixing a leak of the same variable in this function, but only got half the job done. daemon/libvirtd.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Add support for network filter code in LXC driver
Daniel P. Berrange berra...@redhat.com wrote on 06/07/2011 09:36:22 AM: The LXC driver networking uses veth device pairs. These can be easily hooked into the network filtering code. * src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter --- src/lxc/lxc_driver.c | 12 ++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 8eb87a2..4d14466 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -52,7 +52,7 @@ #include hooks.h #include files.h #include fdstream.h - +#include domain_nwfilter.h #define VIR_FROM_THIS VIR_FROM_LXC @@ -1027,6 +1027,8 @@ static void lxcVmCleanup(lxc_driver_t *driver, vethDelete(vm-def-nets[i]-ifname); } +virDomainConfVMNWFilterTeardown(vm); + if (driver-cgroup virCgroupForDomain(driver-cgroup, vm-def-name, cgroup, 0) == 0) { virCgroupRemove(cgroup); @@ -1146,6 +1148,10 @@ static int lxcSetupInterfaces(virConnectPtr conn, if (vethInterfaceUpOrDown(parentVeth, 1) 0) goto error_exit; + +if (def-nets[i]-filter +virDomainConfNWFilterInstantiate(conn, def-nets[i]) 0) +goto error_exit; } rc = 0; @@ -1538,8 +1544,10 @@ cleanup: vethDelete(veths[i]); VIR_FREE(veths[i]); } -if (rc != 0) +if (rc != 0) { VIR_FORCE_CLOSE(priv-monitor); +virDomainConfVMNWFilterTeardown(vm); +} VIR_FORCE_CLOSE(parentTty); VIR_FREE(logfile); return rc; -- 1.7.4.4 I would have thought a bit more code to be necessary, especially for supporting the live filter updates. At least something along the lines that the UML support shows: [...] static int umlVMFilterRebuild(virConnectPtr conn ATTRIBUTE_UNUSED, virHashIterator iter, void *data) { virHashForEach(uml_driver-domains.objs, iter, data); return 0; } [...] static void umlVMDriverLock(void) { umlDriverLock(uml_driver); } static void umlVMDriverUnlock(void) { umlDriverUnlock(uml_driver); } static virNWFilterCallbackDriver umlCallbackDriver = { .name = UML, .vmFilterRebuild = umlVMFilterRebuild, .vmDriverLock = umlVMDriverLock, .vmDriverUnlock = umlVMDriverUnlock, }; int umlRegister(void) { virRegisterDriver(umlDriver); virRegisterStateDriver(umlStateDriver); virNWFilterRegisterCallbackDriver(umlCallbackDriver); return 0; } Regards, Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 09/12] esx: avoid dead code
2011/6/6 Eric Blake ebl...@redhat.com: Detected by Coverity. The beginning of the function already filtered out NULL objectContentList as invalid; more likely, the code was trying to see if esxVI_RetrieveProperties modified *objectContentList. * src/esx/esx_vi.c (esxVI_LookupObjectContentByType): Check correct pointer. --- Matthias, I'm not sure if this is the correct fix, because I don't know how escVI_RetrieveProperties is supposed to work. Sometime one got to love static code analysis tools. Yes, your patch is correct and necessary :) esxVI_RetrieveProperties is generated and returns a list of objects that match the given propertyFilterSpec. esxVI_LookupObjectContentByType then tests whether the result corresponds to the expected occurrence and reports an error otherwise. This simplifies the callers of esxVI_LookupObjectContentByType, but due to the missing dereference the check was never performed because the code thought that at least one item was obtained. NULL represents an empty list. Your patch now fixes this and is also a potential segfault fix because callers of esxVI_LookupObjectContentByType that specified required occurrence assume *objectContentList to be non-NULL when esxVI_LookupObjectContentByType succeeds. src/esx/esx_vi.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index c5c38ca..64e5b73 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -2,7 +2,7 @@ /* * esx_vi.c: client for the VMware VI API 2.5 to manage ESX hosts * - * Copyright (C) 2010 Red Hat, Inc. + * Copyright (C) 2010-2011 Red Hat, Inc. * Copyright (C) 2009-2011 Matthias Bolte matthias.bo...@googlemail.com * * This library is free software; you can redistribute it and/or @@ -1737,7 +1737,7 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, goto cleanup; } - if (objectContentList == NULL) { + if (*objectContentList == NULL) { switch (occurrence) { case esxVI_Occurrence_OptionalItem: case esxVI_Occurrence_OptionalList: ACK. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] Move virRun, virExec*, virFork to util/command
On 06/01/2011 04:02 PM, Cole Robinson wrote: On 06/01/2011 03:52 PM, Eric Blake wrote: On 05/17/2011 09:06 AM, Cole Robinson wrote: Seems reasonable to have all command wrappers in the same place v2: Dont move SetInherit v3: Comment spelling fix Adjust WARN0 comment Remove spurious #include movement Don't include sys/types.h Combine virExec enums Signed-off-by: Cole Robinson crobi...@redhat.com @@ -42,9 +48,13 @@ virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) Looks like you addressed all my comments; and sorry for the delay on this last round of reviews. ACK. Overall, this is a rather large change to be pushing after feature freeze; I'm 50-50 on whether we should delay this until after the release, since it is missing test exposure by not being part of RC1. Does anyone else have an opinion on whether this is safe enough to push now? Not really worth potentially rocking the boat over, I say we just wait till after the release. I've pushed this series now. Thanks, Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/7] lxc: Improve guest startup error reporting
On 06/02/2011 04:19 PM, Eric Blake wrote: On 06/02/2011 01:40 PM, Cole Robinson wrote: Add a simple handshake with the lxc_controller process so we can detect process startup failures. We do this by adding a new --handshake cli arg to lxc_controller for passing a file descriptor. If the process fails to launch, we scrape all output from the logfile and report it to the user. Signed-off-by: Cole Robinson crobi...@redhat.com --- src/lxc/lxc_container.c |2 +- src/lxc/lxc_container.h |1 + src/lxc/lxc_controller.c | 33 +- src/lxc/lxc_driver.c | 107 +- 4 files changed, 137 insertions(+), 6 deletions(-) @@ -1489,6 +1572,12 @@ static int lxcVmStart(virConnectPtr conn, if (virCommandRun(cmd, NULL) 0) goto cleanup; +if (VIR_CLOSE(handshakefds[1]) 0) { +virReportSystemError(errno, %s, _(could not close handshake fd)); +goto cleanup; +} +handshakefds[1] = -1; This line is redundant; the VIR_CLOSE() above already set this to -1. ACK with that nit fixed, post-release. Thanks, pushed series with this cleanup and the spelling fix in patch 3. - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH 6/9] net: Improve layout of 'info network'
On 06/07/2011 11:45 AM, Jan Kiszka wrote: Improve the layout when listing non-vlan clients via 'info network'. The result looks like this: (qemu) info network Devices not on any VLAN: orphan: net=10.0.2.0, restricted=n virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:56 \ network2: fd=5 e1000.0: model=e1000,macaddr=52:54:00:12:34:57 \ network1: net=10.0.2.0, restricted=n rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:58 ie. peers are grouped, orphans are listed as before. CC: Markus Armbrusterarm...@redhat.com Signed-off-by: Jan Kiszkajan.kis...@siemens.com There isn't a query-network yet in QMP so libvirt is probably still using the HMP version. Can someone on the libvirt side Ack/Nack about whether this patch will break libvirt? Regards, Anthony Liguori --- net.c | 14 +- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/net.c b/net.c index 4f777c3..606ce70 100644 --- a/net.c +++ b/net.c @@ -1224,7 +1224,8 @@ int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data) void do_info_network(Monitor *mon) { VLANState *vlan; -VLANClientState *vc; +VLANClientState *vc, *peer; +net_client_type type; QTAILQ_FOREACH(vlan,vlans, next) { monitor_printf(mon, VLAN %d devices:\n, vlan-id); @@ -1235,11 +1236,14 @@ void do_info_network(Monitor *mon) } monitor_printf(mon, Devices not on any VLAN:\n); QTAILQ_FOREACH(vc,non_vlan_clients, next) { -monitor_printf(mon, %s: %s, vc-name, vc-info_str); -if (vc-peer) { -monitor_printf(mon, peer=%s, vc-peer-name); +peer = vc-peer; +type = vc-info-type; +if (!peer || type == NET_CLIENT_TYPE_NIC) { +monitor_printf(mon, %s: %s\n, vc-name, vc-info_str); +} +if (peer type == NET_CLIENT_TYPE_NIC) { +monitor_printf(mon,\\ %s: %s\n, peer-name, peer-info_str); } -monitor_printf(mon, \n); } } -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Make check on current git fails when building --with-vbox
Hi all, ./configure --without-vbox make make check produces on my F-13 and F-15 machines. make[1]: Entering directory `/home/ruben/src/libvirt/tests' make virshtest conftest sockettest nodeinfotest qparamtest virbuftest commandtest commandhelper seclabeltest hashtest qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest openvzutilstest vmx2xmltest xml2vmxtest networkxml2xmltest nwfilterxml2xmltest storagevolxml2xmltest storagepoolxml2xmltest nodedevxml2xmltest interfacexml2xmltest cputest eventtest make[2]: Entering directory `/home/ruben/src/libvirt/tests' CC virshtest.o CC testutils.o CCLD virshtest CC conftest.o CCLD conftest CC sockettest.o CCLD sockettest CC nodeinfotest.o CCLD nodeinfotest CC qparamtest.o CCLD qparamtest CC virbuftest.o CCLD virbuftest CC commandtest-commandtest.o CC commandtest-testutils.o CCLD commandtest CC commandhelper-commandhelper.o CCLD commandhelper CC seclabeltest.o CCLD seclabeltest CC hashtest.o CCLD hashtest CC qemuxml2argvtest.o CC testutilsqemu.o CCLD qemuxml2argvtest /usr/bin/ld: ../src/.libs/libvirt_test.a(libvirt_driver_la-lock_manager.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' /usr/bin/ld: note: 'dlclose@@GLIBC_2.2.5' is defined in DSO /lib64/libdl.so.2 so try adding it to the linker command line /lib64/libdl.so.2: could not read symbols: Invalid operation collect2: ld returned 1 exit status make[2]: *** [qemuxml2argvtest] Error 1 make[2]: Leaving directory `/home/ruben/src/libvirt/tests' make[1]: *** [check-am] Error 2 make[1]: Leaving directory `/home/ruben/src/libvirt/tests' make: *** [check-recursive] Error 1 Kind regards, Ruben -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Make check on current git fails when building --with-vbox
2011/6/7 Ruben Kerkhof ru...@rubenkerkhof.com: Hi all, ./configure --without-vbox make make check produces on my F-13 and F-15 machines. make[1]: Entering directory `/home/ruben/src/libvirt/tests' make virshtest conftest sockettest nodeinfotest qparamtest virbuftest commandtest commandhelper seclabeltest hashtest qemuxml2argvtest qemuxml2xmltest qemuargv2xmltest qemuhelptest openvzutilstest vmx2xmltest xml2vmxtest networkxml2xmltest nwfilterxml2xmltest storagevolxml2xmltest storagepoolxml2xmltest nodedevxml2xmltest interfacexml2xmltest cputest eventtest make[2]: Entering directory `/home/ruben/src/libvirt/tests' CC virshtest.o CC testutils.o CCLD virshtest CC conftest.o CCLD conftest CC sockettest.o CCLD sockettest CC nodeinfotest.o CCLD nodeinfotest CC qparamtest.o CCLD qparamtest CC virbuftest.o CCLD virbuftest CC commandtest-commandtest.o CC commandtest-testutils.o CCLD commandtest CC commandhelper-commandhelper.o CCLD commandhelper CC seclabeltest.o CCLD seclabeltest CC hashtest.o CCLD hashtest CC qemuxml2argvtest.o CC testutilsqemu.o CCLD qemuxml2argvtest /usr/bin/ld: ../src/.libs/libvirt_test.a(libvirt_driver_la-lock_manager.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5' /usr/bin/ld: note: 'dlclose@@GLIBC_2.2.5' is defined in DSO /lib64/libdl.so.2 so try adding it to the linker command line /lib64/libdl.so.2: could not read symbols: Invalid operation collect2: ld returned 1 exit status make[2]: *** [qemuxml2argvtest] Error 1 make[2]: Leaving directory `/home/ruben/src/libvirt/tests' make[1]: *** [check-am] Error 2 make[1]: Leaving directory `/home/ruben/src/libvirt/tests' make: *** [check-recursive] Error 1 Kind regards, Ruben This is because of the locking manager using dlopen but not linking against libdl explicitly. The VirtualBox driver happens to link libdl in, but without it libdl is missing, We currently link libvirt with libdl when the VirtualBox driver is enabled or when driver modules are enabled. We need to link with libdl unconditional now. I'll post a patch for this. Matthias -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] [PATCH 6/9] net: Improve layout of 'info network'
On 06/07/2011 03:55 PM, Anthony Liguori wrote: On 06/07/2011 11:45 AM, Jan Kiszka wrote: Improve the layout when listing non-vlan clients via 'info network'. The result looks like this: (qemu) info network Devices not on any VLAN: orphan: net=10.0.2.0, restricted=n virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:56 \ network2: fd=5 e1000.0: model=e1000,macaddr=52:54:00:12:34:57 \ network1: net=10.0.2.0, restricted=n rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:58 ie. peers are grouped, orphans are listed as before. CC: Markus Armbrusterarm...@redhat.com Signed-off-by: Jan Kiszkajan.kis...@siemens.com There isn't a query-network yet in QMP so libvirt is probably still using the HMP version. Can someone on the libvirt side Ack/Nack about whether this patch will break libvirt? libvirt doesn't use 'info network' - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: Expose virDomainMigrateSetMaxSpeed API to virsh
On 06/07/2011 08:38 PM, Eric Blake wrote: On 06/07/2011 06:45 AM, Osier Yang wrote: API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++ tools/virsh.pod |5 + 2 files changed, 51 insertions(+), 0 deletions(-) ACK. Thanks, applied. Regards Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-php][PATCH] screenshot of remote host is available
Hi Yukihiro, On Thu, Jun 02, 2011 at 06:26:27AM +, warp.kaw...@gmail.com wrote: screenshot of remote host is available. get_domain_object make so many error to message log, so you had better not use . I must admit I don't fully understand the problem you are having, do you mean that when trying to use the PHP binding for the new API to get the screenshots you were having errors ? What kind of errors and could you describe the context a bit, it will help understanding the issue and verifying your patch, Michal could you have a look ? Seems the patch changes the way to lookup the domain, and tries to provide non-local access but I'm not 100% sure, thanks ! Daniel diff --git a/examples/libvirt.php b/examples/libvirt.php index 1ca71b6..bf903f6 100644 --- a/examples/libvirt.php +++ b/examples/libvirt.php @@ -29,9 +29,9 @@ } function domain_get_screenshot($domain) { - $dom = $this-get_domain_object($domain); - - $tmp = libvirt_domain_get_screenshot($dom); + $dom = libvirt_domain_lookup_by_uuid_string($this-conn, $domain); + $hostname = $this-get_hostname(); + $tmp = libvirt_domain_get_screenshot($dom, $hostname); return ($tmp) ? $tmp : $this-_set_last_error(); } diff --git a/src/libvirt-php.cb/src/libvirt-php.c index 87e0467..4a53e33 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1880,6 +1880,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) int port = -1; int scancode = 10; char *path; + char *hostname; path = get_feature_binary(screenshot); if (access(path, X_OK) != 0) { @@ -1887,7 +1888,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) RETURN_FALSE; } - GET_DOMAIN_FROM_ARGS(r|l,zdomain, scancode); + GET_DOMAIN_FROM_ARGS(rs|l,zdomain, hostname, scancode); xml=virDomainGetXMLDesc(domain-domain, 0); if (xml==NULL) { @@ -1912,10 +1913,16 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) RETURN_FALSE; if (childpid == 0) { + char *prm = NULL; char tmpp[8] = { 0 }; - + snprintf(tmpp, sizeof(tmpp), :%d, port); - retval = execlp(path, basename(path), tmpp, file, NULL); + prm = emalloc((sizeof(tmpp) + sizeof(hostname)) * sizeof(char)); + sprintf(prm, %s%s, hostname, tmpp); + + retval = execlp(path, basename(path), prm, file, NULL); + + free(prm); _exit( retval ); } else { -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] FreeBSD Port, update to 0.9.2 compile error
Hi, I am trying to update the port for libvirt to 0.9.2, but am receiving a new compiling error, that I have not seen yet. console.c:280: warning: declaration of 'devname' shadows a global declaration [-Wshadow] /usr/include/stdlib.h:264: warning: shadowed declaration is here [-Wshadow] CC virsh-virsh.o CCLD virsh GENvirt-xml-validate GENvirt-pki-validate gmake[3]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2/tools' gmake[2]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2/tools' Making all in docs gmake[2]: Entering directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2/docs' GENlibvirt-api.xml ./apibuild.py: not found gmake[2]: *** [libvirt-api.xml] Error 127 gmake[2]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2/docs' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2' gmake: *** [all] Error 2 *** Error code 1 Stop in /home/jhelfman/ports/devel/libvirt. Any thoughts? Thanks, Jason -- Jason Helfman System Administrator experts-exchange.com http://www.experts-exchange.com/M_4830110.html E4AD 7CF1 1396 27F6 79DD 4342 5E92 AD66 8C8C FBA5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] FreeBSD Port, update to 0.9.2 compile error
On 06/07/2011 09:27 PM, Jason Helfman wrote: Hi, I am trying to update the port for libvirt to 0.9.2, but am receiving a new compiling error, that I have not seen yet. Is this a VPATH build? `/home/jhelfman/ports/devel/libvirt/work/libvirt-0.9.2/docs' GENlibvirt-api.xml ./apibuild.py: not found What does 'gmake V=1' show for the full command being attempted here? Any thoughts? Possibly a missing make dependency, or a VPATH problem. I'll try to find some time to look into it tomorrow (it's late for me tonight). -- Eric Blake ebl...@redhat.com+1-801-349-2682 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 8/7] tests: add a test for multi function PCI device
--- .../qemuxml2argv-multifunction-pci-device.args | 15 ++ .../qemuxml2argv-multifunction-pci-device.xml | 51 tests/qemuxml2argvtest.c |4 ++ 3 files changed, 70 insertions(+), 0 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.args b/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.args new file mode 100644 index 000..ff229f2 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.args @@ -0,0 +1,15 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ +pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \ +-device lsi,id=scsi0,bus=pci.0,multifunction=on,addr=0x3.0x0 \ +-device lsi,id=scsi1,bus=pci.0,multifunction=on,addr=0x4.0x0 \ +-device lsi,id=scsi2,bus=pci.0,multifunction=on,addr=0x4.0x1 \ +-device lsi,id=scsi3,bus=pci.0,multifunction=on,addr=0x4.0x2 \ +-device lsi,id=scsi4,bus=pci.0,multifunction=on,addr=0x4.0x3 \ +-device lsi,id=scsi5,bus=pci.0,multifunction=on,addr=0x4.0x4 \ +-device lsi,id=scsi6,bus=pci.0,multifunction=on,addr=0x4.0x5 \ +-device lsi,id=scsi7,bus=pci.0,multifunction=on,addr=0x4.0x6 \ +-device lsi,id=scsi8,bus=pci.0,multifunction=on,addr=0x4.0x7 \ +-drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0 \ +-device scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0 \ +-usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,multifunction=on,addr=0x5.0x0 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.xml b/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.xml new file mode 100644 index 000..672fb61 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-multifunction-pci-device.xml @@ -0,0 +1,51 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory219136/memory + currentMemory219136/currentMemory + vcpu1/vcpu + 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='file' device='disk' + source file='/tmp/scsidisk.img'/ + target dev='sda' bus='scsi'/ + address type='drive' controller='0' bus='0' unit='0'/ +/disk +controller type='scsi' index='0' + address type='pci' domain='0x' bus='0x00' slot='0x03' function='0x0'/ +/controller +controller type='scsi' index='1' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x0'/ +/controller +controller type='scsi' index='2' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x1'/ +/controller +controller type='scsi' index='3' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x2'/ +/controller +controller type='scsi' index='4' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x3'/ +/controller +controller type='scsi' index='5' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x4'/ +/controller +controller type='scsi' index='6' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x5'/ +/controller +controller type='scsi' index='7' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x6'/ +/controller +controller type='scsi' index='8' + address type='pci' domain='0x' bus='0x00' slot='0x04' function='0x7'/ +/controller +memballoon model='virtio'/ + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index cbd9a5f..b8fd468 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -503,6 +503,10 @@ mymain(void) DO_TEST(blkiotune, false, QEMU_CAPS_NAME); DO_TEST(cputune, false, QEMU_CAPS_NAME); +DO_TEST(multifunction-pci-device, false, +QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG, +QEMU_CAPS_PCI_MULTIFUNCTION); + free(driver.stateDir); virCapabilitiesFree(driver.caps); free(map); -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list