[virt-tools-list] [virt-manager PATCH] choosecd: change order of check operations
Pavel Hrdina
phrdina at redhat.com
Tue Sep 19 14:18:49 UTC 2017
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 <phrdina at redhat.com>
---
virtManager/choosecd.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/virtManager/choosecd.py b/virtManager/choosecd.py
index 32542c35..340be656 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()
--
2.13.5
More information about the virt-tools-list
mailing list