From patchwork Wed Oct 7 06:20:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 527148 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 C26D1140D95 for ; Wed, 7 Oct 2015 17:21:36 +1100 (AEDT) Received: from localhost ([::1]:55429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zji6Y-0003ZP-DB for incoming@patchwork.ozlabs.org; Wed, 07 Oct 2015 02:21:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zji5v-0002W8-7K for qemu-devel@nongnu.org; Wed, 07 Oct 2015 02:20:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zji5t-0000Nl-3k for qemu-devel@nongnu.org; Wed, 07 Oct 2015 02:20:55 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:25299 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zji5s-0000NV-NW for qemu-devel@nongnu.org; Wed, 07 Oct 2015 02:20:53 -0400 Received: from irbis.sw.ru ([10.30.2.139]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id t976KkkR031932; Wed, 7 Oct 2015 09:20:50 +0300 (MSK) From: "Denis V. Lunev" To: Date: Wed, 7 Oct 2015 09:20:40 +0300 Message-Id: <1444198846-5383-3-git-send-email-den@openvz.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444198846-5383-1-git-send-email-den@openvz.org> References: <5614531B.5080107@redhat.com> <1444198846-5383-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: OpenBSD 3.x X-Received-From: 195.214.232.25 Cc: "Denis V. Lunev" , Igor Redko , jsnow@redhat.com, qemu-devel@nongnu.org, annam@virtuozzo.com Subject: [Qemu-devel] [PATCH 2/8] qemu-file: new hook in qemu-file 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: Igor Redko This patch adds hook_ram_sync() to QEMUFile abstraction. This hook can be used for passing information about dirty memory. An alternative is using existing hook_ram_load(). But this hook is designed for incoming VM migration, so using it for outcoming VM migration may complicate understanding of the code. On the other hand, using existing code decreases volume of the patchset and its impact. Signed-off-by: Igor Redko Reviewed-by: Anna Melekhova Signed-off-by: Denis V. Lunev --- include/migration/migration.h | 1 + include/migration/qemu-file.h | 1 + migration/qemu-file.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/migration/migration.h b/include/migration/migration.h index 8334621..deb0d21 100644 --- a/include/migration/migration.h +++ b/include/migration/migration.h @@ -182,6 +182,7 @@ bool migrate_use_events(void); void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data); +void ram_control_sync_hook(QEMUFile *f, uint64_t flags, void *data); /* Whenever this is found in the data stream, the flags * will be passed to ram_control_load_hook in the incoming-migration diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h index 29a338d..770dd98 100644 --- a/include/migration/qemu-file.h +++ b/include/migration/qemu-file.h @@ -105,6 +105,7 @@ typedef struct QEMUFileOps { QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; + QEMURamHookFunc *hook_ram_sync; QEMURamSaveFunc *save_page; QEMUFileShutdownFunc *shut_down; } QEMUFileOps; diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 49addf6..a05d672 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -168,6 +168,18 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data) } } +void ram_control_sync_hook(QEMUFile *f, uint64_t flags, void *data) +{ + int ret = 0; + + if (f->ops->hook_ram_sync) { + ret = f->ops->hook_ram_sync(f, f->opaque, flags, data); + if (ret < 0) { + qemu_file_set_error(f, ret); + } + } +} + size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, uint64_t *bytes_sent)