goto cleanup;
}
+ /* Mark the (s) sparse/snapshot lv, e.g. the lv created using
+ * the --virtualsize/-V option. We've already ignored the (t)hin
+ * pool definition. In the manner libvirt defines these, the
+ * thin pool is hidden to the lvs output, except as the name
+ * in brackets [] described for the groups[1] (backingStore).
+ */
+ if (attrs[0] == 's')
+ vol->target.sparse = true;
+
/* Skips the backingStore of lv created with "--virtualsize",
* its original device "/dev/$vgname/$lvname_vorigin" is
* just for lvm internal use, one should never use it.
VIR_DIV_UP(vol->target.allocation
? vol->target.allocation : 1, 1024));
virCommandAddArg(cmd, "--virtualsize");
+ vol->target.sparse = true;
}
virCommandAddArgFormat(cmd, "%lluK", VIR_DIV_UP(vol->target.capacity,
1024));
return build_func(conn, pool, vol, inputvol, flags);
}
+static int
+virStorageBackendLogicalVolWipe(virConnectPtr conn,
+ virStoragePoolObjPtr pool,
+ virStorageVolDefPtr vol,
+ unsigned int algorithm,
+ unsigned int flags)
+{
+ if (!vol->target.sparse)
+ return virStorageBackendVolWipeLocal(conn, pool, vol, algorithm, flags);
+
+ /* The wiping algorithms will write something to the logical volume.
+ * Writing to a sparse logical volume causes it to be filled resulting
+ * in the volume becoming INACTIVE because there is some amount of
+ * metadata contained within the sparse lv. Choosing to only write
+ * a wipe pattern to the already written portion lv based on what
+ * 'lvs' shows in the "Data%" column/field for the sparse lv was
+ * considered. However, there is no guarantee that sparse lv could
+ * grow or shrink outside of libvirt's knowledge and thus still render
+ * the volume INACTIVE. Until there is some sort of wipe function
+ * implemented by lvm for one of these sparse lv, we'll just return
+ * unsupported.
+ */
+ virReportError(VIR_ERR_NO_SUPPORT,
+ _("logical volue '%s' is sparse, volume wipe not supported"),
+ vol->target.path);
+ return -1;
+}
virStorageBackend virStorageBackendLogical = {
.type = VIR_STORAGE_POOL_LOGICAL,
.deleteVol = virStorageBackendLogicalDeleteVol,
.uploadVol = virStorageBackendVolUploadLocal,
.downloadVol = virStorageBackendVolDownloadLocal,
- .wipeVol = virStorageBackendVolWipeLocal,
+ .wipeVol = virStorageBackendLogicalVolWipe,
};