d76c62
From f27731da867f6a0784c1f2a222d5b7663c418784 Mon Sep 17 00:00:00 2001
d76c62
Message-Id: <f27731da867f6a0784c1f2a222d5b7663c418784@dist-git>
d76c62
From: Peter Krempa <pkrempa@redhat.com>
d76c62
Date: Fri, 28 Feb 2020 10:24:36 +0100
d76c62
Subject: [PATCH] virStorageSourceUpdateCapacity: Drop 'probe' argument
d76c62
MIME-Version: 1.0
d76c62
Content-Type: text/plain; charset=UTF-8
d76c62
Content-Transfer-Encoding: 8bit
d76c62
d76c62
Both callers pass false. Since we frown upon format probing, remove the
d76c62
unused possibility to do the probing.
d76c62
d76c62
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
(cherry picked from commit 35d1f5bd145163edf4f05c377b488ffa50d527d6)
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1798148
d76c62
Message-Id: <c2cfa21552eee3b2cfca74096dfe9d301bbf4e61.1582881363.git.pkrempa@redhat.com>
d76c62
Reviewed-by: Ján Tomko <jtomko@redhat.com>
d76c62
---
d76c62
 src/qemu/qemu_driver.c     |  2 +-
d76c62
 src/storage/storage_util.c |  2 +-
d76c62
 src/util/virstoragefile.c  | 23 ++++++-----------------
d76c62
 src/util/virstoragefile.h  |  3 +--
d76c62
 4 files changed, 9 insertions(+), 21 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
d76c62
index ac3a7ad282..d346446444 100644
d76c62
--- a/src/qemu/qemu_driver.c
d76c62
+++ b/src/qemu/qemu_driver.c
d76c62
@@ -12221,7 +12221,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver,
d76c62
     if (virStorageSourceUpdateBackingSizes(src, fd, &sb) < 0)
d76c62
         goto cleanup;
d76c62
 
d76c62
-    if (virStorageSourceUpdateCapacity(src, buf, len, false) < 0)
d76c62
+    if (virStorageSourceUpdateCapacity(src, buf, len) < 0)
d76c62
         goto cleanup;
d76c62
 
d76c62
     /* If guest is not using raw disk format and is on a host block
d76c62
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
d76c62
index ebc262278d..c562cf313f 100644
d76c62
--- a/src/storage/storage_util.c
d76c62
+++ b/src/storage/storage_util.c
d76c62
@@ -1755,7 +1755,7 @@ storageBackendUpdateVolTargetInfo(virStorageVolType voltype,
d76c62
             }
d76c62
         }
d76c62
 
d76c62
-        if (virStorageSourceUpdateCapacity(target, buf, len, false) < 0)
d76c62
+        if (virStorageSourceUpdateCapacity(target, buf, len) < 0)
d76c62
             return -1;
d76c62
     }
d76c62
 
d76c62
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
d76c62
index 5a74034ec4..391e2ce86f 100644
d76c62
--- a/src/util/virstoragefile.c
d76c62
+++ b/src/util/virstoragefile.c
d76c62
@@ -3964,18 +3964,15 @@ virStorageSourceUpdateBackingSizes(virStorageSourcePtr src,
d76c62
  * @src: disk source definition structure
d76c62
  * @buf: buffer to the storage file header
d76c62
  * @len: length of the storage file header
d76c62
- * @probe: allow probe
d76c62
  *
d76c62
- * Update the storage @src capacity. This may involve probing the storage
d76c62
- * @src in order to "see" if we can recognize what exists.
d76c62
+ * Update the storage @src capacity.
d76c62
  *
d76c62
  * Returns 0 on success, -1 on error.
d76c62
  */
d76c62
 int
d76c62
 virStorageSourceUpdateCapacity(virStorageSourcePtr src,
d76c62
                                char *buf,
d76c62
-                               ssize_t len,
d76c62
-                               bool probe)
d76c62
+                               ssize_t len)
d76c62
 {
d76c62
     int format = src->format;
d76c62
     g_autoptr(virStorageSource) meta = NULL;
d76c62
@@ -3984,18 +3981,10 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr src,
d76c62
      * the metadata has a capacity, use that, otherwise fall back to
d76c62
      * physical size.  */
d76c62
     if (format == VIR_STORAGE_FILE_NONE) {
d76c62
-        if (!probe) {
d76c62
-            virReportError(VIR_ERR_INTERNAL_ERROR,
d76c62
-                           _("no disk format for %s and probing is disabled"),
d76c62
-                           src->path);
d76c62
-            return -1;
d76c62
-        }
d76c62
-
d76c62
-        if ((format = virStorageFileProbeFormatFromBuf(src->path,
d76c62
-                                                       buf, len)) < 0)
d76c62
-            return -1;
d76c62
-
d76c62
-        src->format = format;
d76c62
+        virReportError(VIR_ERR_INTERNAL_ERROR,
d76c62
+                       _("no disk format for %s was specified"),
d76c62
+                       src->path);
d76c62
+        return -1;
d76c62
     }
d76c62
 
d76c62
     if (format == VIR_STORAGE_FILE_RAW && !src->encryption) {
d76c62
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
d76c62
index 1f41e6e357..2a684fd746 100644
d76c62
--- a/src/util/virstoragefile.h
d76c62
+++ b/src/util/virstoragefile.h
d76c62
@@ -472,8 +472,7 @@ int virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src,
d76c62
 int virStorageSourceUpdateBackingSizes(virStorageSourcePtr src,
d76c62
                                        int fd, struct stat const *sb);
d76c62
 int virStorageSourceUpdateCapacity(virStorageSourcePtr src,
d76c62
-                                   char *buf, ssize_t len,
d76c62
-                                   bool probe);
d76c62
+                                   char *buf, ssize_t len);
d76c62
 
d76c62
 int virStorageSourceNewFromBacking(virStorageSourcePtr parent,
d76c62
                                    virStorageSourcePtr *backing);
d76c62
-- 
d76c62
2.25.1
d76c62