[libvirt] [PATCH] tests: avoid probing host CPU from bhyve test

Daniel P. Berrangé posted 1 patch 4 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20200108182002.1199650-1-berrange@redhat.com
tests/bhyveargv2xmlmock.c | 8 ++++++++
1 file changed, 8 insertions(+)
[libvirt] [PATCH] tests: avoid probing host CPU from bhyve test
Posted by Daniel P. Berrangé 4 years, 4 months ago
bhyveargv2xmlmock calls virBhyveCapsBuild which in turn
calls virCPUProbeHost, probing the real host CPU. This
causes a test failure if the host CPU happens to contain
the 'arch-capabilities' feature as it triggers a call
to virHostCPUGetMSR() which fails on FreeBSD.

Fortunately we already have convenient code for mocking
the host CPU probing.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 tests/bhyveargv2xmlmock.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/bhyveargv2xmlmock.c b/tests/bhyveargv2xmlmock.c
index 1f08bebb7b..8120be29c1 100644
--- a/tests/bhyveargv2xmlmock.c
+++ b/tests/bhyveargv2xmlmock.c
@@ -2,7 +2,9 @@
 
 #include "virnetdev.h"
 #include "internal.h"
+#include "testutilshostcpus.h"
 #include "util/viruuid.h"
+#include "cpu/cpu.h"
 
 #define VIR_FROM_THIS VIR_FROM_BHYVE
 
@@ -25,3 +27,9 @@ virUUIDGenerate(unsigned char *uuid)
         return -1;
     return 0;
 }
+
+virCPUDefPtr
+virCPUProbeHost(virArch arch)
+{
+    return testUtilsHostCpusGetDefForArch(arch);
+}
-- 
2.24.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: avoid probing host CPU from bhyve test
Posted by Michal Privoznik 4 years, 4 months ago
On 1/8/20 7:20 PM, Daniel P. Berrangé wrote:
> bhyveargv2xmlmock calls virBhyveCapsBuild which in turn
> calls virCPUProbeHost, probing the real host CPU. This
> causes a test failure if the host CPU happens to contain
> the 'arch-capabilities' feature as it triggers a call
> to virHostCPUGetMSR() which fails on FreeBSD.
> 
> Fortunately we already have convenient code for mocking
> the host CPU probing.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>   tests/bhyveargv2xmlmock.c | 8 ++++++++
>   1 file changed, 8 insertions(+)

With this squashed in:

diff --git i/src/cpu/cpu.h w/src/cpu/cpu.h
index 13909bb7a4..2e8b8923ae 100644
--- i/src/cpu/cpu.h
+++ w/src/cpu/cpu.h
@@ -193,7 +193,7 @@ virCPUGetHost(virArch arch,
                virDomainCapsCPUModelsPtr models);

  virCPUDefPtr
-virCPUProbeHost(virArch arch);
+virCPUProbeHost(virArch arch) G_GNUC_NO_INLINE;

  virCPUDefPtr
  virCPUBaseline(virArch arch,



Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal

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