From patchwork Fri Jan 3 13:06:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316899 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 AB9FB109A for ; Fri, 3 Jan 2020 13:07:49 +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 888FC20866 for ; Fri, 3 Jan 2020 13:07:49 +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="gnjV879b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 888FC20866 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 1inMev-00044u-6W; Fri, 03 Jan 2020 13:06:33 +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 1inMet-00044n-AY for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:31 +0000 X-Inumbo-ID: db7f7e60-2e29-11ea-a47f-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id db7f7e60-2e29-11ea-a47f-12813bfff9fa; Fri, 03 Jan 2020 13:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056791; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=8QgjIzer1gxVrXiuNa9rtKVD3ywdbUj6QwacUYHSSTk=; b=gnjV879b/E1gXtrDcvyTfODfcHzAlln4Ix7cnLUSDsw0EwyXfBPNkTSc RywH1+beYk+OHAyR7Vjxdve9fQDq67Pki7oI0+Vtu0jirVbuGxti4NPCK J//TMd5GeR+WaP9r9EBvC0Ntm8w16ZUdU3uqnzr6H4h7Moyh+mUjrVOs0 U=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: uns0wV9xBooSFJ4wHF/9AfHsMsMb4ZBQYK44VzTR6JqIT/jBIAHLGJ6wIjrjJBlsYXX8DFnb+N 4WwS4exmaT/bsFUDHta90MWdVrb8JX44vWjwvAbkNkQhSkz1DxO+HdJfAXRtti3rt//clPujA5 NkHmsFd2SokRA0xWTR2EEdzHYeXknKHBdBCIuPtpctrKmqpE+OHiRg8ALb+/KAtupko2jEs7Vi nC73CGPnqKuC9SrUTg3Z2emrv6Cw/xv0F7TsdrQfzIDwFOh5MS/tNKeH8Vc89biG5L/RN7ruUV C3g= X-SBRS: 2.7 X-MesageID: 10571942 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10571942" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:11 +0000 Message-ID: <20200103130616.13724-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 15/20] fixup tools/migration: Formatting and style cleanup 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Further cleanup. Signed-off-by: Andrew Cooper --- tools/libxc/include/xenguest.h | 37 ++++++++++++++++++++----------------- tools/libxc/xc_sr_save.c | 8 ++++---- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index 9ba09af743..d81baa6cc2 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -55,10 +55,11 @@ typedef int (*precopy_policy_t)(struct precopy_stats, void *); /* callbacks provided by xc_domain_save */ struct save_callbacks { - /* Called after expiration of checkpoint interval, + /* + * Called after expiration of checkpoint interval, * to suspend the guest. */ - int (*suspend)(void* data); + int (*suspend)(void *data); /* * Called before and after every batch of page data sent during @@ -82,7 +83,7 @@ struct save_callbacks { * xc_domain_save then flushes the output buffer, while the * guest continues to run. */ - int (*postcopy)(void* data); + int (*postcopy)(void *data); /* * Called after the memory checkpoint has been flushed @@ -97,7 +98,7 @@ struct save_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*checkpoint)(void* data); + int (*checkpoint)(void *data); /* * Called after the checkpoint callback. @@ -106,13 +107,13 @@ struct save_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*wait_checkpoint)(void* data); + int (*wait_checkpoint)(void *data); /* Enable qemu-dm logging dirty pages to xen */ int (*switch_qemu_logdirty)(uint32_t domid, unsigned enable, void *data); /* HVM only */ /* to be provided as the last argument to each callback function */ - void* data; + void *data; }; /* Type of stream. Plain, or using a continuous replication protocol? */ @@ -134,27 +135,29 @@ typedef enum { */ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, uint32_t flags /* XCFLAGS_xxx */, - struct save_callbacks* callbacks, int hvm, + struct save_callbacks *callbacks, int hvm, xc_stream_type_t stream_type, int recv_fd); /* callbacks provided by xc_domain_restore */ struct restore_callbacks { - /* Called after a new checkpoint to suspend the guest. - */ - int (*suspend)(void* data); + /* Called after a new checkpoint to suspend the guest. */ + int (*suspend)(void *data); - /* Called after the secondary vm is ready to resume. + /* + * Called after the secondary vm is ready to resume. * Callback function resumes the guest & the device model, * returns to xc_domain_restore. */ - int (*postcopy)(void* data); + int (*postcopy)(void *data); - /* A checkpoint record has been found in the stream. - * returns: */ + /* + * A checkpoint record has been found in the stream. + * returns: + */ #define XGR_CHECKPOINT_ERROR 0 /* Terminate processing */ #define XGR_CHECKPOINT_SUCCESS 1 /* Continue reading more data from the stream */ #define XGR_CHECKPOINT_FAILOVER 2 /* Failover and resume VM */ - int (*checkpoint)(void* data); + int (*checkpoint)(void *data); /* * Called after the checkpoint callback. @@ -163,7 +166,7 @@ struct restore_callbacks { * 0: terminate checkpointing gracefully * 1: take another checkpoint */ - int (*wait_checkpoint)(void* data); + int (*wait_checkpoint)(void *data); /* * callback to send store gfn and console gfn to xl @@ -174,7 +177,7 @@ struct restore_callbacks { void *data); /* to be provided as the last argument to each callback function */ - void* data; + void *data; }; /** diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index f24dd0d00b..0e66f31aae 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -579,7 +579,7 @@ static int send_memory_live(struct xc_sr_context *ctx) static int colo_merge_secondary_dirty_bitmap(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; - struct xc_sr_record rec = { 0, 0, NULL }; + struct xc_sr_record rec; uint64_t *pfns = NULL; uint64_t pfn; unsigned int count, i; @@ -593,14 +593,14 @@ static int colo_merge_secondary_dirty_bitmap(struct xc_sr_context *ctx) if ( rec.type != REC_TYPE_CHECKPOINT_DIRTY_PFN_LIST ) { - PERROR("Expect dirty bitmap record, but received %u", rec.type ); + PERROR("Expect dirty bitmap record, but received %u", rec.type); rc = -1; goto err; } if ( rec.length % sizeof(*pfns) ) { - PERROR("Invalid dirty pfn list record length %u", rec.length ); + PERROR("Invalid dirty pfn list record length %u", rec.length); rc = -1; goto err; } @@ -611,7 +611,7 @@ static int colo_merge_secondary_dirty_bitmap(struct xc_sr_context *ctx) for ( i = 0; i < count; i++ ) { pfn = pfns[i]; - if (pfn > ctx->save.p2m_size) + if ( pfn > ctx->save.p2m_size ) { PERROR("Invalid pfn 0x%" PRIx64, pfn); rc = -1; From patchwork Fri Jan 3 13:06:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316901 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 398251580 for ; Fri, 3 Jan 2020 13:07:50 +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 16B1E20866 for ; Fri, 3 Jan 2020 13:07:50 +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="HiIWVy5Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16B1E20866 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 1inMf8-00046N-PR; Fri, 03 Jan 2020 13:06:46 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMf7-00045y-8M for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:45 +0000 X-Inumbo-ID: defe041c-2e29-11ea-a914-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id defe041c-2e29-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 13:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056796; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=+brguB1nMVjS8uTomgW5MTQducEv5eNRXPfnzSMU2XE=; b=HiIWVy5ZSGyJOJ27E7YhtNsr9Hc/53Zo002lmFxQPrf1gCO/o5YcltVH joRqXm0kVrxzjaPYXphp9xGfckGNOgZtALgedU39s4cDtVFzSIemEo+TH t8GQ2yRdcpsTS1mdCP3Rfxm8dI1cyGd8o8jixFGlMI3wvuVtj2z181zwe 0=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Ks7qC2eM8OTWEDOGYXsFbRVKgCVf7V7FlLwJVXwdZV4MZGx1KyThFlarxv26HoyKMFZgvXT6UL WIknRSO+AsJVtAjbtJzOdYXg5SiuzJKevzK3ePuG6SL6cszKZhcsSOZcRgXPJTh/3j7dnOzR7Y zh7i1307iVmjfAJTm+pgqCM0C1lo68kRgYE5FIJEffFbCycqIiq2WE77jMAl9nkpYbd+Qx+o6W +wTf80Eibn1bQNEcoNeFXq/IbPaTq3pD2bjNUhRQZtvakLVfgV3AqEmCycu0ZM6sbB828Xe9SL jPA= X-SBRS: 2.7 X-MesageID: 10571944 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10571944" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:12 +0000 Message-ID: <20200103130616.13724-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 16/20] tools/libxl: Simplify callback handling in libxl-save-helper 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: Anthony PERARD , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The {save,restore}_callback helpers can have their scope reduced vastly, and helper_setcallbacks_{save,restore}() doesn't need to use a ternary operator to write 0 (meaning NULL) into an already zeroed structure. No functional change. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxl/libxl_save_helper.c | 15 ++++++--------- tools/libxl/libxl_save_msgs_gen.pl | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c index 398df00dd6..a91f36db73 100644 --- a/tools/libxl/libxl_save_helper.c +++ b/tools/libxl/libxl_save_helper.c @@ -217,8 +217,6 @@ int helper_getreply(void *user) /*----- other callbacks -----*/ -static struct save_callbacks helper_save_callbacks; - static void startup(const char *op) { xtl_log(&logger,XTL_DEBUG,0,program,"starting %s",op); @@ -234,8 +232,6 @@ static void complete(int retval) { exit(0); } -static struct restore_callbacks helper_restore_callbacks; - int main(int argc, char **argv) { int r; @@ -247,6 +243,7 @@ int main(int argc, char **argv) assert(mode); if (!strcmp(mode,"--save-domain")) { + static struct save_callbacks cb; io_fd = atoi(NEXTARG); recv_fd = atoi(NEXTARG); @@ -257,16 +254,17 @@ int main(int argc, char **argv) xc_stream_type_t stream_type = strtoul(NEXTARG,0,10); assert(!*++argv); - helper_setcallbacks_save(&helper_save_callbacks, cbflags); + helper_setcallbacks_save(&cb, cbflags); startup("save"); setup_signals(save_signal_handler); - r = xc_domain_save(xch, io_fd, dom, flags, &helper_save_callbacks, + r = xc_domain_save(xch, io_fd, dom, flags, &cb, hvm, stream_type, recv_fd); complete(r); } else if (!strcmp(mode,"--restore-domain")) { + static struct restore_callbacks cb; io_fd = atoi(NEXTARG); send_back_fd = atoi(NEXTARG); @@ -281,7 +279,7 @@ int main(int argc, char **argv) xc_stream_type_t stream_type = strtoul(NEXTARG,0,10); assert(!*++argv); - helper_setcallbacks_restore(&helper_restore_callbacks, cbflags); + helper_setcallbacks_restore(&cb, cbflags); unsigned long store_mfn = 0; unsigned long console_mfn = 0; @@ -292,8 +290,7 @@ int main(int argc, char **argv) r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn, store_domid, console_evtchn, &console_mfn, console_domid, hvm, pae, - stream_type, - &helper_restore_callbacks, send_back_fd); + stream_type, &cb, send_back_fd); helper_stub_restore_results(store_mfn,console_mfn,0); complete(r); diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index 6f1d79f821..831a15e0bb 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -333,7 +333,7 @@ END_ALWAYS my $c_v = "(1u<<$msgnum)"; my $c_cb = "cbs->$name"; $f_more_sr->(" if ($c_cb) cbflags |= $c_v;\n", $enumcallbacks); - $f_more_sr->(" $c_cb = (cbflags & $c_v) ? ${encode}_${name} : 0;\n", + $f_more_sr->(" if (cbflags & $c_v) $c_cb = ${encode}_${name};\n", $setcallbacks); } $f_more_sr->(" return 1;\n }\n\n"); From patchwork Fri Jan 3 13:06:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316907 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 04284109A for ; Fri, 3 Jan 2020 13:08:05 +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 D3BC520866 for ; Fri, 3 Jan 2020 13:08:04 +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="C4VkVu4Z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3BC520866 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 1inMfN-0004ED-6d; Fri, 03 Jan 2020 13:07:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMfM-0004DX-8V for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:07:00 +0000 X-Inumbo-ID: e49a8fc6-2e29-11ea-a914-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e49a8fc6-2e29-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 13:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056805; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=PHP2KunlTWORkKc8EeqqmVhshlq7AlcvEna5zhXo66M=; b=C4VkVu4ZPU3+9AexlW++lW1Yewlx1uKYJYhmwbt+3rF4msAWvtFqRjlv UDrispWNckaq4+6Dkv+M5VsWgdS4YjX1+Ht7+2lwrC7DrQjaV4wRI7oXt cIsb8B4c/r9txLGd3xBP8ey8DKWpszqlhX4ZNXbdoItPONItRcDFPFdDh s=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: iy6gUgXeuZl6uXIjKSuftEPHCTLrunRcpPynxXgyD7E63ttotEyIXxT9nNGR3yK41WF0b99R8S OG14qvBgImhI4iJsoctcHqlQgZoYRIxMB9jI6x7Gh+n7IG5kcA2nais83fklZu+mWlq7g+SR0l M1ZL5u83OBmz9x7G19yuDTBdvnjUZXVuf7KmmjG4iUeOTezRPY07ZNnzPhp6Z0fPgGaslilTGZ kj+sFOkvQo7/CSzESjxM3fYtH9ztxojGWVdlHhiiT0p/MFep9w4vc7omF29Mki7aSCmscF7GMr IFs= X-SBRS: 2.7 X-MesageID: 10571945 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10571945" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:13 +0000 Message-ID: <20200103130616.13724-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 17/20] tools/libx[cl]: Plumb static_data_done() up into libxl 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: Anthony PERARD , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" libxl is going to have to provide compatibility for pre 4.14 streams which don't contain CPUID information. Introduce the static_data_done() callback and plumb it up into libxl. No overall change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxc/include/xenguest.h | 9 +++++++++ tools/libxc/xc_sr_common_x86.c | 13 ++++++++++++- tools/libxc/xc_sr_restore.c | 1 + tools/libxl/libxl_create.c | 13 +++++++++++++ tools/libxl/libxl_save_msgs_gen.pl | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h index d81baa6cc2..be80544bd0 100644 --- a/tools/libxc/include/xenguest.h +++ b/tools/libxc/include/xenguest.h @@ -140,6 +140,15 @@ int xc_domain_save(xc_interface *xch, int io_fd, uint32_t dom, /* callbacks provided by xc_domain_restore */ struct restore_callbacks { + /* + * Called once the STATIC_DATA_END record has been received/inferred. + * Passes in the blocks of static data which have not been received, which + * the higher level toolstack must provide backwards compatibility for. + */ +#define XGR_SDD_MISSING_CPUID (1 << 0) +#define XGR_SDD_MISSING_MSR (1 << 1) + int (*static_data_done)(unsigned int missing, void *data); + /* Called after a new checkpoint to suspend the guest. */ int (*suspend)(void *data); diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index 09fb1d93d6..c3d1d30d91 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -44,9 +44,20 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) int x86_static_data_complete(struct xc_sr_context *ctx) { + xc_interface *xch = ctx->xch; + unsigned int missing = 0; + int rc; + /* TODO - something useful. */ + missing = XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; - return 0; + rc = ctx->restore.callbacks->static_data_done( + missing, ctx->restore.callbacks->data); + + if ( rc ) + ERROR("static_data_done() callback failed: %d\n", rc); + + return rc; } int write_x86_cpu_policy_records(struct xc_sr_context *ctx) diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c index d4bd60a31e..09d8a08316 100644 --- a/tools/libxc/xc_sr_restore.c +++ b/tools/libxc/xc_sr_restore.c @@ -908,6 +908,7 @@ int xc_domain_restore(xc_interface *xch, int io_fd, uint32_t dom, assert(callbacks->checkpoint); /* Fallthrough */ case XC_STREAM_PLAIN: + assert(callbacks->static_data_done); break; default: diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 32d45dcef0..fdc76917dc 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1227,6 +1227,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->srs.dcs = dcs; /* Restore */ + callbacks->static_data_done = libxl__srm_callout_callback_static_data_done; callbacks->restore_results = libxl__srm_callout_callback_restore_results; /* COLO only supports HVM now because it does not work very @@ -1296,6 +1297,18 @@ static void libxl__colo_restore_setup_done(libxl__egc *egc, libxl__stream_read_start(egc, &dcs->srs); } +int libxl__srm_callout_callback_static_data_done(unsigned int missing, + void *user) +{ + libxl__save_helper_state *shs = user; + libxl__domain_create_state *dcs = shs->caller_state; + STATE_AO_GC(dcs->ao); + + /* TODO - something useful. */ + + return 0; +} + void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn, xen_pfn_t console_mfn, void *user) { diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index 831a15e0bb..5bfbd4fd10 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -29,6 +29,7 @@ our @msgs = ( [ 'srcxA', "wait_checkpoint", [] ], [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid unsigned enable)] ], + [ 'rcxW', "static_data_done", [qw(unsigned missing)] ], [ 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', 'xen_pfn_t', 'console_gfn'] ], [ 'srW', "complete", [qw(int retval From patchwork Fri Jan 3 13:06:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316905 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 586751580 for ; Fri, 3 Jan 2020 13:07:54 +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 352C420866 for ; Fri, 3 Jan 2020 13:07:54 +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="hBA5VhvH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 352C420866 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 1inMfA-00046k-2C; Fri, 03 Jan 2020 13:06:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMf8-00046C-D3 for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:46 +0000 X-Inumbo-ID: dfb1f22e-2e29-11ea-a914-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dfb1f22e-2e29-11ea-a914-bc764e2007e4; Fri, 03 Jan 2020 13:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056798; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=bHE34mz55AI6eBPHMQXmopKla4bbLs51RrfmKWEJhFU=; b=hBA5VhvHJH6TX22e1jjCp4+BP9dGrwevg2C5X3uZNaFYwR6gRG8nPA3R EEomZmuX2xR1uZUtVj2+unCRWCgJUlEQRQPQfOTwuJ4V3kbogxv7YaQeD hHBsIGEx4hjwd2nDgVfbwCoPjIm9LKqIJhi6OFL2RSYeYqGt/lFelzLi1 U=; Authentication-Results: esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.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=esa3.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 (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 6jVAkSzLzgfI9cGZEb6IVRTK0PPnlZfsW1uolWAsPwYe2ZVVFTDP44cKzSNtCR741fS1s8D1ge kuYh97dzOTJ9W5wcRU+NaGBSFjjM+Kdco2JPOz/2yqPif8PKvwBs7ShCVAiz8U/sW1m2141zra +uKDAeywhtGtZD9cQhHWp9EMo2QbYhQDgtMDeFk4ue1afPI19paV8s17E+xErbP73zpoWxl5aP iuPs6K3IAKJQc4MbB55KDYPU2VXMvc+4cYmHBhfmxmXiHqe4ETHIb/2ePgvhZK9lz6baTyxS6k 5yo= X-SBRS: 2.7 X-MesageID: 10406761 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10406761" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:14 +0000 Message-ID: <20200103130616.13724-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 18/20] tools/libxl: Plumb domain_create_state down into libxl__build_pre() 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: Anthony PERARD , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" To fix CPUID handling, libxl__build_pre() is going to have to distinguish between a brand new VM vs one which is being migrated-in/resumed. No functional change. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD The data handling is completely chaotic, but I can't find a less bad way of doing this. It really doesn't help that DCS is the superset contining domain_{build,create}_config and domain_build_state, rather than being symetric with its similarly named counterparts. Suggestions welcome. --- tools/libxl/libxl_create.c | 16 ++++++++-------- tools/libxl/libxl_dm.c | 5 +++-- tools/libxl/libxl_dom.c | 4 +++- tools/libxl/libxl_internal.h | 11 ++++------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index fdc76917dc..a8fa4ca11b 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -431,17 +431,17 @@ static void init_console_info(libxl__gc *gc, Only 'channels' when mapped to consoles have a string name. */ } -int libxl__domain_build(libxl__gc *gc, - libxl_domain_config *d_config, - uint32_t domid, - libxl__domain_build_state *state) +int libxl__domain_build(libxl__gc *gc, uint32_t domid, + libxl__domain_create_state *dcs) { + libxl_domain_config *d_config = dcs->guest_config; libxl_domain_build_info *const info = &d_config->b_info; + libxl__domain_build_state *state = &dcs->build_state; char **vments = NULL, **localents = NULL; struct timeval start_time; int i, ret; - ret = libxl__build_pre(gc, domid, d_config, state); + ret = libxl__build_pre(gc, domid, dcs); if (ret) goto out; @@ -1218,7 +1218,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, dcs->sdss.callback = domcreate_devmodel_started; if (restore_fd < 0 && dcs->domid_soft_reset == INVALID_DOMID) { - rc = libxl__domain_build(gc, d_config, domid, state); + rc = libxl__domain_build(gc, domid, dcs); domcreate_rebuild_done(egc, dcs, rc); return; } @@ -1245,7 +1245,7 @@ static void domcreate_bootloader_done(libxl__egc *egc, goto out; } - rc = libxl__build_pre(gc, domid, d_config, state); + rc = libxl__build_pre(gc, domid, dcs); if (rc) goto out; @@ -1567,7 +1567,7 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, dcs->sdss.dm.guest_domid = domid; if (libxl_defbool_val(d_config->b_info.device_model_stubdomain)) - libxl__spawn_stub_dm(egc, &dcs->sdss); + libxl__spawn_stub_dm(egc, dcs); else libxl__spawn_local_dm(egc, &dcs->sdss.dm); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index dac1b8ddb8..b595dc03b3 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2094,8 +2094,9 @@ char *libxl__stub_dm_name(libxl__gc *gc, const char *guest_name) return GCSPRINTF("%s-dm", guest_name); } -void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) +void libxl__spawn_stub_dm(libxl__egc *egc, libxl__domain_create_state *dcs) { + libxl__stub_dm_spawn_state *sdss = &dcs->sdss; STATE_AO_GC(sdss->dm.spawn.ao); libxl_ctx *ctx = libxl__gc_owner(gc); int ret; @@ -2194,7 +2195,7 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) if (ret) goto out; uint32_t dm_domid = sdss->pvqemu.guest_domid; - ret = libxl__domain_build(gc, dm_config, dm_domid, stubdom_state); + ret = libxl__domain_build(gc, dm_domid, dcs); if (ret) goto out; diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 573c63692b..01aefa6ce4 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -244,9 +244,11 @@ static int numa_place_domain(libxl__gc *gc, uint32_t domid, } int libxl__build_pre(libxl__gc *gc, uint32_t domid, - libxl_domain_config *d_config, libxl__domain_build_state *state) + libxl__domain_create_state *dcs) { + libxl_domain_config *d_config = dcs->guest_config; libxl_domain_build_info *const info = &d_config->b_info; + libxl__domain_build_state *state = &dcs->build_state; libxl_ctx *ctx = libxl__gc_owner(gc); char *xs_domid, *con_domid; int rc; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b5adbfe4b7..16dc02e8a3 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1389,8 +1389,7 @@ _hidden void libxl__domain_build_state_init(libxl__domain_build_state *s); _hidden void libxl__domain_build_state_dispose(libxl__domain_build_state *s); _hidden int libxl__build_pre(libxl__gc *gc, uint32_t domid, - libxl_domain_config * const d_config, - libxl__domain_build_state *state); + libxl__domain_create_state *dcs); _hidden int libxl__build_post(libxl__gc *gc, uint32_t domid, libxl_domain_build_info *info, libxl__domain_build_state *state, char **vms_ents, char **local_ents); @@ -1960,10 +1959,8 @@ _hidden int libxl__domain_make(libxl__gc *gc, libxl__domain_build_state *state, uint32_t *domid); -_hidden int libxl__domain_build(libxl__gc *gc, - libxl_domain_config *d_config, - uint32_t domid, - libxl__domain_build_state *state); +_hidden int libxl__domain_build(libxl__gc *gc, uint32_t domid, + libxl__domain_create_state *dcs); /* for device model creation */ _hidden const char *libxl__domain_device_model(libxl__gc *gc, @@ -4114,7 +4111,7 @@ typedef struct { libxl__xswait_state xswait; } libxl__stub_dm_spawn_state; -_hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state*); +_hidden void libxl__spawn_stub_dm(libxl__egc *egc, libxl__domain_create_state *dcs); _hidden char *libxl__stub_dm_name(libxl__gc *gc, const char * guest_name); From patchwork Fri Jan 3 13:06:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316897 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 DC25D1580 for ; Fri, 3 Jan 2020 13:07:48 +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 B941C20866 for ; Fri, 3 Jan 2020 13:07:48 +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="SCEF8M0V" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B941C20866 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 1inMfD-00048k-Hw; Fri, 03 Jan 2020 13:06:51 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMfC-00048B-91 for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:50 +0000 X-Inumbo-ID: dfece334-2e29-11ea-88e7-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dfece334-2e29-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 13:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056798; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Ghhi+RSLsrDx7pejd4UHQhkCE61aWmnYz3y2yoDz8/w=; b=SCEF8M0VC4OQh+e9ntA2UuepkqEKheJNASaXBY/4BXjSKpWRJl8+YM0H 3YPToTX03KgLe1h8sDdPLkGxYBSSIcskVmwfeAk8YhfRLy6NxrOt14NY5 yCW8jv9sk3FGmDNhNBHinOViVyFi7D6xcMAf7jvLfo5IPUm7KjHJ8s5nY k=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: aB2mVbjZtYHDTHbjUbYCeOEa4582xLX2ykXXCFrAzpkOgfbtT9qex4e+5NXDYJ9jN8qEp1WPj8 LhM+hGeirmpJJ1m2EtUAz3WN45BtiK09MPJW8fxFBqpg4DCUSiGna5Kel8zW7uGjHq+p6nsjsU yrwTEaQCQqdQy213LSy/izbtW3wvyZ2wxNKy4udzeW73n4IwI3OgcNjPyn0tJYiRzcv6+vDZS0 D5g6OBxn/BhpLh1dnObTJQv3ntKvy5udt0k0nMkGFSGxjDEcpspKpiULz1+k2RKxRTRyhXAejW IYc= X-SBRS: 2.7 X-MesageID: 10435307 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10435307" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:15 +0000 Message-ID: <20200103130616.13724-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 19/20] tools/libxl: Re-position CPUID handling during domain construction 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: Anthony PERARD , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" CPUID handling needs to be earlier in construction. Move it from its current position in libxl__build_post() to libxl__build_pre() for fresh builds, and libxl__srm_callout_callback_static_data_done() for the migration/resume case. In the migration case, take account of XGR_SDD_MISSING_CPUID. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu CC: Anthony PERARD --- tools/libxl/libxl_create.c | 19 ++++++++++++++++++- tools/libxl/libxl_dom.c | 12 ++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index a8fa4ca11b..0d9a91aeeb 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -1303,8 +1303,25 @@ int libxl__srm_callout_callback_static_data_done(unsigned int missing, libxl__save_helper_state *shs = user; libxl__domain_create_state *dcs = shs->caller_state; STATE_AO_GC(dcs->ao); + libxl_ctx *ctx = libxl__gc_owner(gc); + + const libxl_domain_config *d_config = dcs->guest_config; + const libxl_domain_build_info *info = &d_config->b_info; - /* TODO - something useful. */ + /* + * For pre-4.14 streams, no CPUID/MSR information will be sent. Retain + * the old behaviour by regenerating CPUID from first principles. + */ + if (missing & XGR_SDD_MISSING_CPUID) + libxl_cpuid_apply_policy(ctx, dcs->guest_domid); + + /* + * In all cases, cpuid=[] needs re-evaluating. The common case is that it + * will match libxl_cpuid_apply_policy() and/or whatever is in the stream, + * but the legacy XEND 'k' modifier passes through host values. + */ + if (info->cpuid != NULL) + libxl_cpuid_set(ctx, dcs->guest_domid, info->cpuid); return 0; } diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index 01aefa6ce4..099a913019 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -254,6 +254,8 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, int rc; uint64_t size; + const int restore_fd = dcs->restore_fd; + if (xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus) != 0) { LOG(ERROR, "Couldn't set max vcpu count"); return ERROR_FAIL; @@ -376,6 +378,12 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, return ERROR_FAIL; } + if (restore_fd < 0) { + libxl_cpuid_apply_policy(ctx, domid); + if (info->cpuid != NULL) + libxl_cpuid_set(ctx, domid, info->cpuid); + } + xs_domid = xs_read(ctx->xsh, XBT_NULL, "/tool/xenstored/domid", NULL); state->store_domid = xs_domid ? atoi(xs_domid) : 0; free(xs_domid); @@ -456,10 +464,6 @@ int libxl__build_post(libxl__gc *gc, uint32_t domid, if (rc) return rc; - libxl_cpuid_apply_policy(ctx, domid); - if (info->cpuid != NULL) - libxl_cpuid_set(ctx, domid, info->cpuid); - if (info->type == LIBXL_DOMAIN_TYPE_HVM && !libxl_ms_vm_genid_is_zero(&info->u.hvm.ms_vm_genid)) { rc = libxl__ms_vm_genid_set(gc, domid, From patchwork Fri Jan 3 13:06:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11316903 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 C78EC138D for ; Fri, 3 Jan 2020 13:07:53 +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 A48E420866 for ; Fri, 3 Jan 2020 13:07:53 +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="JA/eem2l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A48E420866 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 1inMfI-0004B2-RS; Fri, 03 Jan 2020 13:06:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1inMfH-0004AN-8i for xen-devel@lists.xenproject.org; Fri, 03 Jan 2020 13:06:55 +0000 X-Inumbo-ID: e56956bc-2e29-11ea-88e7-bc764e2007e4 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e56956bc-2e29-11ea-88e7-bc764e2007e4; Fri, 03 Jan 2020 13:06:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578056806; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=p5FEpdaxz96h2yAh0G89UJzZg2BFVDzVF56s4ViHgDc=; b=JA/eem2luti+Uw/Dn/sXFr49/kjxcj9jQnWeVnmVb64UyvFdNgLsbiak ywzKjjZekwmYA9qeA9LKsfvy436LQHo2P7IDcUQKcyFoHXBL/Hd7qMGOR y4qqdTS1ijaW+t+jy8ASGpmnfYFD7EcNnPYpsW0/9hXwTVMmZe70kmHw3 s=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: fKMR6Q9Bbwn+2k8260f4loJiGkMiARZ7eBUq7skpyvCMQTHuxba/KmIKA5m2zE4j5mEP+yMxyx 7f0GoLmUJn7noBJcS6NGxT835NcJxCZzesC5QFwihWaTpfVei/VlIblX5W4oB3CdJAxa+rR6Gs MGQJrIZ/2VP1kkCYzy1W/SYGUTlle1UHMA68Aa1TYW5mrgnkBmckJ1PAbgoDh/zDeU/JOVEdd6 25ye6Bm7eRV76/LKpVvKtTk0htHL42h7Yj7hJlCWjrZ7IBduPzaWZjSuM1HhmqeDyXj5c02R6I N94= X-SBRS: 2.7 X-MesageID: 10435308 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,390,1571716800"; d="scan'208";a="10435308" From: Andrew Cooper To: Xen-devel Date: Fri, 3 Jan 2020 13:06:16 +0000 Message-ID: <20200103130616.13724-7-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200103130616.13724-1-andrew.cooper3@citrix.com> References: <20200103130616.13724-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 20/20] tools/libxc: Restore CPUID/MSR data found in the migration 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 , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With libxl suitably adjusted, it is now safe to restore the CPUID/MSR data directly from the migration stream. Adjust the XGR_SDD_MISSING_* flags for the static_data_done() callback appropriately. Signed-off-by: Andrew Cooper Acked-by: Ian Jackson --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_common_x86.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c index c3d1d30d91..5c5b3e7635 100644 --- a/tools/libxc/xc_sr_common_x86.c +++ b/tools/libxc/xc_sr_common_x86.c @@ -45,11 +45,31 @@ int handle_x86_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec) int x86_static_data_complete(struct xc_sr_context *ctx) { xc_interface *xch = ctx->xch; + uint32_t nr_leaves = 0, nr_msrs = 0; + uint32_t err_l = ~0, err_s = ~0, err_m = ~0; unsigned int missing = 0; int rc; - /* TODO - something useful. */ - missing = XGR_SDD_MISSING_MSR | XGR_SDD_MISSING_CPUID; + if ( ctx->x86.restore.cpuid.ptr ) + nr_leaves = ctx->x86.restore.cpuid.size / sizeof(xen_cpuid_leaf_t); + else + missing |= XGR_SDD_MISSING_CPUID; + + if ( ctx->x86.restore.msr.ptr ) + nr_msrs = ctx->x86.restore.msr.size / sizeof(xen_msr_entry_t); + else + missing |= XGR_SDD_MISSING_MSR; + + if ( (nr_leaves || nr_msrs) && + xc_set_domain_cpu_policy(xch, ctx->domid, + nr_leaves, ctx->x86.restore.cpuid.ptr, + nr_msrs, ctx->x86.restore.msr.ptr, + &err_l, &err_s, &err_m) ) + { + PERROR("Failed to set CPUID policy: leaf %08x, subleaf %08x, msr %08x", + err_l, err_s, err_m); + return -1; + } rc = ctx->restore.callbacks->static_data_done( missing, ctx->restore.callbacks->data);