[PATCH V5 2/2] addhardware: Deal with the conflict host device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 virtManager/addhardware.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index b2888ee..c1fd9e6 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 . import uiutil
 from .fsdetails import vmmFSDetails
@@ -1739,6 +1740,20 @@ class vmmAddHardware(vmmGObjectUI):
 
         try:
             dev = virtinst.VirtualHostDevice(self.conn.get_backend())
+            # Hostdev collision
+            names  = []
+            vms = self.conn.get_backend().fetch_all_guests()
+            for vm in vms:
+                for hostdev in vm.get_devices("hostdev"):
+                    if NodeDevice.compare_to_nodedev(hostdev, nodedev):
+                        names.append(vm.name)
+            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

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list




[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux