Not all possible emulators are actually in the capabilities, so if we
don't find the supplied emulator we should probe it directly for machine
types.
* src/qemu_driver.c: add qemudCanonicalizeMachineDirect() to directly
probe an emulator for the canonical machine type
---
src/qemu_conf.c | 2 +-
src/qemu_conf.h | 4 ++++
src/qemu_driver.c | 30 ++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 6f89f33..8325bfa 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -340,7 +340,7 @@ error:
return -1;
}
-static int
+int
qemudProbeMachineTypes(const char *binary,
virCapsGuestMachinePtr **machines,
int *nmachines)
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
index 50d7c0a..379cac4 100644
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -163,6 +163,10 @@ int qemuBuildNicStr (virConnectPtr conn,
int qemuAssignNetNames (virDomainDefPtr def,
virDomainNetDefPtr net);
+int qemudProbeMachineTypes (const char *binary,
+ virCapsGuestMachinePtr **machines,
+ int *nmachines);
+
virDomainDefPtr qemuParseCommandLine(virConnectPtr conn,
virCapsPtr caps,
const char **progenv,
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index e2fa4d4..3e33e0d 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -4084,6 +4084,32 @@ qemudCanonicalizeMachineFromInfo(virDomainDefPtr def,
}
static int
+qemudCanonicalizeMachineDirect(virDomainDefPtr def, char **canonical)
+{
+ virCapsGuestMachinePtr *machines = NULL;
+ int i, nmachines = 0;
+
+ if (qemudProbeMachineTypes(def->emulator, &machines, &nmachines) < 0)
+ return -1;
+
+ for (i = 0; i < nmachines; i++) {
+ if (!machines[i]->canonical)
+ continue;
+
+ if (strcmp(def->os.machine, machines[i]->name) != 0)
+ continue;
+
+ *canonical = machines[i]->canonical;
+ machines[i]->canonical = NULL;
+ break;
+ }
+
+ virCapabilitiesFreeMachines(machines, nmachines);
+
+ return 0;
+}
+
+static int
qemudCanonicalizeMachine(virConnectPtr conn, virDomainDefPtr def)
{
struct qemud_driver *driver = conn->privateData;
@@ -4120,6 +4146,10 @@ qemudCanonicalizeMachine(virConnectPtr conn, virDomainDefPtr def)
goto out;
}
}
+
+ if (qemudCanonicalizeMachineDirect(def, &canonical) < 0)
+ return -1;
+
out:
if (canonical) {
VIR_FREE(def->os.machine);
--
1.6.2.5