You need to sign in or sign up before continuing.
testutilsxen.c 2.1 KB
Newer Older
1 2 3 4 5 6
#include <config.h>

#include <sys/utsname.h>
#include <stdlib.h>

#include "testutilsxen.h"
7 8
#include "domain_conf.h"

9

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

23
    uname(&utsname);
24
    if ((caps = virCapabilitiesNew(VIR_ARCH_I686,
25 26 27
                                   0, 0)) == NULL)
        return NULL;

28 29 30 31
    nmachines = ARRAY_CARDINALITY(x86_machines);
    if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
        goto cleanup;

32
    if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
33
                                         "/usr/lib/xen/bin/qemu-dm", NULL,
34
                                         nmachines, machines)) == NULL)
35
        goto cleanup;
36 37
    machines = NULL;

38 39 40 41 42 43 44 45
    if (virCapabilitiesAddGuestDomain(guest,
                                      "xen",
                                      NULL,
                                      NULL,
                                      0,
                                      NULL) == NULL)
        goto cleanup;

46 47 48 49
    nmachines = ARRAY_CARDINALITY(xen_machines);
    if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
        goto cleanup;

50
    if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_I686,
51
                                         "/usr/lib/xen/bin/qemu-dm", NULL,
52
                                         nmachines, machines)) == NULL)
53
        goto cleanup;
54 55
    machines = NULL;

56 57 58 59 60 61 62 63 64 65 66
    if (virCapabilitiesAddGuestDomain(guest,
                                      "xen",
                                      NULL,
                                      NULL,
                                      0,
                                      NULL) == NULL)
        goto cleanup;

    return caps;

cleanup:
67
    virCapabilitiesFreeMachines(machines, nmachines);
68
    virObjectUnref(caps);
69 70
    return NULL;
}