]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: Disallow wiping an extended disk partition
authorJohn Ferlan <jferlan@redhat.com>
Tue, 9 Jun 2015 22:15:39 +0000 (18:15 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 15 Jun 2015 11:45:06 +0000 (07:45 -0400)
https://bugzilla.redhat.com/show_bug.cgi?id=1225694

Check if the disk partition to be wiped is the extended partition, if
so then disallow it. Do this via changing the wipeVol backend to check
the volume before passing to the common virStorageBackendVolWipeLocal

src/storage/storage_backend_disk.c

index c4bd6fe2c501d089b75322c3e1f927d473f7512c..a283a86bb4f06c37790d60004d343967b1e49c7e 100644 (file)
@@ -851,6 +851,24 @@ virStorageBackendDiskBuildVolFrom(virConnectPtr conn,
 }
 
 
+static int
+virStorageBackendDiskVolWipe(virConnectPtr conn,
+                             virStoragePoolObjPtr pool,
+                             virStorageVolDefPtr vol,
+                             unsigned int algorithm,
+                             unsigned int flags)
+{
+    if (vol->source.partType != VIR_STORAGE_VOL_DISK_TYPE_EXTENDED)
+        return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, flags);
+
+    /* Wiping an extended partition is not support */
+    virReportError(VIR_ERR_NO_SUPPORT,
+                   _("cannot wipe extended partition '%s'"),
+                   vol->target.path);
+    return -1;
+}
+
+
 virStorageBackend virStorageBackendDisk = {
     .type = VIR_STORAGE_POOL_DISK,
 
@@ -862,5 +880,5 @@ virStorageBackend virStorageBackendDisk = {
     .buildVolFrom = virStorageBackendDiskBuildVolFrom,
     .uploadVol = virStorageBackendVolUploadLocal,
     .downloadVol = virStorageBackendVolDownloadLocal,
-    .wipeVol = virStorageBackendVolWipeLocal,
+    .wipeVol = virStorageBackendDiskVolWipe,
 };