1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value

Rather than an opencoded string. This should be a no-op
This commit is contained in:
Cole Robinson 2015-04-17 18:09:16 -04:00
parent 4231485c1c
commit d0440e3269
23 changed files with 56 additions and 53 deletions

View File

@ -86,7 +86,7 @@ virBhyveCapsBuild(void)
false, false)) == NULL)
return NULL;
if ((guest = virCapabilitiesAddGuest(caps, "hvm",
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
"bhyve",
NULL, 0, NULL)) == NULL)

View File

@ -393,7 +393,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
/**
* virCapabilitiesAddGuest:
* @caps: capabilities to extend
* @ostype: guest operating system type ('hvm' or 'xen')
* @ostype: guest operating system type, of enum VIR_DOMAIN_OSTYPE
* @arch: guest CPU architecture
* @wordsize: number of bits in CPU word
* @emulator: path to default device emulator for arch/ostype
@ -407,7 +407,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
*/
virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps,
const char *ostypestr,
int ostype,
virArch arch,
const char *emulator,
const char *loader,
@ -415,17 +415,10 @@ virCapabilitiesAddGuest(virCapsPtr caps,
virCapsGuestMachinePtr *machines)
{
virCapsGuestPtr guest;
int ostype;
if (VIR_ALLOC(guest) < 0)
goto error;
if ((ostype = virDomainOSTypeFromString(ostypestr)) < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown OS type '%s'"), ostypestr);
goto error;
}
guest->ostype = ostype;
guest->arch.id = arch;
guest->arch.wordsize = virArchGetWordSize(arch);

View File

@ -236,7 +236,7 @@ virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines,
extern virCapsGuestPtr
virCapabilitiesAddGuest(virCapsPtr caps,
const char *ostype,
int ostype,
virArch arch,
const char *emulator,
const char *loader,

View File

@ -573,7 +573,7 @@ esxCapsInit(esxPrivate *priv)
goto failure;
/* i686 */
guest = virCapabilitiesAddGuest(caps, "hvm",
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_I686,
NULL, NULL, 0,
NULL);
@ -586,7 +586,7 @@ esxCapsInit(esxPrivate *priv)
/* x86_64 */
if (supportsLongMode == esxVI_Boolean_True) {
guest = virCapabilitiesAddGuest(caps, "hvm",
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
NULL, NULL,
0, NULL);

View File

@ -425,7 +425,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
return -1;
if ((guest = virCapabilitiesAddGuest(caps,
guest_archs[i].hvm ? "hvm" : "xen",
guest_archs[i].hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN,
guest_archs[i].arch,
LIBXL_EXECBIN_DIR "/qemu-system-i386",
(guest_archs[i].hvm ?

View File

@ -99,7 +99,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
goto error;
if ((guest = virCapabilitiesAddGuest(caps,
"exe",
VIR_DOMAIN_OSTYPE_EXE,
caps->host.arch,
lxc_path,
NULL,
@ -118,7 +118,7 @@ virCapsPtr virLXCDriverCapsInit(virLXCDriverPtr driver)
/* On 64-bit hosts, we can use personality() to request a 32bit process */
if ((altArch = lxcContainerGetAlt32bitArch(caps->host.arch)) != VIR_ARCH_NONE) {
if ((guest = virCapabilitiesAddGuest(caps,
"exe",
VIR_DOMAIN_OSTYPE_EXE,
altArch,
lxc_path,
NULL,

View File

@ -179,7 +179,7 @@ virCapsPtr openvzCapsInit(void)
goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps,
"exe",
VIR_DOMAIN_OSTYPE_EXE,
caps->host.arch,
NULL,
NULL,

View File

@ -93,13 +93,13 @@ parallelsBuildCapabilities(void)
if (nodeCapsInitNUMA(caps) < 0)
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "hvm",
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
"parallels",
NULL, 0, NULL)) == NULL)
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "hvm",
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_I686,
"parallels",
NULL, 0, NULL)) == NULL)
@ -110,7 +110,7 @@ parallelsBuildCapabilities(void)
"parallels", NULL, NULL, 0, NULL) == NULL)
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "exe",
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_X86_64,
"parallels",
NULL, 0, NULL)) == NULL)

View File

@ -342,7 +342,7 @@ phypCapsInit(void)
}
if ((guest = virCapabilitiesAddGuest(caps,
"linux",
VIR_DOMAIN_OSTYPE_LINUX,
caps->host.arch,
NULL, NULL, 0, NULL)) == NULL)
goto no_memory;

View File

@ -829,7 +829,7 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
/* We register kvm as the base emulator too, since we can
* just give -no-kvm to disable acceleration if required */
if ((guest = virCapabilitiesAddGuest(caps,
"hvm",
VIR_DOMAIN_OSTYPE_HVM,
guestarch,
binary,
NULL,

View File

@ -707,7 +707,7 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
static int
get_definition(vahControl * ctl, const char *xmlStr)
{
int rc = -1;
int rc = -1, ostype;
virCapsGuestPtr guest; /* this is freed when caps is freed */
/*
@ -727,8 +727,13 @@ get_definition(vahControl * ctl, const char *xmlStr)
goto exit;
}
if ((ostype = virDomainOSTypeFromString(ctl->hvm)) < 0) {
vah_error(ctl, 0, _("unknown OS type"));
goto exit;
}
if ((guest = virCapabilitiesAddGuest(ctl->caps,
ctl->hvm,
ostype,
ctl->arch,
NULL,
NULL,

View File

@ -314,7 +314,8 @@ testBuildCapabilities(virConnectPtr conn)
testConnPtr privconn = conn->privateData;
virCapsPtr caps;
virCapsGuestPtr guest;
const char *const guest_types[] = { "hvm", "xen" };
int guest_types[] = { VIR_DOMAIN_OSTYPE_HVM,
VIR_DOMAIN_OSTYPE_XEN };
size_t i;
if ((caps = virCapabilitiesNew(VIR_ARCH_I686, false, false)) == NULL)

View File

@ -80,7 +80,7 @@ virCapsPtr umlCapsInit(void)
}
if ((guest = virCapabilitiesAddGuest(caps,
"uml",
VIR_DOMAIN_OSTYPE_UML,
caps->host.arch,
NULL,
NULL,

View File

@ -322,7 +322,7 @@ static virCapsPtr vboxCapsInit(void)
goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps,
"hvm",
VIR_DOMAIN_OSTYPE_HVM,
caps->host.arch,
NULL,
NULL,

View File

@ -73,7 +73,7 @@ vmwareCapsInit(void)
/* i686 guests are always supported */
if ((guest = virCapabilitiesAddGuest(caps,
"hvm",
VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_I686,
NULL, NULL, 0, NULL)) == NULL)
goto error;
@ -105,7 +105,7 @@ vmwareCapsInit(void)
cpuHasFeature(data, "svm")))) {
if ((guest = virCapabilitiesAddGuest(caps,
"hvm",
VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
NULL, NULL, 0, NULL)) == NULL)
goto error;

View File

@ -2142,7 +2142,7 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,
goto no_memory;
if ((guest = virCapabilitiesAddGuest(caps,
guest_archs[i].hvm ? "hvm" : "xen",
guest_archs[i].hvm ? VIR_DOMAIN_OSTYPE_HVM : VIR_DOMAIN_OSTYPE_XEN,
guest_archs[i].arch,
(hostarch == VIR_ARCH_X86_64 ?
"/usr/lib64/xen/bin/qemu-dm" :

View File

@ -106,13 +106,13 @@ getCapsObject(void)
if (!caps)
return NULL;
guest1 = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, "", "", 0, NULL);
guest1 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64, "", "", 0, NULL);
if (!guest1)
goto error_cleanup;
domain1 = virCapabilitiesAddGuestDomain(guest1, "xen", "", "", 0, NULL);
if (!domain1)
goto error_cleanup;
guest2 = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64, "", "", 0, NULL);
guest2 = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_X86_64, "", "", 0, NULL);
if (!guest2)
goto error_cleanup;
domain2 = virCapabilitiesAddGuestDomain(guest2, "xen", "", "", 0, NULL);

View File

@ -935,7 +935,7 @@ virCapsPtr virTestGenericCapsInit(void)
false, false)) == NULL)
return NULL;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
"/usr/bin/acme-virt", NULL,
0, NULL)) == NULL)
goto error;
@ -944,7 +944,7 @@ virCapsPtr virTestGenericCapsInit(void)
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_X86_64,
"/usr/bin/acme-virt", NULL,
0, NULL)) == NULL)
goto error;

