[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] Virtual machine using the encrypted image fail to migrate by libvirt



      
The qemu-kvm and libvirt migration process is as follows:
e.g: migrate from VM1 to VM2

(1)virtual machine migration process by qemu-kvm (qemu-kvm-0.12.1.2-2.209.el6)is as follows:
==>VM1
1.set password 
2.continue
==>VM2
3.start and wait for migration(--incoming)
==>VM1
4.migrating 
5.migrate finish
6.close VM1
==>VM2
7.clear password
8.set password
9.continue

(2)virtual machine migration process by libvirt is as follows:
==>VM1
1.set password
2.continue
==>VM2
3.start (--incoming)
4.set password
5.wait for migration
==>VM1
6.migrating 
7.migrate finish
8.close VM1
==>VM2
9.clear password (here we lost the password !!)
10.continue

The migration process by libvirt will cause the migrate fail, because qemu-kvm will clear password before it continues.  So, I move step 4 just before step 10.

Here is the patch:

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 6ad1c30..8cb8fdc 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -169,6 +169,10 @@ struct _qemuMigrationCookie {
     qemuMigrationCookieNBDPtr nbd;
 };
 
+extern int qemuProcessInitPasswords(virConnectPtr conn,
+                         virQEMUDriverPtr driver,
+                         virDomainObjPtr vm);
+
 static void qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphicsPtr grap)
 {
     if (!grap)
@@ -4002,6 +4006,10 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
              * >= 0.10.6 to work properly.  This isn't strictly necessary on
              * older qemu's, but it also doesn't hurt anything there
              */
+            /* we will set password here */
+            if (qemuProcessInitPasswords(dconn, driver, vm) < 0)
+                virReportError(VIR_ERR_INTERNAL_ERROR,"%s", _("init passwords failed"));
+
             if (qemuProcessStartCPUs(driver, vm, dconn,
                                      VIR_DOMAIN_RUNNING_MIGRATED,
                                      QEMU_ASYNC_JOB_MIGRATION_IN) < 0) {
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 925939d..093e638 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -73,6 +73,11 @@
 #define ATTACH_POSTFIX ": attaching\n"
 #define SHUTDOWN_POSTFIX ": shutting down\n"
 
+int qemuProcessInitPasswords(virConnectPtr conn,
+                         virQEMUDriverPtr driver,
+                         virDomainObjPtr vm);
+
+
 /**
  * qemuProcessRemoveDomainStatus
  *
@@ -1981,8 +1986,7 @@ qemuProcessSetEmulatorAffinities(virConnectPtr conn ATTRIBUTE_UNUSED,
     return ret;
 }
 
-static int
-qemuProcessInitPasswords(virConnectPtr conn,
+int qemuProcessInitPasswords(virConnectPtr conn,
                          virQEMUDriverPtr driver,
                          virDomainObjPtr vm)
 {
@@ -3828,8 +3832,11 @@ int qemuProcessStart(virConnectPtr conn,
         goto cleanup;
 
     VIR_DEBUG("Setting any required VM passwords");
-    if (qemuProcessInitPasswords(conn, driver, vm) < 0)
-        goto cleanup;
+    /* if it is migration , we will not set password here */
+    if (!migrateFrom){ 
+        if (qemuProcessInitPasswords(conn, driver, vm) < 0)
+       	      goto cleanup;
+       }
 
     /* If we have -device, then addresses are assigned explicitly.
      * If not, then we have to detect dynamic ones here */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]