Currently qmpOnly is the only bool parameter of
virQEMUCapsNewForBinaryInternal, but we will need to add more. Let's
turn the bool parameter into flags.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 27 +++++++++++++++------------
src/qemu/qemu_capspriv.h | 6 +++++-
tests/qemucapsprobe.c | 3 ++-
3 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 9fce7a6..2df710a 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3855,7 +3855,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
const char *libDir,
uid_t runUid,
gid_t runGid,
- char **qmperr)
+ char **qmperr,
+ unsigned int flags)
{
int ret = -1;
virCommandPtr cmd = NULL;
@@ -3955,6 +3956,15 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
ret = 0;
cleanup:
+ if (flags & VIR_QEMU_CAPS_NEW_FORCE_QMP &&
+ ret == 0 &&
+ !qemuCaps->usedQMP) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to probe QEMU binary with QMP: %s"),
+ *qmperr ? *qmperr : _("unknown error"));
+ ret = -1;
+ }
+
if (mon)
virObjectUnlock(mon);
qemuMonitorClose(mon);
@@ -4013,7 +4023,7 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
const char *cacheDir,
uid_t runUid,
gid_t runGid,
- bool qmpOnly)
+ unsigned int flags)
{
virQEMUCapsPtr qemuCaps;
struct stat sb;
@@ -4051,15 +4061,8 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
goto error;
if (rv == 0) {
- if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr) < 0) {
- virQEMUCapsLogProbeFailure(binary);
- goto error;
- }
-
- if (qmpOnly && !qemuCaps->usedQMP) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to probe QEMU binary with QMP: %s"),
- qmperr ? qmperr : _("unknown error"));
+ if (virQEMUCapsInitQMP(qemuCaps, libDir, runUid, runGid, &qmperr,
+ flags) < 0) {
virQEMUCapsLogProbeFailure(binary);
goto error;
}
@@ -4096,7 +4099,7 @@ virQEMUCapsNewForBinary(virCapsPtr caps,
gid_t runGid)
{
return virQEMUCapsNewForBinaryInternal(caps, binary, libDir, cacheDir,
- runUid, runGid, false);
+ runUid, runGid, 0);
}
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index fab2c2a..573cba6 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -39,6 +39,10 @@ struct _virQEMUCapsCache {
virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps);
+typedef enum {
+ VIR_QEMU_CAPS_NEW_FORCE_QMP = 1 << 0,
+} virQEMUCapsNewFlags;
+
virQEMUCapsPtr
virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
const char *binary,
@@ -46,7 +50,7 @@ virQEMUCapsNewForBinaryInternal(virCapsPtr caps,
const char *cacheDir,
uid_t runUid,
gid_t runGid,
- bool qmpOnly);
+ unsigned int flags);
int virQEMUCapsLoadCache(virCapsPtr caps,
virQEMUCapsPtr qemuCaps,
diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
index fb9f3e9..0f59bb9 100644
--- a/tests/qemucapsprobe.c
+++ b/tests/qemucapsprobe.c
@@ -47,6 +47,7 @@ main(int argc, char **argv)
{
virThread thread;
virQEMUCapsPtr caps;
+ unsigned int flags = VIR_QEMU_CAPS_NEW_FORCE_QMP;
VIRT_TEST_PRELOAD(abs_builddir "/.libs/qemucapsprobemock.so");
@@ -71,7 +72,7 @@ main(int argc, char **argv)
return EXIT_FAILURE;
if (!(caps = virQEMUCapsNewForBinaryInternal(NULL, argv[1], "/tmp", NULL,
- -1, -1, true)))
+ -1, -1, flags)))
return EXIT_FAILURE;
virObjectUnref(caps);
--
2.10.2