From c0710c74ff4d3d19fe035c2d3451cb62af5958ea Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Tue, 19 Sep 2017 16:18:49 +0200 Subject: [PATCH] choosecd: change order of check operations The current order of check operations is wrong. First we set the new path for the disk in question and after that we check whether some guest already uses a disk with the same path. The issue is that virt-manager returns a cached list of guests in path_in_use_by() and the cached guest has the disk path already updated. Ideally we don't update the path at all, but we do it to run some checks before the path is actually changed. In order to fix the referenced bug, change the order of check operations. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1453094 Signed-off-by: Pavel Hrdina --- virtManager/choosecd.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/virtManager/choosecd.py b/virtManager/choosecd.py index 32542c35d..340be656c 100644 --- a/virtManager/choosecd.py +++ b/virtManager/choosecd.py @@ -22,6 +22,8 @@ import logging from gi.repository import GObject +from virtinst import VirtualDisk + from .baseclass import vmmGObjectUI from .mediacombo import vmmMediaCombo from .storagebrowse import vmmStorageBrowser @@ -114,22 +116,22 @@ class vmmChooseCD(vmmGObjectUI): return self.err.val_err(_("Invalid Media Path"), _("A media path must be specified.")) - try: - self.disk.path = path - except Exception as e: - return self.err.val_err(_("Invalid Media Path"), e) - - names = self.disk.is_conflict_disk() + names = VirtualDisk.path_in_use_by(self.disk.conn, path) if names: res = self.err.yes_no( _('Disk "%s" is already in use by other guests %s') % - (self.disk.path, names), + (path, names), _("Do you really want to use the disk?")) if not res: return False vmmAddStorage.check_path_search(self, self.conn, path) + try: + self.disk.path = path + except Exception as e: + return self.err.val_err(_("Invalid Media Path"), e) + self.emit("cdrom-chosen", self.disk, path) self.close()