コード例 #1
0
static int
test_node_info_parser(const void *opaque)
{
    const struct testNodeInfoParserData *data = opaque;
    collie_test test = data->data;
    VIR_AUTOFREE(char *) output = NULL;
    VIR_AUTOPTR(virStoragePoolDef) pool = NULL;

    if (!(pool = virStoragePoolDefParseFile(data->poolxml)))
        return -1;

    if (VIR_STRDUP(output, test.output) < 0)
        return -1;

    if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
        test.expected_return)
        return -1;

    if (test.expected_return)
        return 0;

    if (pool->capacity == test.expected_capacity &&
        pool->allocation == test.expected_allocation)
        return 0;

    return -1;
}
コード例 #2
0
static int
virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
                                     virStoragePoolObjPtr pool)
{
    int ret;
    char *output = NULL;
    virCommandPtr cmd;

    cmd = virCommandNewArgList(COLLIE, "node", "info", "-r", NULL);
    virStorageBackendSheepdogAddHostArg(cmd, pool);
    virCommandSetOutputBuffer(cmd, &output);
    ret = virCommandRun(cmd, NULL);
    if (ret == 0)
        ret = virStorageBackendSheepdogParseNodeInfo(pool->def, output);

    virCommandFree(cmd);
    VIR_FREE(output);
    return ret;
}
コード例 #3
0
static int
test_node_info_parser(collie_test test, char *poolxml)
{
    int ret = -1;
    char *output = NULL;
    char *poolXmlData = NULL;
    virStoragePoolDefPtr pool = NULL;

    if (virtTestLoadFile(poolxml, &poolXmlData) < 0)
        goto cleanup;

    if (!(pool = virStoragePoolDefParseString(poolXmlData)))
        goto cleanup;

    output = strdup(test.output);
    if (!output)
        goto cleanup;

    if (virStorageBackendSheepdogParseNodeInfo(pool, output) !=
        test.expected_return)
        goto cleanup;

    if (test.expected_return) {
        ret = 0;
        goto cleanup;
    }

    if (pool->capacity == test.expected_capacity &&
        pool->allocation == test.expected_allocation)
        ret = 0;

  cleanup:
    VIR_FREE(output);
    VIR_FREE(poolXmlData);
    virStoragePoolDefFree(pool);
    return ret;
}