Exemplo n.º 1
0
static int
testQemuCaps(const void *opaque)
{
    int ret = -1;
    const testQemuData *data = opaque;
    char *repliesFile = NULL, *capsFile = NULL;
    char *replies = NULL;
    qemuMonitorTestPtr mon = NULL;
    virQEMUCapsPtr capsProvided = NULL, capsComputed = NULL;

    if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.replies",
                    abs_srcdir, data->base) < 0 ||
        virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.caps",
                    abs_srcdir, data->base) < 0)
        goto cleanup;

    if (virtTestLoadFile(repliesFile, &replies) < 0)
        goto cleanup;

    if (!(mon = testQemuFeedMonitor(replies, data->xmlopt)))
        goto cleanup;

    if (!(capsProvided = qemuTestParseCapabilities(capsFile)))
        goto cleanup;

    if (!(capsComputed = virQEMUCapsNew()))
        goto cleanup;

    if (virQEMUCapsInitQMPMonitor(capsComputed,
                                  qemuMonitorTestGetMonitor(mon)) < 0)
        goto cleanup;

    /* So that our test does not depend on the contents of /proc, we
     * hoisted the setting of ENABLE_FIPS to virQEMUCapsInitQMP.  But
     * we do want to test the effect of that flag.  */
    if (data->fips)
        virQEMUCapsSet(capsComputed, QEMU_CAPS_ENABLE_FIPS);

    if (testQemuCapsCompare(capsProvided, capsComputed) < 0)
        goto cleanup;

    ret = 0;
 cleanup:
    VIR_FREE(repliesFile);
    VIR_FREE(capsFile);
    VIR_FREE(replies);
    qemuMonitorTestFree(mon);
    virObjectUnref(capsProvided);
    virObjectUnref(capsComputed);
    return ret;
}
Exemplo n.º 2
0
static int
testQemuCaps(const void *opaque)
{
    int ret = -1;
    const testQemuDataPtr data = (const testQemuDataPtr) opaque;
    char *repliesFile = NULL, *capsFile = NULL;
    char *replies = NULL, *caps = NULL;
    qemuMonitorTestPtr mon = NULL;
    virQEMUCapsPtr capsProvided = NULL, capsComputed = NULL;

    if (virAsprintf(&repliesFile, "%s/qemucapabilitiesdata/%s.replies",
                    abs_srcdir, data->base) < 0 ||
        virAsprintf(&capsFile, "%s/qemucapabilitiesdata/%s.caps",
                    abs_srcdir, data->base) < 0)
        goto cleanup;

    if (virtTestLoadFile(repliesFile, &replies) < 0 ||
        virtTestLoadFile(capsFile, &caps) < 0)
        goto cleanup;

    if (!(mon = testQemuFeedMonitor(replies, data->xmlopt)))
        goto cleanup;

    if (!(capsProvided = testQemuGetCaps(caps)))
        goto cleanup;

    if (!(capsComputed = virQEMUCapsNew()))
        goto cleanup;

    if (virQEMUCapsInitQMPMonitor(capsComputed,
                                  qemuMonitorTestGetMonitor(mon)) < 0)
        goto cleanup;

    if (testQemuCapsCompare(capsProvided, capsComputed) < 0)
        goto cleanup;

    ret = 0;
cleanup:
    VIR_FREE(repliesFile);
    VIR_FREE(capsFile);
    VIR_FREE(replies);
    VIR_FREE(caps);
    qemuMonitorTestFree(mon);
    virObjectUnref(capsProvided);
    virObjectUnref(capsComputed);
    return ret;
}