From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: stefanb@linux.vnet.ibm.com, qemu-devel@nongnu.org
Cc: anbang.ruan@cs.ox.ac.uk, andreas.niederl@iaik.tugraz.at,
serge@hallyn.com
Subject: [Qemu-devel] [PATCH V6 11/13] Experimental support for block migrating TPMs state
Date: Wed, 06 Jul 2011 12:34:51 -0400 [thread overview]
Message-ID: <20110706163517.391554439@linux.vnet.ibm.com> (raw)
In-Reply-To: 20110706163440.987096936@linux.vnet.ibm.com
[-- Attachment #1: qemu_tpm_blkmig.diff --]
[-- Type: text/plain, Size: 2935 bytes --]
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 <stefanb@linux.vnet.ibm.com>
---
hw/tpm_builtin.c | 5 +++++
savevm.c | 22 +++++++++++-----------
2 files changed, 16 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
@@ -1546,17 +1546,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)
@@ -1577,6 +1566,17 @@ 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))
next prev parent reply other threads:[~2011-07-06 16:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-06 16:34 [Qemu-devel] [PATCH V6 00/13] Qemu Trusted Platform Module (TPM) integration Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 01/13] Support for TPM command line options Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 02/13] Add TPM (frontend) hardware interface (TPM TIS) to Qemu Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 03/13] Add persistent state handling to TPM TIS frontend driver Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 04/13] Add tpm_tis driver to build process Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 05/13] Add a debug register Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 06/13] Add a TPM backend skeleton implementation Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 07/13] Implementation of the libtpms-based backend Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 08/13] Introduce file lock for the block layer Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 09/13] Add block storage support for libtpms based TPM backend Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 10/13] Encrypt state blobs using AES CBC encryption Stefan Berger
2011-07-06 16:34 ` Stefan Berger [this message]
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 12/13] Support for taking measurements when kernel etc. are passed to Qemu Stefan Berger
2011-07-06 16:34 ` [Qemu-devel] [PATCH V6 13/13] Add a TPM backend null driver implementation Stefan Berger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110706163517.391554439@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=anbang.ruan@cs.ox.ac.uk \
--cc=andreas.niederl@iaik.tugraz.at \
--cc=qemu-devel@nongnu.org \
--cc=serge@hallyn.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).