View File

@ -17,7 +17,8 @@ virCapsPtr testLXCCapsInit(void)
false, false)) == NULL)
return NULL;
if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_I686,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;
@ -26,7 +27,8 @@ virCapsPtr testLXCCapsInit(void)
goto error;
if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_X86_64,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE,
VIR_ARCH_X86_64,
"/usr/libexec/libvirt_lxc", NULL,
0, NULL)) == NULL)
goto error;

View File

@ -146,7 +146,7 @@ static int testQemuAddPPC64Guest(virCapsPtr caps)
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC64,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64,
"/usr/bin/qemu-system-ppc64", NULL,
1, machines);
if (!guest)
@ -173,7 +173,7 @@ static int testQemuAddPPC64LEGuest(virCapsPtr caps)
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC64LE,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC64LE,
"/usr/bin/qemu-system-ppc64", NULL,
1, machines);
if (!guest)
@ -203,7 +203,7 @@ static int testQemuAddPPCGuest(virCapsPtr caps)
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_PPC,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_PPC,
"/usr/bin/qemu-system-ppc", NULL,
1, machines);
if (!guest)
@ -232,7 +232,7 @@ static int testQemuAddS390Guest(virCapsPtr caps)
if (!machines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_S390X,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_S390X,
"/usr/bin/qemu-system-s390x", NULL,
ARRAY_CARDINALITY(s390_machines),
machines);
@ -262,7 +262,7 @@ static int testQemuAddArmGuest(virCapsPtr caps)
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_ARMV7L,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_ARMV7L,
"/usr/bin/qemu-system-arm", NULL,
ARRAY_CARDINALITY(machines),
capsmachines);
@ -290,7 +290,7 @@ static int testQemuAddAARCH64Guest(virCapsPtr caps)
if (!capsmachines)
goto error;
guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_AARCH64,
guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_AARCH64,
"/usr/bin/qemu-system-aarch64", NULL,
ARRAY_CARDINALITY(machines),
capsmachines);
@ -339,7 +339,7 @@ virCapsPtr testQemuCapsInit(void)
if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
"/usr/bin/qemu", NULL,
nmachines, machines)) == NULL ||
!virCapabilitiesAddGuestFeature(guest, "cpuselection", true, false))
@ -357,7 +357,7 @@ virCapsPtr testQemuCapsInit(void)
if ((machines = testQemuAllocNewerMachines(&nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64,
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))
@ -388,7 +388,7 @@ virCapsPtr testQemuCapsInit(void)
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_X86_64,
"/usr/bin/xenner", NULL,
nmachines, machines)) == NULL)
goto cleanup;

