]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStorageBackendGlusterRefreshVol: Refactor handling of backing store
authorPeter Krempa <pkrempa@redhat.com>
Fri, 21 Feb 2020 11:28:14 +0000 (12:28 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 24 Feb 2020 14:12:32 +0000 (15:12 +0100)
Take the format of the backing store from the 'meta' object directly and
use g_steal_pointer to steal the path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/storage/storage_backend_gluster.c

index 4a8ee3870dc4f95f8cde0f198be8c9ead7e1a0dd..e92e9612bd4742a47f667d464b4cc6ed75b77cd3 100644 (file)
@@ -224,7 +224,6 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
     int ret = -1;
     glfs_fd_t *fd = NULL;
     ssize_t len;
-    int backingFormat;
     g_autoptr(virStorageVolDef) vol = NULL;
     g_autoptr(virStorageSource) meta = NULL;
     g_autofree char *header = NULL;
@@ -277,7 +276,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
 
     if (!(meta = virStorageFileGetMetadataFromBuf(name, header, len,
                                                   VIR_STORAGE_FILE_AUTO,
-                                                  &backingFormat)))
+                                                  NULL)))
         goto cleanup;
 
     if (meta->backingStoreRaw) {
@@ -286,13 +285,11 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
 
         vol->target.backingStore->type = VIR_STORAGE_TYPE_NETWORK;
 
-        vol->target.backingStore->path = meta->backingStoreRaw;
+        vol->target.backingStore->path = g_steal_pointer(&meta->backingStoreRaw);
+        vol->target.backingStore->format = meta->backingStoreRawFormat;
 
-        if (backingFormat < 0)
+        if (vol->target.backingStore->format < 0)
             vol->target.backingStore->format = VIR_STORAGE_FILE_RAW;
-        else
-            vol->target.backingStore->format = backingFormat;
-        meta->backingStoreRaw = NULL;
     }
 
     vol->target.format = meta->format;