this patch decouples the binary and the capabilities detection
from the guest initialization.
The purpose is to make testing easier.
---
src/qemu/qemu_capabilities.c | 45 +++++++++++++++++++++++++++++---------------
src/qemu/qemu_capabilities.h | 7 +++++++
2 files changed, 37 insertions(+), 15 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 061ddae..6faef02 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -689,18 +689,12 @@ virQEMUCapsInitGuest(virCapsPtr caps,
virArch hostarch,
virArch guestarch)
{
- virCapsGuestPtr guest;
size_t i;
- bool haskvm = false;
- bool haskqemu = false;
char *kvmbin = NULL;
char *binary = NULL;
- virCapsGuestMachinePtr *machines = NULL;
- size_t nmachines = 0;
virQEMUCapsPtr qemubinCaps = NULL;
virQEMUCapsPtr kvmbinCaps = NULL;
int ret = -1;
- bool hasdisksnapshot = false;
/* Check for existence of base emulator, or alternate base
* which can be used with magic cpu choice
@@ -748,6 +742,35 @@ virQEMUCapsInitGuest(virCapsPtr caps,
}
}
+ ret = virQEMUCapsInitGuestFromBinary(caps,
+ binary, qemubinCaps,
+ kvmbin, kvmbinCaps,
+ guestarch);
+
+ VIR_FREE(binary);
+ VIR_FREE(kvmbin);
+ virObjectUnref(qemubinCaps);
+ virObjectUnref(kvmbinCaps);
+
+ return ret;
+}
+
+int
+virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
+ const char *binary,
+ virQEMUCapsPtr qemubinCaps,
+ const char *kvmbin,
+ virQEMUCapsPtr kvmbinCaps,
+ virArch guestarch)
+{
+ virCapsGuestPtr guest;
+ bool haskvm = false;
+ bool haskqemu = false;
+ virCapsGuestMachinePtr *machines = NULL;
+ size_t nmachines = 0;
+ int ret = -1;
+ bool hasdisksnapshot = false;
+
if (!binary)
return 0;
@@ -845,18 +868,10 @@ virQEMUCapsInitGuest(virCapsPtr caps,
ret = 0;
-cleanup:
- VIR_FREE(binary);
- VIR_FREE(kvmbin);
- virObjectUnref(qemubinCaps);
- virObjectUnref(kvmbinCaps);
-
- return ret;
-
error:
virCapabilitiesFreeMachines(machines, nmachines);
- goto cleanup;
+ return ret;
}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index a9082d5..df8c978 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -295,4 +295,11 @@ bool virQEMUCapsSupportsChardev(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainChrDefPtr chr);
+int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
+ const char *binary,
+ virQEMUCapsPtr qemubinCaps,
+ const char *kvmbin,
+ virQEMUCapsPtr kvmbinCaps,
+ virArch guestarch);
+
#endif /* __QEMU_CAPABILITIES_H__*/
--
1.8.5.3