* Resolves aliased machine names to the actual machine name. If qemuCaps isn't
* present @name is returned.
*/
-const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
- const char *name)
+const char *
+virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType G_GNUC_UNUSED,
+ const char *name)
{
size_t i;
}
-int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
- const char *name)
+int
+virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType G_GNUC_UNUSED,
+ const char *name)
{
size_t i;
}
-bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
- const char *name)
+bool
+virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType G_GNUC_UNUSED,
+ const char *name)
{
size_t i;
static bool
virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType G_GNUC_UNUSED,
const char *canonical_machine)
{
size_t i;
static int
virQEMUCapsProbeQMPMachineProps(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
qemuMonitorPtr mon)
{
char **values;
for (i = 0; i < G_N_ELEMENTS(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;
- if (!virQEMUCapsIsMachineSupported(qemuCaps, canon))
+ if (!virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon))
continue;
/* The QOM type for machine types is the machine type name
return -1;
if (virQEMUCapsProbeQMPMachineTypes(qemuCaps, mon) < 0)
return -1;
- if (virQEMUCapsProbeQMPMachineProps(qemuCaps, mon) < 0)
+ if (virQEMUCapsProbeQMPMachineProps(qemuCaps, type, mon) < 0)
return -1;
if (virQEMUCapsProbeQMPCPUDefinitions(qemuCaps, accel, mon) < 0)
return -1;
void
virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
const char *machineType)
{
size_t i;
virQEMUCapsClear(qemuCaps, filter->flags[j]);
}
- if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, machineType))
+ if (!virQEMUCapsGetMachineHotplugCpus(qemuCaps, virtType, machineType))
virQEMUCapsClear(qemuCaps, QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS);
}
virQEMUCapsPtr
virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
+ virDomainVirtType virtType,
const char *binary,
const char *machineType)
{
if (!ret)
return NULL;
- virQEMUCapsFilterByMachineType(ret, machineType);
+ virQEMUCapsFilterByMachineType(ret, virtType, machineType);
return ret;
}
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))
capsType = VIR_DOMAIN_VIRT_KVM;
else
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)
*retArch = arch;
if (retVirttype)
* Note that this may differ from QEMU's own default machine
*/
const char *
-virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps)
+virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType G_GNUC_UNUSED)
{
if (!qemuCaps->nmachineTypes)
return NULL;
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
+ domCaps->virttype,
domCaps->machine);
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM) {
int hostmaxvcpus;
virDomainVirtType type,
virCPUMode mode);
const char *virQEMUCapsGetCanonicalMachine(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
const char *name);
int virQEMUCapsGetMachineMaxCpus(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
const char *name);
bool virQEMUCapsGetMachineHotplugCpus(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
const char *name);
void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType,
const char *machineType);
virFileCachePtr virQEMUCapsCacheNew(const char *libDir,
virQEMUCapsPtr virQEMUCapsCacheLookup(virFileCachePtr cache,
const char *binary);
virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virFileCachePtr cache,
+ virDomainVirtType virtType,
const char *binary,
const char *machineType);
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virFileCachePtr cache,
virDomainVirtType virtType,
virGICVersion version);
-const char *virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps);
+const char *virQEMUCapsGetPreferredMachine(virQEMUCapsPtr qemuCaps,
+ virDomainVirtType virtType);
int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
const char *binary,
{
const char *canon;
- if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->os.machine)))
+ if (!(canon = virQEMUCapsGetCanonicalMachine(qemuCaps, def->virtType,
+ def->os.machine)))
return 0;
if (STRNEQ(canon, def->os.machine)) {
qemuDomainValidateCpuCount(const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
- unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
+ unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->virtType,
+ def->os.machine);
if (virDomainDefGetVcpus(def) == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
qCaps = virObjectRef(qemuCaps);
} else {
if (!(qCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
+ def->virtType,
def->emulator,
def->os.machine)))
goto cleanup;
virObjectUnref(priv->qemuCaps);
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(qemuCapsCache,
+ vm->def->virtType,
vm->def->emulator,
vm->def->os.machine)))
return -1;
virCapsPtr caps = NULL;
virQEMUCapsPtr qemuCaps = NULL;
virDomainCapsLoaderPtr loader = &domCaps->os.loader;
+ virDomainVirtType virtType;
if (!(caps = virCapabilitiesNew(domCaps->arch, false, false)) ||
fakeHostCPU(caps, domCaps->arch) < 0)
if (!(qemuCaps = qemuTestParseCapabilities(caps, path)))
goto cleanup;
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
+ virtType = VIR_DOMAIN_VIRT_KVM;
+ else
+ virtType = VIR_DOMAIN_VIRT_QEMU;
+
if (machine) {
VIR_FREE(domCaps->machine);
- domCaps->machine = g_strdup(virQEMUCapsGetCanonicalMachine(qemuCaps, machine));
+ domCaps->machine = g_strdup(virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, machine));
}
if (!domCaps->machine)
- domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps));
+ domCaps->machine = g_strdup(virQEMUCapsGetPreferredMachine(qemuCaps, virtType));
if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps,
false,