[libvirt] [PATCH 0/3] Reflect changes in kernel 3.12 in our cgroups code
To see what changed in the kernel, see explanation in PATCH 1/3. First two patches make proper use of VIR_DOMAIN_MEMORY_PARAM_UNLIMITED, the third one just fixes a typo. Martin Kletzander (3): cgroups: Redefine what unlimited means wrt memory limits qemu: Report VIR_DOMAIN_MEMORY_PARAM_UNLIMITED properly qemu: Fix minor inconsistency in error message src/qemu/qemu_driver.c | 27 src/util/vircgroup.c | 57 ++ 2 files changed, 53 insertions(+), 31 deletions(-) -- 1.8.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/3] cgroups: Redefine what unlimited means wrt memory limits
Since kernel 3.12 (commit 34ff8dc08956098563989d8599840b130be81252 in linux-stable.git in particular) the value for 'unlimited' in cgroup memory limits changed from LLONG_MAX to ULLONG_MAX. Due to rather unfortunate choice of our VIR_DOMAIN_MEMORY_PARAM_UNLIMITED constant (which we transfer as an unsigned long long in Kibibytes), we ended up with the situation described below (applies to x86_64): - 2^64-1 (ULLONG_MAX) -- unlimited in kernel = 3.12 - 2^63-1 (LLONG_MAX) -- unlimited in kernel 3.12 - 2^63-1024 -- our PARAM_UNLIMITED scaled to Bytes - 2^53-1 -- our PARAM_UNLIMITED unscaled (in Kibibytes) This means that when any number within (2^63-1, 2^64-1] is read from memory cgroup, we are transferring that number instead of unlimited. Unfortunately, changing VIR_DOMAIN_MEMORY_PARAM_UNLIMITED would break ABI compatibility and thus we have to resort to a different solution. With this patch every value greater than PARAM_UNLIMITED means unlimited. Even though this may seem misleading, we are already in such unclear situation when running 3.12 kernel with memory limits set to 2^63. One example showing most of the problems at once (with kernel 3.12.2): # virsh memtune asdf --hard-limit 9007199254740991 --swap-hard-limit -1 # echo 12345678901234567890 \ /sys/fs/cgroup/memory/machine/asdf.libvirt-qemu/memory.soft_limit_in_bytes # virsh memtune asdf hard_limit : 18014398509481983 soft_limit : 12056327051986884 swap_hard_limit: 18014398509481983 Signed-off-by: Martin Kletzander mklet...@redhat.com --- src/util/vircgroup.c | 57 +++- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 9674328..43eb649 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1957,12 +1957,19 @@ int virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned long long *kb) { long long unsigned int limit_in_bytes; -int ret; -ret = virCgroupGetValueU64(group, - VIR_CGROUP_CONTROLLER_MEMORY, - memory.limit_in_bytes, limit_in_bytes); -if (ret == 0) -*kb = limit_in_bytes 10; +int ret = -1; + +if (virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.limit_in_bytes, limit_in_bytes) 0) +goto cleanup; + +*kb = limit_in_bytes 10; +if (*kb VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) +*kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; + +ret = 0; + cleanup: return ret; } @@ -2012,12 +2019,19 @@ int virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned long long *kb) { long long unsigned int limit_in_bytes; -int ret; -ret = virCgroupGetValueU64(group, - VIR_CGROUP_CONTROLLER_MEMORY, - memory.soft_limit_in_bytes, limit_in_bytes); -if (ret == 0) -*kb = limit_in_bytes 10; +int ret = -1; + +if (virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.soft_limit_in_bytes, limit_in_bytes) 0) +goto cleanup; + +*kb = limit_in_bytes 10; +if (*kb VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) +*kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; + +ret = 0; + cleanup: return ret; } @@ -2067,12 +2081,19 @@ int virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned long long *kb) { long long unsigned int limit_in_bytes; -int ret; -ret = virCgroupGetValueU64(group, - VIR_CGROUP_CONTROLLER_MEMORY, - memory.memsw.limit_in_bytes, limit_in_bytes); -if (ret == 0) -*kb = limit_in_bytes 10; +int ret = -1; + +if (virCgroupGetValueU64(group, + VIR_CGROUP_CONTROLLER_MEMORY, + memory.memsw.limit_in_bytes, limit_in_bytes) 0) +goto cleanup; + +*kb = limit_in_bytes 10; +if (*kb VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) +*kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; + +ret = 0; + cleanup: return ret; } -- 1.8.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/3] qemu: Report VIR_DOMAIN_MEMORY_PARAM_UNLIMITED properly
For dead domains that have no memtune limits, we return 0 instead of unlimited, this patch fixes it to return PARAM_UNLIMITED. Signed-off-by: Martin Kletzander mklet...@redhat.com --- src/qemu/qemu_driver.c | 25 + 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 66f2a0e..4b93c02 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8053,29 +8053,30 @@ qemuDomainGetMemoryParameters(virDomainPtr dom, if (flags VIR_DOMAIN_AFFECT_CONFIG) { for (i = 0; i *nparams i QEMU_NB_MEM_PARAM; i++) { virMemoryParameterPtr param = params[i]; +unsigned long long value; switch (i) { case 0: /* fill memory hard limit here */ -if (virTypedParameterAssign(param, -VIR_DOMAIN_MEMORY_HARD_LIMIT, -VIR_TYPED_PARAM_ULLONG, -persistentDef-mem.hard_limit) 0) +value = persistentDef-mem.hard_limit; +value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; +if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_HARD_LIMIT, +VIR_TYPED_PARAM_ULLONG, value) 0) goto cleanup; break; case 1: /* fill memory soft limit here */ -if (virTypedParameterAssign(param, -VIR_DOMAIN_MEMORY_SOFT_LIMIT, -VIR_TYPED_PARAM_ULLONG, -persistentDef-mem.soft_limit) 0) +value = persistentDef-mem.soft_limit; +value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; +if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SOFT_LIMIT, +VIR_TYPED_PARAM_ULLONG, value) 0) goto cleanup; break; case 2: /* fill swap hard limit here */ -if (virTypedParameterAssign(param, -VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT, -VIR_TYPED_PARAM_ULLONG, - persistentDef-mem.swap_hard_limit) 0) +value = persistentDef-mem.swap_hard_limit; +value = value ? value : VIR_DOMAIN_MEMORY_PARAM_UNLIMITED; +if (virTypedParameterAssign(param, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT, +VIR_TYPED_PARAM_ULLONG, value) 0) goto cleanup; break; -- 1.8.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 3/3] qemu: Fix minor inconsistency in error message
Signed-off-by: Martin Kletzander mklet...@redhat.com --- src/qemu/qemu_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4b93c02..a55c762 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7948,7 +7948,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, if (virCompareLimitUlong(mem_limit, swap_limit) 0) { virReportError(VIR_ERR_INVALID_ARG, %s, _(memory hard_limit tunable value must be lower - than swap_hard_limit)); + than or equal to swap_hard_limit)); goto cleanup; } } -- 1.8.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 0/4] add support for panic device
panic device is a device that enables libvirt to receive notification of guest panic event. qemu implements it by pvpanic. This series adds support for panic device. It is implemented in qemu driver only. changes in v3: - introduce generic ISA address - rename pvpanic to panic. - add RNG schemas for new elements - add tests for panic device - error out if panic device is requested but qemu is too old Hu Tao (4): conf: introduce generic ISA address conf: add support for panic device qemu: add support for -device pvpanic test: add test for panic device docs/formatdomain.html.in | 33 ++ docs/schemas/basictypes.rng| 17 docs/schemas/domaincommon.rng | 16 +++ src/conf/domain_conf.c | 135 - src/conf/domain_conf.h | 18 src/qemu/qemu_capabilities.c | 3 + src/qemu/qemu_capabilities.h | 2 + src/qemu/qemu_command.c| 16 +++ tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuxml2argvdata/qemuxml2argv-panic.args | 6 ++ tests/qemuxml2argvdata/qemuxml2argv-panic.xml | 31 ++ tests/qemuxml2argvtest.c | 3 + tests/qemuxml2xmltest.c| 2 + 15 files changed, 284 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.xml -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 4/4] test: add test for panic device
--- tests/qemuxml2argvdata/qemuxml2argv-panic.args | 6 + tests/qemuxml2argvdata/qemuxml2argv-panic.xml | 31 ++ tests/qemuxml2argvtest.c | 3 +++ tests/qemuxml2xmltest.c| 2 ++ 4 files changed, 42 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-panic.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.args b/tests/qemuxml2argvdata/qemuxml2argv-panic.args new file mode 100644 index 000..8e07cba --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-panic.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \ +-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ +-hda /dev/HostVG/QEMUGuest1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-device pvpanic,ioport=1285 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-panic.xml b/tests/qemuxml2argvdata/qemuxml2argv-panic.xml new file mode 100644 index 000..e354511 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-panic.xml @@ -0,0 +1,31 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='KiB'219136/memory + currentMemory unit='KiB'219136/currentMemory + vcpu placement='static'1/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='block' device='disk' + source dev='/dev/HostVG/QEMUGuest1'/ + target dev='hda' bus='ide'/ + address type='drive' controller='0' bus='0' target='0' unit='0'/ +/disk +controller type='usb' index='0'/ +controller type='fdc' index='0'/ +controller type='ide' index='0'/ +controller type='pci' index='0' model='pci-root'/ +memballoon model='virtio'/ +panic + address type='isa' iobase='0x505'/ +/panic + /devices +/domain diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index dad5973..537b3ce 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1115,6 +1115,9 @@ mymain(void) DO_TEST(kvm-pit-device, QEMU_CAPS_NO_KVM_PIT, QEMU_CAPS_KVM_PIT_TICK_POLICY); +DO_TEST(panic, QEMU_CAPS_DEVICE_PANIC, +QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + virObjectUnref(driver.config); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ceaaf6a..0253f4e 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -322,6 +322,8 @@ mymain(void) DO_TEST(pcihole64-none); DO_TEST(pcihole64-q35); +DO_TEST(panic); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 3/4] qemu: add support for -device pvpanic
Signed-off-by: Hu Tao hu...@cn.fujitsu.com --- src/qemu/qemu_capabilities.c | 3 +++ src/qemu/qemu_capabilities.h | 2 ++ src/qemu/qemu_command.c | 16 tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + 6 files changed, 24 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 548b988..b532dbb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -243,6 +243,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, virtio-mmio, ich9-intel-hda, kvm-pit-lost-tick-policy, + + pvpanic, /* 160 */ ); struct _virQEMUCaps { @@ -1394,6 +1396,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { usb-storage, QEMU_CAPS_DEVICE_USB_STORAGE }, { virtio-mmio, QEMU_CAPS_DEVICE_VIRTIO_MMIO }, { ich9-intel-hda, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA }, +{ pvpanic, QEMU_CAPS_DEVICE_PANIC }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 02d47c6..1aedbf9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -199,6 +199,8 @@ enum virQEMUCapsFlags { QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */ QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */ +QEMU_CAPS_DEVICE_PANIC = 160, /* -device pvpanic */ + QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 763417f..8487356 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9588,6 +9588,22 @@ qemuBuildCommandLine(virConnectPtr conn, goto error; } +if (def-panic) { +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PANIC)) { +if (def-panic-info.addr.isa.iobase 0) { +virCommandAddArg(cmd, -device); +virCommandAddArgFormat(cmd, pvpanic,ioport=%d, + def-panic-info.addr.isa.iobase); +} else { +virCommandAddArgList(cmd, -device, pvpanic, NULL); +} +} else { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s, + _(your QEMU is too old to support pvpanic)); +goto error; +} +} + if (mlock) { unsigned long long memKB; diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 09cf657..1c84ce2 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -131,4 +131,5 @@ flag name='usb-storage.removable'/ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='pvpanic'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 33ee73b..3b1b456 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -135,4 +135,5 @@ flag name='virtio-mmio'/ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='pvpanic'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index a66034a..fc9e034 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -134,4 +134,5 @@ flag name='virtio-mmio'/ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='pvpanic'/ /qemuCaps -- 1.7.11.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 1/4] conf: introduce generic ISA address
--- docs/formatdomain.html.in | 5 docs/schemas/basictypes.rng | 17 docs/schemas/domaincommon.rng | 6 + src/conf/domain_conf.c| 63 ++- src/conf/domain_conf.h| 9 +++ 5 files changed, 99 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1850a2b..054ebc6 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2425,6 +2425,11 @@ operating system. span class=sinceSince 1.0.4/span /dd + dtcodetype='isa'/code/dt + ddISA addresses have the following additional +attributes: codeiobase/code and codeirq/code. +span class=sinceSince 1.2.1/span + /dd /dl h4a name=elementsControllersControllers/a/h4 diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng index 268bc5a..34ef613 100644 --- a/docs/schemas/basictypes.rng +++ b/docs/schemas/basictypes.rng @@ -380,4 +380,21 @@ /element /define + define name=isaaddress +optional + attribute name=iobase +data type=string + param name=pattern0x[a-fA-F0-9]{1,4}/param +/data + /attribute +/optional +optional + attribute name=irq +data type=string + param name=pattern0x[a-fA-F0-9]/param +/data + /attribute +/optional + /define + /grammar diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 80848d2..3e98af9 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3921,6 +3921,12 @@ /attribute ref name=ccwaddress/ /group +group + attribute name=type +valueisa/value + /attribute + ref name=isaaddress/ +/group /choice /element /define diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 140eb80..7d5617e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -212,7 +212,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, spapr-vio, virtio-s390, ccw, - virtio-mmio) + virtio-mmio, + isa) VIR_ENUM_IMPL(virDomainDisk, VIR_DOMAIN_DISK_TYPE_LAST, block, @@ -3053,6 +3054,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: break; +case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: +if (info-addr.isa.iobase 0) +virBufferAsprintf(buf, iobase='0x%x', info-addr.isa.iobase); +if (info-addr.isa.irq 0) +virBufferAsprintf(buf, irq='0x%x', info-addr.isa.irq); +break; + default: virReportError(VIR_ERR_INTERNAL_ERROR, _(unknown address type '%d'), info-type); @@ -3389,6 +3397,40 @@ cleanup: return ret; } +static int +virDomainDeviceISAAddressParseXML(xmlNodePtr node, + virDomainDeviceISAAddressPtr addr) +{ +int ret = -1; +char *iobase; +char *irq; + +memset(addr, 0, sizeof(*addr)); + +iobase = virXMLPropString(node, iobase); +irq = virXMLPropString(node, irq); + +if (iobase +virStrToLong_ui(iobase, NULL, 16, addr-iobase) 0) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(Cannot parse address 'iobase' attribute)); +goto cleanup; +} + +if (irq +virStrToLong_ui(irq, NULL, 16, addr-irq) 0) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(Cannot parse address 'irq' attribute)); +goto cleanup; +} + +ret = 0; +cleanup: +VIR_FREE(iobase); +VIR_FREE(irq); +return ret; +} + /* Parse the XML definition for a device address * @param node XML nodeset to parse for device address definition */ @@ -3520,6 +3562,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: break; +case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: +if (virDomainDeviceISAAddressParseXML(address, info-addr.isa) 0) +goto cleanup; +break; + default: /* Should not happen */ virReportError(VIR_ERR_INTERNAL_ERROR, @@ -12916,6 +12963,20 @@ virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src, return false; } break; + +case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: +if (src-addr.isa.iobase != dst-addr.isa.iobase || +src-addr.isa.irq != dst-addr.isa.irq) { +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _(Target device isa address %d:%d + does not match source %d:%d), + dst-addr.isa.iobase, + dst-addr.isa.irq, + src-addr.isa.iobase, +
[libvirt] [PATCH v3 2/4] conf: add support for panic device
panic device is a device that enables libvirt to receive notification of guest panic event. --- docs/formatdomain.html.in | 28 + docs/schemas/domaincommon.rng | 10 ++ src/conf/domain_conf.c| 72 +++ src/conf/domain_conf.h| 9 ++ 4 files changed, 119 insertions(+) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 054ebc6..c8f213e 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5085,6 +5085,34 @@ qemu-kvm -net nic,model=? /dev/null /dd /dl +h4a name=elementsPanicpanic device/a/h4 +p + panic device enables libvirt to receive panic notification from a QEMU + guest. + span class=sinceSince 1.2.1, QEMU and KVM only/span +/p +p + Example: usage of panic configuration +/p +pre + ... + lt;devicesgt; +lt;panicgt; + lt;address type='isa' iobase='0x505'/gt; +lt;/panicgt; + lt;/devicesgt; + ... +/pre + dl +dtcodeaddress/code/dt +dd + p +address of panic. The default ioport is 0x505. Most users +don't need to specify an address. + /p +/dd + /dl + h3a name=seclabelSecurity label/a/h3 p diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 3e98af9..8ae96f2 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3556,6 +3556,9 @@ optional ref name=nvram/ /optional +optional + ref name=panic/ +/optional /interleave /element /define @@ -4409,4 +4412,11 @@ /data /choice /define + define name=panic +element name=panic + optional +ref name=address/ + /optional +/element + /define /grammar diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7d5617e..233b848 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1877,6 +1877,15 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource) VIR_FREE(resource); } +void +virDomainPanicDefFree(virDomainPanicDefPtr panic) +{ +if (!panic) +return; + +virDomainDeviceInfoClear(panic-info); +VIR_FREE(panic); +} void virDomainDefFree(virDomainDefPtr def) { @@ -1965,6 +1974,8 @@ void virDomainDefFree(virDomainDefPtr def) virDomainTPMDefFree(def-tpm); +virDomainPanicDefFree(def-panic); + VIR_FREE(def-idmap.uidmap); VIR_FREE(def-idmap.gidmap); @@ -10673,6 +10684,22 @@ cleanup: return idmap; } +static virDomainPanicDefPtr +virDomainPanicDefParseXML(xmlNodePtr node) +{ +virDomainPanicDefPtr panic; + +if (VIR_ALLOC(panic) 0) +return NULL; + +if (virDomainDeviceInfoParseXML(node, NULL, panic-info, 0) 0) +goto error; + +return panic; +error: +virDomainPanicDefFree(panic); +return NULL; +} /* Parse the XML definition for a vcpupin or emulatorpin. * @@ -12500,6 +12527,27 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); +/* analysis of the panic devices */ +def-panic = NULL; +if ((n = virXPathNodeSet(./devices/panic, ctxt, nodes)) 0) { +goto error; +} +if (n 1) { +virReportError(VIR_ERR_XML_ERROR, %s, + _(only a single panic device is supported)); +goto error; +} +if (n 0) { +virDomainPanicDefPtr panic = +virDomainPanicDefParseXML(nodes[0]); +if (!panic) +goto error; + +def-panic = panic; +VIR_FREE(nodes); +} + + /* analysis of the user namespace mapping */ if ((n = virXPathNodeSet(./idmap/uid, ctxt, nodes)) 0) goto error; @@ -13589,6 +13637,13 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, return true; } +static bool +virDomainPanicCheckABIStability(virDomainPanicDefPtr src, +virDomainPanicDefPtr dst) +{ +return virDomainDeviceInfoCheckABIStability(src-info, dst-info); +} + /* This compares two configurations and looks for any differences * which will affect the guest ABI. This is primarily to allow @@ -13930,6 +13985,9 @@ virDomainDefCheckABIStability(virDomainDefPtr src, if (!virDomainRNGDefCheckABIStability(src-rng, dst-rng)) return false; +if (!virDomainPanicCheckABIStability(src-panic, dst-panic)) +return false; + return true; } @@ -15776,6 +15834,16 @@ virDomainWatchdogDefFormat(virBufferPtr buf, return 0; } +static int virDomainPanicDefFormat(virBufferPtr buf, + virDomainPanicDefPtr def) +{ +virBufferAddLit(buf, panic\n); +if (virDomainDeviceInfoFormat(buf, def-info, 0) 0) +return -1; +virBufferAddLit(buf, /panic\n); + +return 0; +} static int virDomainRNGDefFormat(virBufferPtr buf, @@ -17199,6 +17267,10 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def-nvram)
Re: [libvirt] [PATCH] qemu: conf: Work around race condition on libvirt start
On Sat, Dec 07, 2013 at 02:03:00AM -0500, Adam Walters wrote: This patch works around a race condition present during libvirt startup. The race condition only applies when using storage pool volumes for domain disks, and even then, only when restarting libvirt with running domains. The gist of the patch is simply to enter a (limited) retry loop during qemuTranslateDiskSourcePool. This particular implementation does have a slight drawback, though. Within that function, I can not determine if we are currently starting libvirt, or if we are just starting up a domain. In the latter case, this could cause a 800ms delay in reporting an error that the storage pool is inactive. I am happy to report, however, that with this patch, domains continue to run without restarts regardless of how often I restart libvirt. I have a fairly fast hypervisor, and have never seen it try more than one iteration of the retry loop unless I purposely set one of the storage pools to be inactive. --- src/qemu/qemu_conf.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c28908a..2e52fbf 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1359,6 +1359,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, virStorageVolInfo info; int ret = -1; virErrorPtr savedError = NULL; +int attempt = 0; +int poolAutostart; if (def-type != VIR_DOMAIN_DISK_TYPE_VOLUME) return 0; @@ -1369,7 +1371,16 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, if (!(pool = virStoragePoolLookupByName(conn, def-srcpool-pool))) return -1; +retry: if (virStoragePoolIsActive(pool) != 1) { +if (!(virStoragePoolGetAutostart(pool, poolAutostart) 0)) +if (poolAutostart attempt 4) { +VIR_DEBUG(Waiting for storage pool '%s' to activate, + def-srcpool-pool); +usleep(200*1000); /* sleep 200ms */ +attempt++; +goto retry; +} virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(storage pool '%s' containing volume '%s' is not active), This is rather dubious and points toa bug elsewhere. The storage driver should complete its autostart before the QEMU driver even starts its own initialization. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: conf: Work around race condition on libvirt start
On 12/09/13 11:56, Daniel P. Berrange wrote: On Sat, Dec 07, 2013 at 02:03:00AM -0500, Adam Walters wrote: This patch works around a race condition present during libvirt startup. The race condition only applies when using storage pool volumes for domain disks, and even then, only when restarting libvirt with running domains. The gist of the patch is simply to enter a (limited) retry loop during qemuTranslateDiskSourcePool. This particular implementation does have a slight drawback, though. Within that function, I can not determine if we are currently starting libvirt, or if we are just starting up a domain. In the latter case, this could cause a 800ms delay in reporting an error that the storage pool is inactive. I am happy to report, however, that with this patch, domains continue to run without restarts regardless of how often I restart libvirt. I have a fairly fast hypervisor, and have never seen it try more than one iteration of the retry loop unless I purposely set one of the storage pools to be inactive. --- src/qemu/qemu_conf.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c28908a..2e52fbf 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1359,6 +1359,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, virStorageVolInfo info; int ret = -1; virErrorPtr savedError = NULL; +int attempt = 0; +int poolAutostart; if (def-type != VIR_DOMAIN_DISK_TYPE_VOLUME) return 0; @@ -1369,7 +1371,16 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, if (!(pool = virStoragePoolLookupByName(conn, def-srcpool-pool))) return -1; +retry: if (virStoragePoolIsActive(pool) != 1) { +if (!(virStoragePoolGetAutostart(pool, poolAutostart) 0)) +if (poolAutostart attempt 4) { +VIR_DEBUG(Waiting for storage pool '%s' to activate, + def-srcpool-pool); +usleep(200*1000); /* sleep 200ms */ +attempt++; +goto retry; +} virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(storage pool '%s' containing volume '%s' is not active), This is rather dubious and points toa bug elsewhere. The storage driver should complete its autostart before the QEMU driver even starts its own initialization. We definitely need to make sure that storage is available at that point. This particular regression was introduced by my commit e1a4d08baf9a although was latently present for a few releases now as the volume code isn't used that much probably. Prior to my patch that added the check whether the pool is available we were blindly assuming that the pool was online. Pool drivers like gluster don't have their internal structures initialized if the pool isn't started and thus the translation would fail either way. Also the translation function is called separately from the reconnection code, thus we can pass different arguments to it so we don't spoil the normal code paths with unnecessary delays and other stuff. The question is what to do with domains that have storage on pools that can't be initialized. Should we kill those? Should we skip translation of the source and then something later may fail? Peter Daniel 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] qemu: conf: Work around race condition on libvirt start
On Mon, Dec 09, 2013 at 12:15:52PM +0100, Peter Krempa wrote: On 12/09/13 11:56, Daniel P. Berrange wrote: On Sat, Dec 07, 2013 at 02:03:00AM -0500, Adam Walters wrote: This patch works around a race condition present during libvirt startup. The race condition only applies when using storage pool volumes for domain disks, and even then, only when restarting libvirt with running domains. The gist of the patch is simply to enter a (limited) retry loop during qemuTranslateDiskSourcePool. This particular implementation does have a slight drawback, though. Within that function, I can not determine if we are currently starting libvirt, or if we are just starting up a domain. In the latter case, this could cause a 800ms delay in reporting an error that the storage pool is inactive. I am happy to report, however, that with this patch, domains continue to run without restarts regardless of how often I restart libvirt. I have a fairly fast hypervisor, and have never seen it try more than one iteration of the retry loop unless I purposely set one of the storage pools to be inactive. --- src/qemu/qemu_conf.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c28908a..2e52fbf 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1359,6 +1359,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, virStorageVolInfo info; int ret = -1; virErrorPtr savedError = NULL; +int attempt = 0; +int poolAutostart; if (def-type != VIR_DOMAIN_DISK_TYPE_VOLUME) return 0; @@ -1369,7 +1371,16 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, if (!(pool = virStoragePoolLookupByName(conn, def-srcpool-pool))) return -1; +retry: if (virStoragePoolIsActive(pool) != 1) { +if (!(virStoragePoolGetAutostart(pool, poolAutostart) 0)) +if (poolAutostart attempt 4) { +VIR_DEBUG(Waiting for storage pool '%s' to activate, + def-srcpool-pool); +usleep(200*1000); /* sleep 200ms */ +attempt++; +goto retry; +} virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _(storage pool '%s' containing volume '%s' is not active), This is rather dubious and points toa bug elsewhere. The storage driver should complete its autostart before the QEMU driver even starts its own initialization. We definitely need to make sure that storage is available at that point. This particular regression was introduced by my commit e1a4d08baf9a although was latently present for a few releases now as the volume code isn't used that much probably. Prior to my patch that added the check whether the pool is available we were blindly assuming that the pool was online. Pool drivers like gluster don't have their internal structures initialized if the pool isn't started and thus the translation would fail either way. Also the translation function is called separately from the reconnection code, thus we can pass different arguments to it so we don't spoil the normal code paths with unnecessary delays and other stuff. The question is what to do with domains that have storage on pools that can't be initialized. Should we kill those? Should we skip translation of the source and then something later may fail? We do we need todo translation when restarting libvirtd ? Surely we should only do translation when initialy starting a guest, and then remember that data thereafter. If we ever try re-translating data later for a running guest, we risk getting different answers which would be bad. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] save-image-edit fails to change the memory configuration of the image
On Mon, Dec 09, 2013 at 12:43:28 +0530, Shivaprasad bhat wrote: Hi, I see the below error when i change the memory. virsh save-image-edit /MANAS/rhel7VM1-running-save2 --running error: unsupported configuration: Target domain max memory 4194304 does not match source 2097152 Failed. Try again? [y,n,f,?]: n error: unsupported configuration: Target domain max memory 4194304 does not match source 2097152 Any idea why is this disallowed ? You can only change parameters that don't change guest ABI. Changing maximum memory changes this ABI (it changes what hardware the guest OS sees). Not to mention that you can't increase max memory for a running domain anyway as memory hotplug is not implemented yet. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Libvirt support for KVM/ARM on armv7l hardware
I have found Libvirt supporting for armv7b in http://libvirt.org/news.html. But armv7l is not found there. Does Libvirt support run KVM/ARM for hardware virtualization on armv7l platform? Thanks! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/3] qemu: hotplug: Fix adding USB devices to the driver list
On Thu, Dec 05, 2013 at 15:40:28 -0500, Cole Robinson wrote: We were unconditionally removing the device from the host list, when it should only be done on error. This fixes USB collision detection when hotplugging the same device to two guests. --- src/qemu/qemu_hotplug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index b7512a7..16b990d 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1515,9 +1515,9 @@ cleanup: virSecurityManagerRestoreHostdevLabel(driver-securityManager, vm-def, hostdev, NULL) 0) VIR_WARN(Unable to restore host device labelling on hotplug fail); +if (added) +virUSBDeviceListSteal(driver-activeUsbHostdevs, usb); } -if (added) -virUSBDeviceListSteal(driver-activeUsbHostdevs, usb); if (list usb !virUSBDeviceListFind(list, usb) !virUSBDeviceListFind(driver-activeUsbHostdevs, usb)) ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/3] qemu: hotplug: Fix double free on USB collision
On Thu, Dec 05, 2013 at 15:40:27 -0500, Cole Robinson wrote: If we hit a collision, we free the USB device while it is still part of our temporary USBDeviceList. When the list is unref'd, the device is free'd again. Make the initial device freeing dependent on whether it is present in the temporary list or not. --- src/qemu/qemu_hotplug.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bff9e23..b7512a7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1518,7 +1518,10 @@ cleanup: } if (added) virUSBDeviceListSteal(driver-activeUsbHostdevs, usb); -virUSBDeviceFree(usb); +if (list usb +!virUSBDeviceListFind(list, usb) +!virUSBDeviceListFind(driver-activeUsbHostdevs, usb)) +virUSBDeviceFree(usb); virObjectUnref(list); VIR_FREE(devstr); return ret; ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] qemu: hotplug: Only label hostdev after checking device conflicts
On Thu, Dec 05, 2013 at 15:40:26 -0500, Cole Robinson wrote: Similar to what Jiri did for cgroup setup/teardown in 05e149f94, push it all into the device handler functions so we can do the necessary prep work before claiming the device. This also fixes hotplugging USB devices by product/vendor (virt-manager's default behavior): https://bugzilla.redhat.com/show_bug.cgi?id=1016511 --- src/qemu/qemu_hotplug.c | 42 ++ 1 file changed, 34 insertions(+), 8 deletions(-) ACK Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] save-image-edit fails to change the memory configuration of the image
Thanks Jirka. Regards, Shiva On Mon, Dec 9, 2013 at 5:23 PM, Jiri Denemark jdene...@redhat.com wrote: On Mon, Dec 09, 2013 at 12:43:28 +0530, Shivaprasad bhat wrote: Hi, I see the below error when i change the memory. virsh save-image-edit /MANAS/rhel7VM1-running-save2 --running error: unsupported configuration: Target domain max memory 4194304 does not match source 2097152 Failed. Try again? [y,n,f,?]: n error: unsupported configuration: Target domain max memory 4194304 does not match source 2097152 Any idea why is this disallowed ? You can only change parameters that don't change guest ABI. Changing maximum memory changes this ABI (it changes what hardware the guest OS sees). Not to mention that you can't increase max memory for a running domain anyway as memory hotplug is not implemented yet. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: conf: Work around race condition on libvirt start
Wow, you guys certainly wake up bright and early on Monday morning. Regarding the patch, I knew before I submitted it that it likely wouldn't be to final solution to the overall problem. I just have issues leaving things unresolved (or at least un-hacked-around, anyway) before I can get to sleep. Besides, it at least hacks around my problem of domain restarts, and by posting it, if someone else has the same issue, they could roll their own package with that patch to resolve it at least temporarily. As far as the actual problem, I would agree that the storage driver should complete initialization and autostart before the QEMU driver does anything. I originally implemented a system like that (basically, I added an enum-backed field to the struct used for the state drivers), then created two separate lists in the driver initialization function (one for hypervisors, the other for everything else). Finally, I initialized and auto-started everything else, then did the hypervisors. I wanted to implement a proper driver dependency tree, but just couldn't figure out how to do it other than building the tree manually. That, unfortunately, showed a new bug. The storage driver opens a connection (hardcoded) to 'qemu:///' during auto-start because it (or rather its backends) needs to be able to lookup storage pools and secrets by name/uuid. Both of those existing API functions require a connection in order to accomplish. After thinking about it over the weekend, I came up with a possible solution for the circular dependency issue, though. What if a new connection URI were defined? The URI would not implement any domain-related API functions, only the API functions that would be considered global, like secret lookups, storage pool lookups, etc. The URI could be something like 'conf:///' and while it may be available to anyone, would likely only be useful within the libvirt code. That would allow the storage backends (and other sections of code) to have a valid hardcoded connection URI for when they require data from a connection, but are called when a connection won't exist, like during their auto-start sequence. Outside of a new connection URI, the other option would be to provide libvirt code a method to perform those lookups without needing a connection. That may already exist for all I know, but if it does, not everything was changed to use it. Luckily, it looks like only two sections of code actually open hard-coded connections (storage/storage_driver.c and lxc/lxc_process.c). I haven't looked into why lxc_process opens one, just found it in a grep of the code. Lastly, I also agree that translating domain XML into a QEMU command line during a restart of libvirt shouldn't be required. If the command line arguments are required during initialization, perhaps they could be added to the domain XML after the initial translation? It'd be ugly to look at, but would serve to persist that data across libvirt restarts since the running version of the domain XML is stored under /var/run (or /run) alongside the PID. That, however, is actually a separate issue from the storage driver requiring a connection to QEMU during auto-start. On Mon, Dec 9, 2013 at 6:20 AM, Daniel P. Berrange berra...@redhat.comwrote: On Mon, Dec 09, 2013 at 12:15:52PM +0100, Peter Krempa wrote: On 12/09/13 11:56, Daniel P. Berrange wrote: On Sat, Dec 07, 2013 at 02:03:00AM -0500, Adam Walters wrote: This patch works around a race condition present during libvirt startup. The race condition only applies when using storage pool volumes for domain disks, and even then, only when restarting libvirt with running domains. The gist of the patch is simply to enter a (limited) retry loop during qemuTranslateDiskSourcePool. This particular implementation does have a slight drawback, though. Within that function, I can not determine if we are currently starting libvirt, or if we are just starting up a domain. In the latter case, this could cause a 800ms delay in reporting an error that the storage pool is inactive. I am happy to report, however, that with this patch, domains continue to run without restarts regardless of how often I restart libvirt. I have a fairly fast hypervisor, and have never seen it try more than one iteration of the retry loop unless I purposely set one of the storage pools to be inactive. --- src/qemu/qemu_conf.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c28908a..2e52fbf 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1359,6 +1359,8 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, virStorageVolInfo info; int ret = -1; virErrorPtr savedError = NULL; +int attempt = 0; +int poolAutostart; if (def-type != VIR_DOMAIN_DISK_TYPE_VOLUME) return 0; @@ -1369,7 +1371,16 @@
[libvirt] [PATCH 0/2] Introduce max_anonymous_clients
https://bugzilla.redhat.com/show_bug.cgi?id=981729 So far we can limit how many clients are connected, how many are waiting in accept() line but we could not control the count of accepted but not authenticated yet. Michal Privoznik (2): virNetServer: Introduce unauth clients counter daemon: Introduce max_anonymous_clients daemon/libvirtd-config.c| 1 + daemon/libvirtd-config.h| 1 + daemon/libvirtd.aug | 1 + daemon/libvirtd.c | 1 + daemon/libvirtd.conf| 3 ++ daemon/remote.c | 21 - daemon/test_libvirtd.aug.in | 1 + src/locking/lock_daemon.c | 4 +-- src/lxc/lxc_controller.c| 2 +- src/rpc/virnetserver.c | 73 + src/rpc/virnetserver.h | 3 ++ 11 files changed, 95 insertions(+), 16 deletions(-) -- 1.8.5.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/2] virNetServer: Introduce unauth clients counter
The counter gets incremented on each unauthenticated client added to the server and decremented whenever the client authenticates. Signed-off-by: Michal Privoznik mpriv...@redhat.com --- daemon/remote.c| 21 + src/rpc/virnetserver.c | 36 +--- src/rpc/virnetserver.h | 2 ++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index decaecc..8354376 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -2298,7 +2298,7 @@ cleanup: /*-*/ static int -remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED, +remoteDispatchAuthList(virNetServerPtr server, virNetServerClientPtr client, virNetMessagePtr msg ATTRIBUTE_UNUSED, virNetMessageErrorPtr rerr, @@ -2328,6 +2328,7 @@ remoteDispatchAuthList(virNetServerPtr server ATTRIBUTE_UNUSED, goto cleanup; VIR_INFO(Bypass polkit auth for privileged client %s, ident); virNetServerClientSetAuth(client, 0); +virNetServerClientAuth(server, false); auth = VIR_NET_SERVER_SERVICE_AUTH_NONE; VIR_FREE(ident); } @@ -2443,7 +2444,8 @@ authfail: * Returns 0 if ok, -1 on error, -2 if rejected */ static int -remoteSASLFinish(virNetServerClientPtr client) +remoteSASLFinish(virNetServerPtr server, + virNetServerClientPtr client) { const char *identity; struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); @@ -2468,6 +2470,7 @@ remoteSASLFinish(virNetServerClientPtr client) return -2; virNetServerClientSetAuth(client, 0); +virNetServerClientAuth(server, false); virNetServerClientSetSASLSession(client, priv-sasl); VIR_DEBUG(Authentication successful %d, virNetServerClientGetFD(client)); @@ -2489,7 +2492,7 @@ error: * This starts the SASL authentication negotiation. */ static int -remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED, +remoteDispatchAuthSaslStart(virNetServerPtr server, virNetServerClientPtr client, virNetMessagePtr msg ATTRIBUTE_UNUSED, virNetMessageErrorPtr rerr, @@ -2547,7 +2550,7 @@ remoteDispatchAuthSaslStart(virNetServerPtr server ATTRIBUTE_UNUSED, ret-complete = 0; } else { /* Check username whitelist ACL */ -if ((err = remoteSASLFinish(client)) 0) { +if ((err = remoteSASLFinish(server, client)) 0) { if (err == -2) goto authdeny; else @@ -2587,7 +2590,7 @@ error: static int -remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED, +remoteDispatchAuthSaslStep(virNetServerPtr server, virNetServerClientPtr client, virNetMessagePtr msg ATTRIBUTE_UNUSED, virNetMessageErrorPtr rerr, @@ -2645,7 +2648,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED, ret-complete = 0; } else { /* Check username whitelist ACL */ -if ((err = remoteSASLFinish(client)) 0) { +if ((err = remoteSASLFinish(server, client)) 0) { if (err == -2) goto authdeny; else @@ -2730,7 +2733,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server ATTRIBUTE_UNUSED, #if WITH_POLKIT1 static int -remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED, +remoteDispatchAuthPolkit(virNetServerPtr server, virNetServerClientPtr client, virNetMessagePtr msg ATTRIBUTE_UNUSED, virNetMessageErrorPtr rerr, @@ -2822,6 +2825,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED, ret-complete = 1; virNetServerClientSetAuth(client, 0); +virNetServerClientAuth(server, false); virMutexUnlock(priv-lock); virCommandFree(cmd); VIR_FREE(pkout); @@ -2862,7 +2866,7 @@ authdeny: } #elif WITH_POLKIT0 static int -remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED, +remoteDispatchAuthPolkit(virNetServerPtr server, virNetServerClientPtr client, virNetMessagePtr msg ATTRIBUTE_UNUSED, virNetMessageErrorPtr rerr, @@ -2977,6 +2981,7 @@ remoteDispatchAuthPolkit(virNetServerPtr server ATTRIBUTE_UNUSED, ret-complete = 1; virNetServerClientSetAuth(client, 0); +virNetServerClientAuth(server, false); virMutexUnlock(priv-lock); VIR_FREE(ident); return 0; diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 8907768..1b2c6d4 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -87,9 +87,10 @@ struct _virNetServer { size_t nprograms;
[libvirt] [PATCH 2/2] daemon: Introduce max_anonymous_clients
https://bugzilla.redhat.com/show_bug.cgi?id=981729 This config tunable allows users to determine the maximum number of accepted but yet not authenticated users. Signed-off-by: Michal Privoznik mpriv...@redhat.com --- daemon/libvirtd-config.c| 1 + daemon/libvirtd-config.h| 1 + daemon/libvirtd.aug | 1 + daemon/libvirtd.c | 1 + daemon/libvirtd.conf| 3 +++ daemon/test_libvirtd.aug.in | 1 + src/locking/lock_daemon.c | 4 ++-- src/lxc/lxc_controller.c| 2 +- src/rpc/virnetserver.c | 37 +++-- src/rpc/virnetserver.h | 1 + 10 files changed, 47 insertions(+), 5 deletions(-) diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c index c816fda..04482c5 100644 --- a/daemon/libvirtd-config.c +++ b/daemon/libvirtd-config.c @@ -415,6 +415,7 @@ daemonConfigLoadOptions(struct daemonConfig *data, GET_CONF_INT(conf, filename, max_workers); GET_CONF_INT(conf, filename, max_clients); GET_CONF_INT(conf, filename, max_queued_clients); +GET_CONF_INT(conf, filename, max_anonymous_clients); GET_CONF_INT(conf, filename, prio_workers); diff --git a/daemon/libvirtd-config.h b/daemon/libvirtd-config.h index a24d5d2..66dc80b 100644 --- a/daemon/libvirtd-config.h +++ b/daemon/libvirtd-config.h @@ -64,6 +64,7 @@ struct daemonConfig { int max_workers; int max_clients; int max_queued_clients; +int max_anonymous_clients; int prio_workers; diff --git a/daemon/libvirtd.aug b/daemon/libvirtd.aug index 70fce5c..5a0807c 100644 --- a/daemon/libvirtd.aug +++ b/daemon/libvirtd.aug @@ -57,6 +57,7 @@ module Libvirtd = | int_entry max_workers | int_entry max_clients | int_entry max_queued_clients +| int_entry max_anonymous_clients | int_entry max_requests | int_entry max_client_requests | int_entry prio_workers diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 49c42ad..61c706c 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -1367,6 +1367,7 @@ int main(int argc, char **argv) { config-max_workers, config-prio_workers, config-max_clients, +config-max_anonymous_clients, config-keepalive_interval, config-keepalive_count, !!config-keepalive_required, diff --git a/daemon/libvirtd.conf b/daemon/libvirtd.conf index 5353927..28d3735 100644 --- a/daemon/libvirtd.conf +++ b/daemon/libvirtd.conf @@ -263,6 +263,9 @@ # connection succeeds. #max_queued_clients = 1000 +# The maximum length of queue of accepted but not yet not +# authenticated clients. +#max_anonymous_clients = 20 # The minimum limit sets the number of workers to start up # initially. If the number of active clients exceeds this, diff --git a/daemon/test_libvirtd.aug.in b/daemon/test_libvirtd.aug.in index a7e8515..b03451c 100644 --- a/daemon/test_libvirtd.aug.in +++ b/daemon/test_libvirtd.aug.in @@ -36,6 +36,7 @@ module Test_libvirtd = } { max_clients = 20 } { max_queued_clients = 1000 } +{ max_anonymous_clients = 20 } { min_workers = 5 } { max_workers = 20 } { prio_workers = 5 } diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 35ccb4e..c97bc61 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -143,8 +143,8 @@ virLockDaemonNew(virLockDaemonConfigPtr config, bool privileged) } if (!(lockd-srv = virNetServerNew(1, 1, 0, config-max_clients, - -1, 0, - false, NULL, + config-max_clients, + -1, 0, false, NULL, virLockDaemonClientNew, virLockDaemonClientPreExecRestart, virLockDaemonClientFree, diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c013147..578a135 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -736,7 +736,7 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl) LXC_STATE_DIR, ctrl-name) 0) return -1; -if (!(ctrl-server = virNetServerNew(0, 0, 0, 1, +if (!(ctrl-server = virNetServerNew(0, 0, 0, 1, 1, -1, 0, false, NULL, virLXCControllerClientPrivateNew, diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 1b2c6d4..bbb91d4 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@
[libvirt] [PATCH] docs: Enhance memoryBacking/locked documentation
Mention the need to set memtune/hard_limit. https://bugzilla.redhat.com/show_bug.cgi?id=1035954 Signed-off-by: Jiri Denemark jdene...@redhat.com --- docs/formatdomain.html.in | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1850a2b..b4ee9f3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -638,7 +638,10 @@ dtcodelocked/code/dt ddWhen set and supported by the hypervisor, memory pages belonging to the domain will be locked in host's memory and the host will not -be allowed to swap them out. +be allowed to swap them out. For QEMU/KVM this requires +codehard_limit/code a href=#elementsMemoryTuningmemory tunning/a +element to be used and set to the maximum memory configured for the +domain plus any memory consumed by the QEMU process itself. span class=sinceSince 1.0.6/span/dd /dl -- 1.8.5.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python 1/3] setup: Drop unused exception variable
On Wed, Dec 04, 2013 at 02:34:06PM -0600, Doug Goldstein wrote: Drop the unused exception variable in setup.py. This has the benefit of dropping syntax that is not valid with Python 3. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 561157c..24d4cf2 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ try: spawn([pkgcfg, --atleast-version=%s % MIN_LIBVIRT_LXC, libvirt]) -except DistutilsExecError,e: +except DistutilsExecError: have_libvirt_lxc=False def get_pkgconfig_data(args, mod, required=True): ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python 1/2] override: Fix exception handling syntax
On Fri, Dec 06, 2013 at 04:25:09PM -0600, Doug Goldstein wrote: Python 3 no longer accepts 'except Exception, e:' as valid while Python 2.4 does not accept the new syntax 'except Exception as e:' so this uses a fall back method that is compatible with both. --- libvirt-override-virStream.py | 3 ++- libvirt-override.py | 8 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-python 2/2] test: Invoke print(...) instead of print ...
On Fri, Dec 06, 2013 at 04:25:10PM -0600, Doug Goldstein wrote: The 'print' statement no longer exists in Python 3 and now must be called as a function. This is compatible down to Python 2.4 as we are not using any special syntax of the function. --- sanitytest.py | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) ACK 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 python 01/14] examples: Invoke print(...) instead of print ...
From: Daniel P. Berrange berra...@redhat.com The 'print' method must be called as a function in python3, ie with brackets. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- examples/consolecallback.py | 6 ++-- examples/dominfo.py | 14 +- examples/domrestore.py | 17 ++-- examples/domsave.py | 15 +- examples/domstart.py| 19 ++--- examples/esxlist.py | 14 +- examples/event-test.py | 68 ++--- examples/topology.py| 14 +- 8 files changed, 82 insertions(+), 85 deletions(-) diff --git a/examples/consolecallback.py b/examples/consolecallback.py index d8e33a9..c539a92 100644 --- a/examples/consolecallback.py +++ b/examples/consolecallback.py @@ -62,14 +62,14 @@ def lifecycle_callback (connection, domain, event, detail, console): # main if len(sys.argv) != 3: -print Usage:, sys.argv[0], URI UUID -print for example:, sys.argv[0], 'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81' +print(Usage:, sys.argv[0], URI UUID) +print(for example:, sys.argv[0], 'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81') sys.exit(1) uri = sys.argv[1] uuid = sys.argv[2] -print Escape character is ^] +print(Escape character is ^]) logging.basicConfig(filename='msg.log', level=logging.DEBUG) logging.info(URI: %s, uri) logging.info(UUID: %s, uuid) diff --git a/examples/dominfo.py b/examples/dominfo.py index bfa3ca3..d3049cd 100755 --- a/examples/dominfo.py +++ b/examples/dominfo.py @@ -8,15 +8,15 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DOMAIN' % sys.argv[0] - print ' Print information about the domain DOMAIN' + print('Usage: %s DOMAIN' % sys.argv[0]) + print(' Print information about the domain DOMAIN') def print_section(title): -print \n%s % title -print = * 60 +print(\n%s % title) +print(= * 60) def print_entry(key, value): -print %-10s %-10s % (key, value) +print(%-10s %-10s % (key, value)) def print_xml(key, ctx, path): res = ctx.xpathEval(path) @@ -36,14 +36,14 @@ name = sys.argv[1] # Connect to libvirt conn = libvirt.openReadOnly(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) try: dom = conn.lookupByName(name) # Annoyiingly, libvirt prints its own error message here except libvirt.libvirtError: -print Domain %s is not running % name +print(Domain %s is not running % name) sys.exit(0) info = dom.info() diff --git a/examples/domrestore.py b/examples/domrestore.py index fffc90f..06fdfbc 100755 --- a/examples/domrestore.py +++ b/examples/domrestore.py @@ -8,10 +8,10 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DIR' % sys.argv[0] - print ' Restore all the domains contained in DIR' - print ' It is assumed that all files in DIR are' - print ' images of domU\'s previously created with save' + print('Usage: %s DIR' % sys.argv[0]) + print(' Restore all the domains contained in DIR') + print(' It is assumed that all files in DIR are') + print(' images of domU\'s previously created with save') if len(sys.argv) != 2: usage() @@ -22,15 +22,14 @@ imgs = os.listdir(dir) conn = libvirt.open(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) for img in imgs: file = os.path.join(dir, img) -print Restoring %s ... % img, -sys.stdout.flush() +print(Restoring %s ... % img) ret = conn.restore(file) if ret == 0: -print done +print(done) else: -print error %d % ret +print(error %d % ret) diff --git a/examples/domsave.py b/examples/domsave.py index bac4536..727217c 100755 --- a/examples/domsave.py +++ b/examples/domsave.py @@ -8,9 +8,9 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DIR' % sys.argv[0] - print ' Save all currently running domU\'s into DIR' - print ' DIR must exist and be writable by this process' + print('Usage: %s DIR' % sys.argv[0]) + print(' Save all currently running domU\'s into DIR') + print(' DIR must exist and be writable by this process') if len(sys.argv) != 2: usage() @@ -20,7 +20,7 @@ dir = sys.argv[1] conn = libvirt.open(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) doms = conn.listDomainsID() @@ -28,13 +28,12 @@ for id in doms: if id == 0: continue dom = conn.lookupByID(id) -print Saving %s[%d] ... % (dom.name(), id), -sys.stdout.flush() +print(Saving %s[%d] ... % (dom.name(), id)) path = os.path.join(dir, dom.name()) ret = dom.save(path)
[libvirt] [PATCH python 03/14] override: Fix native module registration to work with Python3
From: Daniel P. Berrange berra...@redhat.com The way native modules are registered has completely changed, so the code must be #ifdef'd for Python2 3 Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 73 +++ libvirt-override.c | 75 - libvirt-qemu-override.c | 73 +++ 3 files changed, 166 insertions(+), 55 deletions(-) diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 03b00b0..60b41d8 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -21,10 +21,18 @@ #include libvirt-utils.h #include build/libvirt-lxc.h -#ifndef __CYGWIN__ -extern void initlibvirtmod_lxc(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject *PyInit_libvirtmod_lxc(void); +# else +extern PyObject *PyInit_cygvirtmod_lxc(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod_lxc(void); +# else extern void initcygvirtmod_lxc(void); +# endif #endif #if 0 @@ -110,30 +118,59 @@ static PyMethodDef libvirtLxcMethods[] = { {NULL, NULL, 0, NULL} }; +#if PY_MAJOR_VERSION 2 +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +# ifndef __CYGWIN__ +libvirtmod_lxc, +# else +cygvirtmod_lxc, +# endif +NULL, +-1, +libvirtLxcMethods, +NULL, +NULL, +NULL, +NULL +}; + +PyObject * +# ifndef __CYGWIN__ +PyInit_libvirtmod_lxc +# else +PyInit_cygvirtmod_lxc +# endif + (void) +{ +PyObject *module; + +if (virInitialize() 0) +return NULL; + +module = PyModule_Create(moduledef); + +return module; +} +#else /* ! PY_MAJOR_VERSION 2 */ void -#ifndef __CYGWIN__ +# ifndef __CYGWIN__ initlibvirtmod_lxc -#else +# else initcygvirtmod_lxc -#endif +# endif (void) { -static int initialized = 0; - -if (initialized != 0) -return; - if (virInitialize() 0) return; /* initialize the python extension module */ Py_InitModule((char *) -#ifndef __CYGWIN__ - libvirtmod_lxc -#else - cygvirtmod_lxc -#endif - , libvirtLxcMethods); - -initialized = 1; +# ifndef __CYGWIN__ + libvirtmod_lxc, +# else + cygvirtmod_lxc, +# endif + libvirtLxcMethods); } +#endif /* ! PY_MAJOR_VERSION 2 */ diff --git a/libvirt-override.c b/libvirt-override.c index 5deb414..03aab89 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -25,10 +25,18 @@ #include build/libvirt.h #include libvirt-utils.h -#ifndef __CYGWIN__ -extern void initlibvirtmod(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject *PyInit_libvirtmod(void); +# else +extern PyObject *PyInit_cygvirtmod(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod(void); +# else extern void initcygvirtmod(void); +# endif #endif #if 0 @@ -7466,30 +7474,59 @@ static PyMethodDef libvirtMethods[] = { {NULL, NULL, 0, NULL} }; +#if PY_MAJOR_VERSION 2 +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +# ifndef __CYGWIN__ +libvirtmod, +# else +cygvirtmod, +# endif +NULL, +-1, +libvirtMethods, +NULL, +NULL, +NULL, +NULL +}; + +PyObject * +# ifndef __CYGWIN__ +PyInit_libvirtmod +# else +PyInit_cygvirtmod +# endif + (void) +{ +PyObject *module; + +if (virInitialize() 0) +return NULL; + +module = PyModule_Create(moduledef); + +return module; +} +#else /* ! PY_MAJOR_VERSION 2 */ void -#ifndef __CYGWIN__ +# ifndef __CYGWIN__ initlibvirtmod -#else +# else initcygvirtmod -#endif +# endif (void) { -static int initialized = 0; - -if (initialized != 0) -return; - if (virInitialize() 0) return; /* initialize the python extension module */ Py_InitModule((char *) -#ifndef __CYGWIN__ - libvirtmod -#else - cygvirtmod -#endif - , libvirtMethods); - -initialized = 1; -} +# ifndef __CYGWIN__ + libvirtmod, +# else + cygvirtmod, +# endif + libvirtMethods); +} +#endif /* ! PY_MAJOR_VERSION 2 */ diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c index a8e8c09..72257ac 100644 --- a/libvirt-qemu-override.c +++ b/libvirt-qemu-override.c @@ -21,10 +21,18 @@ #include libvirt-utils.h #include build/libvirt-qemu.h -#ifndef __CYGWIN__ -extern void initlibvirtmod_qemu(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject *PyInit_libvirtmod_qemu(void); +# else +extern PyObject *PyInit_cygvirtmod_qemu(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod_qemu(void); +# else extern void initcygvirtmod_qemu(void); +# endif #endif #if 0 @@ -128,30 +136,59 @@ static PyMethodDef
[libvirt] [PATCH python 00/14] Finished port to Python3
From: Daniel P. Berrange berra...@redhat.com This series finishes the initial port to Python3. The code generator works, the C code compiles without warnings, and the sanitytest passes. The APIs using strings have all switched to PyUnicode except for thos which deal with binary data which now use PyBytes in Python 3 builds. Daniel P. Berrange (14): examples: Invoke print(...) instead of print ... examples: Ensure we write bytes to the self-pipe override: Fix native module registration to work with Python3 sanitytest: Fix libvirtError class handling for Python 2.4 override: Replace PyString_FromString with libvirt_constcharPtrWrap override: Replace PyString_AsString with libvirt_charPtrUnwrap override: Replace Py{Int,Long}_FromLong with helpers override: Replace PyInt_AsLong with helper typewrappers: Replace use of PyString class typewrappers: PyInt/PyLong merge for Python3 override: Conditionalize use of PyString_Check and PyInt_Check override: Switch virStreamSend wrapper to use libvirt_charPtrSizeUnwrap sanitytest: Fix broken comparison between int and string sanitytest: remove use of string.lower() examples/consolecallback.py | 6 +- examples/dominfo.py | 14 +- examples/domrestore.py | 17 +-- examples/domsave.py | 15 +- examples/domstart.py| 19 ++- examples/esxlist.py | 14 +- examples/event-test.py | 70 - examples/topology.py| 14 +- libvirt-lxc-override.c | 75 +++--- libvirt-override.c | 348 ++-- libvirt-qemu-override.c | 77 +++--- sanitytest.py | 10 +- typewrappers.c | 97 +++- typewrappers.h | 3 + 14 files changed, 500 insertions(+), 279 deletions(-) -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 02/14] examples: Ensure we write bytes to the self-pipe
From: Daniel P. Berrange berra...@redhat.com Strings in python3 default to unicode, so when writing to the self-pipe we must be sure to use bytes by calling the encode() method. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- examples/event-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/event-test.py b/examples/event-test.py index cf1a8b8..1402c04 100644 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -236,7 +236,7 @@ class virEventLoopPure: def interrupt(self): if self.runningPoll and not self.pendingWakeup: self.pendingWakeup = True -os.write(self.pipetrick[1], 'c') +os.write(self.pipetrick[1], 'c'.encode(UTF-8)) # Registers a new file handle 'fd', monitoring for 'events' (libvirt -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 05/14] override: Replace PyString_FromString with libvirt_constcharPtrWrap
From: Daniel P. Berrange berra...@redhat.com Make use of libvirt_constcharPtrWrap in all override code, to match generated code. This will isolate Python3 specific changes in one place. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 36 ++-- libvirt-qemu-override.c | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 03aab89..84a5436 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2127,15 +2127,15 @@ static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred, Py_INCREF(Py_None); PyTuple_SetItem(pycred, i, pycreditem); PyList_SetItem(pycreditem, 0, PyInt_FromLong((long) cred[i].type)); -PyList_SetItem(pycreditem, 1, PyString_FromString(cred[i].prompt)); +PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt)); if (cred[i].challenge) { -PyList_SetItem(pycreditem, 2, PyString_FromString(cred[i].challenge)); +PyList_SetItem(pycreditem, 2, libvirt_constcharPtrWrap(cred[i].challenge)); } else { Py_INCREF(Py_None); PyList_SetItem(pycreditem, 2, Py_None); } if (cred[i].defresult) { -PyList_SetItem(pycreditem, 3, PyString_FromString(cred[i].defresult)); +PyList_SetItem(pycreditem, 3, libvirt_constcharPtrWrap(cred[i].defresult)); } else { Py_INCREF(Py_None); PyList_SetItem(pycreditem, 3, Py_None); @@ -2319,7 +2319,7 @@ libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED, for (i = 0; i c_retval; i++) { PyObject *str; -if ((str = PyString_FromString(models[i])) == NULL) +if ((str = libvirt_constcharPtrWrap(models[i])) == NULL) goto error; PyList_SET_ITEM(rv, i, str); @@ -2969,7 +2969,7 @@ libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -2997,7 +2997,7 @@ libvirt_virDomainGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -3186,7 +3186,7 @@ libvirt_virNetworkGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -3214,7 +3214,7 @@ libvirt_virNetworkGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -3816,7 +3816,7 @@ libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -3843,7 +3843,7 @@ libvirt_virStoragePoolGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -4030,7 +4030,7 @@ libvirt_virSecretGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -4058,7 +4058,7 @@ libvirt_virSecretGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -4201,7 +4201,7 @@ libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED, if (c_retval == NULL) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((const char *)c_retval, size); +py_retval = libvirt_charPtrSizeWrap((char*)c_retval, size); VIR_FREE(c_retval); return py_retval; @@ -4252,7 +4252,7 @@ libvirt_virNWFilterGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0],
[libvirt] [PATCH python 08/14] override: Replace PyInt_AsLong with helper
From: Daniel P. Berrange berra...@redhat.com Replace use of the PyInt_AsLong libvirt_intUnwrap helper. This isolates the need for Python3 specific code in one place Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 3334c3f..9a013ca 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -5177,10 +5177,8 @@ libvirt_virEventAddHandleFunc (int fd, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addHandle)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -5304,10 +5302,8 @@ libvirt_virEventAddTimeoutFunc(int timeout, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addTimeout)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -6825,7 +6821,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED, } for (i = 0; i nkeycodes; i++) { -keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i)); +libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), (keycodes[i])); } LIBVIRT_BEGIN_ALLOW_THREADS; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 07/14] override: Replace Py{Int, Long}_FromLong with helpers
From: Daniel P. Berrange berra...@redhat.com Replace use of the PyInt_FromLong and PyLong_FromLongLong with libvirt_{int,uint,longlong,ulonglong}Wrap helpers. This isolates the need for Python3 specific code in one place. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 2 +- libvirt-override.c | 104 - typewrappers.c | 8 typewrappers.h | 1 + 4 files changed, 62 insertions(+), 53 deletions(-) diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 60b41d8..ba97551 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -89,7 +89,7 @@ libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED, for (i = 0; i c_retval; i++) { PyObject *item = NULL; -if ((item = PyInt_FromLong(fdlist[i])) == NULL) +if ((item = libvirt_intWrap(fdlist[i])) == NULL) goto error; if (PyList_Append(py_retval, item) 0) { diff --git a/libvirt-override.c b/libvirt-override.c index 579ea43..3334c3f 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -86,19 +86,19 @@ getPyVirTypedParameter(const virTypedParameter *params, int nparams) for (i = 0; i nparams; i++) { switch (params[i].type) { case VIR_TYPED_PARAM_INT: -val = PyInt_FromLong(params[i].value.i); +val = libvirt_intWrap(params[i].value.i); break; case VIR_TYPED_PARAM_UINT: -val = PyInt_FromLong(params[i].value.ui); +val = libvirt_intWrap(params[i].value.ui); break; case VIR_TYPED_PARAM_LLONG: -val = PyLong_FromLongLong(params[i].value.l); +val = libvirt_longlongWrap(params[i].value.l); break; case VIR_TYPED_PARAM_ULLONG: -val = PyLong_FromUnsignedLongLong(params[i].value.ul); +val = libvirt_ulonglongWrap(params[i].value.ul); break; case VIR_TYPED_PARAM_DOUBLE: @@ -493,11 +493,11 @@ libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { /* convert to a Python tuple of long objects */ if ((info = PyTuple_New(5)) == NULL) return VIR_PY_NONE; -PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rd_req)); -PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rd_bytes)); -PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.wr_req)); -PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.wr_bytes)); -PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.errs)); +PyTuple_SetItem(info, 0, libvirt_longlongWrap(stats.rd_req)); +PyTuple_SetItem(info, 1, libvirt_longlongWrap(stats.rd_bytes)); +PyTuple_SetItem(info, 2, libvirt_longlongWrap(stats.wr_req)); +PyTuple_SetItem(info, 3, libvirt_longlongWrap(stats.wr_bytes)); +PyTuple_SetItem(info, 4, libvirt_longlongWrap(stats.errs)); return info; } @@ -708,14 +708,14 @@ libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) /* convert to a Python tuple of long objects */ if ((info = PyTuple_New(8)) == NULL) return VIR_PY_NONE; -PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rx_bytes)); -PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rx_packets)); -PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.rx_errs)); -PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.rx_drop)); -PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.tx_bytes)); -PyTuple_SetItem(info, 5, PyLong_FromLongLong(stats.tx_packets)); -PyTuple_SetItem(info, 6, PyLong_FromLongLong(stats.tx_errs)); -PyTuple_SetItem(info, 7, PyLong_FromLongLong(stats.tx_drop)); +PyTuple_SetItem(info, 0, libvirt_longlongWrap(stats.rx_bytes)); +PyTuple_SetItem(info, 1, libvirt_longlongWrap(stats.rx_packets)); +PyTuple_SetItem(info, 2, libvirt_longlongWrap(stats.rx_errs)); +PyTuple_SetItem(info, 3, libvirt_longlongWrap(stats.rx_drop)); +PyTuple_SetItem(info, 4, libvirt_longlongWrap(stats.tx_bytes)); +PyTuple_SetItem(info, 5, libvirt_longlongWrap(stats.tx_packets)); +PyTuple_SetItem(info, 6, libvirt_longlongWrap(stats.tx_errs)); +PyTuple_SetItem(info, 7, libvirt_longlongWrap(stats.tx_drop)); return info; } @@ -744,28 +744,28 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { for (i = 0; i nr_stats; i++) { if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_IN) PyDict_SetItem(info, libvirt_constcharPtrWrap(swap_in), - PyLong_FromUnsignedLongLong(stats[i].val)); + libvirt_ulonglongWrap(stats[i].val)); else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_OUT) PyDict_SetItem(info, libvirt_constcharPtrWrap(swap_out), - PyLong_FromUnsignedLongLong(stats[i].val)); +
[libvirt] [PATCH python 11/14] override: Conditionalize use of PyString_Check and PyInt_Check
From: Daniel P. Berrange berra...@redhat.com The PyString and PyInt classes are gone in Python 3, so we must conditionalize their use to be Python 2 only. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 9a013ca..77c0af2 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -322,7 +322,11 @@ virPyDictToTypedParams(PyObject *dict, } if (type == -1) { +#if PY_MAJOR_VERSION 2 +if (PyUnicode_Check(value)) { +#else if (PyString_Check(value)) { +#endif type = VIR_TYPED_PARAM_STRING; } else if (PyBool_Check(value)) { type = VIR_TYPED_PARAM_BOOLEAN; @@ -332,11 +336,13 @@ virPyDictToTypedParams(PyObject *dict, type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#if PY_MAJOR_VERSION == 2 } else if (PyInt_Check(value)) { if (PyInt_AS_LONG(value) 0) type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#endif } else if (PyFloat_Check(value)) { type = VIR_TYPED_PARAM_DOUBLE; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 04/14] sanitytest: Fix libvirtError class handling for Python 2.4
From: Daniel P. Berrange berra...@redhat.com The Exception class hiearchy in Python 2.4 reports different data types than in later Python versions. As a result the type(libvirt.libvirtError) does not return 'type'. We just special case handling of this class. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index bd93fe6..eb4caee 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -39,9 +39,11 @@ for name in dir(libvirt): if name[0] == '_': continue thing = getattr(libvirt, name) +# Special-case libvirtError to deal with python 2.4 difference +# in Exception class type reporting. if type(thing) == int: gotenums.append(name) -elif type(thing) == type: +elif type(thing) == type or name == libvirtError: gottypes.append(name) gotfunctions[name] = [] elif callable(thing): -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 12/14] override: Switch virStreamSend wrapper to use libvirt_charPtrSizeUnwrap
From: Daniel P. Berrange berra...@redhat.com Instead of using a 'z#i' format string to receive byte array, use 'O' and then libvirt_charPtrSizeUnwrap. This lets us hide the Python 3 vs 2 differences in typewrappers.c Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 11 ++- typewrappers.c | 19 +++ typewrappers.h | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 77c0af2..7e54cf6 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6770,21 +6770,22 @@ libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED, { PyObject *py_retval; PyObject *pyobj_stream; +PyObject *pyobj_data; virStreamPtr stream; char *data; -int datalen; +Py_ssize_t datalen; int ret; -int nbytes; -if (!PyArg_ParseTuple(args, (char *) Oz#i:virStreamRecv, - pyobj_stream, data, datalen, nbytes)) { +if (!PyArg_ParseTuple(args, (char *) OO:virStreamRecv, + pyobj_stream, pyobj_data)) { DEBUG(%s failed to parse tuple\n, __FUNCTION__); return VIR_PY_INT_FAIL; } stream = PyvirStream_Get(pyobj_stream); +libvirt_charPtrSizeUnwrap(pyobj_data, data, datalen); LIBVIRT_BEGIN_ALLOW_THREADS; -ret = virStreamSend(stream, data, nbytes); +ret = virStreamSend(stream, data, datalen); LIBVIRT_END_ALLOW_THREADS; DEBUG(StreamSend ret=%d\n, ret); diff --git a/typewrappers.c b/typewrappers.c index 7331cbd..a8cca30 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -385,6 +385,25 @@ libvirt_charPtrUnwrap(PyObject *obj, char **str) return 0; } +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size) +{ +int ret; +*str = NULL; +*size = 0; +if (!obj) { +PyErr_SetString(PyExc_TypeError, unexpected type); +return -1; +} + +#if PY_MAJOR_VERSION 2 +ret = PyBytes_AsStringAndSize(obj, str, size); +#else +ret = PyString_AsStringAndSize(obj, str, size); +#endif + +return ret; +} + PyObject * libvirt_virDomainPtrWrap(virDomainPtr node) { diff --git a/typewrappers.h b/typewrappers.h index 6bb193c..ed1e4a3 100644 --- a/typewrappers.h +++ b/typewrappers.h @@ -175,6 +175,7 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val); int libvirt_doubleUnwrap(PyObject *obj, double *val); int libvirt_boolUnwrap(PyObject *obj, bool *val); int libvirt_charPtrUnwrap(PyObject *obj, char **str); +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size); PyObject * libvirt_virConnectPtrWrap(virConnectPtr node); PyObject * libvirt_virDomainPtrWrap(virDomainPtr node); PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 10/14] typewrappers: PyInt/PyLong merge for Python3
From: Daniel P. Berrange berra...@redhat.com In Python3 the PyInt / PyLong types have merged into a single PyLong type. Conditionalize the use of PyInt to Python 2 only Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 33 - 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/typewrappers.c b/typewrappers.c index 532fe13..7331cbd 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -39,7 +39,11 @@ PyObject * libvirt_intWrap(int val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -47,7 +51,11 @@ PyObject * libvirt_uintWrap(uint val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -55,7 +63,7 @@ PyObject * libvirt_longWrap(long val) { PyObject *ret; -ret = PyInt_FromLong(val); +ret = PyLong_FromLong(val); return ret; } @@ -159,7 +167,11 @@ libvirt_intUnwrap(PyObject *obj, int *val) * to C long type directly. If it is of PyLong_Type, PyInt_AsLong * will call PyLong_AsLong() to deal with it automatically. */ +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -187,7 +199,11 @@ libvirt_uintUnwrap(PyObject *obj, unsigned int *val) return -1; } +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -211,7 +227,7 @@ libvirt_longUnwrap(PyObject *obj, long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -229,7 +245,7 @@ libvirt_ulongUnwrap(PyObject *obj, unsigned long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -253,10 +269,14 @@ libvirt_longlongUnwrap(PyObject *obj, long long *val) return -1; } +#if PY_MAJOR_VERSION == 2 /* If obj is of PyInt_Type, PyLong_AsLongLong * will call PyInt_AsLong() to handle it automatically. */ if (PyInt_Check(obj) || PyLong_Check(obj)) +#else +if (PyLong_Check(obj)) +#endif llong_val = PyLong_AsLongLong(obj); else PyErr_SetString(PyExc_TypeError, an integer is required); @@ -272,24 +292,27 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val) { unsigned long long ullong_val = -1; -long long llong_val; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION == 2 /* The PyLong_AsUnsignedLongLong doesn't check the type of * obj, only accept argument of PyLong_Type, so we check it instead. */ if (PyInt_Check(obj)) { -llong_val = PyInt_AsLong(obj); +long long llong_val = PyInt_AsLong(obj); if (llong_val 0) PyErr_SetString(PyExc_OverflowError, negative Python int cannot be converted to C unsigned long long); else ullong_val = llong_val; } else if (PyLong_Check(obj)) { +#else +if (PyLong_Check(obj)) { +#endif ullong_val = PyLong_AsUnsignedLongLong(obj); } else { PyErr_SetString(PyExc_TypeError, an integer is required); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 14/14] sanitytest: remove use of string.lower()
From: Daniel P. Berrange berra...@redhat.com Call lower() directly on the string object instance, not the class Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanitytest.py b/sanitytest.py index 50e4069..363507b 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -201,8 +201,8 @@ for name in sorted(basicklassmap): klass = virDomain func = snapshot + func -# Names should stsart with lowercase letter... -func = string.lower(func[0:1]) + func[1:] +# Names should start with lowercase letter... +func = func[0:1].lower() + func[1:] if func[0:8] == nWFilter: func = nwfilter + func[8:] -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 09/14] typewrappers: Replace use of PyString class
From: Daniel P. Berrange berra...@redhat.com Replace use of PyString with either PyBytes or PyUnicode. The former is used for buffers with explicit sizes, which are used by APIs processing raw bytes. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/typewrappers.c b/typewrappers.c index c230e0f..532fe13 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -92,7 +92,11 @@ libvirt_charPtrSizeWrap(char *str, Py_ssize_t size) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyBytes_FromStringAndSize(str, size); +#else ret = PyString_FromStringAndSize(str, size); +#endif VIR_FREE(str); return ret; } @@ -106,7 +110,11 @@ libvirt_charPtrWrap(char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif VIR_FREE(str); return ret; } @@ -120,7 +128,11 @@ libvirt_constcharPtrWrap(const char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif return ret; } @@ -328,17 +340,24 @@ libvirt_boolUnwrap(PyObject *obj, bool *val) int libvirt_charPtrUnwrap(PyObject *obj, char **str) { +#if PY_MAJOR_VERSION 3 const char *ret; +#endif *str = NULL; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION 2 +if (!(*str = PyUnicode_AsUTF8(obj))) +return -1; +#else ret = PyString_AsString(obj); if (ret !(*str = strdup(ret))) return -1; +#endif return 0; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH python 06/14] override: Replace PyString_AsString with libvirt_charPtrUnwrap
From: Daniel P. Berrange berra...@redhat.com Replace calls to PyString_AsString with the helper method libvirt_charPtrUnwrap. This isolates the code that will change in Python3. In making this change, all callers now have responsibility for free'ing the string. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 106 +++-- typewrappers.c | 18 + typewrappers.h | 1 + 3 files changed, 81 insertions(+), 44 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 84a5436..579ea43 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -58,18 +58,17 @@ extern void initcygvirtmod(void); #define VIR_PY_INT_FAIL (libvirt_intWrap(-1)) #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0)) -/* We don't want to free() returned value. As written in doc: - * PyString_AsString returns pointer to 'internal buffer of string, - * not a copy' and 'It must not be deallocated'. */ static char *py_str(PyObject *obj) { PyObject *str = PyObject_Str(obj); +char *ret; if (!str) { PyErr_Print(); PyErr_Clear(); return NULL; }; -return PyString_AsString(str); +libvirt_charPtrUnwrap(str, ret); +return ret; } /* Helper function to convert a virTypedParameter output array into a @@ -147,9 +146,8 @@ cleanup: /* Allocate a new typed parameter array with the same contents and * length as info, and using the array params of length nparams as * hints on what types to use when creating the new array. The caller - * must NOT clear the array before freeing it, as it points into info - * rather than allocated strings. Return NULL on failure, after - * raising a python exception. */ + * must clear the array before freeing it. Return NULL on failure, + * after raising a python exception. */ static virTypedParameterPtr ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) setPyVirTypedParameter(PyObject *info, const virTypedParameter *params, int nparams) @@ -183,7 +181,8 @@ setPyVirTypedParameter(PyObject *info, while (PyDict_Next(info, pos, key, value)) { char *keystr = NULL; -if ((keystr = PyString_AsString(key)) == NULL) +if (libvirt_charPtrUnwrap(key, keystr) 0 || +keystr == NULL) goto cleanup; for (i = 0; i nparams; i++) { @@ -194,12 +193,14 @@ setPyVirTypedParameter(PyObject *info, PyErr_Format(PyExc_LookupError, Attribute name \%s\ could not be recognized, keystr); +free(keystr); goto cleanup; } strncpy(temp-field, keystr, sizeof(*temp-field) - 1); temp-field[sizeof(*temp-field) - 1] = '\0'; temp-type = params[i].type; +free(keystr); switch (params[i].type) { case VIR_TYPED_PARAM_INT: @@ -237,8 +238,9 @@ setPyVirTypedParameter(PyObject *info, } case VIR_TYPED_PARAM_STRING: { -char *string_val = PyString_AsString(value); -if (!string_val) +char *string_val; +if (libvirt_charPtrUnwrap(value, string_val) 0 || +!string_val) goto cleanup; temp-value.s = string_val; break; @@ -297,6 +299,7 @@ virPyDictToTypedParams(PyObject *dict, int n = 0; int max = 0; int ret = -1; +char *keystr = NULL; *ret_params = NULL; *ret_nparams = 0; @@ -305,10 +308,10 @@ virPyDictToTypedParams(PyObject *dict, return -1; while (PyDict_Next(dict, pos, key, value)) { -char *keystr; int type = -1; -if (!(keystr = PyString_AsString(key))) +if (libvirt_charPtrUnwrap(key, keystr) 0 || +!keystr) goto cleanup; for (i = 0; i nhints; i++) { @@ -396,15 +399,20 @@ virPyDictToTypedParams(PyObject *dict, } case VIR_TYPED_PARAM_STRING: { -char *val = PyString_AsString(value); -if (!val || -virTypedParamsAddString(params, n, max, keystr, val) 0) +char *val;; +if (libvirt_charPtrUnwrap(value, val) 0 || +!val || +virTypedParamsAddString(params, n, max, keystr, val) 0) { +VIR_FREE(val); goto cleanup; +} +VIR_FREE(val); break; } case VIR_TYPED_PARAM_LAST: break; /* unreachable */ } +VIR_FREE(keystr); } *ret_params = params; @@ -413,6 +421,7 @@ virPyDictToTypedParams(PyObject *dict, ret = 0; cleanup: +VIR_FREE(keystr); virTypedParamsFree(params, n); return ret; } @@ -957,7 +966,7 @@ libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED, cleanup: virTypedParamsFree(params, nparams); -VIR_FREE(new_params); +
[libvirt] [PATCH python 13/14] sanitytest: Fix broken comparison between int and string
From: Daniel P. Berrange berra...@redhat.com Python2 was forgiving of a comparison between an int and string but Python3 gets very upset. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index eb4caee..50e4069 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -103,7 +103,7 @@ for cname in wantfunctions: found = True if name not in basicklassmap: basicklassmap[name] = [klassname, name[klen:], cname] -elif len(basicklassmap[name]) klassname: +elif len(basicklassmap[name]) klen: basicklassmap[name] = [klassname, name[klen:], cname] # Anything which can't map to a class goes into the -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 01/14] examples: Invoke print(...) instead of print ...
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The 'print' method must be called as a function in python3, ie with brackets. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- examples/consolecallback.py | 6 ++-- examples/dominfo.py | 14 +- examples/domrestore.py | 17 ++-- examples/domsave.py | 15 +- examples/domstart.py| 19 ++--- examples/esxlist.py | 14 +- examples/event-test.py | 68 ++--- examples/topology.py| 14 +- 8 files changed, 82 insertions(+), 85 deletions(-) diff --git a/examples/consolecallback.py b/examples/consolecallback.py index d8e33a9..c539a92 100644 --- a/examples/consolecallback.py +++ b/examples/consolecallback.py @@ -62,14 +62,14 @@ def lifecycle_callback (connection, domain, event, detail, console): # main if len(sys.argv) != 3: -print Usage:, sys.argv[0], URI UUID -print for example:, sys.argv[0], 'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81' +print(Usage:, sys.argv[0], URI UUID) +print(for example:, sys.argv[0], 'qemu:///system' '32ad945f-7e78-c33a-e96d-39f25e025d81') sys.exit(1) uri = sys.argv[1] uuid = sys.argv[2] -print Escape character is ^] +print(Escape character is ^]) logging.basicConfig(filename='msg.log', level=logging.DEBUG) logging.info(URI: %s, uri) logging.info(UUID: %s, uuid) diff --git a/examples/dominfo.py b/examples/dominfo.py index bfa3ca3..d3049cd 100755 --- a/examples/dominfo.py +++ b/examples/dominfo.py @@ -8,15 +8,15 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DOMAIN' % sys.argv[0] - print ' Print information about the domain DOMAIN' + print('Usage: %s DOMAIN' % sys.argv[0]) + print(' Print information about the domain DOMAIN') def print_section(title): -print \n%s % title -print = * 60 +print(\n%s % title) +print(= * 60) def print_entry(key, value): -print %-10s %-10s % (key, value) +print(%-10s %-10s % (key, value)) def print_xml(key, ctx, path): res = ctx.xpathEval(path) @@ -36,14 +36,14 @@ name = sys.argv[1] # Connect to libvirt conn = libvirt.openReadOnly(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) try: dom = conn.lookupByName(name) # Annoyiingly, libvirt prints its own error message here except libvirt.libvirtError: -print Domain %s is not running % name +print(Domain %s is not running % name) sys.exit(0) info = dom.info() diff --git a/examples/domrestore.py b/examples/domrestore.py index fffc90f..06fdfbc 100755 --- a/examples/domrestore.py +++ b/examples/domrestore.py @@ -8,10 +8,10 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DIR' % sys.argv[0] - print ' Restore all the domains contained in DIR' - print ' It is assumed that all files in DIR are' - print ' images of domU\'s previously created with save' + print('Usage: %s DIR' % sys.argv[0]) + print(' Restore all the domains contained in DIR') + print(' It is assumed that all files in DIR are') + print(' images of domU\'s previously created with save') if len(sys.argv) != 2: usage() @@ -22,15 +22,14 @@ imgs = os.listdir(dir) conn = libvirt.open(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) for img in imgs: file = os.path.join(dir, img) -print Restoring %s ... % img, -sys.stdout.flush() +print(Restoring %s ... % img) ret = conn.restore(file) if ret == 0: -print done +print(done) else: -print error %d % ret +print(error %d % ret) diff --git a/examples/domsave.py b/examples/domsave.py index bac4536..727217c 100755 --- a/examples/domsave.py +++ b/examples/domsave.py @@ -8,9 +8,9 @@ import libxml2 import pdb def usage(): - print 'Usage: %s DIR' % sys.argv[0] - print ' Save all currently running domU\'s into DIR' - print ' DIR must exist and be writable by this process' + print('Usage: %s DIR' % sys.argv[0]) + print(' Save all currently running domU\'s into DIR') + print(' DIR must exist and be writable by this process') if len(sys.argv) != 2: usage() @@ -20,7 +20,7 @@ dir = sys.argv[1] conn = libvirt.open(None) if conn is None: -print 'Failed to open connection to the hypervisor' +print('Failed to open connection to the hypervisor') sys.exit(1) doms = conn.listDomainsID() @@ -28,13 +28,12 @@ for id in doms: if id == 0: continue dom = conn.lookupByID(id)
Re: [libvirt] [PATCH python 02/14] examples: Ensure we write bytes to the self-pipe
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Strings in python3 default to unicode, so when writing to the self-pipe we must be sure to use bytes by calling the encode() method. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- examples/event-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/event-test.py b/examples/event-test.py index cf1a8b8..1402c04 100644 --- a/examples/event-test.py +++ b/examples/event-test.py @@ -236,7 +236,7 @@ class virEventLoopPure: def interrupt(self): if self.runningPoll and not self.pendingWakeup: self.pendingWakeup = True -os.write(self.pipetrick[1], 'c') +os.write(self.pipetrick[1], 'c'.encode(UTF-8)) # Registers a new file handle 'fd', monitoring for 'events' (libvirt -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 03/14] override: Fix native module registration to work with Python3
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The way native modules are registered has completely changed, so the code must be #ifdef'd for Python2 3 Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 73 +++ libvirt-override.c | 75 - libvirt-qemu-override.c | 73 +++ 3 files changed, 166 insertions(+), 55 deletions(-) diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 03b00b0..60b41d8 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -21,10 +21,18 @@ #include libvirt-utils.h #include build/libvirt-lxc.h -#ifndef __CYGWIN__ -extern void initlibvirtmod_lxc(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject *PyInit_libvirtmod_lxc(void); +# else +extern PyObject *PyInit_cygvirtmod_lxc(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod_lxc(void); +# else extern void initcygvirtmod_lxc(void); +# endif #endif #if 0 @@ -110,30 +118,59 @@ static PyMethodDef libvirtLxcMethods[] = { {NULL, NULL, 0, NULL} }; +#if PY_MAJOR_VERSION 2 +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +# ifndef __CYGWIN__ +libvirtmod_lxc, +# else +cygvirtmod_lxc, +# endif +NULL, +-1, +libvirtLxcMethods, +NULL, +NULL, +NULL, +NULL +}; + +PyObject * +# ifndef __CYGWIN__ +PyInit_libvirtmod_lxc +# else +PyInit_cygvirtmod_lxc +# endif + (void) +{ +PyObject *module; + +if (virInitialize() 0) +return NULL; + +module = PyModule_Create(moduledef); + +return module; +} +#else /* ! PY_MAJOR_VERSION 2 */ void -#ifndef __CYGWIN__ +# ifndef __CYGWIN__ initlibvirtmod_lxc -#else +# else initcygvirtmod_lxc -#endif +# endif (void) { -static int initialized = 0; - -if (initialized != 0) -return; - if (virInitialize() 0) return; /* initialize the python extension module */ Py_InitModule((char *) -#ifndef __CYGWIN__ - libvirtmod_lxc -#else - cygvirtmod_lxc -#endif - , libvirtLxcMethods); - -initialized = 1; +# ifndef __CYGWIN__ + libvirtmod_lxc, +# else + cygvirtmod_lxc, +# endif + libvirtLxcMethods); } +#endif /* ! PY_MAJOR_VERSION 2 */ diff --git a/libvirt-override.c b/libvirt-override.c index 5deb414..03aab89 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -25,10 +25,18 @@ #include build/libvirt.h #include libvirt-utils.h -#ifndef __CYGWIN__ -extern void initlibvirtmod(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject *PyInit_libvirtmod(void); +# else +extern PyObject *PyInit_cygvirtmod(void); +# endif #else +# ifndef __CYGWIN__ +extern void initlibvirtmod(void); +# else extern void initcygvirtmod(void); +# endif #endif #if 0 @@ -7466,30 +7474,59 @@ static PyMethodDef libvirtMethods[] = { {NULL, NULL, 0, NULL} }; +#if PY_MAJOR_VERSION 2 +static struct PyModuleDef moduledef = { +PyModuleDef_HEAD_INIT, +# ifndef __CYGWIN__ +libvirtmod, +# else +cygvirtmod, +# endif +NULL, +-1, +libvirtMethods, +NULL, +NULL, +NULL, +NULL +}; + +PyObject * +# ifndef __CYGWIN__ +PyInit_libvirtmod +# else +PyInit_cygvirtmod +# endif + (void) +{ +PyObject *module; + +if (virInitialize() 0) +return NULL; + +module = PyModule_Create(moduledef); + +return module; +} +#else /* ! PY_MAJOR_VERSION 2 */ void -#ifndef __CYGWIN__ +# ifndef __CYGWIN__ initlibvirtmod -#else +# else initcygvirtmod -#endif +# endif (void) { -static int initialized = 0; - -if (initialized != 0) -return; - if (virInitialize() 0) return; /* initialize the python extension module */ Py_InitModule((char *) -#ifndef __CYGWIN__ - libvirtmod -#else - cygvirtmod -#endif - , libvirtMethods); - -initialized = 1; -} +# ifndef __CYGWIN__ + libvirtmod, +# else + cygvirtmod, +# endif + libvirtMethods); +} +#endif /* ! PY_MAJOR_VERSION 2 */ diff --git a/libvirt-qemu-override.c b/libvirt-qemu-override.c index a8e8c09..72257ac 100644 --- a/libvirt-qemu-override.c +++ b/libvirt-qemu-override.c @@ -21,10 +21,18 @@ #include libvirt-utils.h #include build/libvirt-qemu.h -#ifndef __CYGWIN__ -extern void initlibvirtmod_qemu(void); +#if PY_MAJOR_VERSION 2 +# ifndef __CYGWIN__ +extern PyObject
Re: [libvirt] [PATCH python 04/14] sanitytest: Fix libvirtError class handling for Python 2.4
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The Exception class hiearchy in Python 2.4 reports different data types than in later Python versions. As a result the type(libvirt.libvirtError) does not return 'type'. We just special case handling of this class. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index bd93fe6..eb4caee 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -39,9 +39,11 @@ for name in dir(libvirt): if name[0] == '_': continue thing = getattr(libvirt, name) +# Special-case libvirtError to deal with python 2.4 difference +# in Exception class type reporting. if type(thing) == int: gotenums.append(name) -elif type(thing) == type: +elif type(thing) == type or name == libvirtError: gottypes.append(name) gotfunctions[name] = [] elif callable(thing): -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Don't have a setup to test, but in principle the code makes sense. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 05/14] override: Replace PyString_FromString with libvirt_constcharPtrWrap
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Make use of libvirt_constcharPtrWrap in all override code, to match generated code. This will isolate Python3 specific changes in one place. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 36 ++-- libvirt-qemu-override.c | 4 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 03aab89..84a5436 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -2127,15 +2127,15 @@ static int virConnectCredCallbackWrapper(virConnectCredentialPtr cred, Py_INCREF(Py_None); PyTuple_SetItem(pycred, i, pycreditem); PyList_SetItem(pycreditem, 0, PyInt_FromLong((long) cred[i].type)); -PyList_SetItem(pycreditem, 1, PyString_FromString(cred[i].prompt)); +PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt)); if (cred[i].challenge) { -PyList_SetItem(pycreditem, 2, PyString_FromString(cred[i].challenge)); +PyList_SetItem(pycreditem, 2, libvirt_constcharPtrWrap(cred[i].challenge)); } else { Py_INCREF(Py_None); PyList_SetItem(pycreditem, 2, Py_None); } if (cred[i].defresult) { -PyList_SetItem(pycreditem, 3, PyString_FromString(cred[i].defresult)); +PyList_SetItem(pycreditem, 3, libvirt_constcharPtrWrap(cred[i].defresult)); } else { Py_INCREF(Py_None); PyList_SetItem(pycreditem, 3, Py_None); @@ -2319,7 +2319,7 @@ libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED, for (i = 0; i c_retval; i++) { PyObject *str; -if ((str = PyString_FromString(models[i])) == NULL) +if ((str = libvirt_constcharPtrWrap(models[i])) == NULL) goto error; PyList_SET_ITEM(rv, i, str); @@ -2969,7 +2969,7 @@ libvirt_virDomainGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -2997,7 +2997,7 @@ libvirt_virDomainGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -3186,7 +3186,7 @@ libvirt_virNetworkGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -3214,7 +3214,7 @@ libvirt_virNetworkGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -3816,7 +3816,7 @@ libvirt_virStoragePoolGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -3843,7 +3843,7 @@ libvirt_virStoragePoolGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -4030,7 +4030,7 @@ libvirt_virSecretGetUUID(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((char *) uuid[0], VIR_UUID_BUFLEN); +py_retval = libvirt_charPtrSizeWrap((char *) uuid[0], VIR_UUID_BUFLEN); return py_retval; } @@ -4058,7 +4058,7 @@ libvirt_virSecretGetUUIDString(PyObject *self ATTRIBUTE_UNUSED, if (c_retval 0) return VIR_PY_NONE; -py_retval = PyString_FromString((char *) uuidstr[0]); +py_retval = libvirt_constcharPtrWrap((char *) uuidstr[0]); return py_retval; } @@ -4201,7 +4201,7 @@ libvirt_virSecretGetValue(PyObject *self ATTRIBUTE_UNUSED, if (c_retval == NULL) return VIR_PY_NONE; -py_retval = PyString_FromStringAndSize((const char *)c_retval, size); +py_retval = libvirt_charPtrSizeWrap((char*)c_retval, size); VIR_FREE(c_retval); return py_retval; @@ -4252,7 +4252,7 @@
Re: [libvirt] [PATCH 2/2] daemon: Introduce max_anonymous_clients
On 09.12.2013 15:35, Michal Privoznik wrote: https://bugzilla.redhat.com/show_bug.cgi?id=981729 This config tunable allows users to determine the maximum number of accepted but yet not authenticated users. Signed-off-by: Michal Privoznik mpriv...@redhat.com --- daemon/libvirtd-config.c| 1 + daemon/libvirtd-config.h| 1 + daemon/libvirtd.aug | 1 + daemon/libvirtd.c | 1 + daemon/libvirtd.conf| 3 +++ daemon/test_libvirtd.aug.in | 1 + src/locking/lock_daemon.c | 4 ++-- src/lxc/lxc_controller.c| 2 +- src/rpc/virnetserver.c | 37 +++-- src/rpc/virnetserver.h | 1 + 10 files changed, 47 insertions(+), 5 deletions(-) D'oh! I've made some changes but didn't amend them. Consider this squashed in: diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index bbb91d4..62490a7 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -1164,7 +1164,7 @@ void virNetServerRun(virNetServerPtr srv) nclients_unauth=%zu nclients_unauth_max=%zu, srv-nclients, srv-nclients_max, srv-nclients_unauth, srv-nclients_unauth_max); -if ((srv-nclients == srv-nclients_max - 1) +if ((srv-nclients srv-nclients_max) (srv-nclients_unauth srv-nclients_unauth_max)) { /* Now it makes sense to accept() a new client. */ VIR_DEBUG(Re-enabling services); @@ -1285,7 +1285,7 @@ size_t virNetServerClientAuth(virNetServerPtr srv, srv-nclients, srv-nclients_max, srv-nclients_unauth, srv-nclients_unauth_max); if ((srv-nclients srv-nclients_max) -(srv-nclients_unauth == srv-nclients_unauth_max - 1)) { +(srv-nclients_unauth srv-nclients_unauth_max)) { /* Now it makes sense to accept() a new client. */ VIR_DEBUG(Re-enabling services); virNetServerUpdateServicesLocked(srv, true); Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 06/14] override: Replace PyString_AsString with libvirt_charPtrUnwrap
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace calls to PyString_AsString with the helper method libvirt_charPtrUnwrap. This isolates the code that will change in Python3. In making this change, all callers now have responsibility for free'ing the string. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 106 +++-- typewrappers.c | 18 + typewrappers.h | 1 + 3 files changed, 81 insertions(+), 44 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 84a5436..579ea43 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -58,18 +58,17 @@ extern void initcygvirtmod(void); #define VIR_PY_INT_FAIL (libvirt_intWrap(-1)) #define VIR_PY_INT_SUCCESS (libvirt_intWrap(0)) -/* We don't want to free() returned value. As written in doc: - * PyString_AsString returns pointer to 'internal buffer of string, - * not a copy' and 'It must not be deallocated'. */ static char *py_str(PyObject *obj) { PyObject *str = PyObject_Str(obj); +char *ret; if (!str) { PyErr_Print(); PyErr_Clear(); return NULL; }; -return PyString_AsString(str); +libvirt_charPtrUnwrap(str, ret); +return ret; } /* Helper function to convert a virTypedParameter output array into a @@ -147,9 +146,8 @@ cleanup: /* Allocate a new typed parameter array with the same contents and * length as info, and using the array params of length nparams as * hints on what types to use when creating the new array. The caller - * must NOT clear the array before freeing it, as it points into info - * rather than allocated strings. Return NULL on failure, after - * raising a python exception. */ + * must clear the array before freeing it. Return NULL on failure, + * after raising a python exception. */ static virTypedParameterPtr ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) setPyVirTypedParameter(PyObject *info, const virTypedParameter *params, int nparams) @@ -183,7 +181,8 @@ setPyVirTypedParameter(PyObject *info, while (PyDict_Next(info, pos, key, value)) { char *keystr = NULL; -if ((keystr = PyString_AsString(key)) == NULL) +if (libvirt_charPtrUnwrap(key, keystr) 0 || +keystr == NULL) goto cleanup; for (i = 0; i nparams; i++) { @@ -194,12 +193,14 @@ setPyVirTypedParameter(PyObject *info, PyErr_Format(PyExc_LookupError, Attribute name \%s\ could not be recognized, keystr); +free(keystr); Here you use free() but goto cleanup; } strncpy(temp-field, keystr, sizeof(*temp-field) - 1); temp-field[sizeof(*temp-field) - 1] = '\0'; temp-type = params[i].type; +free(keystr); switch (params[i].type) { case VIR_TYPED_PARAM_INT: @@ -237,8 +238,9 @@ setPyVirTypedParameter(PyObject *info, } case VIR_TYPED_PARAM_STRING: { -char *string_val = PyString_AsString(value); -if (!string_val) +char *string_val; +if (libvirt_charPtrUnwrap(value, string_val) 0 || +!string_val) goto cleanup; temp-value.s = string_val; break; @@ -297,6 +299,7 @@ virPyDictToTypedParams(PyObject *dict, int n = 0; int max = 0; int ret = -1; +char *keystr = NULL; *ret_params = NULL; *ret_nparams = 0; @@ -305,10 +308,10 @@ virPyDictToTypedParams(PyObject *dict, return -1; while (PyDict_Next(dict, pos, key, value)) { -char *keystr; int type = -1; -if (!(keystr = PyString_AsString(key))) +if (libvirt_charPtrUnwrap(key, keystr) 0 || +!keystr) goto cleanup; for (i = 0; i nhints; i++) { @@ -396,15 +399,20 @@ virPyDictToTypedParams(PyObject *dict, } case VIR_TYPED_PARAM_STRING: { -char *val = PyString_AsString(value); -if (!val || -virTypedParamsAddString(params, n, max, keystr, val) 0) +char *val;; +if (libvirt_charPtrUnwrap(value, val) 0 || +!val || +virTypedParamsAddString(params, n, max, keystr, val) 0) { +VIR_FREE(val); Here you use VIR_FREE(). We should probably be consistent. goto cleanup; +} +VIR_FREE(val); break; } case VIR_TYPED_PARAM_LAST: break; /* unreachable */ } +VIR_FREE(keystr); } *ret_params = params; @@ -413,6 +421,7 @@ virPyDictToTypedParams(PyObject *dict,
Re: [libvirt] [PATCH python 07/14] override: Replace Py{Int, Long}_FromLong with helpers
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace use of the PyInt_FromLong and PyLong_FromLongLong with libvirt_{int,uint,longlong,ulonglong}Wrap helpers. This isolates the need for Python3 specific code in one place. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-lxc-override.c | 2 +- libvirt-override.c | 104 - typewrappers.c | 8 typewrappers.h | 1 + 4 files changed, 62 insertions(+), 53 deletions(-) diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c index 60b41d8..ba97551 100644 --- a/libvirt-lxc-override.c +++ b/libvirt-lxc-override.c @@ -89,7 +89,7 @@ libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED, for (i = 0; i c_retval; i++) { PyObject *item = NULL; -if ((item = PyInt_FromLong(fdlist[i])) == NULL) +if ((item = libvirt_intWrap(fdlist[i])) == NULL) goto error; if (PyList_Append(py_retval, item) 0) { diff --git a/libvirt-override.c b/libvirt-override.c index 579ea43..3334c3f 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -86,19 +86,19 @@ getPyVirTypedParameter(const virTypedParameter *params, int nparams) for (i = 0; i nparams; i++) { switch (params[i].type) { case VIR_TYPED_PARAM_INT: -val = PyInt_FromLong(params[i].value.i); +val = libvirt_intWrap(params[i].value.i); break; case VIR_TYPED_PARAM_UINT: -val = PyInt_FromLong(params[i].value.ui); +val = libvirt_intWrap(params[i].value.ui); break; case VIR_TYPED_PARAM_LLONG: -val = PyLong_FromLongLong(params[i].value.l); +val = libvirt_longlongWrap(params[i].value.l); break; case VIR_TYPED_PARAM_ULLONG: -val = PyLong_FromUnsignedLongLong(params[i].value.ul); +val = libvirt_ulonglongWrap(params[i].value.ul); break; case VIR_TYPED_PARAM_DOUBLE: @@ -493,11 +493,11 @@ libvirt_virDomainBlockStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { /* convert to a Python tuple of long objects */ if ((info = PyTuple_New(5)) == NULL) return VIR_PY_NONE; -PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rd_req)); -PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rd_bytes)); -PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.wr_req)); -PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.wr_bytes)); -PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.errs)); +PyTuple_SetItem(info, 0, libvirt_longlongWrap(stats.rd_req)); +PyTuple_SetItem(info, 1, libvirt_longlongWrap(stats.rd_bytes)); +PyTuple_SetItem(info, 2, libvirt_longlongWrap(stats.wr_req)); +PyTuple_SetItem(info, 3, libvirt_longlongWrap(stats.wr_bytes)); +PyTuple_SetItem(info, 4, libvirt_longlongWrap(stats.errs)); return info; } @@ -708,14 +708,14 @@ libvirt_virDomainInterfaceStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) /* convert to a Python tuple of long objects */ if ((info = PyTuple_New(8)) == NULL) return VIR_PY_NONE; -PyTuple_SetItem(info, 0, PyLong_FromLongLong(stats.rx_bytes)); -PyTuple_SetItem(info, 1, PyLong_FromLongLong(stats.rx_packets)); -PyTuple_SetItem(info, 2, PyLong_FromLongLong(stats.rx_errs)); -PyTuple_SetItem(info, 3, PyLong_FromLongLong(stats.rx_drop)); -PyTuple_SetItem(info, 4, PyLong_FromLongLong(stats.tx_bytes)); -PyTuple_SetItem(info, 5, PyLong_FromLongLong(stats.tx_packets)); -PyTuple_SetItem(info, 6, PyLong_FromLongLong(stats.tx_errs)); -PyTuple_SetItem(info, 7, PyLong_FromLongLong(stats.tx_drop)); +PyTuple_SetItem(info, 0, libvirt_longlongWrap(stats.rx_bytes)); +PyTuple_SetItem(info, 1, libvirt_longlongWrap(stats.rx_packets)); +PyTuple_SetItem(info, 2, libvirt_longlongWrap(stats.rx_errs)); +PyTuple_SetItem(info, 3, libvirt_longlongWrap(stats.rx_drop)); +PyTuple_SetItem(info, 4, libvirt_longlongWrap(stats.tx_bytes)); +PyTuple_SetItem(info, 5, libvirt_longlongWrap(stats.tx_packets)); +PyTuple_SetItem(info, 6, libvirt_longlongWrap(stats.tx_errs)); +PyTuple_SetItem(info, 7, libvirt_longlongWrap(stats.tx_drop)); return info; } @@ -744,28 +744,28 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) { for (i = 0; i nr_stats; i++) { if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_IN) PyDict_SetItem(info, libvirt_constcharPtrWrap(swap_in), - PyLong_FromUnsignedLongLong(stats[i].val)); + libvirt_ulonglongWrap(stats[i].val)); else if (stats[i].tag == VIR_DOMAIN_MEMORY_STAT_SWAP_OUT) PyDict_SetItem(info,
Re: [libvirt] [PATCH] docs: Enhance memoryBacking/locked documentation
On Mon, Dec 09, 2013 at 03:43:55PM +0100, Jiri Denemark wrote: Mention the need to set memtune/hard_limit. https://bugzilla.redhat.com/show_bug.cgi?id=1035954 Signed-off-by: Jiri Denemark jdene...@redhat.com --- docs/formatdomain.html.in | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1850a2b..b4ee9f3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -638,7 +638,10 @@ dtcodelocked/code/dt ddWhen set and supported by the hypervisor, memory pages belonging to the domain will be locked in host's memory and the host will not -be allowed to swap them out. +be allowed to swap them out. For QEMU/KVM this requires +codehard_limit/code a href=#elementsMemoryTuningmemory tunning/a +element to be used and set to the maximum memory configured for the +domain plus any memory consumed by the QEMU process itself. span class=sinceSince 1.0.6/span/dd /dl -- 1.8.5.1 ACK, Martin signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 08/14] override: Replace PyInt_AsLong with helper
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace use of the PyInt_AsLong libvirt_intUnwrap helper. This isolates the need for Python3 specific code in one place Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 3334c3f..9a013ca 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -5177,10 +5177,8 @@ libvirt_virEventAddHandleFunc (int fd, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addHandle)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -5304,10 +5302,8 @@ libvirt_virEventAddTimeoutFunc(int timeout, if (!result) { PyErr_Print(); PyErr_Clear(); -} else if (!PyInt_Check(result)) { -DEBUG(%s: %s should return an int\n, __FUNCTION__, NAME(addTimeout)); } else { -retval = (int)PyInt_AsLong(result); +libvirt_intUnwrap(result, retval); } Py_XDECREF(result); @@ -6825,7 +6821,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED, } for (i = 0; i nkeycodes; i++) { -keycodes[i] = (int)PyInt_AsLong(PyList_GetItem(pyobj_list, i)); +libvirt_uintUnwrap(PyList_GetItem(pyobj_list, i), (keycodes[i])); } LIBVIRT_BEGIN_ALLOW_THREADS; -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 09/14] typewrappers: Replace use of PyString class
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Replace use of PyString with either PyBytes or PyUnicode. The former is used for buffers with explicit sizes, which are used by APIs processing raw bytes. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/typewrappers.c b/typewrappers.c index c230e0f..532fe13 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -92,7 +92,11 @@ libvirt_charPtrSizeWrap(char *str, Py_ssize_t size) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyBytes_FromStringAndSize(str, size); +#else ret = PyString_FromStringAndSize(str, size); +#endif VIR_FREE(str); return ret; } @@ -106,7 +110,11 @@ libvirt_charPtrWrap(char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif VIR_FREE(str); return ret; } @@ -120,7 +128,11 @@ libvirt_constcharPtrWrap(const char *str) Py_INCREF(Py_None); return Py_None; } +#if PY_MAJOR_VERSION 2 +ret = PyUnicode_FromString(str); +#else ret = PyString_FromString(str); +#endif return ret; } @@ -328,17 +340,24 @@ libvirt_boolUnwrap(PyObject *obj, bool *val) int libvirt_charPtrUnwrap(PyObject *obj, char **str) { +#if PY_MAJOR_VERSION 3 const char *ret; +#endif *str = NULL; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION 2 +if (!(*str = PyUnicode_AsUTF8(obj))) +return -1; +#else ret = PyString_AsString(obj); if (ret !(*str = strdup(ret))) return -1; +#endif return 0; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] docs: Enhance memoryBacking/locked documentation
On Mon, Dec 09, 2013 at 17:37:14 +0100, Martin Kletzander wrote: On Mon, Dec 09, 2013 at 03:43:55PM +0100, Jiri Denemark wrote: Mention the need to set memtune/hard_limit. https://bugzilla.redhat.com/show_bug.cgi?id=1035954 Signed-off-by: Jiri Denemark jdene...@redhat.com --- docs/formatdomain.html.in | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1850a2b..b4ee9f3 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -638,7 +638,10 @@ dtcodelocked/code/dt ddWhen set and supported by the hypervisor, memory pages belonging to the domain will be locked in host's memory and the host will not -be allowed to swap them out. +be allowed to swap them out. For QEMU/KVM this requires +codehard_limit/code a href=#elementsMemoryTuningmemory tunning/a +element to be used and set to the maximum memory configured for the +domain plus any memory consumed by the QEMU process itself. span class=sinceSince 1.0.6/span/dd /dl -- 1.8.5.1 ACK, Thanks, pushed. Jirka -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 10/14] typewrappers: PyInt/PyLong merge for Python3
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com In Python3 the PyInt / PyLong types have merged into a single PyLong type. Conditionalize the use of PyInt to Python 2 only Signed-off-by: Daniel P. Berrange berra...@redhat.com --- typewrappers.c | 33 - 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/typewrappers.c b/typewrappers.c index 532fe13..7331cbd 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -39,7 +39,11 @@ PyObject * libvirt_intWrap(int val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -47,7 +51,11 @@ PyObject * libvirt_uintWrap(uint val) { PyObject *ret; +#if PY_MAJOR_VERSION 2 +ret = PyLong_FromLong((long) val); +#else ret = PyInt_FromLong((long) val); +#endif return ret; } @@ -55,7 +63,7 @@ PyObject * libvirt_longWrap(long val) { PyObject *ret; -ret = PyInt_FromLong(val); +ret = PyLong_FromLong(val); return ret; } @@ -159,7 +167,11 @@ libvirt_intUnwrap(PyObject *obj, int *val) * to C long type directly. If it is of PyLong_Type, PyInt_AsLong * will call PyLong_AsLong() to deal with it automatically. */ +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -187,7 +199,11 @@ libvirt_uintUnwrap(PyObject *obj, unsigned int *val) return -1; } +#if PY_MAJOR_VERSION 2 +long_val = PyLong_AsLong(obj); +#else long_val = PyInt_AsLong(obj); +#endif if ((long_val == -1) PyErr_Occurred()) return -1; @@ -211,7 +227,7 @@ libvirt_longUnwrap(PyObject *obj, long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -229,7 +245,7 @@ libvirt_ulongUnwrap(PyObject *obj, unsigned long *val) return -1; } -long_val = PyInt_AsLong(obj); +long_val = PyLong_AsLong(obj); if ((long_val == -1) PyErr_Occurred()) return -1; @@ -253,10 +269,14 @@ libvirt_longlongUnwrap(PyObject *obj, long long *val) return -1; } +#if PY_MAJOR_VERSION == 2 /* If obj is of PyInt_Type, PyLong_AsLongLong * will call PyInt_AsLong() to handle it automatically. */ if (PyInt_Check(obj) || PyLong_Check(obj)) +#else +if (PyLong_Check(obj)) +#endif llong_val = PyLong_AsLongLong(obj); else PyErr_SetString(PyExc_TypeError, an integer is required); @@ -272,24 +292,27 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val) { unsigned long long ullong_val = -1; -long long llong_val; if (!obj) { PyErr_SetString(PyExc_TypeError, unexpected type); return -1; } +#if PY_MAJOR_VERSION == 2 /* The PyLong_AsUnsignedLongLong doesn't check the type of * obj, only accept argument of PyLong_Type, so we check it instead. */ if (PyInt_Check(obj)) { -llong_val = PyInt_AsLong(obj); +long long llong_val = PyInt_AsLong(obj); if (llong_val 0) PyErr_SetString(PyExc_OverflowError, negative Python int cannot be converted to C unsigned long long); else ullong_val = llong_val; } else if (PyLong_Check(obj)) { +#else +if (PyLong_Check(obj)) { +#endif ullong_val = PyLong_AsUnsignedLongLong(obj); } else { PyErr_SetString(PyExc_TypeError, an integer is required); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 11/14] override: Conditionalize use of PyString_Check and PyInt_Check
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com The PyString and PyInt classes are gone in Python 3, so we must conditionalize their use to be Python 2 only. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 9a013ca..77c0af2 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -322,7 +322,11 @@ virPyDictToTypedParams(PyObject *dict, } if (type == -1) { +#if PY_MAJOR_VERSION 2 +if (PyUnicode_Check(value)) { +#else if (PyString_Check(value)) { +#endif type = VIR_TYPED_PARAM_STRING; } else if (PyBool_Check(value)) { type = VIR_TYPED_PARAM_BOOLEAN; @@ -332,11 +336,13 @@ virPyDictToTypedParams(PyObject *dict, type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#if PY_MAJOR_VERSION == 2 Every where else in your other patches you did PY_MAJOR_VERSION 3, but its not like we're going to support Python 1 but just a note on inconsistency. } else if (PyInt_Check(value)) { if (PyInt_AS_LONG(value) 0) type = VIR_TYPED_PARAM_LLONG; else type = VIR_TYPED_PARAM_ULLONG; +#endif } else if (PyFloat_Check(value)) { type = VIR_TYPED_PARAM_DOUBLE; } -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 13/14] sanitytest: Fix broken comparison between int and string
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Python2 was forgiving of a comparison between an int and string but Python3 gets very upset. Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sanitytest.py b/sanitytest.py index eb4caee..50e4069 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -103,7 +103,7 @@ for cname in wantfunctions: found = True if name not in basicklassmap: basicklassmap[name] = [klassname, name[klen:], cname] -elif len(basicklassmap[name]) klassname: +elif len(basicklassmap[name]) klen: basicklassmap[name] = [klassname, name[klen:], cname] # Anything which can't map to a class goes into the -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 14/14] sanitytest: remove use of string.lower()
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Call lower() directly on the string object instance, not the class Signed-off-by: Daniel P. Berrange berra...@redhat.com --- sanitytest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sanitytest.py b/sanitytest.py index 50e4069..363507b 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -201,8 +201,8 @@ for name in sorted(basicklassmap): klass = virDomain func = snapshot + func -# Names should stsart with lowercase letter... -func = string.lower(func[0:1]) + func[1:] +# Names should start with lowercase letter... +func = func[0:1].lower() + func[1:] if func[0:8] == nWFilter: func = nwfilter + func[8:] -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH python 12/14] override: Switch virStreamSend wrapper to use libvirt_charPtrSizeUnwrap
On Mon, Dec 9, 2013 at 9:15 AM, Daniel P. Berrange berra...@redhat.com wrote: From: Daniel P. Berrange berra...@redhat.com Instead of using a 'z#i' format string to receive byte array, use 'O' and then libvirt_charPtrSizeUnwrap. This lets us hide the Python 3 vs 2 differences in typewrappers.c Signed-off-by: Daniel P. Berrange berra...@redhat.com --- libvirt-override.c | 11 ++- typewrappers.c | 19 +++ typewrappers.h | 1 + 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/libvirt-override.c b/libvirt-override.c index 77c0af2..7e54cf6 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -6770,21 +6770,22 @@ libvirt_virStreamSend(PyObject *self ATTRIBUTE_UNUSED, { PyObject *py_retval; PyObject *pyobj_stream; +PyObject *pyobj_data; virStreamPtr stream; char *data; -int datalen; +Py_ssize_t datalen; int ret; -int nbytes; -if (!PyArg_ParseTuple(args, (char *) Oz#i:virStreamRecv, - pyobj_stream, data, datalen, nbytes)) { +if (!PyArg_ParseTuple(args, (char *) OO:virStreamRecv, + pyobj_stream, pyobj_data)) { DEBUG(%s failed to parse tuple\n, __FUNCTION__); return VIR_PY_INT_FAIL; } stream = PyvirStream_Get(pyobj_stream); +libvirt_charPtrSizeUnwrap(pyobj_data, data, datalen); LIBVIRT_BEGIN_ALLOW_THREADS; -ret = virStreamSend(stream, data, nbytes); +ret = virStreamSend(stream, data, datalen); LIBVIRT_END_ALLOW_THREADS; DEBUG(StreamSend ret=%d\n, ret); diff --git a/typewrappers.c b/typewrappers.c index 7331cbd..a8cca30 100644 --- a/typewrappers.c +++ b/typewrappers.c @@ -385,6 +385,25 @@ libvirt_charPtrUnwrap(PyObject *obj, char **str) return 0; } +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size) +{ +int ret; +*str = NULL; +*size = 0; +if (!obj) { +PyErr_SetString(PyExc_TypeError, unexpected type); +return -1; +} + +#if PY_MAJOR_VERSION 2 +ret = PyBytes_AsStringAndSize(obj, str, size); +#else +ret = PyString_AsStringAndSize(obj, str, size); +#endif + +return ret; +} + PyObject * libvirt_virDomainPtrWrap(virDomainPtr node) { diff --git a/typewrappers.h b/typewrappers.h index 6bb193c..ed1e4a3 100644 --- a/typewrappers.h +++ b/typewrappers.h @@ -175,6 +175,7 @@ int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val); int libvirt_doubleUnwrap(PyObject *obj, double *val); int libvirt_boolUnwrap(PyObject *obj, bool *val); int libvirt_charPtrUnwrap(PyObject *obj, char **str); +int libvirt_charPtrSizeUnwrap(PyObject *obj, char **str, Py_ssize_t *size); PyObject * libvirt_virConnectPtrWrap(virConnectPtr node); PyObject * libvirt_virDomainPtrWrap(virDomainPtr node); PyObject * libvirt_virNetworkPtrWrap(virNetworkPtr node); -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list I don't really know the format specifier but it seems reasonably correct that O is object and then you're unwrapping it which makes sense so ACK. -- Doug Goldstein -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] ANNOUNCE: ruby-libvirt 0.5.0
All, I'm pleased to announce the release of ruby-libvirt 0.5.0. ruby-libvirt is a ruby wrapper around the libvirt API. Version 0.5.0 brings new APIs, more documentation, and bugfixes: * Updated Network class, implementing almost all libvirt APIs * Updated Domain class, implementing almost all libvirt APIs * Updated Connection class, implementing almost all libvirt APIs * Updated DomainSnapshot class, implementing almost all libvirt APIs * Updated NodeDevice class, implementing almost all libvirt APIs * Updated Storage class, implementing almost all libvirt APIs * Add constants for almost all libvirt defines * Improved performance in the library by using alloca Version 0.5.0 is available from http://libvirt.org/ruby: Tarball: http://libvirt.org/ruby/download/ruby-libvirt-0.5.0.tgz Gem: http://libvirt.org/ruby/download/ruby-libvirt-0.5.0.gem It is also available from rubygems.org; to get the latest version, run: $ gem install ruby-libvirt As usual, if you run into questions, problems, or bugs, please feel free to mail me (clalance...@gmail.com) and/or the libvirt mailing list. Thanks to everyone who contributed patches and submitted bugs. Chris Lalancette -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 1/6] conf: Add a keyboard input device type
From: Li Zhang zhlci...@linux.vnet.ibm.com There is no keyboard for non-x86 platforms when graphics are enabled. It's preferred to add one USB keyboard. This patch is to add keyboard input device type. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c| 3 ++- src/conf/domain_conf.h| 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 38c6801..964350d 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3167,6 +3167,7 @@ choice valuetablet/value valuemouse/value + valuekbd/value /choice /attribute optional diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b76cf26..f8b9639 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -504,7 +504,8 @@ VIR_ENUM_IMPL(virDomainVideo, VIR_DOMAIN_VIDEO_TYPE_LAST, VIR_ENUM_IMPL(virDomainInput, VIR_DOMAIN_INPUT_TYPE_LAST, mouse, - tablet) + tablet, + kbd) VIR_ENUM_IMPL(virDomainInputBus, VIR_DOMAIN_INPUT_BUS_LAST, ps2, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 4934911..8aa5f50 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1223,6 +1223,7 @@ struct _virDomainTPMDef { enum virDomainInputType { VIR_DOMAIN_INPUT_TYPE_MOUSE, VIR_DOMAIN_INPUT_TYPE_TABLET, +VIR_DOMAIN_INPUT_TYPE_KBD, VIR_DOMAIN_INPUT_TYPE_LAST }; -- 1.8.2.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 4/6] qemu_cap: Add USB keyboard capability
From: Li Zhang zhlci...@linux.vnet.ibm.com QEMU can support USB keyboard but libvirt haven't supportted it yet. This patch is to add USB keyboard capabilities and test cases. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 ++ tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 8 9 files changed, 18 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a68e555..580d598 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -245,6 +245,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, kvm-pit-lost-tick-policy, boot-strict, /* 160 */ + usb-kbd, ); struct _virQEMUCaps { @@ -1396,6 +1397,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { usb-storage, QEMU_CAPS_DEVICE_USB_STORAGE }, { virtio-mmio, QEMU_CAPS_DEVICE_VIRTIO_MMIO }, { ich9-intel-hda, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA }, +{ usb-kbd, QEMU_CAPS_DEVICE_USB_KBD }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index aea64ea..05837b2 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -199,6 +199,7 @@ enum virQEMUCapsFlags { QEMU_CAPS_DEVICE_ICH9_INTEL_HDA = 158, /* -device ich9-intel-hda */ QEMU_CAPS_KVM_PIT_TICK_POLICY = 159, /* kvm-pit.lost_tick_policy */ QEMU_CAPS_BOOT_STRICT= 160, /* -boot strict */ +QEMU_CAPS_DEVICE_USB_KBD = 161, /*-device usb-kbd*/ QEMU_CAPS_LAST, /* this must always be the last item */ }; diff --git a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps index 73a561d..b620341 100644 --- a/tests/qemucapabilitiesdata/caps_1.2.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.2.2-1.caps @@ -112,4 +112,5 @@ flag name='usb-storage'/ flag name='usb-storage.removable'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='usb-kbd'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps index da15d8b..6b4a8f0 100644 --- a/tests/qemucapabilitiesdata/caps_1.3.1-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.3.1-1.caps @@ -126,4 +126,5 @@ flag name='usb-storage'/ flag name='usb-storage.removable'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='usb-kbd'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps index c419068..e3d0047 100644 --- a/tests/qemucapabilitiesdata/caps_1.4.2-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.4.2-1.caps @@ -127,4 +127,5 @@ flag name='usb-storage.removable'/ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ +flag name='usb-kbd'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps index 2b00449..b29ea60 100644 --- a/tests/qemucapabilitiesdata/caps_1.5.3-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.5.3-1.caps @@ -132,4 +132,5 @@ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ flag name='boot-strict'/ +flag name='usb-kbd'/ /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps index 7bce4aa..2fa7d20 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.0-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.0-1.caps @@ -136,4 +136,6 @@ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ flag name='boot-strict'/ +flag name='usb-kbd'/ + /qemuCaps diff --git a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps index bfaab9d..0151cde 100644 --- a/tests/qemucapabilitiesdata/caps_1.6.50-1.caps +++ b/tests/qemucapabilitiesdata/caps_1.6.50-1.caps @@ -135,4 +135,5 @@ flag name='ich9-intel-hda'/ flag name='kvm-pit-lost-tick-policy'/ flag name='boot-strict'/ +flag name='usb-kbd'/ /qemuCaps diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 3628fbe..6e0a5f8 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -403,6 +403,7 @@ mymain(void) QEMU_CAPS_DEVICE_VMWARE_SVGA, QEMU_CAPS_DEVICE_USB_SERIAL, QEMU_CAPS_DEVICE_USB_NET, +QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_DEVICE_PCI_BRIDGE); DO_TEST(qemu-kvm-0.12.3, 12003, 1, 0, QEMU_CAPS_VNC_COLON, @@ -515,6 +516,7 @@
[libvirt] [PATCH v3 5/6] qemu: parse qemu command line for USB keyboard
From: Li Zhang zhlci...@linux.vnet.ibm.com This patch is to format qemu command line and xen driver for USB keyboard and add test cases for it. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- src/qemu/qemu_command.c| 44 +- src/xenxs/xen_sxpr.c | 27 + src/xenxs/xen_xm.c | 30 +++ .../qemuxml2argv-pseries-usb-kbd.args | 9 + .../qemuxml2argv-pseries-usb-kbd.xml | 19 ++ tests/qemuxml2argvtest.c | 3 ++ 6 files changed, 106 insertions(+), 26 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9539be7..ceba848 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5307,9 +5307,22 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def, { virBuffer buf = VIR_BUFFER_INITIALIZER; -virBufferAsprintf(buf, %s,id=%s, - dev-type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? - usb-mouse : usb-tablet, dev-info.alias); +switch (dev-type) { +case VIR_DOMAIN_INPUT_TYPE_MOUSE: +virBufferAsprintf(buf, usb-mouse,id=%s, dev-info.alias); +break; +case VIR_DOMAIN_INPUT_TYPE_TABLET: +virBufferAsprintf(buf, usb-tablet,id=%s, dev-info.alias); +break; +case VIR_DOMAIN_INPUT_TYPE_KBD: +if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_KBD)) { +virReportError(VIR_ERR_INTERNAL_ERROR, + %s, _(Can't get QEMU_CAPS_DEVICE_USB_KBD capability)); +goto error; +} +virBufferAsprintf(buf, usb-kbd,id=%s, dev-info.alias); +break; +} if (qemuBuildDeviceAddressStr(buf, def, dev-info, qemuCaps) 0) goto error; @@ -8996,9 +9009,17 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, optstr); VIR_FREE(optstr); } else { -virCommandAddArgList(cmd, -usbdevice, - input-type == VIR_DOMAIN_INPUT_TYPE_MOUSE - ? mouse : tablet, NULL); +switch (input-type) { +case VIR_DOMAIN_INPUT_TYPE_MOUSE: +virCommandAddArgList(cmd, -usbdevice, mouse, NULL); +break; +case VIR_DOMAIN_INPUT_TYPE_TABLET: +virCommandAddArgList(cmd, -usbdevice, tablet, NULL); +break; +case VIR_DOMAIN_INPUT_TYPE_KBD: +virCommandAddArgList(cmd, -usbdevice, kbd, NULL); +break; +} } } } @@ -11668,20 +11689,23 @@ qemuParseCommandLine(virCapsPtr qemuCaps, } else if (STREQ(arg, -usbdevice)) { WANT_VALUE(); if (STREQ(val, tablet) || -STREQ(val, mouse)) { +STREQ(val, mouse) || +STREQ(val, kbd)) { virDomainInputDefPtr input; if (VIR_ALLOC(input) 0) goto error; input-bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(val, tablet)) input-type = VIR_DOMAIN_INPUT_TYPE_TABLET; -else +else if (STREQ(val, mouse)) input-type = VIR_DOMAIN_INPUT_TYPE_MOUSE; -if (VIR_REALLOC_N(def-inputs, def-ninputs+1) 0) { +else +input-type = VIR_DOMAIN_INPUT_TYPE_KBD; + +if (VIR_APPEND_ELEMENT(def-inputs, def-ninputs, input) 0) { virDomainInputDefFree(input); goto error; } -def-inputs[def-ninputs++] = input; } else if (STRPREFIX(val, disk:)) { if (VIR_ALLOC(disk) 0) goto error; diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c index d514725..a02f999 100644 --- a/src/xenxs/xen_sxpr.c +++ b/src/xenxs/xen_sxpr.c @@ -724,21 +724,23 @@ xenParseSxprUSB(virDomainDefPtr def, tmp = sexpr_node(node, usbdevice); if (tmp *tmp) { if (STREQ(tmp, tablet) || -STREQ(tmp, mouse)) { +STREQ(tmp, mouse) || +STREQ(tmp, kbd)) { virDomainInputDefPtr input; if (VIR_ALLOC(input) 0) goto error; input-bus = VIR_DOMAIN_INPUT_BUS_USB; if (STREQ(tmp, tablet)) input-type = VIR_DOMAIN_INPUT_TYPE_TABLET; -else +else if (STREQ(tmp, mouse))
[libvirt] [PATCH v3 0/6] Support keyboard device
From: Li Zhang zhlci...@linux.vnet.ibm.com This patchset is to add keyboard input device. For PPC64, it doesn't support a default keyboard device when the graphic is enabled. Libvirt supports QEMU command line as -device VGA which won't create any keyboard device for it. So it requires libvirt to add a default USB keyboard device for it. This patchset is to add keyboard input device and a default USB keyboard for PPC64. The related discussion in QEMU community: http://lists.nongnu.org/archive/html/qemu-devel/2013-11/msg01734.html Li Zhang (6): conf: Add a keyboard input device type conf: Add one interface to add input devices. Remove PS2 mouse device for non-X86 platforms qemu_cap: Add USB keyboard capability qemu: parse qemu command line for USB keyboard. Add a default USB keyboard for PPC64 v3 - v2: * Handle the KBD device type in xen and QEMU driver. (Daniel.P.Berrange) * Remove PS2 mouse device for non-X86 platforms. * Move virDomainDefMaybeAddInput to a new patch. (Jan Tomko) * Replace VIR_REALLOC_N with VIR_APPEND_ELEMENT. (Jan Tomoko) * Fix several typos. (Jan Tomoko) * Add a virReportError when QEMU_CAPS_DEVICE_USB_KBD can't be gotten. (Jan Tomoko) v2 - v1: * change ifs to switch clause. * reconstruct the patches docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 91 -- src/conf/domain_conf.h | 5 ++ src/libvirt_private.syms | 1 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c| 41 +++--- src/qemu/qemu_domain.c | 29 ++- src/util/virarch.h | 2 + src/xenxs/xen_sxpr.c | 27 +-- src/xenxs/xen_xm.c | 30 +-- tests/qemucapabilitiesdata/caps_1.2.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 + tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 2 + tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 + tests/qemuhelptest.c | 8 ++ .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 3 +- .../qemuxml2argv-pseries-usb-kbd.args | 9 +++ .../qemuxml2argv-pseries-usb-kbd.xml | 19 + tests/qemuxml2argvtest.c | 3 + 22 files changed, 211 insertions(+), 68 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml -- 1.8.2.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 2/6] conf: Add one interface to add default input devices.
From: Li Zhang zhlci...@linux.vnet.ibm.com This patch is to add one new interface to add input devices. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- src/conf/domain_conf.c | 29 + src/conf/domain_conf.h | 4 src/libvirt_private.syms | 1 + 3 files changed, 34 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f8b9639..82339ea 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10822,6 +10822,35 @@ virDomainDefMaybeAddController(virDomainDefPtr def, return 0; } +int +virDomainDefMaybeAddInput(virDomainDefPtr def, + int type, + int bus) +{ +size_t i; +virDomainInputDefPtr input; + +for (i = 0; i def-ninputs; i++) { +if (def-inputs[i]-type == type +def-inputs[i]-bus == bus) +return 0; +} + +if (VIR_ALLOC(input) 0) +return -1; + +input-type = type; +input-bus = bus; + +if (VIR_APPEND_ELEMENT(def-inputs, def-ninputs, input) 0) { +VIR_FREE(input); +return -1; +} + +return 0; +} + + /* Parse a memory element located at XPATH within CTXT, and store the * result into MEM. If REQUIRED, then the value must exist; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8aa5f50..8616066 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2764,6 +2764,10 @@ virDomainDefMaybeAddController(virDomainDefPtr def, int type, int idx, int model); +int +virDomainDefMaybeAddInput(virDomainDefPtr def, + int type, + int bus); char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b2c7a8e..e37931c 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -165,6 +165,7 @@ virDomainDefGenSecurityLabelDef; virDomainDefGetDefaultEmulator; virDomainDefGetSecurityLabelDef; virDomainDefMaybeAddController; +virDomainDefMaybeAddInput; virDomainDefNew; virDomainDefParseFile; virDomainDefParseNode; -- 1.8.2.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 6/6] Add a default USB keyboard for PPC64
From: Li Zhang zhlci...@linux.vnet.ibm.com There is no keyboard working on PPC64 when graphics are enabled. It needs to add a USB keyboard for it. This patch is to add a USB keyboard when graphics are enabled. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- src/qemu/qemu_domain.c | 9 + tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 1 + 2 files changed, 10 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 75e615a..68d9e0c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -691,6 +691,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, bool addPCIRoot = false; bool addPCIeRoot = false; bool addDefaultMemballoon = true; +bool addDefaultUSBKBD = false; bool addDefaultMouse = false; int mouse_bus = VIR_DOMAIN_INPUT_BUS_XEN; @@ -735,6 +736,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, case VIR_ARCH_PPC64: addPCIRoot = true; +addDefaultUSBKBD = true; addDefaultMouse = true; if (STREQ(def-os.type, hvm)) mouse_bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -801,6 +803,13 @@ qemuDomainDefPostParse(virDomainDefPtr def, return -1; } +if (addDefaultUSBKBD +def-ngraphics 0 +virDomainDefMaybeAddInput(def, + VIR_DOMAIN_INPUT_TYPE_KBD, + VIR_DOMAIN_INPUT_BUS_USB) 0) +return -1; + return 0; } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml index 117213d..8c87998 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-disk.xml @@ -31,6 +31,7 @@ controller type='scsi' index='0'/ controller type='pci' index='0' model='pci-root'/ input type='mouse' bus='usb'/ +input type='kbd' bus='usb'/ graphics type='sdl'/ video model type='cirrus' vram='9216' heads='1'/ -- 1.8.2.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v3 3/6] Remove PS2 mouse device for non-X86 platforms
From: Li Zhang zhlci...@linux.vnet.ibm.com PS2 device only works for X86 platform, other platforms may need USB mouse. Athough it doesn't influence the QEMU command line, but It's not right to add one PS2 mouse for non-X86 platform. This patch is to remove PS2 device definition from other platforms. Add one default USB mouse for PPC64. It can be also added for other platforms if necessary. Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com --- src/conf/domain_conf.c | 59 -- src/qemu/qemu_domain.c | 20 +++- src/util/virarch.h | 2 + .../qemuxml2argvdata/qemuxml2argv-pseries-disk.xml | 2 +- 4 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 82339ea..e53a786 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7567,7 +7567,7 @@ error: /* Parse the XML definition for an input device */ static virDomainInputDefPtr -virDomainInputDefParseXML(const char *ostype, +virDomainInputDefParseXML(const virDomainDef *dom, xmlNodePtr node, unsigned int flags) { @@ -7600,7 +7600,7 @@ virDomainInputDefParseXML(const char *ostype, goto error; } -if (STREQ(ostype, hvm)) { +if (STREQ(dom-os.type, hvm)) { if (def-bus == VIR_DOMAIN_INPUT_BUS_PS2 /* Only allow mouse for ps2 */ def-type != VIR_DOMAIN_INPUT_TYPE_MOUSE) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -7628,8 +7628,9 @@ virDomainInputDefParseXML(const char *ostype, } } } else { -if (STREQ(ostype, hvm)) { -if (def-type == VIR_DOMAIN_INPUT_TYPE_MOUSE) +if (STREQ(dom-os.type, hvm)) { +if (def-type == VIR_DOMAIN_INPUT_TYPE_MOUSE +ARCH_IS_X86(dom-os.arch)) def-bus = VIR_DOMAIN_INPUT_BUS_PS2; else def-bus = VIR_DOMAIN_INPUT_BUS_USB; @@ -9631,7 +9632,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; break; case VIR_DOMAIN_DEVICE_INPUT: -if (!(dev-data.input = virDomainInputDefParseXML(def-os.type, +if (!(dev-data.input = virDomainInputDefParseXML(def, node, flags))) goto error; break; @@ -12211,7 +12212,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i n; i++) { -virDomainInputDefPtr input = virDomainInputDefParseXML(def-os.type, +virDomainInputDefPtr input = virDomainInputDefParseXML(def, nodes[i], flags); if (!input) @@ -12230,9 +12231,11 @@ virDomainDefParseXML(xmlDocPtr xml, * with graphics, so don't store it. * XXX will this be true for other virt types ? */ if ((STREQ(def-os.type, hvm) + ARCH_IS_X86(def-os.arch) input-bus == VIR_DOMAIN_INPUT_BUS_PS2 input-type == VIR_DOMAIN_INPUT_TYPE_MOUSE) || (STRNEQ(def-os.type, hvm) + ARCH_IS_X86(def-os.arch) input-bus == VIR_DOMAIN_INPUT_BUS_XEN input-type == VIR_DOMAIN_INPUT_TYPE_MOUSE)) { virDomainInputDefFree(input); @@ -12260,30 +12263,6 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); -/* If graphics are enabled, there's an implicit PS2 mouse */ -if (def-ngraphics 0) { -virDomainInputDefPtr input; - -if (VIR_ALLOC(input) 0) { -goto error; -} -if (STREQ(def-os.type, hvm)) { -input-type = VIR_DOMAIN_INPUT_TYPE_MOUSE; -input-bus = VIR_DOMAIN_INPUT_BUS_PS2; -} else { -input-type = VIR_DOMAIN_INPUT_TYPE_MOUSE; -input-bus = VIR_DOMAIN_INPUT_BUS_XEN; -} - -if (VIR_REALLOC_N(def-inputs, def-ninputs + 1) 0) { -virDomainInputDefFree(input); -goto error; -} -def-inputs[def-ninputs] = input; -def-ninputs++; -} - - /* analysis of the sound devices */ if ((n = virXPathNodeSet(./devices/sound, ctxt, nodes)) 0) { goto error; @@ -17201,15 +17180,17 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (def-ngraphics 0) { /* If graphics is enabled, add the implicit mouse */ -virDomainInputDef autoInput = { -VIR_DOMAIN_INPUT_TYPE_MOUSE, -STREQ(def-os.type, hvm) ? -VIR_DOMAIN_INPUT_BUS_PS2 : VIR_DOMAIN_INPUT_BUS_XEN, -{ .alias = NULL }, -}; - -if (virDomainInputDefFormat(buf, autoInput, flags) 0) -goto error; +if (ARCH_IS_X86(def-os.arch)) { +virDomainInputDef autoInput = { +
[libvirt] [PATCH] conf: don't format memtune with unlimited values
When changing memtune limits to unlimited with AFFECT_CONFIG, the values in virDomainDef are set to PARAM_UNLIMITED, which causes the whole memtune to be formatted. This can be changed in all drivers, but it also makes sense to use the default (0) as another value for unlimited, since zero memory limit makes no sense. Signed-off-by: Martin Kletzander mklet...@redhat.com --- Notes: This patch efectively completes my previous patch on PARAM_UNLIMITED [1], but I discovered it just now and found out that the behavior hasn't changed in between. [1] https://www.redhat.com/archives/libvir-list/2013-December/msg00434.html src/conf/domain_conf.c | 44 -- .../qemuxml2argv-memtune-unlimited.args| 6 +++ .../qemuxml2argv-memtune-unlimited.xml | 29 ++ tests/qemuxml2argvtest.c | 1 + .../qemuxml2xmlout-memtune-unlimited.xml | 27 + tests/qemuxml2xmltest.c| 1 + 6 files changed, 88 insertions(+), 20 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-memtune-unlimited.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b76cf26..e0ab4b1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16643,28 +16643,32 @@ virDomainDefFormatInternal(virDomainDefPtr def, } /* add memtune only if there are any */ -if (def-mem.hard_limit || def-mem.soft_limit || def-mem.min_guarantee || -def-mem.swap_hard_limit) +if ((def-mem.hard_limit + def-mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) || +(def-mem.soft_limit + def-mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) || +(def-mem.swap_hard_limit + def-mem.hard_limit != VIR_DOMAIN_MEMORY_PARAM_UNLIMITED) || +def-mem.min_guarantee) { virBufferAddLit(buf, memtune\n); -if (def-mem.hard_limit) { -virBufferAsprintf(buf, hard_limit unit='KiB' - %llu/hard_limit\n, def-mem.hard_limit); -} -if (def-mem.soft_limit) { -virBufferAsprintf(buf, soft_limit unit='KiB' - %llu/soft_limit\n, def-mem.soft_limit); -} -if (def-mem.min_guarantee) { -virBufferAsprintf(buf, min_guarantee unit='KiB' - %llu/min_guarantee\n, def-mem.min_guarantee); -} -if (def-mem.swap_hard_limit) { -virBufferAsprintf(buf, swap_hard_limit unit='KiB' - %llu/swap_hard_limit\n, def-mem.swap_hard_limit); -} -if (def-mem.hard_limit || def-mem.soft_limit || def-mem.min_guarantee || -def-mem.swap_hard_limit) +if (def-mem.hard_limit) { +virBufferAsprintf(buf, hard_limit unit='KiB' + %llu/hard_limit\n, def-mem.hard_limit); +} +if (def-mem.soft_limit) { +virBufferAsprintf(buf, soft_limit unit='KiB' + %llu/soft_limit\n, def-mem.soft_limit); +} +if (def-mem.min_guarantee) { +virBufferAsprintf(buf, min_guarantee unit='KiB' + %llu/min_guarantee\n, def-mem.min_guarantee); +} +if (def-mem.swap_hard_limit) { +virBufferAsprintf(buf, swap_hard_limit unit='KiB' + %llu/swap_hard_limit\n, def-mem.swap_hard_limit); +} virBufferAddLit(buf, /memtune\n); +} if (def-mem.hugepage_backed || def-mem.nosharepages || def-mem.locked) { virBufferAddLit(buf, memoryBacking\n); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.args b/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.args new file mode 100644 index 000..8bef546 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.args @@ -0,0 +1,6 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 -S -M pc -m 214 -smp 1 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb \ +-hda /dev/HostVG/QEMUGuest1 -net none -serial \ +none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml b/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml new file mode 100644 index 000..526129b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-memtune-unlimited.xml @@ -0,0 +1,29 @@ +domain type='qemu' + nameQEMUGuest1/name + uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid + memory unit='MiB'214/memory + currentMemory unit='KiB'219136/currentMemory + memtune +hard_limit unit='KiB'9007199254740991/hard_limit + /memtune + vcpu placement='static'1/vcpu + os +type arch='i686'