diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 36f8158d4a..f4f10fae81 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -225,6 +225,29 @@ static const char *defaultPoolXML = " " ""; +static const char *defaultPoolSourcesLogicalXML = +"\n" +" \n" +" \n" +" testvg1\n" +" \n" +" \n" +" \n" +" \n" +" testvg2\n" +" \n" +" \n" +"\n"; + +static const char *defaultPoolSourcesNetFSXML = +"\n" +" \n" +" \n" +" \n" +" \n" +" \n" +"\n"; + static const char *defaultNodeXML = "" " computer" @@ -3210,12 +3233,56 @@ cleanup: } static char * -testStorageFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED, - const char *type ATTRIBUTE_UNUSED, - const char *srcSpec ATTRIBUTE_UNUSED, +testStorageFindPoolSources(virConnectPtr conn, + const char *type, + const char *srcSpec, unsigned int flags ATTRIBUTE_UNUSED) { - return NULL; + virStoragePoolSourcePtr source = NULL; + int pool_type; + char *ret = NULL; + + pool_type = virStoragePoolTypeFromString(type); + if (!pool_type) { + testError(conn, VIR_ERR_INTERNAL_ERROR, + _("unknown storage pool type %s"), type); + goto cleanup; + } + + if (srcSpec) { + source = virStoragePoolDefParseSourceString(conn, srcSpec, pool_type); + if (!source) + goto cleanup; + } + + switch (pool_type) { + + case VIR_STORAGE_POOL_LOGICAL: + ret = strdup(defaultPoolSourcesLogicalXML); + if (!ret) + virReportOOMError(conn); + break; + + case VIR_STORAGE_POOL_NETFS: + if (!source || !source->host.name) { + testError(conn, VIR_ERR_INVALID_ARG, + "%s", "hostname must be specified for netfs sources"); + goto cleanup; + } + + if (virAsprintf(&ret, defaultPoolSourcesNetFSXML, + source->host.name) < 0) + virReportOOMError(conn); + break; + + default: + testError(conn, VIR_ERR_NO_SUPPORT, + _("pool type '%s' does not support source discovery"), type); + } + +cleanup: + virStoragePoolSourceFree(source); + return ret; }