mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
devicedisk: Add set_vol_install
And use it in places where we don't need set_create_storage
This commit is contained in:
parent
2acbf52ce3
commit
210ab4d8e0
@ -1585,7 +1585,7 @@ class ParserDisk(VirtCLIParser):
|
||||
vol_install = VirtualDisk.build_vol_install(
|
||||
self.guest.conn, newvolname, poolobj, size, sparse,
|
||||
fmt=fmt, backing_store=backing_store)
|
||||
inst.set_create_storage(vol_install=vol_install)
|
||||
inst.set_vol_install(vol_install)
|
||||
|
||||
if not inst.target:
|
||||
skip_targets = [d.target for d in self.guest.get_devices("disk")]
|
||||
|
@ -509,6 +509,11 @@ class VirtualDisk(VirtualDevice):
|
||||
self._change_backend(None, vol_object)
|
||||
self._set_xmlpath(self.path)
|
||||
|
||||
def set_vol_install(self, vol_install):
|
||||
self._storage_creator = diskbackend.StorageCreator(self.conn,
|
||||
None, None, vol_install, None, None, None, None, None)
|
||||
self._set_xmlpath(self.path)
|
||||
|
||||
def get_vol_object(self):
|
||||
return self._storage_backend.get_vol_object()
|
||||
def get_vol_install(self):
|
||||
|
@ -106,9 +106,6 @@ def _upload_file(conn, meter, destpool, src):
|
||||
# Build placeholder volume
|
||||
size = os.path.getsize(src)
|
||||
basename = os.path.basename(src)
|
||||
xmlobj = StoragePool(conn, parsexml=destpool.XMLDesc(0))
|
||||
poolpath = xmlobj.target_path
|
||||
|
||||
name = StorageVolume.find_free_name(destpool, basename)
|
||||
if name != basename:
|
||||
logging.debug("Generated non-colliding volume name %s", name)
|
||||
@ -117,8 +114,7 @@ def _upload_file(conn, meter, destpool, src):
|
||||
(float(size) / 1024.0 / 1024.0 / 1024.0), True)
|
||||
|
||||
disk = VirtualDisk(conn)
|
||||
disk.path = os.path.join(poolpath, name)
|
||||
disk.set_create_storage(vol_install=vol_install)
|
||||
disk.set_vol_install(vol_install)
|
||||
disk.validate()
|
||||
|
||||
disk.setup(meter=meter)
|
||||
|
Loading…
Reference in New Issue
Block a user