qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH V7 11/13] Experimental support for block migrating T


From: Stefan Berger
Subject: [Qemu-devel] [PATCH V7 11/13] Experimental support for block migrating TPMs state
Date: Wed, 10 Aug 2011 15:29:30 -0400
User-agent: quilt/0.48-1

This patch adds (experimental) support for block migration.

In the case of block migration an empty QCoW2 image must be found on
the destination so that early checks on the content and whether it can be
decrytped with the provided key have to be skipped. That empty file needs
to be created by higher layers (i.e., libvirt).

Also, the completion of the block migration has to be delayed until after
the TPM has written the last bytes of its state into the block device so
that we get the latest state on the target as well. Before the change to
savevm.c it could happen that the latest state of the TPM did not make it to
the destination host since the TPM was still processing a command and
changing its state (written into block storage) but the block migration
already had finished. Re-ordering the saving of the live_state to finish
after the 'non live_state' seems to get it right.

Signed-off-by: Stefan Berger <address@hidden>

---
 hw/tpm_builtin.c |    5 +++++
 savevm.c         |   23 ++++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

Index: qemu-git/hw/tpm_builtin.c
===================================================================
--- qemu-git.orig/hw/tpm_builtin.c
+++ qemu-git/hw/tpm_builtin.c
@@ -488,6 +488,11 @@ static int tpm_builtin_startup_bs(BlockD
 
     if (!tpm_builtin_is_valid_bsdir(dir) ||
         !tpm_builtin_has_valid_content(dir)) {
+        if (incoming_expected) {
+            /* during migration with block migration, we may end
+               up here due to an empty block file */
+            return -ENOKEY;
+        }
         /* if it's encrypted and has something else than null-content,
            we assume to have the wrong key */
         if (bdrv_is_encrypted(bs)) {
Index: qemu-git/savevm.c
===================================================================
--- qemu-git.orig/savevm.c
+++ qemu-git/savevm.c
@@ -1547,17 +1547,6 @@ int qemu_savevm_state_complete(Monitor *
     cpu_synchronize_all_states();
 
     QTAILQ_FOREACH(se, &savevm_handlers, entry) {
-        if (se->save_live_state == NULL)
-            continue;
-
-        /* Section type */
-        qemu_put_byte(f, QEMU_VM_SECTION_END);
-        qemu_put_be32(f, se->section_id);
-
-        se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
-    }
-
-    QTAILQ_FOREACH(se, &savevm_handlers, entry) {
         int len;
 
        if (se->save_state == NULL && se->vmsd == NULL)
@@ -1578,6 +1567,18 @@ int qemu_savevm_state_complete(Monitor *
         vmstate_save(f, se);
     }
 
+    QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+        if (se->save_live_state == NULL) {
+            continue;
+        }
+
+        /* Section type */
+        qemu_put_byte(f, QEMU_VM_SECTION_END);
+        qemu_put_be32(f, se->section_id);
+
+        se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque);
+    }
+
     qemu_put_byte(f, QEMU_VM_EOF);
 
     if (qemu_file_has_error(f))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]