migrate: Add 'temporary' option

This doesn't undefine the VM source, and leaves it temporary on the
destination. Basically the default migration action
This commit is contained in:
Cole Robinson 2015-04-21 17:32:43 -04:00
parent fb26349546
commit 18a6d8b444
3 changed files with 47 additions and 10 deletions

View File

@ -552,7 +552,7 @@ Enabling this option tells libvirt to skip those checks.</property>
<property name="label" translatable="yes">A_llow unsafe:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">migrate-unsafe</property>
<property name="xalign">1</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@ -573,6 +573,36 @@ Enabling this option tells libvirt to skip those checks.</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="migrate-temporary-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">By default, the migrated VM config is removed from the source host, and saved persistently on the destination host. The destination host is considered the new home of the VM.
If 'temporary' is selected, the migration is considered only a temporary move: the source host maintains a copy of the VM config, and the running copy moved to the destination is only transient, and will disappear when it is shutdown.</property>
<property name="label" translatable="yes">_Temporary move:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">migrate-temporary</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="migrate-temporary">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>

View File

@ -1495,13 +1495,15 @@ class vmmDomain(vmmLibvirtObject):
def migrate(self, destconn, interface=None,
secure=False, unsafe=False, meter=None):
secure=False, unsafe=False, temporary=False, meter=None):
self._install_abort = True
flags = 0
flags |= libvirt.VIR_MIGRATE_LIVE
flags |= libvirt.VIR_MIGRATE_PERSIST_DEST
flags |= libvirt.VIR_MIGRATE_UNDEFINE_SOURCE
if not temporary:
flags |= libvirt.VIR_MIGRATE_PERSIST_DEST
flags |= libvirt.VIR_MIGRATE_UNDEFINE_SOURCE
if secure:
flags |= libvirt.VIR_MIGRATE_PEER2PEER
@ -1511,8 +1513,9 @@ class vmmDomain(vmmLibvirtObject):
flags |= libvirt.VIR_MIGRATE_UNSAFE
libvirt_destconn = destconn.get_backend().get_conn_for_api_arg()
logging.debug("Migrating: conn=%s flags=%s uri=%s secure=%s unsafe=%s",
destconn, flags, interface, secure, unsafe)
logging.debug("Migrating: conn=%s flags=%s uri=%s secure=%s "
"unsafe=%s temporary=%s",
destconn, flags, interface, secure, unsafe, temporary)
if meter:
start_job_progress_thread(self, meter, _("Migrating domain"))

View File

@ -135,6 +135,8 @@ class vmmMigrateDialog(vmmGObjectUI):
self.widget("migrate-mode-label").get_tooltip_text())
self.widget("migrate-unsafe").set_tooltip_text(
self.widget("migrate-unsafe-label").get_tooltip_text())
self.widget("migrate-temporary").set_tooltip_text(
self.widget("migrate-temporary-label").get_tooltip_text())
def _reset_state(self):
title_str = ("<span size='large' color='white'>%s '%s'</span>" %
@ -159,6 +161,7 @@ class vmmMigrateDialog(vmmGObjectUI):
self.widget("migrate-mode").set_active(0)
self.widget("migrate-unsafe").set_active(False)
self.widget("migrate-temporary").set_active(False)
if self.conn.is_xen():
# Default xen port is 8002
@ -206,7 +209,6 @@ class vmmMigrateDialog(vmmGObjectUI):
address_warning = ""
tunnel_warning = ""
tunnel_uri = ""
is_tunnel = self._is_tunnel_selected()
if can_migrate and uri in self._conns:
destconn = self._conns[uri]
@ -370,6 +372,7 @@ class vmmMigrateDialog(vmmGObjectUI):
tunnel = self._is_tunnel_selected()
unsafe = self.widget("migrate-unsafe").get_active()
temporary = self.widget("migrate-temporary").get_active()
if tunnel:
uri = self.widget("migrate-tunnel-uri").get_text()
@ -395,7 +398,7 @@ class vmmMigrateDialog(vmmGObjectUI):
progWin = vmmAsyncJob(
self._async_migrate,
[self.vm, destconn, uri, tunnel, unsafe],
[self.vm, destconn, uri, tunnel, unsafe, temporary],
self._finish_cb, [destconn],
_("Migrating VM '%s'" % self.vm.get_name()),
(_("Migrating VM '%s' to %s. This may take a while.") %
@ -419,7 +422,7 @@ class vmmMigrateDialog(vmmGObjectUI):
return
def _async_migrate(self, asyncjob,
origvm, origdconn, migrate_uri, tunnel, unsafe):
origvm, origdconn, migrate_uri, tunnel, unsafe, temporary):
meter = asyncjob.get_meter()
srcconn = origvm.conn
@ -431,4 +434,5 @@ class vmmMigrateDialog(vmmGObjectUI):
logging.debug("Migrating vm=%s from %s to %s", vm.get_name(),
srcconn.get_uri(), dstconn.get_uri())
vm.migrate(dstconn, migrate_uri, tunnel, unsafe, meter=meter)
vm.migrate(dstconn, migrate_uri, tunnel, unsafe, temporary,
meter=meter)