mirror of
https://github.com/retspen/webvirtcloud
synced 2024-11-01 03:54:15 +00:00
Add qcow2/qcow extension for vol clone. Make image features additions for only qcow2 images.
This commit is contained in:
parent
52fbe95e30
commit
6bc4e895b6
1 changed files with 26 additions and 14 deletions
|
@ -230,22 +230,31 @@ class wvmStorage(wvmConnect):
|
|||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
</permissions>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>
|
||||
</features>"""
|
||||
xml += """
|
||||
</target>
|
||||
</volume>""" % (name, size, alloc, vol_fmt, owner['uid'], owner['guid'])
|
||||
</volume>"""
|
||||
self._createXML(xml, metadata)
|
||||
return name
|
||||
|
||||
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)
|
||||
if not vol_fmt:
|
||||
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 = """
|
||||
<volume>
|
||||
<name>%s</name>
|
||||
|
@ -258,11 +267,14 @@ class wvmStorage(wvmConnect):
|
|||
<group>%s</group>
|
||||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
</permissions>""" % (target_file, vol_fmt, owner['uid'], owner['guid'])
|
||||
if vol_fmt == 'qcow2':
|
||||
xml += """
|
||||
<compat>1.1</compat>
|
||||
<features>
|
||||
<lazy_refcounts/>
|
||||
</features>
|
||||
</target>
|
||||
</volume>""" % (target_file, vol_fmt, owner['uid'],owner['guid'])
|
||||
</features>"""
|
||||
xml += """ </target>
|
||||
</volume>"""
|
||||
self._createXMLFrom(xml, vol, metadata)
|
||||
return target_file
|
||||
|
|
Loading…
Reference in a new issue