cinder/cinder/volume/drivers
whoami-rajat 8d7e292bcd Skip sparse copy during volume reimage
When rebuilding a volume backed instance, while copying the new
image to the existing volume, we preserve sparseness.
This could be problematic since we don't write the zero blocks of
the new image and the data in the old image can still persist
leading to a data leak scenario.

To prevent this, we are using `-S 0`[1][2] option with the `qemu-img convert`
command to write all the zero bytes into the volume.

In the testing done, this doesn't seem to be a problem with known 'raw'
images but good to handle the case anyway.

Following is the testing performed with 3 images:

1. CIRROS QCOW2 to RAW
======================

Volume size: 1 GiB
Image size (raw): 112 MiB

CREATE VOLUME FROM IMAGE (without -S 0)

LVS (10.94% allocated)
  volume-91ea43ef-684c-402f-896e-63e45e5f4fff stack-volumes-lvmdriver-1 Vwi-a-tz-- 1.00g stack-volumes-lvmdriver-1-pool 10.94

REBUILD (with -S 0)

LVS (10.94% allocated)
  volume-91ea43ef-684c-402f-896e-63e45e5f4fff stack-volumes-lvmdriver-1 Vwi-aotz-- 1.00g stack-volumes-lvmdriver-1-pool 10.94

Conclusion:
Same space is consumed on the disk with and without preserving sparseness.

2. DEBIAN QCOW2 to RAW
======================

Volume size: 3 GiB
Image size (raw): 2 GiB

CREATE VOLUME FROM IMAGE (without -S 0)

LVS (66.67% allocated)
  volume-edc42b6a-df5d-420e-85d3-b3e52bcb735e stack-volumes-lvmdriver-1 Vwi-a-tz-- 3.00g stack-volumes-lvmdriver-1-pool 66.67

REBUILD (with -S 0)

LVS (66.67% allocated)
  volume-edc42b6a-df5d-420e-85d3-b3e52bcb735e stack-volumes-lvmdriver-1 Vwi-aotz-- 3.00g stack-volumes-lvmdriver-1-pool 66.67

Conclusion:
Same space is consumed on the disk with and without preserving sparseness.

3. FEDORA QCOW2 TO RAW
======================

CREATE VOLUME FROM IMAGE (without -S 0)

Volume size: 6 GiB
Image size (raw): 5 GiB

LVS (83.33% allocated)
  volume-efa1a227-a30d-4385-867a-db22a3e80ad7 stack-volumes-lvmdriver-1 Vwi-a-tz-- 6.00g stack-volumes-lvmdriver-1-pool 83.33

REBUILD (with -S 0)

LVS (83.33% allocated)
  volume-efa1a227-a30d-4385-867a-db22a3e80ad7 stack-volumes-lvmdriver-1 Vwi-aotz-- 6.00g stack-volumes-lvmdriver-1-pool 83.33

Conclusion:
Same space is consumed on the disk with and without preserving sparseness.

Another testing was done to check if the `-S 0` option actually
works in OpenStack setup.
Note that we are converting qcow2 to qcow2 image which won't
happen in a real world deployment and only for test purposes.

DEBIAN QCOW2 TO QCOW2
=====================

CREATE VOLUME FROM IMAGE (without -S 0)

LVS (52.61% allocated)
  volume-de581f84-e722-4f4a-94fb-10f767069f50 stack-volumes-lvmdriver-1 Vwi-a-tz-- 3.00g stack-volumes-lvmdriver-1-pool 52.61

REBUILD (with -S 0)

LVS (66.68% allocated)
  volume-de581f84-e722-4f4a-94fb-10f767069f50 stack-volumes-lvmdriver-1 Vwi-aotz-- 3.00g stack-volumes-lvmdriver-1-pool 66.68

Conclusion:
We can see that the space allocation increased hence we are not preserving sparseness when using the -S 0 option.

[1] https://qemu-project.gitlab.io/qemu/tools/qemu-img.html#cmdoption-qemu-img-common-opts-S
[2] abf635ddfe/qemu-img.c (L182-L186)

Closes-Bug: #2045431

