[PATCH 2/2] qemu: Add support for enabling/disabling PMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]