storage: Use qcow2 metadata preallocation if supported

This commit is contained in:
Cole Robinson 2013-10-01 14:29:58 -04:00
parent fa8422f278
commit 37350859ce
2 changed files with 16 additions and 2 deletions

View File

@ -661,6 +661,16 @@ class StorageVolume(_StorageObject):
if not meter: if not meter:
meter = urlgrabber.progress.BaseMeter() meter = urlgrabber.progress.BaseMeter()
cloneflags = 0
createflags = 0
if (self.format == "qcow2" and
not self.backing_store and
not self.conn.is_test() and
self.conn.check_pool_support(
self.pool, self.conn.SUPPORT_POOL_METADATA_PREALLOC)):
createflags |= libvirt.VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA
try: try:
self._install_finished = False self._install_finished = False
t.start() t.start()
@ -668,9 +678,10 @@ class StorageVolume(_StorageObject):
text=_("Allocating '%s'") % self.name) text=_("Allocating '%s'") % self.name)
if self.input_vol: if self.input_vol:
vol = self.pool.createXMLFrom(xml, self.input_vol, 0) vol = self.pool.createXMLFrom(xml, self.input_vol, cloneflags)
else: else:
vol = self.pool.createXML(xml, 0) logging.debug("Using vol create flags=%s", createflags)
vol = self.pool.createXML(xml, createflags)
self._install_finished = True self._install_finished = True
t.join() t.join()

View File

@ -356,6 +356,9 @@ SUPPORT_POOL_CREATEVOLFROM = _make(function="virStoragePool.createXMLFrom",
SUPPORT_POOL_ISACTIVE = _make(function="virStoragePool.isActive", args=()) SUPPORT_POOL_ISACTIVE = _make(function="virStoragePool.isActive", args=())
SUPPORT_POOL_LISTALLVOLUMES = _make(function="virStoragePool.listAllVolumes", SUPPORT_POOL_LISTALLVOLUMES = _make(function="virStoragePool.listAllVolumes",
args=()) args=())
SUPPORT_POOL_METADATA_PREALLOC = _make(
flag="VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA",
version="1000001")
# Interface checks # Interface checks