Change-Id: I5be7eaba68a5b8e1c43f0d95486b5c79c14e1b95
(cherry picked from commit 1a8ea0eac4)
(cherry picked from commit 85857a19ab)
2024-02-13 05:31:06 +00:00
..
ceph Merge "Replace distutils with packaging in 3rd party drivers" 2022-05-13 19:12:37 +00:00
datacore DataCore: Add note about unique CHAP storage paths 2022-07-14 10:57:48 -04:00
datera Fix cacheable capability 2022-04-20 18:47:46 +02:00
dell_emc Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
fujitsu Fix cacheable capability 2022-04-20 18:47:46 +02:00
fungible Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
fusionstorage Fix cacheable capability 2022-04-20 18:47:46 +02:00
hedvig Fix cacheable capability 2022-04-20 18:47:46 +02:00
hitachi Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
hpe HPE 3PAR: Few issues with new WSAPI (of 2023) 2023-05-24 10:32:12 +00:00
huawei Fix cacheable capability 2022-04-20 18:47:46 +02:00
ibm Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
infortrend Drivers: remove unused code 2022-03-02 13:04:57 -05:00
inspur Fix cacheable capability 2022-04-20 18:47:46 +02:00
kaminario Merge "Honor multipath config everywhere" 2022-06-28 21:41:13 +00:00
kioxia Fix cacheable capability 2022-04-20 18:47:46 +02:00
lenovo Seagate/Lenovo drivers: Update get_driver_options 2022-05-04 10:31:32 -06:00
macrosan Fix cacheable capability 2022-04-20 18:47:46 +02:00
nec Follow up: Hitachi: Change option name `hitachi_pool` to `hitachi_pools` 2023-03-02 13:34:32 +00:00
netapp Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
nexenta pylint: Remove invalid pylint disable in Nexenta driver 2022-05-17 10:38:57 -04:00
open_e JovianDSS: extend option description 2022-11-10 23:50:04 +01:00
prophetstor Clean up formatting in dplcommon.py 2022-09-23 03:18:56 +00:00
san Drivers: remove unused code 2022-03-02 13:04:57 -05:00
sandstone Fix cacheable capability 2022-04-20 18:47:46 +02:00
stx Merge "Seagate/Lenovo drivers: Update get_driver_options" 2022-05-14 01:24:41 +00:00
synology LVM nvmet: Add support for multiple ip addresses 2023-02-21 19:39:29 +01:00
toyou Toyou: Remove allocated_capacity_gb calculation 2022-10-07 10:51:07 +00:00
veritas_access Fix cacheable capability 2022-04-20 18:47:46 +02:00
vmware Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
windows Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
yadro Initial commit for Yadro Tatlin.UNIFIED driver 2022-07-27 10:05:46 +03:00
zadara Fix cacheable capability 2022-04-20 18:47:46 +02:00
__init__.py Files with no code must be left completely empty 2016-09-28 16:29:30 +07:00
infinidat.py Fix Infinidat driver to backup attached volume 2023-01-31 15:35:50 +00:00
lightos.py lightos: parse urls with urlparse for ipv6 support 2022-09-14 18:31:05 +03:00
linstordrv.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
lvm.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
nfs.py NFS: Use Volume attr instead of dict compat for lock 2022-07-18 15:51:18 -04:00
pure.py [Pure Storage] Fix failure in replication failover 2023-07-26 15:07:12 +00:00
qnap.py Fix cacheable capability 2022-04-20 18:47:46 +02:00
quobyte.py remove the oslo_utils.fnmatch 2021-05-11 01:03:25 +00:00
rbd.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
remotefs.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
rsd.py Merge "Replace distutils with packaging in 3rd party drivers" 2022-05-13 19:12:37 +00:00
solidfire.py NetApp SolidFire: Fix RecursionError accessing undefined attributes 2022-08-04 13:21:02 +00:00
spdk.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
storpool.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00
veritas_cnfs.py Fix cacheable capability 2022-04-20 18:47:46 +02:00
vzstorage.py Skip sparse copy during volume reimage 2024-02-13 05:31:06 +00:00