mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-10-28 19:55:29 +03:00
addhw: Use VirtualDisk to determine block device size.
This commit is contained in:
parent
5c8257d693
commit
e20a74c85a
@ -534,15 +534,11 @@ class vmmAddHardware(gobject.GObject):
|
||||
|
||||
def get_config_partition_size(self):
|
||||
try:
|
||||
partition_address = self.get_config_disk_image()
|
||||
fd = open(partition_address,"rb")
|
||||
fd.seek(0,2)
|
||||
block_size = fd.tell() / 1024 / 1024
|
||||
return block_size
|
||||
except Exception:
|
||||
details = "Unable to verify partition size: '%s'" % \
|
||||
"".join(traceback.format_exc())
|
||||
logging.error(details)
|
||||
d = virtinst.VirtualDisk(conn=self.conn.vmm,
|
||||
path=self.get_config_disk_image(),
|
||||
readOnly=True)
|
||||
return int(d.size * 1024) or None
|
||||
except Exception, e:
|
||||
return None
|
||||
|
||||
def get_config_disk_size(self):
|
||||
|
Loading…
Reference in New Issue
Block a user