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:
Cole Robinson 2009-07-14 15:59:57 -04:00
parent 51a1e0d329
commit a2d49aee87
4 changed files with 22 additions and 40 deletions

View File

@ -737,13 +737,9 @@ class vmmDetails(gobject.GObject):
def control_vm_destroy(self, src): def control_vm_destroy(self, src):
self.emit("action-destroy-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid()) self.emit("action-destroy-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
def control_vm_migrate(self, src): def control_vm_migrate(self, src, uri):
# 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]
self.emit("action-migrate-domain", self.vm.get_connection().get_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): def populate_migrate_menu(self, ignore1=None):
menu = self.window.get_widget("details-menu-migrate_menu") menu = self.window.get_widget("details-menu-migrate_menu")

View File

@ -1455,21 +1455,15 @@ class vmmDomain(gobject.GObject):
self._disk_io = self._sample_disk_io_dummy self._disk_io = self._sample_disk_io_dummy
def migrate(self, destcon): def migrate(self, destconn):
flags = 0 flags = 0
if self.lastStatus == libvirt.VIR_DOMAIN_RUNNING: if self.lastStatus == libvirt.VIR_DOMAIN_RUNNING:
flags = libvirt.VIR_MIGRATE_LIVE 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() 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) gobject.type_register(vmmDomain)

View File

@ -581,21 +581,11 @@ class vmmEngine(gobject.GObject):
self.err.show_err(_("Error shutting down domain: %s" % str(e)), self.err.show_err(_("Error shutting down domain: %s" % str(e)),
"".join(traceback.format_exc())) "".join(traceback.format_exc()))
def migrate_domain(self, uri, uuid, desthost): def migrate_domain(self, uri, uuid, desturi):
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
conn = self._lookup_connection(uri) conn = self._lookup_connection(uri)
vm = conn.get_vm(uuid) 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 " resp = self.err.yes_no(_("Are you sure you want to migrate %s from "
"%s to %s?") % "%s to %s?") %
(vm.get_name(), conn.get_hostname(), (vm.get_name(), conn.get_hostname(),
@ -651,10 +641,10 @@ class vmmEngine(gobject.GObject):
menu.remove(item) menu.remove(item)
for ignore, val_list in conns.items(): 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 = gtk.ImageMenuItem(label)
mitem.set_sensitive(can_migrate) mitem.set_sensitive(can_migrate)
mitem.connect("activate", migrate_func) mitem.connect("activate", migrate_func, uri)
if tooltip: if tooltip:
util.tooltip_wrapper(mitem, tooltip) util.tooltip_wrapper(mitem, tooltip)
mitem.show() mitem.show()
@ -668,13 +658,14 @@ class vmmEngine(gobject.GObject):
def get_available_migrate_hostnames(self, vm): def get_available_migrate_hostnames(self, vm):
driver = vm.get_connection().get_driver() driver = vm.get_connection().get_driver()
uri = vm.get_connection().get_uri() origuri = vm.get_connection().get_uri()
available_migrate_hostnames = {} available_migrate_hostnames = {}
# Returns list of lists of the form # Returns list of lists of the form
# [ Can we migrate to this connection?, # [ Can we migrate to this connection?,
# String to use as list entry, # String to use as list entry,
# Tooltip reason ] # Tooltip reason,
# Conn URI ]
# 1. connected(ACTIVE, INACTIVE) host # 1. connected(ACTIVE, INACTIVE) host
for key, value in self.connections.items(): for key, value in self.connections.items():
@ -685,12 +676,13 @@ class vmmEngine(gobject.GObject):
can_migrate = False can_migrate = False
desc = "%s (%s)" % (conn.get_hostname(), conn.get_driver()) desc = "%s (%s)" % (conn.get_hostname(), conn.get_driver())
reason = "" reason = ""
desturi = conn.get_uri()
if conn.get_driver() != driver: if conn.get_driver() != driver:
reason = _("Connection hypervisors do not match.") reason = _("Connection hypervisors do not match.")
elif conn.get_state() == vmmConnection.STATE_DISCONNECTED: elif conn.get_state() == vmmConnection.STATE_DISCONNECTED:
reason = _("Connection is disconnected.") reason = _("Connection is disconnected.")
elif key == uri: elif key == origuri:
reason = _("Cannot migrate to same connection.") reason = _("Cannot migrate to same connection.")
# Explicitly don't include this in the list # Explicitly don't include this in the list
@ -698,9 +690,11 @@ class vmmEngine(gobject.GObject):
elif conn.get_state() == vmmConnection.STATE_ACTIVE: elif conn.get_state() == vmmConnection.STATE_ACTIVE:
# Assumably we can migrate to this connection # Assumably we can migrate to this connection
can_migrate = True 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 return available_migrate_hostnames

View File

@ -1112,13 +1112,11 @@ class vmmManager(gobject.GObject):
if vm is not None: if vm is not None:
self.emit("action-resume-domain", vm.get_connection().get_uri(), vm.get_uuid()) 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() vm = self.current_vm()
label = self.vmmenumigrate.get_active().get_image().get_stock()[0]
hostname = label.split(" ")[0]
if vm is not None: if vm is not None:
self.emit("action-migrate-domain", vm.get_connection().get_uri(), self.emit("action-migrate-domain", vm.get_connection().get_uri(),
vm.get_uuid(), hostname) vm.get_uuid(), uri)
def populate_migrate_submenu(self, src): def populate_migrate_submenu(self, src):
vm = self.current_vm() vm = self.current_vm()