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

[libvirt] [PATCH 13/19] storage: Move autostartLink deletion to virstorageobj



The virStoragePoolObjDeleteDef already dealt with the configFile - just
add in the autostartLink as well. If there is no autostartLink defined,
then no need to attempt unlink - which also allows removal of one errno
check in moved function.

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/conf/virstorageobj.c     | 11 +++++++++++
 src/storage/storage_driver.c | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
index 9ce3840..69ed66d 100644
--- a/src/conf/virstorageobj.c
+++ b/src/conf/virstorageobj.c
@@ -696,6 +696,17 @@ virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj)
                        obj->def->name);
         return -1;
     }
+    VIR_FREE(obj->configFile);
+
+    if (!obj->autostartLink)
+        return 0;
+
+    if (unlink(obj->autostartLink) < 0 && errno != ENOTDIR) {
+        char ebuf[1024];
+        VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
+                  obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
+    }
+    VIR_FREE(obj->autostartLink);
 
     return 0;
 }
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c4e4e7b..c4650cd 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -841,17 +841,6 @@ storagePoolUndefine(virStoragePoolPtr pool)
     if (virStoragePoolObjDeleteDef(obj) < 0)
         goto cleanup;
 
-    if (unlink(obj->autostartLink) < 0 &&
-        errno != ENOENT &&
-        errno != ENOTDIR) {
-        char ebuf[1024];
-        VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
-                  obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
-    }
-
-    VIR_FREE(obj->configFile);
-    VIR_FREE(obj->autostartLink);
-
     event = virStoragePoolEventLifecycleNew(obj->def->name,
                                             obj->def->uuid,
                                             VIR_STORAGE_POOL_EVENT_UNDEFINED,
-- 
2.9.3


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