[pve-devel] [PATCH v2 qemu-server 11/12] cfg2cmd: add test case for custom CPU model

Stefan Reiter s.reiter at proxmox.com
Mon Sep 30 12:58:54 CEST 2019


Requires a mock CPU-model config, which is given as a raw string to also
test parsing capabilities.

Signed-off-by: Stefan Reiter <s.reiter at proxmox.com>
---
 test/cfg2cmd/custom-cpu-model.conf |  8 ++++++++
 test/run_config2command_tests.pl   | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 test/cfg2cmd/custom-cpu-model.conf

diff --git a/test/cfg2cmd/custom-cpu-model.conf b/test/cfg2cmd/custom-cpu-model.conf
new file mode 100644
index 0000000..d4db550
--- /dev/null
+++ b/test/cfg2cmd/custom-cpu-model.conf
@@ -0,0 +1,8 @@
+# TEST: Check if custom CPU models are resolved correctly
+cores: 3
+cpu: qemu64,custom=1,flags=+virt-ssbd,host-phys-bits=true
+name: customcpu
+numa: 0
+ostype: win10
+smbios1: uuid=2ea3f676-dfa5-11e9-ae82-c721e12f3fcf
+sockets: 1
diff --git a/test/run_config2command_tests.pl b/test/run_config2command_tests.pl
index 6f2fe28..c734133 100755
--- a/test/run_config2command_tests.pl
+++ b/test/run_config2command_tests.pl
@@ -11,6 +11,7 @@ use Test::MockModule;
 use PVE::Tools qw(file_get_contents file_set_contents run_command);
 use PVE::QemuConfig;
 use PVE::QemuServer;
+use PVE::QemuServer::CPUConfig;
 
 my $base_env = {
     storage_config => {
@@ -146,6 +147,26 @@ $pve_common_tools->mock(
     },
 );
 
+my $pve_cpuconfig;
+$pve_cpuconfig = Test::MockModule->new('PVE::QemuServer::CPUConfig');
+$pve_cpuconfig->mock(
+    load_custom_model_conf => sub {
+	# mock custom CPU model config
+	return PVE::QemuServer::CPUConfig->parse_config("cpu-models.conf",
+<<EOF
+
+# "qemu64" is also a default CPU, used here to test that this doesn't matter
+cpu-model: qemu64
+    reported-model athlon
+    flags +aes;+avx;-kvm_pv_unhalt
+    hv-vendor-id testvend
+    phys-bits 40
+
+EOF
+	)
+    },
+);
+
 sub diff($$) {
     my ($a, $b) = @_;
     return if $a eq $b;
-- 
2.20.1





More information about the pve-devel mailing list