From patchwork Fri Apr 21 11:56:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 753340 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 3w8Zdl6D8Yz9s2x for ; Fri, 21 Apr 2017 22:23:23 +1000 (AEST) Received: from localhost ([::1]:58913 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1Xar-0006Rc-9s for incoming@patchwork.ozlabs.org; Fri, 21 Apr 2017 08:23:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1XCO-0002pk-J0 for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1XCI-0007cy-3r for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:58:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35474) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d1XCH-0007c6-RG for qemu-devel@nongnu.org; Fri, 21 Apr 2017 07:57:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0855335EAF for ; Fri, 21 Apr 2017 11:57:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0855335EAF Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=quintela@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B0855335EAF Received: from secure.com (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B3A589F57; Fri, 21 Apr 2017 11:57:55 +0000 (UTC) From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 21 Apr 2017 13:56:19 +0200 Message-Id: <20170421115646.15544-39-quintela@redhat.com> In-Reply-To: <20170421115646.15544-1-quintela@redhat.com> References: <20170421115646.15544-1-quintela@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 21 Apr 2017 11:57:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 38/65] ram: Add QEMUFile to RAMState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dgilbert@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Juan Quintela Reviewed-by: Dr. David Alan Gilbert --- migration/ram.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b9f415c..62b44cf 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -165,6 +165,8 @@ struct RAMSrcPageRequest { /* State of RAM for migration */ struct RAMState { + /* QEMUFile used for this migration */ + QEMUFile *f; /* Last block that we have visited searching for dirty pages */ RAMBlock *last_seen_block; /* Last block from where we have sent data */ @@ -525,14 +527,13 @@ static void xbzrle_cache_zero_page(RAMState *rs, ram_addr_t current_addr) * -1 means that xbzrle would be longer than normal * * @rs: current RAM state - * @f: QEMUFile where to send the data * @current_data: pointer to the address of the page contents * @current_addr: addr of the page * @block: block that contains the page we want to send * @offset: offset inside the block for the page * @last_stage: if we are at the completion stage */ -static int save_xbzrle_page(RAMState *rs, QEMUFile *f, uint8_t **current_data, +static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, ram_addr_t current_addr, RAMBlock *block, ram_addr_t offset, bool last_stage) { @@ -583,10 +584,11 @@ static int save_xbzrle_page(RAMState *rs, QEMUFile *f, uint8_t **current_data, } /* Send XBZRLE based compressed page */ - bytes_xbzrle = save_page_header(f, block, offset | RAM_SAVE_FLAG_XBZRLE); - qemu_put_byte(f, ENCODING_FLAG_XBZRLE); - qemu_put_be16(f, encoded_len); - qemu_put_buffer(f, XBZRLE.encoded_buf, encoded_len); + bytes_xbzrle = save_page_header(rs->f, block, + offset | RAM_SAVE_FLAG_XBZRLE); + qemu_put_byte(rs->f, ENCODING_FLAG_XBZRLE); + qemu_put_be16(rs->f, encoded_len); + qemu_put_buffer(rs->f, XBZRLE.encoded_buf, encoded_len); bytes_xbzrle += encoded_len + 1 + 2; rs->xbzrle_pages++; rs->xbzrle_bytes += bytes_xbzrle; @@ -850,7 +852,7 @@ static int ram_save_page(RAMState *rs, MigrationState *ms, QEMUFile *f, ram_release_pages(ms, block->idstr, pss->offset, pages); } else if (!rs->ram_bulk_stage && !migration_in_postcopy(ms) && migrate_use_xbzrle()) { - pages = save_xbzrle_page(rs, f, &p, current_addr, block, + pages = save_xbzrle_page(rs, &p, current_addr, block, offset, last_stage); if (!last_stage) { /* Can't send this cached data async, since the cache page @@ -2090,6 +2092,7 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return -1; } } + rs->f = f; rcu_read_lock();