1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 15:15:22 +00:00

Add qcow2/qcow extension for vol clone. Make image features additions for only qcow2 images.

This commit is contained in:
catborise 2019-04-29 14:09:17 +03:00
parent 52fbe95e30
commit 6bc4e895b6

View file

@ -230,22 +230,31 @@ class wvmStorage(wvmConnect):
<group>%s</group> <group>%s</group>
<mode>0644</mode> <mode>0644</mode>
<label>virt_image_t</label> <label>virt_image_t</label>
</permissions> </permissions>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
<compat>1.1</compat> if vol_fmt == 'qcow2':
<features> xml += """
<lazy_refcounts/> <compat>1.1</compat>
</features> <features>
</target> <lazy_refcounts/>
</volume>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid']) </features>"""
xml += """
</target>
</volume>"""
self._createXML(xml, metadata) self._createXML(xml, metadata)
return name
def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=owner): def clone_volume(self, name, target_file, vol_fmt=None, metadata=False, owner=owner):
storage_type = self.get_type()
if storage_type == 'dir':
target_file += '.img'
vol = self.get_volume(name) vol = self.get_volume(name)
if not vol_fmt: if not vol_fmt:
vol_fmt = self.get_volume_type(name) vol_fmt = self.get_volume_type(name)
storage_type = self.get_type()
if storage_type == 'dir':
if vol_fmt in ('qcow', 'qcow2'):
target_file += '.' + vol_fmt
else:
target_file += '.img'
xml = """ xml = """
<volume> <volume>
<name>%s</name> <name>%s</name>
@ -258,11 +267,14 @@ class wvmStorage(wvmConnect):
<group>%s</group> <group>%s</group>
<mode>0644</mode> <mode>0644</mode>
<label>virt_image_t</label> <label>virt_image_t</label>
</permissions> </permissions>""" % (target_file, vol_fmt, owner['uid'], owner['guid'])
if vol_fmt == 'qcow2':
xml += """
<compat>1.1</compat> <compat>1.1</compat>
<features> <features>
<lazy_refcounts/> <lazy_refcounts/>
</features> </features>"""
</target> xml += """ </target>
</volume>""" % (target_file, vol_fmt, owner['uid'],owner['guid']) </volume>"""
self._createXMLFrom(xml, vol, metadata) self._createXMLFrom(xml, vol, metadata)
return target_file