[libvirt] [PATCH] tests: Properly reset mocked CPU model

Jiri Denemark posted 1 patch 5 years, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/bf143c0f8ebbea6e33392752d60a54d2589b6bad.1535465850.git.jdenemar@redhat.com
Test syntax-check passed
tests/testutilsqemu.c | 2 ++
1 file changed, 2 insertions(+)
[libvirt] [PATCH] tests: Properly reset mocked CPU model
Posted by Jiri Denemark 5 years, 7 months ago
When switching the host architecture to something for which we do not
have any host CPU model defined, the mocked
virQEMUCapsProbeHostCPUForEmulator would just return the previous CPU
model resulting in strange combinations, such as "core2duo" host CPU
model in QEMU capabilities for "AArch64" architecture. It currently
doesn't break any test case, but we should fix it anyway to avoid future
surprises which would be quite hard to debug.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 tests/testutilsqemu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 8438613f28..52ea6bf655 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -575,6 +575,8 @@ qemuTestSetHostCPU(virCapsPtr caps,
             setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
         else
             unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
+    } else {
+        unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
     }
     caps->host.cpu = cpu;
 }
-- 
2.18.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: Properly reset mocked CPU model
Posted by Erik Skultety 5 years, 7 months ago
On Tue, Aug 28, 2018 at 04:17:30PM +0200, Jiri Denemark wrote:
> When switching the host architecture to something for which we do not
> have any host CPU model defined, the mocked
> virQEMUCapsProbeHostCPUForEmulator would just return the previous CPU
> model resulting in strange combinations, such as "core2duo" host CPU
> model in QEMU capabilities for "AArch64" architecture. It currently
> doesn't break any test case, but we should fix it anyway to avoid future
> surprises which would be quite hard to debug.
>
> Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
> ---
>  tests/testutilsqemu.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
> index 8438613f28..52ea6bf655 100644
> --- a/tests/testutilsqemu.c
> +++ b/tests/testutilsqemu.c
> @@ -575,6 +575,8 @@ qemuTestSetHostCPU(virCapsPtr caps,
>              setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
>          else
>              unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
> +    } else {
> +        unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
>      }
>      caps->host.cpu = cpu;

How about squashing in the following:

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 52ea6bf655..70bed461b5 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -569,14 +569,11 @@ qemuTestSetHostCPU(virCapsPtr caps,
             cpu = cpuPower8;
     }

+    unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
     if (cpu) {
         caps->host.arch = cpu->arch;
         if (cpu->model)
             setenv("VIR_TEST_MOCK_FAKE_HOST_CPU", cpu->model, 1);
-        else
-            unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
-    } else {
-        unsetenv("VIR_TEST_MOCK_FAKE_HOST_CPU");
     }
     caps->host.cpu = cpu;
 }

Reviewed-by: Erik Skultety <eskultet@redhat.com>

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