mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
domain: add 'pre-startup' signal and do nodedevs checking
This patch introduces 'pre-start' signal and registers nodedev checking handler to check duplicate USB devices. If virt-manager can not identify unique usb device any more before domain startup, it will throw a tip error to tell it is time to reattach host USB devices to get updated bus/addr info.
This commit is contained in:
parent
f625cf66d4
commit
a4e736a7cb
@ -149,6 +149,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
"status-changed": (GObject.SignalFlags.RUN_FIRST, None, [int, int]),
|
||||
"resources-sampled": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
"inspection-changed": (GObject.SignalFlags.RUN_FIRST, None, []),
|
||||
"pre-startup": (GObject.SignalFlags.RUN_FIRST, None, [object]),
|
||||
}
|
||||
|
||||
def __init__(self, conn, backend, uuid):
|
||||
@ -252,7 +253,34 @@ class vmmDomain(vmmLibvirtObject):
|
||||
|
||||
self.connect("status-changed", self._update_start_vcpus)
|
||||
self.connect("config-changed", self._reparse_xml)
|
||||
self.connect("pre-startup", self._prestartup_nodedev_check)
|
||||
|
||||
def _prestartup_nodedev_check(self, src, ret):
|
||||
ignore = src
|
||||
error = _("These is more than one '%s' device attached to "
|
||||
"your host, and we can't determine which one to "
|
||||
"use for your guest.\n"
|
||||
"To fix this, remove and reattach the USB device "
|
||||
"to your guest using the 'Add Hardware' wizard.")
|
||||
|
||||
for hostdev in self.get_hostdev_devices():
|
||||
devtype = hostdev.type
|
||||
|
||||
if devtype != "usb":
|
||||
continue
|
||||
|
||||
vendor = hostdev.vendor
|
||||
product = hostdev.product
|
||||
bus = hostdev.bus
|
||||
device = hostdev.device
|
||||
|
||||
if vendor and product:
|
||||
count = self.conn.get_nodedevs_number("usb_device",
|
||||
vendor,
|
||||
product)
|
||||
if count > 1 and not (bus and device):
|
||||
prettyname = "%s %s" % (vendor, product)
|
||||
ret.append(error % prettyname)
|
||||
|
||||
###########################
|
||||
# Misc API getter methods #
|
||||
@ -1171,6 +1199,13 @@ class vmmDomain(vmmLibvirtObject):
|
||||
if self.get_cloning():
|
||||
raise RuntimeError(_("Cannot start guest while cloning "
|
||||
"operation in progress"))
|
||||
|
||||
pre_startup_ret = []
|
||||
self.emit("pre-startup", pre_startup_ret)
|
||||
|
||||
for error in pre_startup_ret:
|
||||
raise RuntimeError(error)
|
||||
|
||||
self._backend.create()
|
||||
self.idle_add(self.force_update_status)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user