From patchwork Thu Jul 21 17:17:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 9242077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2621C607D3 for ; Thu, 21 Jul 2016 17:20:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1468627C39 for ; Thu, 21 Jul 2016 17:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08FA127F46; Thu, 21 Jul 2016 17:20:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B0E7927C39 for ; Thu, 21 Jul 2016 17:20:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQHbU-0003l9-FL; Thu, 21 Jul 2016 17:17:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bQHbS-0003ke-Fv for xen-devel@lists.xen.org; Thu, 21 Jul 2016 17:17:42 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 1C/BF-06162-5B301975; Thu, 21 Jul 2016 17:17:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeJIrShJLcpLzFFi42JxWrohUncr88R wg61TBCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oztr06xFjQIVuyY/oGlgbGLt4uRk0NCwF/i 0K6vLCA2m4C+xO4Xn5hAbBEBdYnTHRdZQWxmgTKJqZNeM3cxcnAIC4RI3G23AAmzCKhKtK87w A5i8wq4S/yZtpIVYqScxPnjP8HKOQU8JCbdCAEJCwGVbN3VyARhq0lc678E1SoocXLmExaITR ISB1+8YIYYwy1x+/RU5gmMfLOQlM1CUraAkWkVo3pxalFZapGupV5SUWZ6RkluYmaOrqGBsV5 uanFxYnpqTmJSsV5yfu4mRmA41TMwMO5gfP3T6RCjJAeTkijv28kTwoX4kvJTKjMSizPii0pz UosPMcpwcChJ8HoyTQwXEixKTU+tSMvMAQY2TFqCg0dJhLcBJM1bXJCYW5yZDpE6xagoJc47A SQhAJLIKM2Da4NF0yVGWSlhXkYGBgYhnoLUotzMElT5V4ziHIxKwrzzQabwZOaVwE1/BbSYCW jxHIF+kMUliQgpqQbGsjfXU474LfmxrL+fvfrUbBv2Gzzy86rvhxjm3uxr4uN+rKH+a9VkI+t mJU9bnYzIN2+0/+/Xu8C/hUOJn+le/nevP+36E07nGAZVGHm3CUd5Hjug9v6QlYqjtdO729ye e5pa34tUfbR+ddN6g/6lyC29vcvmbFh4XuH0ESs5jwft1lkHg1WUWIozEg21mIuKEwH2EB2xo QIAAA== X-Env-Sender: prvs=003bda41c=Andrew.Cooper3@citrix.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1469121459!51172737!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12765 invoked from network); 21 Jul 2016 17:17:41 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 21 Jul 2016 17:17:41 -0000 X-IronPort-AV: E=Sophos;i="5.28,400,1464652800"; d="scan'208";a="367619753" From: Andrew Cooper To: Xen-devel Date: Thu, 21 Jul 2016 18:17:36 +0100 Message-ID: <1469121457-365-4-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1469121457-365-1-git-send-email-andrew.cooper3@citrix.com> References: <1469121457-365-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH 3/4] tools/libxc: Avoid generating inappropriate zero-length records X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP It was never intended for records such as these to be sent with zero content. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_save_x86_hvm.c | 4 ++++ tools/libxc/xc_sr_save_x86_pv.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index ba50a43..5401bf9 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -112,6 +112,10 @@ static int write_hvm_params(struct xc_sr_context *ctx) } } + /* No params? Skip this record. */ + if ( hdr.count == 0 ) + return 0; + rc = write_split_record(ctx, &rec, entries, hdr.count * sizeof(*entries)); if ( rc ) PERROR("Failed to write HVM_PARAMS record"); diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c index 4a29460..5fb9f2f 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -607,6 +607,10 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id) return -1; } + /* No content? Skip the record. */ + if ( domctl.u.ext_vcpucontext.size == 0 ) + return 0; + return write_split_record(ctx, &rec, &domctl.u.ext_vcpucontext, domctl.u.ext_vcpucontext.size); } @@ -662,6 +666,10 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id) goto err; } + /* No xsave state? Skip this record. */ + if ( domctl.u.vcpuextstate.size == 0 ) + goto out; + rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpuextstate.size); if ( rc ) goto err; @@ -728,6 +736,10 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id) goto err; } + /* No MSRs? Skip this record. */ + if ( domctl.u.vcpu_msrs.msr_count == 0 ) + goto out; + rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpu_msrs.msr_count * sizeof(xen_domctl_vcpu_msr_t));