diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 25146ce05..bb17754b2 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -1362,10 +1362,12 @@ class vmmAddHardware(vmmGObjectUI): return False # Disk collision - if disk.is_conflict_disk(conn): - res = self.err.yes_no(_('Disk "%s" is already in use by another ' - 'guest!' % disk.path), - _("Do you really want to use the disk?")) + names = disk.is_conflict_disk(conn) + if names: + res = self.err.yes_no( + _('Disk "%s" is already in use by other guests %s') % + (disk.path, names), + _("Do you really want to use the disk?")) if not res: return False diff --git a/virtManager/create.py b/virtManager/create.py index 7c4d626f0..d5fd50d0b 100644 --- a/virtManager/create.py +++ b/virtManager/create.py @@ -1717,12 +1717,15 @@ class vmmCreate(vmmGObjectUI): return False # Disk collision - if not oldguest and disk.is_conflict_disk(self.guest.conn): - res = self.err.yes_no(_('Disk "%s" is already in use by another ' - 'guest!' % disk.path), - _("Do you really want to use the disk?")) - if not res: - return False + if not oldguest: + names = disk.is_conflict_disk(self.guest.conn) + if names: + res = self.err.yes_no( + _('Disk "%s" is already in use by other guests %s') % + (disk.path, names), + _("Do you really want to use the disk?")) + if not res: + return False if not oldguest: uihelpers.check_path_search_for_qemu(self.topwin, diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py index 32cb79eaf..749840a2a 100644 --- a/virtinst/VirtualDisk.py +++ b/virtinst/VirtualDisk.py @@ -1554,20 +1554,13 @@ class VirtualDisk(VirtualDevice): ((need / (1024 * 1024)), (avail / (1024 * 1024)))) return (ret, msg) - def is_conflict_disk(self, conn, return_names=False): + def is_conflict_disk(self, conn): """ check if specified storage is in use by any other VMs on passed connection. - @param conn: connection to check for collisions on - @type conn: libvirt.virConnect - @param return_names: Whether or not to return a list of VM names using - the same storage (default = False) - @type return_names: C{bool} - - @return: True if a collision, False otherwise (list of names if - return_names passed) - @rtype: C{bool} + @return: list of colliding VM names + @rtype: C{list} """ if self.vol_object: path = self.vol_object.path() @@ -1581,15 +1574,8 @@ class VirtualDisk(VirtualDevice): conn = self.conn check_conflict = self.shareable - names = self.path_in_use_by(conn, path, - check_conflict=check_conflict) - - ret = False - if names: - ret = True - if return_names: - ret = names - + ret = self.path_in_use_by(conn, path, + check_conflict=check_conflict) return ret diff --git a/virtinst/cli.py b/virtinst/cli.py index b24f87e4c..a3eeef072 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -534,11 +534,12 @@ def disk_prompt(conn, origpath, origsize, origsparse, """ Check if disk is inuse by another guest """ - msg = (_("Disk %s is already in use by another guest" % dev.path)) - - if not dev.is_conflict_disk(conn): + names = dev.is_conflict_disk(conn) + if not names: return False + msg = (_("Disk %s is already in use by other guests %s." % + (dev.path, names))) return not prompt_for_yes_or_no(msg, askmsg) def prompt_size_conflict(dev):