[libvirt] [PATCH 0/2] qemu: Add support for PMU feature

This is based on top of: https://www.redhat.com/archives/libvir-list/2015-January/msg00307.html Martin Kletzander (2): docs, schema, conf: Add support for PMU feature qemu: Add support for enabling/disabling PMU docs/formatdomain.html.in | 6 ++++++ docs/schemas/domaincommon.rng | 11 ++++++++++ src/conf/domain_conf.c | 8 +++++-- src/conf/domain_conf.h | 3 ++- src/qemu/qemu_command.c | 12 ++++++++++- .../qemuxml2argv-pmu-feature-off.args | 5 +++++ .../qemuxml2argv-pmu-feature-off.xml | 25 ++++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-pmu-feature.args | 5 +++++ .../qemuxml2argvdata/qemuxml2argv-pmu-feature.xml | 25 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ .../qemuxml2xmlout-pmu-feature.xml | 25 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 3 +++ 12 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml -- 2.2.1

Just a new feature that can be turned on/off. https://bugzilla.redhat.com/show_bug.cgi?id=1178853 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- docs/formatdomain.html.in | 6 ++++++ docs/schemas/domaincommon.rng | 11 ++++++++++ src/conf/domain_conf.c | 8 +++++-- src/conf/domain_conf.h | 3 ++- .../qemuxml2argv-pmu-feature-off.xml | 25 ++++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-pmu-feature.xml | 25 ++++++++++++++++++++++ .../qemuxml2xmlout-pmu-feature.xml | 25 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 3 +++ 8 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 21a557e..4efefa4 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1444,6 +1444,12 @@ </tr> </table> </dd> + <dt><code>pmu</code></dt> + <dd>Depending on the <code>state</code> attribute (values <code>on</code>, + <code>off</code>, default <code>on</code>) enable or disable the + performance monitoring unit for the guest. + <span class="since">Since 1.2.12</span> + </dd> </dl> <h3><a name="elementsTime">Time keeping</a></h3> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 85b3709..d250e6f 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -4079,6 +4079,9 @@ <optional> <ref name="capabilities"/> </optional> + <optional> + <ref name="pmu"/> + </optional> </interleave> </element> </optional> @@ -4904,6 +4907,14 @@ </element> </define> + <define name="pmu"> + <element name="pmu"> + <optional> + <ref name="featurestate"/> + </optional> + </element> + </define> + <define name="featurestate"> <attribute name="state"> <ref name="virOnOff"/> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 57e99e6..96d80a9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1,7 +1,7 @@ /* * domain_conf.c: domain XML processing * - * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2015 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -162,7 +162,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, "hyperv", "kvm", "pvspinlock", - "capabilities") + "capabilities", + "pmu") VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST, "default", @@ -13305,6 +13306,8 @@ virDomainDefParseXML(xmlDocPtr xml, } ctxt->node = node; break; + + case VIR_DOMAIN_FEATURE_PMU: case VIR_DOMAIN_FEATURE_PVSPINLOCK: node = ctxt->node; ctxt->node = nodes[i]; @@ -19761,6 +19764,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, break; + case VIR_DOMAIN_FEATURE_PMU: case VIR_DOMAIN_FEATURE_PVSPINLOCK: switch ((virTristateSwitch) def->features[i]) { case VIR_TRISTATE_SWITCH_LAST: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ac1f4f8..5cc42d1 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1,7 +1,7 @@ /* * domain_conf.h: domain XML processing * - * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2015 Red Hat, Inc. * Copyright (C) 2006-2008 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -1611,6 +1611,7 @@ typedef enum { VIR_DOMAIN_FEATURE_KVM, VIR_DOMAIN_FEATURE_PVSPINLOCK, VIR_DOMAIN_FEATURE_CAPABILITIES, + VIR_DOMAIN_FEATURE_PMU, VIR_DOMAIN_FEATURE_LAST } virDomainFeature; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml new file mode 100644 index 0000000..2f16023 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml @@ -0,0 +1,25 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>6</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <features> + <acpi/> + <pmu state='off'/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml new file mode 100644 index 0000000..8a84703 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml @@ -0,0 +1,25 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>6</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <features> + <acpi/> + <pmu/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml new file mode 100644 index 0000000..7f23253 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml @@ -0,0 +1,25 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>6</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='network'/> + </os> + <features> + <acpi/> + <pmu state='on'/> + </features> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 1166534..0551ac3 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -202,6 +202,9 @@ mymain(void) DO_TEST("kvm-features"); DO_TEST("kvm-features-off"); + DO_TEST_DIFFERENT("pmu-feature"); + DO_TEST("pmu-feature-off"); + DO_TEST("hugepages"); DO_TEST("hugepages-pages"); DO_TEST("hugepages-pages2"); -- 2.2.1

