Skip to content

Commit eb72555

Browse files
committed
feat(SR): support QCOW2 format
Signed-off-by: Ronan Abhamon <ronan.abhamon@vates.tech>
1 parent ce3d315 commit eb72555

20 files changed

Lines changed: 66 additions & 40 deletions

drivers/CephFSSR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
]
5656

5757
DRIVER_INFO = {
58-
'name': 'CephFS VHD',
59-
'description': 'SR plugin which stores disks as VHD files on a CephFS storage',
58+
'name': 'CephFS VHD and QCOW2',
59+
'description': 'SR plugin which stores disks as VHD and QCOW2 files on a CephFS storage',
6060
'vendor': 'Vates SAS',
6161
'copyright': '(C) 2020 Vates SAS',
6262
'driver_version': '1.0',

drivers/EXTSR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
CONFIGURATION = [['device', 'local device path (required) (e.g. /dev/sda3)']]
4444

4545
DRIVER_INFO = {
46-
'name': 'Local EXT4 VHD',
47-
'description': 'SR plugin which represents disks as VHD files stored on a local EXT4 filesystem, created inside an LVM volume',
46+
'name': 'Local EXT4 VHD and QCOW2',
47+
'description': 'SR plugin which represents disks as VHD and QCOW2 files stored on a local EXT4 filesystem, created inside an LVM volume',
4848
'vendor': 'Citrix Systems Inc',
4949
'copyright': '(C) 2008 Citrix Systems Inc',
5050
'driver_version': '1.0',

drivers/FileSR.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949

5050
CONFIGURATION = [
5151
['location', 'local directory path (required)'],
52-
['preferred-image-formats', 'list of preferred image formats to use (default: VHD)']
52+
['preferred-image-formats', 'list of preferred image formats to use (default: VHD,QCOW2)']
5353
]
5454

5555
DRIVER_INFO = {
56-
'name': 'Local Path VHD',
57-
'description': 'SR plugin which represents disks as VHD files stored on a local path',
56+
'name': 'Local Path VHD and QCOW2',
57+
'description': 'SR plugin which represents disks as VHD and QCOW2 files stored on a local path',
5858
'vendor': 'Citrix Systems Inc',
5959
'copyright': '(C) 2008 Citrix Systems Inc',
6060
'driver_version': '1.0',
@@ -103,7 +103,7 @@ def __init__(self, srcmd, sr_uuid):
103103
def load(self, sr_uuid) -> None:
104104
self.ops_exclusive = OPS_EXCLUSIVE
105105
self.lock = lock.Lock(lock.LOCK_TYPE_SR, self.uuid)
106-
self.sr_vditype = VdiType.VHD
106+
self.sr_vditype = SR.DEFAULT_TAP
107107
if 'location' not in self.dconf or not self.dconf['location']:
108108
raise xs_errors.XenError('ConfigLocationMissing')
109109
self.remotepath = self.dconf['location']
@@ -440,16 +440,20 @@ def _check_hardlinks(self) -> bool:
440440
class FileVDI(VDI.VDI):
441441
PARAM_RAW = "raw"
442442
PARAM_VHD = "vhd"
443+
PARAM_QCOW2 = "qcow2"
443444
VDI_TYPE = {
444445
PARAM_RAW: VdiType.RAW,
445-
PARAM_VHD: VdiType.VHD
446+
PARAM_VHD: VdiType.VHD,
447+
PARAM_QCOW2: VdiType.QCOW2
446448
}
447449

448450
def _find_path_with_retries(self, vdi_uuid, maxretry=5, period=2.0):
449451
raw_path = os.path.join(self.sr.path, "%s.%s" % \
450452
(vdi_uuid, self.PARAM_RAW))
451453
vhd_path = os.path.join(self.sr.path, "%s.%s" % \
452454
(vdi_uuid, self.PARAM_VHD))
455+
qcow2_path = os.path.join(self.sr.path, "%s.%s" % \
456+
(vdi_uuid, self.PARAM_QCOW2))
453457
cbt_path = os.path.join(self.sr.path, "%s.%s" %
454458
(vdi_uuid, CBTLOG_TAG))
455459
found = False
@@ -460,6 +464,10 @@ def _find_path_with_retries(self, vdi_uuid, maxretry=5, period=2.0):
460464
self.vdi_type = VdiType.VHD
461465
self.path = vhd_path
462466
found = True
467+
elif util.ioretry(lambda: util.pathexists(qcow2_path)):
468+
self.vdi_type = VdiType.QCOW2
469+
self.path = qcow2_path
470+
found = True
463471
elif util.ioretry(lambda: util.pathexists(raw_path)):
464472
self.vdi_type = VdiType.RAW
465473
self.path = raw_path

drivers/GlusterFSSR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
]
5050

5151
DRIVER_INFO = {
52-
'name': 'GlusterFS VHD',
53-
'description': 'SR plugin which stores disks as VHD files on a GlusterFS storage',
52+
'name': 'GlusterFS VHD and QCOW2',
53+
'description': 'SR plugin which stores disks as VHD and QCOW2 files on a GlusterFS storage',
5454
'vendor': 'Vates SAS',
5555
'copyright': '(C) 2020 Vates SAS',
5656
'driver_version': '1.0',

drivers/LVMSR.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# along with this program; if not, write to the Free Software Foundation, Inc.,
1616
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1717
#
18-
# LVMSR: VHD on LVM storage repository
18+
# LVMSR: VHD and QCOW2 on LVM storage repository
1919
#
2020

2121
from sm_typing import Dict, List, override
@@ -68,8 +68,8 @@
6868
CONFIGURATION = [['device', 'local device path (required) (e.g. /dev/sda3)']]
6969

7070
DRIVER_INFO = {
71-
'name': 'Local VHD on LVM',
72-
'description': 'SR plugin which represents disks as VHD disks on ' + \
71+
'name': 'Local VHD and QCOW2 on LVM',
72+
'description': 'SR plugin which represents disks as VHD and QCOW2 disks on ' + \
7373
'Logical Volumes within a locally-attached Volume Group',
7474
'vendor': 'XenSource Inc',
7575
'copyright': '(C) 2008 XenSource Inc',
@@ -81,7 +81,8 @@
8181

8282
CREATE_PARAM_TYPES = {
8383
"raw": VdiType.RAW,
84-
"vhd": VdiType.VHD
84+
"vhd": VdiType.VHD,
85+
"qcow2": VdiType.QCOW2
8586
}
8687

8788
OPS_EXCLUSIVE = [

drivers/LVMoFCoESR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
DRIVER_INFO = {
4444
'name': 'LVM over FCoE',
45-
'description': 'SR plugin which represents disks as VHDs on Logical \
45+
'description': 'SR plugin which represents disks as VHDs and QCOW2s on Logical \
4646
Volumes within a Volume Group created on a FCoE LUN',
4747
'vendor': 'Citrix Systems Inc',
4848
'copyright': '(C) 2015 Citrix Systems Inc',

drivers/LVMoHBASR.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
DRIVER_INFO = {
5050
'name': 'LVM over FC',
51-
'description': 'SR plugin which represents disks as VHDs on Logical Volumes within a Volume Group created on an HBA LUN, e.g. hardware-based iSCSI or FC support',
51+
'description': 'SR plugin which represents disks as VHDs and QCOW2s on Logical Volumes within a Volume Group created on an HBA LUN, e.g. hardware-based iSCSI or FC support',
5252
'vendor': 'Citrix Systems Inc',
5353
'copyright': '(C) 2008 Citrix Systems Inc',
5454
'driver_version': '1.0',

drivers/LinstorSR.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
# These values represents the types given on the command line.
9393
CREATE_PARAM_TYPES = {
9494
"raw": VdiType.RAW,
95-
"vhd": VdiType.VHD
95+
"vhd": VdiType.VHD,
96+
"qcow2": VdiType.QCOW2
9697
}
9798

9899
# ==============================================================================

drivers/MooseFSSR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
]
5555

5656
DRIVER_INFO = {
57-
'name': 'MooseFS VHD',
58-
'description': 'SR plugin which stores disks as VHD files on a MooseFS storage',
57+
'name': 'MooseFS VHD and QCOW2',
58+
'description': 'SR plugin which stores disks as VHD and QCOW2 files on a MooseFS storage',
5959
'vendor': 'Tappest sp. z o.o.',
6060
'copyright': '(C) 2021 Tappest sp. z o.o.',
6161
'driver_version': '1.0',

drivers/NFSSR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
nfs.NFS_VERSION]
4848

4949
DRIVER_INFO = {
50-
'name': 'NFS VHD',
51-
'description': 'SR plugin which stores disks as VHD files on a remote NFS filesystem',
50+
'name': 'NFS VHD and QCOW2',
51+
'description': 'SR plugin which stores disks as VHD and QCOW2 files on a remote NFS filesystem',
5252
'vendor': 'Citrix Systems Inc',
5353
'copyright': '(C) 2008 Citrix Systems Inc',
5454
'driver_version': '1.0',

0 commit comments

Comments
 (0)