qemu: cache host arch separately from virCapsPtr

As part of a goal to eliminate the need to use virCapsPtr for anything
other than the virConnectGetCapabilies() API impl, cache the host arch
against the QEMU driver struct and use that field directly.

In the tests we move virArchFromHost() globally in testutils.c so that
every test runs with a fixed default architecture reported.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé
2019-11-26 17:51:22 +00:00
parent 5c7cd74a52
commit bce3b0807e
15 changed files with 63 additions and 51 deletions

View File

@@ -576,13 +576,16 @@ virCapsPtr testQemuCapsInit(void)
void
qemuTestSetHostArch(virCapsPtr caps,
qemuTestSetHostArch(virQEMUDriverPtr driver,
virArch arch)
{
if (arch == VIR_ARCH_NONE)
arch = VIR_ARCH_X86_64;
caps->host.arch = arch;
qemuTestSetHostCPU(caps, NULL);
virTestHostArch = arch;
driver->hostarch = virArchFromHost();
driver->caps->host.arch = virArchFromHost();
qemuTestSetHostCPU(driver->caps, NULL);
}
@@ -694,6 +697,8 @@ int qemuTestDriverInit(virQEMUDriver *driver)
if (virMutexInit(&driver->lock) < 0)
return -1;
driver->hostarch = virArchFromHost();
driver->config = virQEMUDriverConfigNew(false);
if (!driver->config)
goto error;