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,