mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-08 04:58:29 +03:00
details: Use devicedisk path lookup for source_pool
This commit is contained in:
parent
7a56c322ed
commit
57fa64e542
@ -432,8 +432,8 @@ Foo bar baz & yeah boii < > yeahfoo
|
||||
</disk>
|
||||
|
||||
<!-- bus usb -->
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/dev/default-pool/overlay.img'/>
|
||||
<disk type='volume' device='disk'>
|
||||
<source pool='default-pool' volume='overlay.img'/>
|
||||
<target dev='sdd' bus='usb'/>
|
||||
</disk>
|
||||
|
||||
|
@ -234,18 +234,7 @@ def populate_storage_list(storage_list, vm, conn):
|
||||
model = storage_list.get_model()
|
||||
model.clear()
|
||||
|
||||
def get_path(disk):
|
||||
if disk.source_pool:
|
||||
pool = conn.get_pool(disk.source_pool)
|
||||
if pool is None:
|
||||
return disk.path
|
||||
vol = pool.get_volume(disk.path)
|
||||
if vol is None:
|
||||
return disk.path
|
||||
return vol.get_target_path()
|
||||
return disk.path
|
||||
|
||||
diskdata = [(d.target, get_path(d), d.read_only, d.shareable) for
|
||||
diskdata = [(d.target, d.path, d.read_only, d.shareable) for
|
||||
d in vm.get_disk_devices()]
|
||||
|
||||
diskdata.append(("kernel", vm.get_xmlobj().os.kernel, True, False))
|
||||
|
@ -2639,7 +2639,6 @@ class vmmDetails(vmmGObjectUI):
|
||||
return
|
||||
|
||||
path = disk.path
|
||||
source_pool = disk.source_pool
|
||||
devtype = disk.device
|
||||
ro = disk.read_only
|
||||
share = disk.shareable
|
||||
@ -2661,27 +2660,12 @@ class vmmDetails(vmmGObjectUI):
|
||||
virtinst.VirtualDisk.path_definitely_exists(
|
||||
disk.conn, disk.path))
|
||||
|
||||
size = _("Unknown")
|
||||
if not path:
|
||||
size = "-"
|
||||
else:
|
||||
vol = None
|
||||
if source_pool:
|
||||
pool = self.conn.get_pool(source_pool)
|
||||
if pool is not None:
|
||||
vol = pool.get_volume(path)
|
||||
else:
|
||||
vol = self.conn.get_vol_by_path(path)
|
||||
|
||||
size = "-"
|
||||
if path:
|
||||
size = _("Unknown")
|
||||
vol = self.conn.get_vol_by_path(path)
|
||||
if vol:
|
||||
size = vol.get_pretty_capacity()
|
||||
elif not self.conn.is_remote():
|
||||
ignore, val = virtinst.VirtualDisk.stat_local_path(path)
|
||||
if val != 0:
|
||||
if val > (1024 * 1024 * 1024):
|
||||
size = "%2.2f GiB" % (val / (1024.0 * 1024.0 * 1024.0))
|
||||
else:
|
||||
size = "%2.2f MiB" % (val / (1024.0 * 1024.0))
|
||||
|
||||
is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM)
|
||||
is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY)
|
||||
|
@ -385,21 +385,6 @@ class VirtualDisk(VirtualDevice):
|
||||
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def stat_local_path(path):
|
||||
"""
|
||||
Return tuple (storage type, storage size) for the passed path on
|
||||
the local machine. This is a best effort attempt.
|
||||
|
||||
@return: tuple of
|
||||
(True if regular file, False otherwise, default is True,
|
||||
max size of storage, default is 0)
|
||||
"""
|
||||
try:
|
||||
return util.stat_disk(path)
|
||||
except:
|
||||
return (True, 0)
|
||||
|
||||
@staticmethod
|
||||
def build_vol_install(conn, volname, poolobj, size, sparse,
|
||||
fmt=None, backing_store=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user