mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
tests/testutilsqemu: extract guest creation into separate functions
All other architectures have separate functions to prepare guest capabilities, do the same for i686 and x86_64 as well. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
2b50a11acb
commit
1da4efbe8a
@ -141,6 +141,118 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
testQemuAddI686Guest(virCapsPtr caps)
|
||||||
|
{
|
||||||
|
int nmachines = 0;
|
||||||
|
virCapsGuestMachinePtr *machines = NULL;
|
||||||
|
virCapsGuestPtr guest;
|
||||||
|
|
||||||
|
if (!(machines = testQemuAllocMachines(&nmachines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(guest = virCapabilitiesAddGuest(caps,
|
||||||
|
VIR_DOMAIN_OSTYPE_HVM,
|
||||||
|
VIR_ARCH_I686,
|
||||||
|
"/usr/bin/qemu",
|
||||||
|
NULL,
|
||||||
|
nmachines,
|
||||||
|
machines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
machines = NULL;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestDomain(guest,
|
||||||
|
VIR_DOMAIN_VIRT_QEMU,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(machines = testQemuAllocMachines(&nmachines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestDomain(guest,
|
||||||
|
VIR_DOMAIN_VIRT_KVM,
|
||||||
|
"/usr/bin/qemu-kvm",
|
||||||
|
NULL,
|
||||||
|
nmachines,
|
||||||
|
machines))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virCapabilitiesFreeMachines(machines, nmachines);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
testQemuAddX86_64Guest(virCapsPtr caps)
|
||||||
|
{
|
||||||
|
int nmachines = 0;
|
||||||
|
virCapsGuestMachinePtr *machines = NULL;
|
||||||
|
virCapsGuestPtr guest;
|
||||||
|
|
||||||
|
if (!(machines = testQemuAllocNewerMachines(&nmachines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(guest = virCapabilitiesAddGuest(caps,
|
||||||
|
VIR_DOMAIN_OSTYPE_HVM,
|
||||||
|
VIR_ARCH_X86_64,
|
||||||
|
"/usr/bin/qemu-system-x86_64",
|
||||||
|
NULL,
|
||||||
|
nmachines,
|
||||||
|
machines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
machines = NULL;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestDomain(guest,
|
||||||
|
VIR_DOMAIN_VIRT_QEMU,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!(machines = testQemuAllocMachines(&nmachines)))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestDomain(guest,
|
||||||
|
VIR_DOMAIN_VIRT_KVM,
|
||||||
|
"/usr/bin/kvm",
|
||||||
|
NULL,
|
||||||
|
nmachines,
|
||||||
|
machines))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
machines = NULL;
|
||||||
|
|
||||||
|
if (!virCapabilitiesAddGuestDomain(guest,
|
||||||
|
VIR_DOMAIN_VIRT_KVM,
|
||||||
|
"/usr/bin/kvm",
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL))
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virCapabilitiesFreeMachines(machines, nmachines);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int testQemuAddPPC64Guest(virCapsPtr caps)
|
static int testQemuAddPPC64Guest(virCapsPtr caps)
|
||||||
{
|
{
|
||||||
static const char *machine[] = { "pseries" };
|
static const char *machine[] = { "pseries" };
|
||||||
@ -315,9 +427,6 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps)
|
|||||||
virCapsPtr testQemuCapsInit(void)
|
virCapsPtr testQemuCapsInit(void)
|
||||||
{
|
{
|
||||||
virCapsPtr caps;
|
virCapsPtr caps;
|
||||||
virCapsGuestPtr guest;
|
|
||||||
virCapsGuestMachinePtr *machines = NULL;
|
|
||||||
int nmachines = 0;
|
|
||||||
|
|
||||||
if (!(caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false)))
|
if (!(caps = virCapabilitiesNew(VIR_ARCH_X86_64, false, false)))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -341,72 +450,10 @@ virCapsPtr testQemuCapsInit(void)
|
|||||||
|
|
||||||
caps->host.nnumaCell_max = 4;
|
caps->host.nnumaCell_max = 4;
|
||||||
|
|
||||||
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
|
if (testQemuAddI686Guest(caps) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
|
if (testQemuAddX86_64Guest(caps) < 0)
|
||||||
"/usr/bin/qemu", NULL,
|
|
||||||
nmachines, machines)) == NULL ||
|
|
||||||
!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
|
||||||
goto cleanup;
|
|
||||||
machines = NULL;
|
|
||||||
|
|
||||||
if (virCapabilitiesAddGuestDomain(guest,
|
|
||||||
VIR_DOMAIN_VIRT_QEMU,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virCapabilitiesAddGuestDomain(guest,
|
|
||||||
VIR_DOMAIN_VIRT_KVM,
|
|
||||||
"/usr/bin/qemu-kvm",
|
|
||||||
NULL,
|
|
||||||
nmachines,
|
|
||||||
machines) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
machines = NULL;
|
|
||||||
|
|
||||||
if ((machines = testQemuAllocNewerMachines(&nmachines)) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
|
|
||||||
"/usr/bin/qemu-system-x86_64", NULL,
|
|
||||||
nmachines, machines)) == NULL ||
|
|
||||||
!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
|
|
||||||
goto cleanup;
|
|
||||||
machines = NULL;
|
|
||||||
|
|
||||||
if (virCapabilitiesAddGuestDomain(guest,
|
|
||||||
VIR_DOMAIN_VIRT_QEMU,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (virCapabilitiesAddGuestDomain(guest,
|
|
||||||
VIR_DOMAIN_VIRT_KVM,
|
|
||||||
"/usr/bin/kvm",
|
|
||||||
NULL,
|
|
||||||
nmachines,
|
|
||||||
machines) == NULL)
|
|
||||||
goto cleanup;
|
|
||||||
machines = NULL;
|
|
||||||
|
|
||||||
if (virCapabilitiesAddGuestDomain(guest,
|
|
||||||
VIR_DOMAIN_VIRT_KVM,
|
|
||||||
"/usr/bin/kvm",
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL) == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (testQemuAddPPC64Guest(caps))
|
if (testQemuAddPPC64Guest(caps))
|
||||||
@ -442,7 +489,6 @@ virCapsPtr testQemuCapsInit(void)
|
|||||||
return caps;
|
return caps;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCapabilitiesFreeMachines(machines, nmachines);
|
|
||||||
caps->host.cpu = NULL;
|
caps->host.cpu = NULL;
|
||||||
virCPUDefFree(cpuDefault);
|
virCPUDefFree(cpuDefault);
|
||||||
virCPUDefFree(cpuHaswell);
|
virCPUDefFree(cpuHaswell);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user