提交 b0b8517e 编写于 作者: J Jiri Denemark

qemu: Make virQEMUCapsNewForBinary usable from tests

virQEMUCapsNewForBinary unconditionally loads data from cache and probes
using both QMP and -help parsing, which is suboptimal when we want to
use it in tests.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 18f63c17
......@@ -3713,11 +3713,13 @@ virQEMUCapsLogProbeFailure(const char *binary)
}
virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
const char *libDir,
const char *cacheDir,
uid_t runUid,
gid_t runGid)
virQEMUCapsPtr
virQEMUCapsNewForBinaryInternal(const char *binary,
const char *libDir,
const char *cacheDir,
uid_t runUid,
gid_t runGid,
bool qmpOnly)
{
virQEMUCapsPtr qemuCaps;
struct stat sb;
......@@ -3749,7 +3751,9 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
goto error;
}
if ((rv = virQEMUCapsInitCached(qemuCaps, cacheDir)) < 0)
if (!cacheDir)
rv = 0;
else if ((rv = virQEMUCapsInitCached(qemuCaps, cacheDir)) < 0)
goto error;
if (rv == 0) {
......@@ -3758,13 +3762,22 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
goto error;
}
if (qmpOnly && !qemuCaps->usedQMP) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to probe QEMU binary with QMP: %s"),
qmperr ? qmperr : _("unknown error"));
virQEMUCapsLogProbeFailure(binary);
goto error;
}
if (!qemuCaps->usedQMP &&
virQEMUCapsInitHelp(qemuCaps, runUid, runGid, qmperr) < 0) {
virQEMUCapsLogProbeFailure(binary);
goto error;
}
if (virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
if (cacheDir &&
virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
goto error;
}
......@@ -3778,6 +3791,17 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
return NULL;
}
virQEMUCapsPtr
virQEMUCapsNewForBinary(const char *binary,
const char *libDir,
const char *cacheDir,
uid_t runUid,
gid_t runGid)
{
return virQEMUCapsNewForBinaryInternal(binary, libDir, cacheDir,
runUid, runGid, false);
}
bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps)
{
......
......@@ -37,4 +37,12 @@ struct _virQEMUCapsCache {
gid_t runGid;
};
virQEMUCapsPtr
virQEMUCapsNewForBinaryInternal(const char *binary,
const char *libDir,
const char *cacheDir,
uid_t runUid,
gid_t runGid,
bool qmpOnly);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册