Add virCapsGuestMachine structure

A subsequent commit will add a "canonical" field to this structure,
this patch basically just prepares the way for that.

The new type is added, along with virCapabilitiesAlloc/FreeMachines()
helpers and a whole bunch of code to make the transition.

One quirk is that virCapabilitiesAddGuestDomain() and
virCapabilitiesAddGuest() take ownership of the machine list rather
than duping it. This makes sense to avoid needless copying.

* src/capabilities.h: add the virCapsGuestMachine struct and use it
  in virCapsGuestDomainInfo, add prototypes for new functions and
  update the AddGuest() prototypes

* src/capabilities.c: add code for allocating and freeing the new
  type, change the machines parameter to AddGuest() etc.

* src/libvirt_private.syms: export the new helpers

* src/qemu_conf.c: update all the machine type code to use the new
  struct

* src/xen_internal.c: ditto

* tests/testutilsqemu.c: ditto
This commit is contained in:
Mark McLoughlin
2009-07-23 18:31:34 +01:00
parent d412487eb7
commit 38fd207e53
6 changed files with 147 additions and 50 deletions

View File

@@ -9,6 +9,8 @@ virCapsPtr testQemuCapsInit(void) {
struct utsname utsname;
virCapsPtr caps;
virCapsGuestPtr guest;
virCapsGuestMachinePtr *machines;
int nmachines;
static const char *const x86_machines[] = {
"pc", "isapc"
};
@@ -21,10 +23,16 @@ virCapsPtr testQemuCapsInit(void) {
0, 0)) == NULL)
return NULL;
nmachines = 2;
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
"/usr/bin/qemu", NULL,
2, x86_machines)) == NULL)
nmachines, machines)) == NULL)
goto cleanup;
machines = NULL;
if (virCapabilitiesAddGuestDomain(guest,
"qemu",
NULL,
@@ -33,10 +41,16 @@ virCapsPtr testQemuCapsInit(void) {
NULL) == NULL)
goto cleanup;
nmachines = 2;
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
"/usr/bin/qemu-system-x86_64", NULL,
2, x86_machines)) == NULL)
nmachines, machines)) == NULL)
goto cleanup;
machines = NULL;
if (virCapabilitiesAddGuestDomain(guest,
"qemu",
NULL,
@@ -52,10 +66,16 @@ virCapsPtr testQemuCapsInit(void) {
NULL) == NULL)
goto cleanup;
nmachines = 1;
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "xen", "x86_64", 64,
"/usr/bin/xenner", NULL,
1, xen_machines)) == NULL)
1, machines)) == NULL)
goto cleanup;
machines = NULL;
if (virCapabilitiesAddGuestDomain(guest,
"kvm",
"/usr/bin/kvm",
@@ -67,6 +87,7 @@ virCapsPtr testQemuCapsInit(void) {
return caps;
cleanup:
virCapabilitiesFreeMachines(machines, nmachines);
virCapabilitiesFree(caps);
return NULL;
}