This is used as a boolean parameter for the '-cpu' option. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1178853 Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_command.c | 12 +++++++++++- tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args | 5 +++++ tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args | 5 +++++ tests/qemuxml2argvtest.c | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 83833ab..d12d739 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1,7 +1,7 @@ /* * qemu_command.c: QEMU command generation * - * Copyright (C) 2006-2014 Red Hat, Inc. + * Copyright (C) 2006-2015 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -6402,6 +6402,16 @@ qemuBuildCpuArgStr(virQEMUDriverPtr driver, } } + if (def->features[VIR_DOMAIN_FEATURE_PMU]) { + virTristateSwitch pmu = def->features[VIR_DOMAIN_FEATURE_PMU]; + if (!have_cpu) + virBufferAdd(&buf, default_model, -1); + + virBufferAsprintf(&buf, ",pmu=%s", + virTristateSwitchTypeToString(pmu)); + have_cpu = true; + } + if (virBufferCheckError(&buf) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args new file mode 100644 index 0000000..4f6fe4f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc \ +-cpu qemu32,pmu=off -m 214 -smp 6 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -boot n -usb -net none -serial none \ +-parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args new file mode 100644 index 0000000..f28b654 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args @@ -0,0 +1,5 @@ +LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \ +/usr/bin/qemu -S -M pc \ +-cpu qemu32,pmu=on -m 214 -smp 6 -nographic -monitor \ +unix:/tmp/test-monitor,server,nowait -boot n -usb -net none -serial none \ +-parallel none diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1d0bd61..aebace9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -698,6 +698,9 @@ mymain(void) DO_TEST("kvm-features", NONE); DO_TEST("kvm-features-off", NONE); + DO_TEST("pmu-feature", NONE); + DO_TEST("pmu-feature-off", NONE); + DO_TEST("hugepages", QEMU_CAPS_MEM_PATH); DO_TEST_LINUX("hugepages-pages", QEMU_CAPS_MEM_PATH, QEMU_CAPS_OBJECT_MEMORY_RAM, -- 2.2.1

On 12.01.2015 14:24, Martin Kletzander wrote:
This is based on top of: https://www.redhat.com/archives/libvir-list/2015-January/msg00307.html
Martin Kletzander (2): docs, schema, conf: Add support for PMU feature qemu: Add support for enabling/disabling PMU
docs/formatdomain.html.in | 6 ++++++ docs/schemas/domaincommon.rng | 11 ++++++++++ src/conf/domain_conf.c | 8 +++++-- src/conf/domain_conf.h | 3 ++- src/qemu/qemu_command.c | 12 ++++++++++- .../qemuxml2argv-pmu-feature-off.args | 5 +++++ .../qemuxml2argv-pmu-feature-off.xml | 25 ++++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-pmu-feature.args | 5 +++++ .../qemuxml2argvdata/qemuxml2argv-pmu-feature.xml | 25 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 3 +++ .../qemuxml2xmlout-pmu-feature.xml | 25 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 3 +++ 12 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature-off.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pmu-feature.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pmu-feature.xml
ACK to both Michal
participants (2)
-
Martin Kletzander
-
Michal Privoznik