[libvirt] [PATCH 0/2] Fix tests failures on some architectures

This fixes the following test failures seen on some architectures: TEST: qemuxml2argvtest ........................................ 40 ........................................ 80 .............................!.!!!!! 116 FAIL Jiri Denemark (2): tests: Fake host capabilities properly qemu: Fix command line generation with faked host CPU src/qemu/qemu_command.c | 8 +++++--- tests/testutilsqemu.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) -- 1.7.4.1

Since we fake host CPU we should also fake host arch instead of taking the real architecture tests are running on. --- tests/testutilsqemu.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index bfac307..fbbb6c1 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -95,7 +95,7 @@ virCapsPtr testQemuCapsInit(void) { }; uname (&utsname); - if ((caps = virCapabilitiesNew(utsname.machine, + if ((caps = virCapabilitiesNew(host_cpu.arch, 0, 0)) == NULL) return NULL; @@ -107,7 +107,8 @@ virCapsPtr testQemuCapsInit(void) { if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32, "/usr/bin/qemu", NULL, - nmachines, machines)) == NULL) + nmachines, machines)) == NULL || + !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) goto cleanup; machines = NULL; @@ -124,7 +125,8 @@ virCapsPtr testQemuCapsInit(void) { if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64, "/usr/bin/qemu-system-x86_64", NULL, - nmachines, machines)) == NULL) + nmachines, machines)) == NULL || + !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) goto cleanup; machines = NULL; -- 1.7.4.1

Quoting Jiri Denemark (jdenemar@redhat.com):
Since we fake host CPU we should also fake host arch instead of taking the real architecture tests are running on. --- tests/testutilsqemu.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
Tested-by: Serge Hallyn <serge.hallyn@canonical.com> Thanks, Jiri!
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index bfac307..fbbb6c1 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -95,7 +95,7 @@ virCapsPtr testQemuCapsInit(void) { };
uname (&utsname); - if ((caps = virCapabilitiesNew(utsname.machine, + if ((caps = virCapabilitiesNew(host_cpu.arch, 0, 0)) == NULL) return NULL;
@@ -107,7 +107,8 @@ virCapsPtr testQemuCapsInit(void) {
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32, "/usr/bin/qemu", NULL, - nmachines, machines)) == NULL) + nmachines, machines)) == NULL || + !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) goto cleanup; machines = NULL;
@@ -124,7 +125,8 @@ virCapsPtr testQemuCapsInit(void) {
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64, "/usr/bin/qemu-system-x86_64", NULL, - nmachines, machines)) == NULL) + nmachines, machines)) == NULL || + !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0)) goto cleanup; machines = NULL;
-- 1.7.4.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 02/15/2011 07:53 AM, Jiri Denemark wrote:
Since we fake host CPU we should also fake host arch instead of taking the real architecture tests are running on. --- tests/testutilsqemu.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index bfac307..fbbb6c1 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -95,7 +95,7 @@ virCapsPtr testQemuCapsInit(void) { };
uname (&utsname); - if ((caps = virCapabilitiesNew(utsname.machine, + if ((caps = virCapabilitiesNew(host_cpu.arch,
Since this was the last use of utsname in the test file (a good thing!), the uname() call, the struct utsname declaration, and the #include <sys/utsname.h> in this file are all now dead code. ACK with that additional cleanup. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

The code expected that host CPU architecture matches the architecture on which libvirt runs. This is normally true but not in tests, where host CPU is faked to produce consistent results. --- src/qemu/qemu_command.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1687203..efd120c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2440,7 +2440,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, *hasHwVirt = false; if (def->cpu && def->cpu->model) { - if (qemuCapsProbeCPUModels(emulator, qemuCmdFlags, ut->machine, + if (host && + qemuCapsProbeCPUModels(emulator, qemuCmdFlags, host->arch, &ncpus, &cpus) < 0) goto cleanup; @@ -2469,7 +2470,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, break; } - if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine))) + if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(host->arch))) goto no_memory; if (def->cpu->match == VIR_CPU_MATCH_MINIMUM) @@ -2528,8 +2529,9 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, ret = 0; cleanup: + if (guest) + cpuDataFree(guest->arch, data); virCPUDefFree(guest); - cpuDataFree(ut->machine, data); if (cpus) { for (i = 0; i < ncpus; i++) -- 1.7.4.1

Quoting Jiri Denemark (jdenemar@redhat.com):
The code expected that host CPU architecture matches the architecture on which libvirt runs. This is normally true but not in tests, where host CPU is faked to produce consistent results. --- src/qemu/qemu_command.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
Tested-by: Serge Hallyn <serge.hallyn@canonical.com>
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1687203..efd120c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2440,7 +2440,8 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, *hasHwVirt = false;
if (def->cpu && def->cpu->model) { - if (qemuCapsProbeCPUModels(emulator, qemuCmdFlags, ut->machine, + if (host && + qemuCapsProbeCPUModels(emulator, qemuCmdFlags, host->arch, &ncpus, &cpus) < 0) goto cleanup;
@@ -2469,7 +2470,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, break; }
- if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(ut->machine))) + if (VIR_ALLOC(guest) < 0 || !(guest->arch = strdup(host->arch))) goto no_memory;
if (def->cpu->match == VIR_CPU_MATCH_MINIMUM) @@ -2528,8 +2529,9 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver, ret = 0;
cleanup: + if (guest) + cpuDataFree(guest->arch, data); virCPUDefFree(guest); - cpuDataFree(ut->machine, data);
if (cpus) { for (i = 0; i < ncpus; i++) -- 1.7.4.1
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 02/15/2011 07:54 AM, Jiri Denemark wrote:
The code expected that host CPU architecture matches the architecture on which libvirt runs. This is normally true but not in tests, where host CPU is faked to produce consistent results. --- src/qemu/qemu_command.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

Jiri Denemark (2): tests: Fake host capabilities properly qemu: Fix command line generation with faked host CPU
src/qemu/qemu_command.c | 8 +++++--- tests/testutilsqemu.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-)
I did the additional cleanup in patch 1/2 and pushed the series. Jirka
participants (3)
-
Eric Blake
-
Jiri Denemark
-
Serge E. Hallyn