mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Pass virDomainVirtType to APIs dealing with machine types
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4682197641
commit
de18836ea7
@ -2105,8 +2105,10 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
|||||||
* Resolves aliased machine names to the actual machine name. If qemuCaps isn't
|
* Resolves aliased machine names to the actual machine name. If qemuCaps isn't
|
||||||
* present @name is returned.
|
* present @name is returned.
|
||||||
*/
|
*/
|
||||||
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
const char *
|
||||||
const char *name)
|
virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType G_GNUC_UNUSED,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -2124,8 +2126,10 @@ const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
int
|
||||||
const char *name)
|
virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType G_GNUC_UNUSED,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -2143,8 +2147,10 @@ int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
bool
|
||||||
const char *name)
|
virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType G_GNUC_UNUSED,
|
||||||
|
const char *name)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -2430,6 +2436,7 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType G_GNUC_UNUSED,
|
||||||
const char *canonical_machine)
|
const char *canonical_machine)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -2444,6 +2451,7 @@ virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
qemuMonitorPtr mon)
|
qemuMonitorPtr mon)
|
||||||
{
|
{
|
||||||
char **values;
|
char **values;
|
||||||
@ -2455,10 +2463,10 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
|
|||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) {
|
for (i = 0; i < G_N_ELEMENTS(virQEMUCapsMachineProps); i++) {
|
||||||
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
|
||||||
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, props.type);
|
const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, props.type);
|
||||||
g_autofree char *type = NULL;
|
g_autofree char *type = NULL;
|
||||||
|
|
||||||
if (!virQEMUCapsIsMachineSupported(qemuCaps, canon))
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* The QOM type for machine types is the machine type name
|
/* The QOM type for machine types is the machine type name
|
||||||
@ -4643,7 +4651,7 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
|
|||||||
return -1;
|
return -1;
|
||||||
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
|
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (virQEMUCapsProbeQMPMachineProps(qemuCaps, mon) < 0)
|
if (virQEMUCapsProbeQMPMachineProps(qemuCaps, type, mon) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, accel, mon) < 0)
|
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, accel, mon) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -4880,6 +4888,7 @@ static const struct virQEMUCapsMachineTypeFilter virQEMUCapsMachineFilter[] = {
|
|||||||
|
|
||||||
void
|
void
|
||||||
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *machineType)
|
const char *machineType)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -4898,7 +4907,7 @@ virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
|||||||
virQEMUCapsClear(qemuCaps, filter->flags[j]);
|
virQEMUCapsClear(qemuCaps, filter->flags[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, machineType))
|
if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, virtType, machineType))
|
||||||
virQEMUCapsClear(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
virQEMUCapsClear(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4972,6 +4981,7 @@ virQEMUCapsCacheLookup(virFileCachePtr cache,
|
|||||||
|
|
||||||
virQEMUCapsPtr
|
virQEMUCapsPtr
|
||||||
virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *binary,
|
const char *binary,
|
||||||
const char *machineType)
|
const char *machineType)
|
||||||
{
|
{
|
||||||
@ -4987,7 +4997,7 @@ virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
virQEMUCapsFilterByMachineType(ret, machineType);
|
virQEMUCapsFilterByMachineType(ret, virtType, machineType);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5130,20 +5140,6 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
|
|||||||
binary = virQEMUCapsGetBinary(qemuCaps);
|
binary = virQEMUCapsGetBinary(qemuCaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (machine) {
|
|
||||||
/* Turn @machine into canonical name */
|
|
||||||
machine = virQEMUCapsGetCanonicalMachine(qemuCaps, machine);
|
|
||||||
|
|
||||||
if (!virQEMUCapsIsMachineSupported(qemuCaps, machine)) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG,
|
|
||||||
_("the machine '%s' is not supported by emulator '%s'"),
|
|
||||||
machine, binary);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
machine = virQEMUCapsGetPreferredMachine(qemuCaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
capsType = VIR_DOMAIN_VIRT_KVM;
|
capsType = VIR_DOMAIN_VIRT_KVM;
|
||||||
else
|
else
|
||||||
@ -5159,6 +5155,20 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (machine) {
|
||||||
|
/* Turn @machine into canonical name */
|
||||||
|
machine = virQEMUCapsGetCanonicalMachine(qemuCaps, virttype, machine);
|
||||||
|
|
||||||
|
if (!virQEMUCapsIsMachineSupported(qemuCaps, virttype, machine)) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG,
|
||||||
|
_("the machine '%s' is not supported by emulator '%s'"),
|
||||||
|
machine, binary);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
machine = virQEMUCapsGetPreferredMachine(qemuCaps, virttype);
|
||||||
|
}
|
||||||
|
|
||||||
if (retArch)
|
if (retArch)
|
||||||
*retArch = arch;
|
*retArch = arch;
|
||||||
if (retVirttype)
|
if (retVirttype)
|
||||||
@ -5191,7 +5201,8 @@ virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
|
|||||||
* Note that this may differ from QEMU's own default machine
|
* Note that this may differ from QEMU's own default machine
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps)
|
virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType G_GNUC_UNUSED)
|
||||||
{
|
{
|
||||||
if (!qemuCaps->nmachineTypes)
|
if (!qemuCaps->nmachineTypes)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -5649,6 +5660,7 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|||||||
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
|
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
|
||||||
|
|
||||||
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
||||||
|
domCaps->virttype,
|
||||||
domCaps->machine);
|
domCaps->machine);
|
||||||
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM) {
|
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM) {
|
||||||
int hostmaxvcpus;
|
int hostmaxvcpus;
|
||||||
|
@ -604,13 +604,17 @@ bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
|
|||||||
virDomainVirtType type,
|
virDomainVirtType type,
|
||||||
virCPUMode mode);
|
virCPUMode mode);
|
||||||
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *name);
|
const char *name);
|
||||||
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *name);
|
const char *name);
|
||||||
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *name);
|
const char *name);
|
||||||
|
|
||||||
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *machineType);
|
const char *machineType);
|
||||||
|
|
||||||
virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
|
virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
|
||||||
@ -620,6 +624,7 @@ virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
|
|||||||
virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache,
|
virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache,
|
||||||
const char *binary);
|
const char *binary);
|
||||||
virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
|
||||||
|
virDomainVirtType virtType,
|
||||||
const char *binary,
|
const char *binary,
|
||||||
const char *machineType);
|
const char *machineType);
|
||||||
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
|
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
|
||||||
@ -645,7 +650,8 @@ bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
|
|||||||
virDomainVirtType virtType,
|
virDomainVirtType virtType,
|
||||||
virGICVersion version);
|
virGICVersion version);
|
||||||
|
|
||||||
const char *virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps);
|
const char *virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType);
|
||||||
|
|
||||||
int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
|
||||||
const char *binary,
|
const char *binary,
|
||||||
|
@ -4306,7 +4306,8 @@ qemuCanonicalizeMachine(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
|
|||||||
{
|
{
|
||||||
const char *canon;
|
const char *canon;
|
||||||
|
|
||||||
if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->os.machine)))
|
if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->virtType,
|
||||||
|
def->os.machine)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (STRNEQ(canon, def->os.machine)) {
|
if (STRNEQ(canon, def->os.machine)) {
|
||||||
@ -4841,7 +4842,8 @@ static int
|
|||||||
qemuDomainValidateCpuCount(const virDomainDef *def,
|
qemuDomainValidateCpuCount(const virDomainDef *def,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
|
unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->virtType,
|
||||||
|
def->os.machine);
|
||||||
|
|
||||||
if (virDomainDefGetVcpus(def) == 0) {
|
if (virDomainDefGetVcpus(def) == 0) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
@ -8940,6 +8942,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
|
|||||||
qCaps = virObjectRef(qemuCaps);
|
qCaps = virObjectRef(qemuCaps);
|
||||||
} else {
|
} else {
|
||||||
if (!(qCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
|
if (!(qCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
|
||||||
|
def->virtType,
|
||||||
def->emulator,
|
def->emulator,
|
||||||
def->os.machine)))
|
def->os.machine)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -14976,6 +14979,7 @@ qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
|
|||||||
|
|
||||||
virObjectUnref(priv->qemuCaps);
|
virObjectUnref(priv->qemuCaps);
|
||||||
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(qemuCapsCache,
|
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(qemuCapsCache,
|
||||||
|
vm->def->virtType,
|
||||||
vm->def->emulator,
|
vm->def->emulator,
|
||||||
vm->def->os.machine)))
|
vm->def->os.machine)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -83,6 +83,7 @@ fillQemuCaps(virDomainCapsPtr domCaps,
|
|||||||
virCapsPtr caps = NULL;
|
virCapsPtr caps = NULL;
|
||||||
virQEMUCapsPtr qemuCaps = NULL;
|
virQEMUCapsPtr qemuCaps = NULL;
|
||||||
virDomainCapsLoaderPtr loader = &domCaps->os.loader;
|
virDomainCapsLoaderPtr loader = &domCaps->os.loader;
|
||||||
|
virDomainVirtType virtType;
|
||||||
|
|
||||||
if (!(caps = virCapabilitiesNew(domCaps->arch, false, false)) ||
|
if (!(caps = virCapabilitiesNew(domCaps->arch, false, false)) ||
|
||||||
fakeHostCPU(caps, domCaps->arch) < 0)
|
fakeHostCPU(caps, domCaps->arch) < 0)
|
||||||
@ -92,13 +93,18 @@ fillQemuCaps(virDomainCapsPtr domCaps,
|
|||||||
if (!(qemuCaps = qemuTestParseCapabilities(caps, path)))
|
if (!(qemuCaps = qemuTestParseCapabilities(caps, path)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||||
|
virtType = VIR_DOMAIN_VIRT_KVM;
|
||||||
|
else
|
||||||
|
virtType = VIR_DOMAIN_VIRT_QEMU;
|
||||||
|
|
||||||
if (machine) {
|
if (machine) {
|
||||||
VIR_FREE(domCaps->machine);
|
VIR_FREE(domCaps->machine);
|
||||||
domCaps->machine = g_strdup(virQEMUCapsGetCanonicalMachine(qemuCaps, machine));
|
domCaps->machine = g_strdup(virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, machine));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!domCaps->machine)
|
if (!domCaps->machine)
|
||||||
domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps));
|
domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps, virtType));
|
||||||
|
|
||||||
if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
|
if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
|
||||||
false,
|
false,
|
||||||
|
Loading…
Reference in New Issue
Block a user