From patchwork Tue Dec 24 15:19:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11309515 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDD7D6C1 for ; Tue, 24 Dec 2019 15:20:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7F7B20706 for ; Tue, 24 Dec 2019 15:20:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="HOwULLze" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7F7B20706 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijlyU-0000Fw-Hh; Tue, 24 Dec 2019 15:19:54 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijlyT-0000F5-2p for xen-devel@lists.xenproject.org; Tue, 24 Dec 2019 15:19:53 +0000 X-Inumbo-ID: cdd8b87e-2660-11ea-97e5-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cdd8b87e-2660-11ea-97e5-12813bfff9fa; Tue, 24 Dec 2019 15:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577200780; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BgJBwMwc+2ZgDVUftpuJ89tJoR9wAvhwn6Ya11l9r0g=; b=HOwULLzeyoMefa2QUo+sQrKWH39XNWscXdFG6lVM6rfmnvQizVAyu7Tp F82XJo8LXM6e9um9PvwSHb6gy7OhnDvnNGrGEpyDQ+RUGwx4NVT9ceRRf riH6ojrFqBoXrW5ihkO1PYZg6/JpJ0urb26UnFdV/8DgR3DDDP1Ua4vsd k=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: pY8uPqMyVJlUYbRUz3s9kmUK13b7iTA07gfVLevMTXxpnWHY9EXb0RvsAZ51I0XiI6uoFsrfL7 s4fdNI5alKpijFBu5vj12lfp69ObEJLVMGLE3wsxyAO1x+0cmPWLbFN404uQLfVrQP24FF64Uc 57AlF9HW2GQFhDCCNu/gGeJMPsj9Qnwf2Pz1Rv1Yj6qHdxBI1bBtj/ZYSrHCzxk6kQ2tSUH3GX BSoPI8tbA92cGP8ci9PQBs9ie/4JUPZ6aaKcNfUteQGTbkMY+vGD8ft96RKNwbyMrqixPQBqgE Bbc= X-SBRS: 2.7 X-MesageID: 10482750 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,351,1571716800"; d="scan'208";a="10482750" From: Andrew Cooper To: Xen-devel Date: Tue, 24 Dec 2019 15:19:29 +0000 Message-ID: <20191224151932.6304-10-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191224151932.6304-1-andrew.cooper3@citrix.com> References: <20191224151932.6304-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 09/12] libxc/save: Write a v3 stream X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , =?utf-8?q?Marek_Marczykowski-?= =?utf-8?q?G=C3=B3recki?= , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Introduce a new static_data() hook which is responsible for writing out any static data records. The HVM side continues to be a no-op, while the PV side moves write_x86_pv_info() into this earlier hook. The the common code writes out a STATIC_DATA_END record, and the stream version is bumped to 3. Update convert-legacy-stream to write a v3 stream, because this will bypass the compatiblity logic in libxc. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Marek Marczykowski-Górecki --- tools/libxc/xc_sr_common.h | 10 ++++++++-- tools/libxc/xc_sr_save.c | 14 +++++++++++++- tools/libxc/xc_sr_save_x86_hvm.c | 6 ++++++ tools/libxc/xc_sr_save_x86_pv.c | 10 ++++++---- tools/python/scripts/convert-legacy-stream | 9 ++++++++- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h index 2e9a4bc587..3f52ef7d53 100644 --- a/tools/libxc/xc_sr_common.h +++ b/tools/libxc/xc_sr_common.h @@ -63,8 +63,14 @@ struct xc_sr_save_ops int (*setup)(struct xc_sr_context *ctx); /** - * Send records which need to be at the start of the stream. This is - * called once, after the Image and Domain headers are written. + * Send static records at the head of the stream. This is called once, + * after the Image and Domain headers are written. + */ + int (*static_data)(struct xc_sr_context *ctx); + + /** + * Send dynamic records which need to be at the start of the stream. This + * is called after the STATIC_DATA_END record is written. */ int (*start_of_stream)(struct xc_sr_context *ctx); diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index fa1a2e6c2a..f24dd0d00b 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -13,7 +13,7 @@ static int write_headers(struct xc_sr_context *ctx, uint16_t guest_type) struct xc_sr_ihdr ihdr = { .marker = IHDR_MARKER, .id = htonl(IHDR_ID), - .version = htonl(2), + .version = htonl(3), .options = htons(IHDR_OPT_LITTLE_ENDIAN), }; struct xc_sr_dhdr dhdr = { @@ -55,6 +55,16 @@ static int write_end_record(struct xc_sr_context *ctx) } /* + * Writes a STATIC_DATA_END record into the stream. + */ +static int write_static_data_end_record(struct xc_sr_context *ctx) +{ + struct xc_sr_record end = { .type = REC_TYPE_STATIC_DATA_END }; + + return write_record(ctx, &end); +} + +/* * Writes a CHECKPOINT record into the stream. */ static int write_checkpoint_record(struct xc_sr_context *ctx) @@ -846,6 +856,8 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) xc_report_progress_single(xch, "Start of stream"); rc = (write_headers(ctx, guest_type) ?: + ctx->save.ops.static_data(ctx) ?: + write_static_data_end_record(ctx) ?: ctx->save.ops.start_of_stream(ctx)); if ( rc ) goto err; diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index 58722118ae..c146e827bc 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -170,6 +170,11 @@ static int x86_hvm_setup(struct xc_sr_context *ctx) return 0; } +static int x86_hvm_static_data(struct xc_sr_context *ctx) +{ + return 0; +} + static int x86_hvm_start_of_stream(struct xc_sr_context *ctx) { return 0; @@ -213,6 +218,7 @@ struct xc_sr_save_ops save_ops_x86_hvm = .pfn_to_gfn = x86_hvm_pfn_to_gfn, .normalise_page = x86_hvm_normalise_page, .setup = x86_hvm_setup, + .static_data = x86_hvm_static_data, .start_of_stream = x86_hvm_start_of_stream, .start_of_checkpoint = x86_hvm_start_of_checkpoint, .end_of_checkpoint = x86_hvm_end_of_checkpoint, diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c index c1c6892666..9d1ca6ead7 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -1028,14 +1028,15 @@ static int x86_pv_setup(struct xc_sr_context *ctx) map_p2m(ctx)); } +static int x86_pv_static_data(struct xc_sr_context *ctx) +{ + return write_x86_pv_info(ctx); +} + static int x86_pv_start_of_stream(struct xc_sr_context *ctx) { int rc; - rc = write_x86_pv_info(ctx); - if ( rc ) - return rc; - /* * Ideally should be able to change during migration. Currently * corruption will occur if the contents or location of the P2M changes @@ -1090,6 +1091,7 @@ struct xc_sr_save_ops save_ops_x86_pv = .pfn_to_gfn = x86_pv_pfn_to_gfn, .normalise_page = x86_pv_normalise_page, .setup = x86_pv_setup, + .static_data = x86_pv_static_data, .start_of_stream = x86_pv_start_of_stream, .start_of_checkpoint = x86_pv_start_of_checkpoint, .end_of_checkpoint = x86_pv_end_of_checkpoint, diff --git a/tools/python/scripts/convert-legacy-stream b/tools/python/scripts/convert-legacy-stream index 02a194178f..ca93a93848 100755 --- a/tools/python/scripts/convert-legacy-stream +++ b/tools/python/scripts/convert-legacy-stream @@ -79,7 +79,7 @@ def write_libxc_ihdr(): stream_write(pack(libxc.IHDR_FORMAT, libxc.IHDR_MARKER, # Marker libxc.IHDR_IDENT, # Ident - 2, # Version + 3, # Version libxc.IHDR_OPT_LE, # Options 0, 0)) # Reserved @@ -166,6 +166,9 @@ def write_libxc_hvm_params(params): pack(libxc.HVM_PARAMS_FORMAT, len(params) / 2, 0), pack("Q" * len(params), *params)) +def write_libxc_static_data_end(): + write_record(libxc.REC_TYPE_static_data_end) + def write_libxl_end(): write_record(libxl.REC_TYPE_end) @@ -590,6 +593,10 @@ def read_legacy_stream(vm): if pv: read_pv_extended_info(vm) + + write_libxc_static_data_end() + + if pv: read_pv_p2m_frames(vm) read_chunks(vm)