testutilsxen.c 2.1 KB
Newer Older
1 2 3 4 5
#include <config.h>

#include <sys/utsname.h>

#include "testutilsxen.h"
P
Pavel Hrdina 已提交
6
#include "testutilshostcpus.h"
7 8
#include "domain_conf.h"

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
virCapsPtr
testXLInitCaps(void)
{
    virCapsPtr caps;
    virCapsGuestPtr guest;
    virCapsGuestMachinePtr *machines;
    int nmachines;
    static const char *const x86_machines[] = {
        "xenfv"
    };
    static const char *const xen_machines[] = {
        "xenpv"
    };

    if ((caps = virCapabilitiesNew(virArchFromHost(),
                                   false, false)) == NULL)
        return NULL;
26 27 28

    caps->host.cpu = virCPUDefCopy(&cpuDefaultData);

29 30 31
    nmachines = ARRAY_CARDINALITY(x86_machines);
    if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
        goto cleanup;
32 33
    if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
                                         VIR_ARCH_X86_64,
34 35
                                         "/usr/lib/xen/bin/qemu-system-i386",
                                         "/usr/lib/xen/boot/hvmloader",
36 37 38
                                         nmachines, machines)) == NULL)
        goto cleanup;
    machines = NULL;
39
    if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
40 41 42 43 44 45
                                      NULL, 0, NULL) == NULL)
        goto cleanup;
    nmachines = ARRAY_CARDINALITY(xen_machines);
    if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
        goto cleanup;

46 47
    if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN,
                                         VIR_ARCH_X86_64,
48 49 50
                                         "/usr/lib/xen/bin/qemu-system-i386",
                                         NULL,
                                         nmachines, machines)) == NULL)
51 52 53
        goto cleanup;
    machines = NULL;

54
    if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_XEN, NULL,
55 56 57 58 59 60 61 62 63
                                      NULL, 0, NULL) == NULL)
        goto cleanup;
    return caps;

 cleanup:
    virCapabilitiesFreeMachines(machines, nmachines);
    virObjectUnref(caps);
    return NULL;
}