bnc#847641

Index: virt-manager-0.9.4/src/vmm-migrate.ui
===================================================================
--- virt-manager-0.9.4.orig/src/vmm-migrate.ui
+++ virt-manager-0.9.4/src/vmm-migrate.ui
@@ -296,6 +296,53 @@
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkAlignment" id="alignment7">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="left_padding">6</property>
+                            <child>
+                              <object class="GtkHBox" id="migrate-unsafe-box">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label17">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="label" translatable="yes">_Allow unsafe migration:</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">migrate-unsafe</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkCheckButton" id="migrate-unsafe">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="use_action_appearance">False</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">True</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkHBox" id="migrate-maxdowntime-box">
                             <property name="visible">True</property>
                             <property name="can_focus">False</property>
@@ -408,7 +455,7 @@
                           <packing>
                             <property name="expand">True</property>
                             <property name="fill">True</property>
-                            <property name="position">1</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                         <child>
@@ -659,7 +706,7 @@
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">2</property>
+                            <property name="position">3</property>
                           </packing>
                         </child>
                       </object>
Index: virt-manager-0.9.4/src/virtManager/migrate.py
===================================================================
--- virt-manager-0.9.4.orig/src/virtManager/migrate.py
+++ virt-manager-0.9.4/src/virtManager/migrate.py
@@ -144,6 +144,7 @@ class vmmMigrateDialog(vmmGObjectUI):
 
         self.widget("migrate-rate").set_value(0)
         self.widget("migrate-secure").set_active(False)
+        self.widget("migrate-unsafe").set_active(False)
 
         downtime_box = self.widget("migrate-maxdowntime-box")
         support_downtime = self.vm.support_downtime()
@@ -171,6 +172,15 @@ class vmmMigrateDialog(vmmGObjectUI):
         secure_box.set_sensitive(support_secure)
         util.tooltip_wrapper(secure_box, secure_tooltip)
 
+        unsafe_box = self.widget("migrate-unsafe-box")
+        support_unsafe = hasattr(libvirt, "VIR_MIGRATE_UNSAFE")
+        unsafe_tooltip = ""
+        if not support_unsafe:
+            unsafe_tooltip = _("Libvirt version does not support unsafe "
+                               "migration.")
+
+        unsafe_box.set_sensitive(support_unsafe)
+        util.tooltip_wrapper(unsafe_box, unsafe_tooltip)
         self.rebuild_dest_rows()
 
     def set_state(self, vm):
@@ -231,6 +241,9 @@ class vmmMigrateDialog(vmmGObjectUI):
     def get_config_secure(self):
         return self.widget("migrate-secure").get_active()
 
+    def get_config_unsafe(self):
+        return self.widget("migrate-unsafe").get_active()
+
     def get_config_max_downtime_enabled(self):
         return self.widget("migrate-max-downtime").get_property("sensitive")
 
@@ -453,6 +466,7 @@ class vmmMigrateDialog(vmmGObjectUI):
             max_downtime = self.get_config_max_downtime()
             live = not self.get_config_offline()
             secure = self.get_config_secure()
+            unsafe = self.get_config_unsafe()
             uri = self.build_migrate_uri(destconn, srcuri)
             rate = self.get_config_rate()
             if rate:
@@ -476,7 +490,7 @@ class vmmMigrateDialog(vmmGObjectUI):
 
         progWin = vmmAsyncJob(self._async_migrate,
                               [self.vm, destconn, uri, rate, live, secure,
-                               max_downtime],
+                               unsafe, max_downtime],
                               _("Migrating VM '%s'" % self.vm.get_name()),
                               (_("Migrating VM '%s' from %s to %s. "
                                  "This may take awhile.") %
@@ -530,7 +544,7 @@ class vmmMigrateDialog(vmmGObjectUI):
 
     def _async_migrate(self, asyncjob,
                        origvm, origdconn, migrate_uri, rate, live,
-                       secure, max_downtime):
+                       secure, unsafe, max_downtime):
         meter = asyncjob.get_meter()
 
         srcconn = util.dup_conn(origvm.conn)
@@ -550,7 +564,7 @@ class vmmMigrateDialog(vmmGObjectUI):
             timer = self.timeout_add(100, self._async_set_max_downtime,
                                      vm, max_downtime, current_thread)
 
-        vm.migrate(dstconn, migrate_uri, rate, live, secure, meter=meter)
+        vm.migrate(dstconn, migrate_uri, rate, live, secure, unsafe, meter=meter)
         if timer:
             self.idle_add(gobject.source_remove, timer)
 
Index: virt-manager-0.9.4/src/virtManager/domain.py
===================================================================
--- virt-manager-0.9.4.orig/src/virtManager/domain.py
+++ virt-manager-0.9.4/src/virtManager/domain.py
@@ -1149,7 +1149,7 @@ class vmmDomain(vmmLibvirtObject):
         self._backend.migrateSetMaxDowntime(max_downtime, flag)
 
     def migrate(self, destconn, interface=None, rate=0,
-                live=False, secure=False, meter=None):
+                live=False, secure=False, unsafe=False, meter=None):
         self._install_abort = True
 
         newname = None
@@ -1162,6 +1162,9 @@ class vmmDomain(vmmLibvirtObject):
             flags |= libvirt.VIR_MIGRATE_PEER2PEER
             flags |= libvirt.VIR_MIGRATE_TUNNELLED
 
+        if unsafe:
+            flags |= libvirt.VIR_MIGRATE_UNSAFE
+
         logging.debug("Migrating: conn=%s flags=%s dname=%s uri=%s rate=%s",
                       destconn.vmm, flags, newname, interface, rate)
 
