mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Fix several broken hacks in migration code.
Key of URI in the migration list, not the short hostname we show: we can have multiple connections with the same hostname, and it confuses things. This allows us to drop the migrate invocation differences for the xen driver, so things work as they should.
This commit is contained in:
parent
51a1e0d329
commit
a2d49aee87
@ -737,13 +737,9 @@ class vmmDetails(gobject.GObject):
|
||||
def control_vm_destroy(self, src):
|
||||
self.emit("action-destroy-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
def control_vm_migrate(self, src):
|
||||
# get selected submenu(destination hostname)
|
||||
info = self.window.get_widget("details-menu-migrate_menu").get_active().get_image().get_stock()[0]
|
||||
hostname = info.split(" ")[0]
|
||||
|
||||
def control_vm_migrate(self, src, uri):
|
||||
self.emit("action-migrate-domain", self.vm.get_connection().get_uri(),
|
||||
self.vm.get_uuid(), hostname)
|
||||
self.vm.get_uuid(), uri)
|
||||
|
||||
def populate_migrate_menu(self, ignore1=None):
|
||||
menu = self.window.get_widget("details-menu-migrate_menu")
|
||||
|
@ -1455,21 +1455,15 @@ class vmmDomain(gobject.GObject):
|
||||
self._disk_io = self._sample_disk_io_dummy
|
||||
|
||||
|
||||
def migrate(self, destcon):
|
||||
def migrate(self, destconn):
|
||||
flags = 0
|
||||
if self.lastStatus == libvirt.VIR_DOMAIN_RUNNING:
|
||||
flags = libvirt.VIR_MIGRATE_LIVE
|
||||
|
||||
if self.get_connection().get_driver().lower() == "xen":
|
||||
# FIXME: these required? need to test this
|
||||
uri = destcon.get_short_hostname()
|
||||
conn = self.get_connection().vmm
|
||||
else:
|
||||
conn = destcon.vmm
|
||||
uri = None
|
||||
|
||||
newxml = self.get_xml()
|
||||
self.vm.migrate(conn, flags, None, uri, 0)
|
||||
destcon.define_domain(newxml)
|
||||
|
||||
self.vm.migrate(destconn.vmm, flags, None, None, 0)
|
||||
|
||||
destconn.define_domain(newxml)
|
||||
|
||||
gobject.type_register(vmmDomain)
|
||||
|
@ -581,21 +581,11 @@ class vmmEngine(gobject.GObject):
|
||||
self.err.show_err(_("Error shutting down domain: %s" % str(e)),
|
||||
"".join(traceback.format_exc()))
|
||||
|
||||
def migrate_domain(self, uri, uuid, desthost):
|
||||
desturi = None
|
||||
for key in self.connections.keys():
|
||||
if self._lookup_connection(key).get_hostname() == desthost:
|
||||
desturi = key
|
||||
break
|
||||
|
||||
if desturi == None:
|
||||
logging.debug("Could not find dest uri for migrate hostname: %s"
|
||||
% desthost)
|
||||
return
|
||||
|
||||
def migrate_domain(self, uri, uuid, desturi):
|
||||
conn = self._lookup_connection(uri)
|
||||
vm = conn.get_vm(uuid)
|
||||
destconn = self._lookup_connection(desturi, False)
|
||||
destconn = self._lookup_connection(desturi)
|
||||
|
||||
resp = self.err.yes_no(_("Are you sure you want to migrate %s from "
|
||||
"%s to %s?") %
|
||||
(vm.get_name(), conn.get_hostname(),
|
||||
@ -651,10 +641,10 @@ class vmmEngine(gobject.GObject):
|
||||
menu.remove(item)
|
||||
|
||||
for ignore, val_list in conns.items():
|
||||
can_migrate, label, tooltip = val_list
|
||||
can_migrate, label, tooltip, uri = val_list
|
||||
mitem = gtk.ImageMenuItem(label)
|
||||
mitem.set_sensitive(can_migrate)
|
||||
mitem.connect("activate", migrate_func)
|
||||
mitem.connect("activate", migrate_func, uri)
|
||||
if tooltip:
|
||||
util.tooltip_wrapper(mitem, tooltip)
|
||||
mitem.show()
|
||||
@ -668,13 +658,14 @@ class vmmEngine(gobject.GObject):
|
||||
|
||||
def get_available_migrate_hostnames(self, vm):
|
||||
driver = vm.get_connection().get_driver()
|
||||
uri = vm.get_connection().get_uri()
|
||||
origuri = vm.get_connection().get_uri()
|
||||
available_migrate_hostnames = {}
|
||||
|
||||
# Returns list of lists of the form
|
||||
# [ Can we migrate to this connection?,
|
||||
# String to use as list entry,
|
||||
# Tooltip reason ]
|
||||
# Tooltip reason,
|
||||
# Conn URI ]
|
||||
|
||||
# 1. connected(ACTIVE, INACTIVE) host
|
||||
for key, value in self.connections.items():
|
||||
@ -685,12 +676,13 @@ class vmmEngine(gobject.GObject):
|
||||
can_migrate = False
|
||||
desc = "%s (%s)" % (conn.get_hostname(), conn.get_driver())
|
||||
reason = ""
|
||||
desturi = conn.get_uri()
|
||||
|
||||
if conn.get_driver() != driver:
|
||||
reason = _("Connection hypervisors do not match.")
|
||||
elif conn.get_state() == vmmConnection.STATE_DISCONNECTED:
|
||||
reason = _("Connection is disconnected.")
|
||||
elif key == uri:
|
||||
elif key == origuri:
|
||||
reason = _("Cannot migrate to same connection.")
|
||||
|
||||
# Explicitly don't include this in the list
|
||||
@ -698,9 +690,11 @@ class vmmEngine(gobject.GObject):
|
||||
elif conn.get_state() == vmmConnection.STATE_ACTIVE:
|
||||
# Assumably we can migrate to this connection
|
||||
can_migrate = True
|
||||
reason = desturi
|
||||
|
||||
|
||||
available_migrate_hostnames[key] = [can_migrate, desc, reason]
|
||||
available_migrate_hostnames[key] = [can_migrate, desc, reason,
|
||||
desturi]
|
||||
|
||||
return available_migrate_hostnames
|
||||
|
||||
|
@ -1112,13 +1112,11 @@ class vmmManager(gobject.GObject):
|
||||
if vm is not None:
|
||||
self.emit("action-resume-domain", vm.get_connection().get_uri(), vm.get_uuid())
|
||||
|
||||
def migrate(self, ignore):
|
||||
def migrate(self, ignore, uri):
|
||||
vm = self.current_vm()
|
||||
label = self.vmmenumigrate.get_active().get_image().get_stock()[0]
|
||||
hostname = label.split(" ")[0]
|
||||
if vm is not None:
|
||||
self.emit("action-migrate-domain", vm.get_connection().get_uri(),
|
||||
vm.get_uuid(), hostname)
|
||||
vm.get_uuid(), uri)
|
||||
|
||||
def populate_migrate_submenu(self, src):
|
||||
vm = self.current_vm()
|
||||
|
Loading…
Reference in New Issue
Block a user