Sometimes it may be useful to get a default machine for given qemu
binary. Fortunately, the default machine is stored always on the first
position in the supported machines array.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 9 +++++++++
src/qemu/qemu_capabilities.h | 2 ++
2 files changed, 11 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 46e469c..e4336e1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3556,3 +3556,12 @@ virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
}
return false;
}
+
+
+const char *
+virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps)
+{
+ if (!qemuCaps->nmachineTypes)
+ return NULL;
+ return qemuCaps->machineTypes[0];
+}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 4857dfd..d0a1092 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -305,6 +305,8 @@ bool virQEMUCapsSupportsChardev(virDomainDefPtr def,
bool virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
const char *canonical_machine);
+const char * virQEMUCapsGetDefaultMachine(virQEMUCapsPtr qemuCaps);
+
int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
const char *binary,
virQEMUCapsPtr qemubinCaps,
--
1.8.5.5