[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v2 06/12] storage: Use virStoragePoolObj{Get|Set}ConfigFile



Use the new accessor APIs for storage_driver and test_driver.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/storage/storage_backend_scsi.c |  4 +++-
 src/storage/storage_driver.c       | 14 +++++++-------
 src/test/test_driver.c             | 20 ++++++++++++--------
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 575e6a6..02fd4b6 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -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;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index b780f9a..7b1396f 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -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 {
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 67b115f..36e5ba1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4056,12 +4056,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;
 }
 
 
@@ -4303,7 +4308,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;
@@ -4469,7 +4474,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;
 
@@ -4634,7 +4639,7 @@ testStoragePoolDestroy(virStoragePoolPtr pool)
                                             VIR_STORAGE_POOL_EVENT_STOPPED,
                                             0);
 
-    if (obj->configFile == NULL) {
+    if (!(virStoragePoolObjGetConfigFile(obj))) {
         virStoragePoolObjRemove(&privconn->pools, obj);
         obj = NULL;
     }
@@ -4740,11 +4745,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;
@@ -4762,7 +4766,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;
-- 
2.9.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]