mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
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: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
18f63c17a4
commit
b0b8517eeb
@ -3713,11 +3713,13 @@ virQEMUCapsLogProbeFailure(const char *binary)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
|
virQEMUCapsPtr
|
||||||
const char *libDir,
|
virQEMUCapsNewForBinaryInternal(const char *binary,
|
||||||
const char *cacheDir,
|
const char *libDir,
|
||||||
uid_t runUid,
|
const char *cacheDir,
|
||||||
gid_t runGid)
|
uid_t runUid,
|
||||||
|
gid_t runGid,
|
||||||
|
bool qmpOnly)
|
||||||
{
|
{
|
||||||
virQEMUCapsPtr qemuCaps;
|
virQEMUCapsPtr qemuCaps;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
@ -3749,7 +3751,9 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rv = virQEMUCapsInitCached(qemuCaps, cacheDir)) < 0)
|
if (!cacheDir)
|
||||||
|
rv = 0;
|
||||||
|
else if ((rv = virQEMUCapsInitCached(qemuCaps, cacheDir)) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (rv == 0) {
|
if (rv == 0) {
|
||||||
@ -3758,13 +3762,22 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
|
|||||||
goto error;
|
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 &&
|
if (!qemuCaps->usedQMP &&
|
||||||
virQEMUCapsInitHelp(qemuCaps, runUid, runGid, qmperr) < 0) {
|
virQEMUCapsInitHelp(qemuCaps, runUid, runGid, qmperr) < 0) {
|
||||||
virQEMUCapsLogProbeFailure(binary);
|
virQEMUCapsLogProbeFailure(binary);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
|
if (cacheDir &&
|
||||||
|
virQEMUCapsRememberCached(qemuCaps, cacheDir) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3778,6 +3791,17 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
|
|||||||
return NULL;
|
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)
|
bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
|
@ -37,4 +37,12 @@ struct _virQEMUCapsCache {
|
|||||||
gid_t runGid;
|
gid_t runGid;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virQEMUCapsPtr
|
||||||
|
virQEMUCapsNewForBinaryInternal(const char *binary,
|
||||||
|
const char *libDir,
|
||||||
|
const char *cacheDir,
|
||||||
|
uid_t runUid,
|
||||||
|
gid_t runGid,
|
||||||
|
bool qmpOnly);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user