[virt-tools-list] [PATCH V3 2/2] addhardware: Deal with the conflict host device

Lin Ma lma at suse.com
Thu Sep 4 06:49:13 UTC 2014


If a host device is in use by guests, Warn user and
let user make choice while adding hardware.

Signed-off-by: Lin Ma <lma at suse.com>
---
 virtManager/addhardware.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 02cff57..dca8b74 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -32,6 +32,7 @@ from virtinst import (VirtualChannelDevice, VirtualParallelDevice,
                       VirtualSmartCardDevice, VirtualRedirDevice,
                       VirtualTPMDevice, VirtualPanicDevice)
 from virtinst import VirtualController
+from virtinst import NodeDevice
 
 from virtManager import uiutil
 from virtManager.fsdetails import vmmFSDetails
@@ -1739,6 +1740,15 @@ class vmmAddHardware(vmmGObjectUI):
 
         try:
             dev = virtinst.VirtualHostDevice(self.conn.get_backend())
+            # Hostdev collision
+            names = NodeDevice.compare_to_nodedev(self.conn, nodedev)
+            if names:
+                res = self.err.yes_no(
+                        _('The device is already in use by other guests %s') %
+                         (names),
+                        _("Do you really want to use the device?"))
+                if not res:
+                    return False
             dev.set_from_nodedev(nodedev, use_full_usb=is_dup)
             self._dev = dev
         except Exception, e:
-- 
1.8.4




More information about the virt-tools-list mailing list