提交 1d1330f3 编写于 作者: J John Ferlan

storage: Create helper to generate FS pool source value

Refactor the code that builds the pool source string during the FS
storage pool mount to be a separate helper.

A future patch will use the helper in order to validate the mounted
FS matches the pool's expectation during poolCheck processing
上级 a8e3247e
......@@ -375,6 +375,39 @@ virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool)
return 0;
}
/**
* virStorageBackendFileSystemGetPoolSource
* @pool: storage pool object pointer
*
* Allocate/return a string representing the FS storage pool source.
* It is up to the caller to VIR_FREE the allocated string
*/
static char *
virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
{
char *src = NULL;
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
if (virAsprintf(&src, "//%s/%s",
pool->def->source.hosts[0].name,
pool->def->source.dir) < 0)
return NULL;
} else {
if (virAsprintf(&src, "%s:%s",
pool->def->source.hosts[0].name,
pool->def->source.dir) < 0)
return NULL;
}
} else {
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
return NULL;
}
return src;
}
/**
* @pool storage pool to check for status
*
......@@ -445,22 +478,8 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
return -1;
}
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
if (virAsprintf(&src, "//%s/%s",
pool->def->source.hosts[0].name,
pool->def->source.dir) == -1)
return -1;
} else {
if (virAsprintf(&src, "%s:%s",
pool->def->source.hosts[0].name,
pool->def->source.dir) == -1)
return -1;
}
} else {
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
return -1;
}
if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
return -1;
if (netauto)
cmd = virCommandNewArgList(MOUNT,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册