提交 4e30af38 编写于 作者: M Michal Privoznik

qemu_capabilities: Introduce virQEMUCapsCacheLookupByArch

The API may come handy if somebody has an architecture and wants to
look through available qemus if the architecture is supported or not.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 3ecb9e76
......@@ -299,6 +299,10 @@ struct _virQEMUCapsCache {
gid_t runGid;
};
struct virQEMUCapsSearchData {
virArch arch;
};
static virClassPtr virQEMUCapsClass;
static void virQEMUCapsDispose(void *obj);
......@@ -3465,6 +3469,35 @@ virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache, const char *binary)
}
static int
virQEMUCapsCompareArch(const void *payload,
const void *name ATTRIBUTE_UNUSED,
const void *opaque)
{
struct virQEMUCapsSearchData *data = (struct virQEMUCapsSearchData *) opaque;
const virQEMUCaps *qemuCaps = payload;
return qemuCaps->arch == data->arch;
}
virQEMUCapsPtr
virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
virArch arch)
{
virQEMUCapsPtr ret = NULL;
struct virQEMUCapsSearchData data = { .arch = arch };
virMutexLock(&cache->lock);
ret = virHashSearch(cache->binaries, virQEMUCapsCompareArch, &data);
VIR_DEBUG("Returning caps %p for arch %s", ret, virArchToString(arch));
virObjectRef(ret);
virMutexUnlock(&cache->lock);
return ret;
}
void
virQEMUCapsCacheFree(virQEMUCapsCachePtr cache)
{
......
......@@ -274,6 +274,8 @@ virQEMUCapsPtr virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache,
const char *binary);
virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache,
const char *binary);
virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache,
virArch arch);
void virQEMUCapsCacheFree(virQEMUCapsCachePtr cache);
virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册