View File

@ -30,7 +30,7 @@ virCapsPtr testXenCapsInit(void)
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_I686,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, VIR_ARCH_I686,
"/usr/lib/xen/bin/qemu-dm", NULL,
nmachines, machines)) == NULL)
goto cleanup;
@ -48,7 +48,7 @@ virCapsPtr testXenCapsInit(void)
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_I686,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN, VIR_ARCH_I686,
"/usr/lib/xen/bin/qemu-dm", NULL,
nmachines, machines)) == NULL)
goto cleanup;
@ -91,7 +91,8 @@ testXLInitCaps(void)
nmachines = ARRAY_CARDINALITY(x86_machines);
if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
"/usr/lib/xen/bin/qemu-system-i386",
"/usr/lib/xen/boot/hvmloader",
nmachines, machines)) == NULL)
@ -104,7 +105,8 @@ testXLInitCaps(void)
if ((machines = virCapabilitiesAllocMachines(xen_machines, nmachines)) == NULL)
goto cleanup;
if ((guest = virCapabilitiesAddGuest(caps, "xen", VIR_ARCH_X86_64,
if ((guest = virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_XEN,
VIR_ARCH_X86_64,
"/usr/lib/xen/bin/qemu-system-i386",
NULL,
nmachines, machines)) == NULL)

View File

@ -34,7 +34,7 @@ testCapsInit(void)
/* i686 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm",
virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_I686,
NULL, NULL, 0, NULL);
@ -48,7 +48,7 @@ testCapsInit(void)
/* x86_64 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm",
virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
NULL, NULL, 0, NULL);

View File

@ -35,7 +35,7 @@ testCapsInit(void)
/* i686 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm",
virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_I686,
NULL, NULL, 0, NULL);
@ -49,7 +49,7 @@ testCapsInit(void)
/* x86_64 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm",
virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM,
VIR_ARCH_X86_64,
NULL, NULL, 0, NULL);