[libvirt] [PATCH 2/2] storage: Forbid wiping formatted volume types that are not supported

Martin Kletzander mkletzan at redhat.com
Thu Jul 14 12:27:41 UTC 2016


Until now we allowed that to happen, however the only thing we supported
was either rewiting the file or truncating it.  That however doesn't
keep the format of that file, so QCOWs, VDIs and all others just became
RAW with arbitrary size.  Not to mention any domain using such volume
could not start anymore.  Instead of dealing with the recreation of
every single possible file that we have (and possibly failing due to
create_tool capabilities) just forbid it for now.  We even state in our
documentation that it has no value for file-backed volumes.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=868771

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 src/storage/storage_backend.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index eff6a2f581a1..600539967430 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -2353,6 +2353,16 @@ virStorageBackendVolWipeLocal(virConnectPtr conn ATTRIBUTE_UNUSED,

     VIR_DEBUG("Wiping volume with path '%s'", vol->target.path);

+    if (vol->type == VIR_STORAGE_VOL_FILE &&
+        vol->target.format != VIR_STORAGE_FILE_PLOOP &&
+        vol->target.format != VIR_STORAGE_FILE_RAW) {
+        virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
+                       _("Wiping file volume with format '%s' is unsupported, "
+                         "consider deleting and re-creating the volume"),
+                       virStorageFileFormatTypeToString(vol->target.format));
+        return -1;
+    }
+
     if (vol->target.format == VIR_STORAGE_FILE_PLOOP)
         ret = virStorageBackendVolWipePloop(vol);
     else
-- 
2.9.0




More information about the libvir-list mailing list