mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Make virQEMUCapsGetMachineTypesCaps static
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c8fe9102fc
commit
42adc0b87d
@ -833,6 +833,82 @@ virQEMUCapsInitGuest(virCapsPtr caps,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
||||||
|
size_t *nmachines,
|
||||||
|
virCapsGuestMachinePtr **machines)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
*machines = NULL;
|
||||||
|
*nmachines = qemuCaps->nmachineTypes;
|
||||||
|
|
||||||
|
if (*nmachines &&
|
||||||
|
VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
||||||
|
virCapsGuestMachinePtr mach;
|
||||||
|
if (VIR_ALLOC(mach) < 0)
|
||||||
|
goto error;
|
||||||
|
(*machines)[i] = mach;
|
||||||
|
if (qemuCaps->machineTypes[i].alias) {
|
||||||
|
mach->name = g_strdup(qemuCaps->machineTypes[i].alias);
|
||||||
|
mach->canonical = g_strdup(qemuCaps->machineTypes[i].name);
|
||||||
|
} else {
|
||||||
|
mach->name = g_strdup(qemuCaps->machineTypes[i].name);
|
||||||
|
}
|
||||||
|
mach->maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure all canonical machine types also have their own entry so that
|
||||||
|
* /capabilities/guest/arch[@name='...']/machine/text() XPath selects all
|
||||||
|
* supported machine types.
|
||||||
|
*/
|
||||||
|
i = 0;
|
||||||
|
while (i < *nmachines) {
|
||||||
|
size_t j;
|
||||||
|
bool found = false;
|
||||||
|
virCapsGuestMachinePtr machine = (*machines)[i];
|
||||||
|
|
||||||
|
if (!machine->canonical) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < *nmachines; j++) {
|
||||||
|
if (STREQ(machine->canonical, (*machines)[j]->name)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
virCapsGuestMachinePtr mach;
|
||||||
|
if (VIR_ALLOC(mach) < 0)
|
||||||
|
goto error;
|
||||||
|
if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
|
||||||
|
VIR_FREE(mach);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
mach->name = g_strdup(machine->canonical);
|
||||||
|
mach->maxCpus = machine->maxCpus;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virCapabilitiesFreeMachines(*machines, *nmachines);
|
||||||
|
*nmachines = 0;
|
||||||
|
*machines = NULL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
||||||
const char *binary,
|
const char *binary,
|
||||||
@ -2021,80 +2097,6 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
|
||||||
size_t *nmachines,
|
|
||||||
virCapsGuestMachinePtr **machines)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
*machines = NULL;
|
|
||||||
*nmachines = qemuCaps->nmachineTypes;
|
|
||||||
|
|
||||||
if (*nmachines &&
|
|
||||||
VIR_ALLOC_N(*machines, qemuCaps->nmachineTypes) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
for (i = 0; i < qemuCaps->nmachineTypes; i++) {
|
|
||||||
virCapsGuestMachinePtr mach;
|
|
||||||
if (VIR_ALLOC(mach) < 0)
|
|
||||||
goto error;
|
|
||||||
(*machines)[i] = mach;
|
|
||||||
if (qemuCaps->machineTypes[i].alias) {
|
|
||||||
mach->name = g_strdup(qemuCaps->machineTypes[i].alias);
|
|
||||||
mach->canonical = g_strdup(qemuCaps->machineTypes[i].name);
|
|
||||||
} else {
|
|
||||||
mach->name = g_strdup(qemuCaps->machineTypes[i].name);
|
|
||||||
}
|
|
||||||
mach->maxCpus = qemuCaps->machineTypes[i].maxCpus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure all canonical machine types also have their own entry so that
|
|
||||||
* /capabilities/guest/arch[@name='...']/machine/text() XPath selects all
|
|
||||||
* supported machine types.
|
|
||||||
*/
|
|
||||||
i = 0;
|
|
||||||
while (i < *nmachines) {
|
|
||||||
size_t j;
|
|
||||||
bool found = false;
|
|
||||||
virCapsGuestMachinePtr machine = (*machines)[i];
|
|
||||||
|
|
||||||
if (!machine->canonical) {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = 0; j < *nmachines; j++) {
|
|
||||||
if (STREQ(machine->canonical, (*machines)[j]->name)) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
virCapsGuestMachinePtr mach;
|
|
||||||
if (VIR_ALLOC(mach) < 0)
|
|
||||||
goto error;
|
|
||||||
if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < 0) {
|
|
||||||
VIR_FREE(mach);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
mach->name = g_strdup(machine->canonical);
|
|
||||||
mach->maxCpus = machine->maxCpus;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error:
|
|
||||||
virCapabilitiesFreeMachines(*machines, *nmachines);
|
|
||||||
*nmachines = 0;
|
|
||||||
*machines = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virQEMUCapsGetCanonicalMachine:
|
* virQEMUCapsGetCanonicalMachine:
|
||||||
* @qemuCaps: qemu capabilities object
|
* @qemuCaps: qemu capabilities object
|
||||||
|
@ -609,9 +609,6 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
|||||||
const char *name);
|
const char *name);
|
||||||
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
||||||
const char *name);
|
const char *name);
|
||||||
int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
|
||||||
size_t *nmachines,
|
|
||||||
virCapsGuestMachinePtr **machines);
|
|
||||||
|
|
||||||
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
||||||
const char *machineType);
|
const char *machineType);
|
||||||
|
Loading…
Reference in New Issue
Block a user