From patchwork Fri Jul 4 17:41:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dr. David Alan Gilbert" X-Patchwork-Id: 367168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5C11F1400DE for ; Sat, 5 Jul 2014 03:52:35 +1000 (EST) Received: from localhost ([::1]:37445 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37ez-0002ra-Ds for incoming@patchwork.ozlabs.org; Fri, 04 Jul 2014 13:52:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37VZ-0007tg-KU for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:42:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X37VT-00008a-80 for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:42:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X37VS-00007o-V8 for qemu-devel@nongnu.org; Fri, 04 Jul 2014 13:42:43 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s64HgeSH004512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Jul 2014 13:42:40 -0400 Received: from dgilbert-t530.home.treblig.org (vpn1-7-141.ams2.redhat.com [10.36.7.141]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s64HfvTr030576; Fri, 4 Jul 2014 13:42:38 -0400 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org Date: Fri, 4 Jul 2014 18:41:35 +0100 Message-Id: <1404495717-4239-25-git-send-email-dgilbert@redhat.com> In-Reply-To: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> References: <1404495717-4239-1-git-send-email-dgilbert@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 24/46] qemu_savevm_state_complete: Postcopy changes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" When postcopy calls qemu_savevm_state_complete it's not really the end of migration, so skip: a) Finishing postcopiable iterative devices - they'll carry on b) The termination byte on the end of the stream. We then also add: qemu_savevm_state_postcopy_complete which is called at the end of a postcopy migration to call the complete methods on devices skipped in the _complete call. Signed-off-by: Dr. David Alan Gilbert --- include/sysemu/sysemu.h | 1 + savevm.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index dc53580..ce52c0a 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -112,6 +112,7 @@ void qemu_savevm_state_cancel(void); void qemu_savevm_state_pending(QEMUFile *f, uint64_t max_size, uint64_t *res_non_postcopiable, uint64_t *res_postcopiable); +void qemu_savevm_state_postcopy_complete(QEMUFile *f); void qemu_savevm_command_send(QEMUFile *f, enum qemu_vm_cmd command, uint16_t len, uint8_t *data); void qemu_savevm_send_reqack(QEMUFile *f, uint32_t value); diff --git a/savevm.c b/savevm.c index d8af526..a2c5fc8 100644 --- a/savevm.c +++ b/savevm.c @@ -845,10 +845,51 @@ int qemu_savevm_state_iterate(QEMUFile *f) return ret; } +/* + * Calls the complete routines just for those devices that are postcopiable; + * causing the last few pages to be sent immediately and doing any associated + * cleanup. + * Note postcopy also calls the plain qemu_savevm_state_complete to complete + * all the other devices, but that happens at the point we switch to postcopy. + */ +void qemu_savevm_state_postcopy_complete(QEMUFile *f) +{ + SaveStateEntry *se; + int ret; + + QTAILQ_FOREACH(se, &savevm_handlers, entry) { + if (!se->ops || !se->ops->save_live_complete || + !se->ops->can_postcopy) { + continue; + } + if (se->ops && se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + trace_savevm_section_start(se->idstr, se->section_id); + /* Section type */ + qemu_put_byte(f, QEMU_VM_SECTION_END); + qemu_put_be32(f, se->section_id); + + ret = se->ops->save_live_complete(f, se->opaque); + trace_savevm_section_end(se->idstr, se->section_id); + if (ret < 0) { + qemu_file_set_error(f, ret); + return; + } + } + + qemu_savevm_send_postcopy_ram_end(f, 0 /* Good */); + qemu_put_byte(f, QEMU_VM_EOF); + qemu_fflush(f); +} + void qemu_savevm_state_complete(QEMUFile *f) { SaveStateEntry *se; int ret; + bool in_postcopy = migration_postcopy_phase(migrate_get_current()); trace_savevm_state_complete(); @@ -863,6 +904,11 @@ void qemu_savevm_state_complete(QEMUFile *f) continue; } } + if (in_postcopy && se->ops && se->ops->can_postcopy && + se->ops->can_postcopy(se->opaque)) { + DPRINTF("%s: Skipping %s in postcopy", __func__, se->idstr); + continue; + } trace_savevm_section_start(se->idstr, se->section_id); /* Section type */ qemu_put_byte(f, QEMU_VM_SECTION_END); @@ -899,7 +945,11 @@ void qemu_savevm_state_complete(QEMUFile *f) trace_savevm_section_end(se->idstr, se->section_id); } - qemu_put_byte(f, QEMU_VM_EOF); + if (!in_postcopy) { + /* Postcopy stream will still be going */ + qemu_put_byte(f, QEMU_VM_EOF); + } + qemu_fflush(f); }