提交 8603d848 编写于 作者: J John Ferlan

storage: Use virStoragePoolObj{Get|Set}ConfigFile

Use the new accessor APIs for storage_driver and test_driver.
上级 5bf9b655
......@@ -443,8 +443,10 @@ static int
virStorageBackendSCSIStartPool(virConnectPtr conn,
virStoragePoolObjPtr pool)
{
const char *configFile = virStoragePoolObjGetConfigFile(pool);
if (pool->def->source.adapter.type == VIR_STORAGE_ADAPTER_TYPE_FC_HOST)
return createVport(conn, pool->def, pool->configFile,
return createVport(conn, pool->def, configFile,
&pool->def->source.adapter.data.fchost);
return 0;
......
......@@ -91,7 +91,7 @@ virStoragePoolUpdateInactive(virStoragePoolObjPtr *objptr)
{
virStoragePoolObjPtr obj = *objptr;
if (obj->configFile == NULL) {
if (!virStoragePoolObjGetConfigFile(obj)) {
virStoragePoolObjRemove(&driver->pools, obj);
*objptr = NULL;
} else if (obj->newDef) {
......@@ -643,7 +643,7 @@ storagePoolIsPersistent(virStoragePoolPtr pool)
if (virStoragePoolIsPersistentEnsureACL(pool->conn, obj->def) < 0)
goto cleanup;
ret = obj->configFile ? 1 : 0;
ret = virStoragePoolObjGetConfigFile(obj) ? 1 : 0;
cleanup:
virStoragePoolObjUnlock(obj);
......@@ -849,7 +849,6 @@ storagePoolUndefine(virStoragePoolPtr pool)
obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
}
VIR_FREE(obj->configFile);
VIR_FREE(obj->autostartLink);
event = virStoragePoolEventLifecycleNew(obj->def->name,
......@@ -1250,7 +1249,7 @@ storagePoolGetAutostart(virStoragePoolPtr pool,
if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0)
goto cleanup;
if (!obj->configFile) {
if (!virStoragePoolObjGetConfigFile(obj)) {
*autostart = 0;
} else {
*autostart = obj->autostart;
......@@ -1268,6 +1267,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
int autostart)
{
virStoragePoolObjPtr obj;
const char *configFile;
int ret = -1;
storageDriverLock();
......@@ -1277,7 +1277,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
if (virStoragePoolSetAutostartEnsureACL(pool->conn, obj->def) < 0)
goto cleanup;
if (!obj->configFile) {
if (!(configFile = virStoragePoolObjGetConfigFile(obj))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("pool has no config file"));
goto cleanup;
......@@ -1294,10 +1294,10 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
goto cleanup;
}
if (symlink(obj->configFile, obj->autostartLink) < 0) {
if (symlink(configFile, obj->autostartLink) < 0) {
virReportSystemError(errno,
_("Failed to create symlink '%s' to '%s'"),
obj->autostartLink, obj->configFile);
obj->autostartLink, configFile);
goto cleanup;
}
} else {
......
......@@ -4072,12 +4072,17 @@ testInterfaceDestroy(virInterfacePtr iface,
static int
testStoragePoolObjSetDefaults(virStoragePoolObjPtr obj)
{
char *configFile;
obj->def->capacity = defaultPoolCap;
obj->def->allocation = defaultPoolAlloc;
obj->def->available = defaultPoolCap - defaultPoolAlloc;
return VIR_STRDUP(obj->configFile, "");
if (VIR_STRDUP(configFile, "") < 0)
return -1;
virStoragePoolObjSetConfigFile(obj, configFile);
return 0;
}
......@@ -4319,7 +4324,7 @@ testStoragePoolIsPersistent(virStoragePoolPtr pool)
if (!(obj = testStoragePoolObjFindByUUID(privconn, pool->uuid)))
return -1;
ret = obj->configFile ? 1 : 0;
ret = virStoragePoolObjGetConfigFile(obj) ? 1 : 0;
virStoragePoolObjUnlock(obj);
return ret;
......@@ -4485,7 +4490,7 @@ testStoragePoolCreateXML(virConnectPtr conn,
/* *SetDefaults fills this in for the persistent pools, but this
* would be a transient pool so remove it; otherwise, the Destroy
* code will not Remove the pool */
VIR_FREE(obj->configFile);
virStoragePoolObjSetConfigFile(obj, NULL);
obj->active = true;
......@@ -4650,7 +4655,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool)
VIR_STORAGE_POOL_EVENT_STOPPED,
0);
if (obj->configFile == NULL) {
if (!(virStoragePoolObjGetConfigFile(obj))) {
virStoragePoolObjRemove(&privconn->pools, obj);
obj = NULL;
}
......@@ -4756,11 +4761,10 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool,
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return -1;
if (!obj->configFile) {
if (!virStoragePoolObjGetConfigFile(obj))
*autostart = 0;
} else {
else
*autostart = obj->autostart;
}
virStoragePoolObjUnlock(obj);
return 0;
......@@ -4778,7 +4782,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool,
if (!(obj = testStoragePoolObjFindByName(privconn, pool->name)))
return -1;
if (!obj->configFile) {
if (!virStoragePoolObjGetConfigFile(obj)) {
virReportError(VIR_ERR_INVALID_ARG,
"%s", _("pool has no config file"));
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册