From patchwork Thu Oct 10 15:11:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11183769 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 0C19413BD for ; Thu, 10 Oct 2019 15:12:28 +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 D1C7F206A1 for ; Thu, 10 Oct 2019 15:12:27 +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="BEYJTDVr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1C7F206A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=eu.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 1iIa62-0006D8-VB; Thu, 10 Oct 2019 15:11:18 +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 1iIa61-0006Cf-NN for xen-devel@lists.xenproject.org; Thu, 10 Oct 2019 15:11:17 +0000 X-Inumbo-ID: 34944303-eb70-11e9-931d-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 34944303-eb70-11e9-931d-12813bfff9fa; Thu, 10 Oct 2019 15:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1570720277; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=1jKUJSikxB9yiqNmqcnpVueJx6HmmRvphhPyUj0dFVU=; b=BEYJTDVrnhqAQbn2Tdq4IQ1Pt2UNV/LmCQNoFWybPudQS1j6fFwvZJWL bmyopJ8MBL+zijWWu7pomER6EV1BhA7tIITCqK/ZmXIZz8OvEruP/Uo31 Qd9p+VoCZIdlhe7I9xVNgW4DDdKor9yb8pWklW7bT+My+QAlvkqa9Syc5 M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=ian.jackson@eu.citrix.com; spf=Pass smtp.mailfrom=Ian.Jackson@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 ian.jackson@eu.citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Ian.Jackson@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="Ian.Jackson@citrix.com"; x-sender="Ian.Jackson@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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: /S7LFuoZBMP3g8IZOOMwgM455tmMhBOC75strZyQvYNda052mNaRgvibjD5ZwQmetXV9kFxPPv 2Lsb6Ct5daBcBjaBzPA6CaSsJZB86bmEofA4fvf2d8i8o4umHtGo1RD/hqyvktdyOOmaY5b4Gr J5cG5ByRai7IslM6nV3ckDUB0urKJns/iSXvzJ/adaxHF0zCqUuZC2Ki9yoMqTMKYsVGYrcj6G 0i+6LrJKkQsSJTMmUpGDhleH/wfXkvWDJOabK6Xf0GAJ1tm3R4BN9SB2rorW4HXMGE//5vlRd3 RFA= X-SBRS: 2.7 X-MesageID: 6722305 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.67,280,1566878400"; d="scan'208";a="6722305" From: Ian Jackson To: Date: Thu, 10 Oct 2019 16:11:05 +0100 Message-ID: <20191010151111.22125-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191010151111.22125-1-ian.jackson@eu.citrix.com> References: <20191010151111.22125-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v2 3/9] libxl: libxl__domain_config_setdefault: New function 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: Wei Liu , Andrew Cooper , Ian Jackson , Paul Durrant , Jan Beulich , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Break out this into a new function. We are going to want to call it from a new call site. Unfortunately not all of the defaults can be moved into the new function without changing the order in which things are done. That does not seem wise at this stage of the release. The effect is that additional calls to libxl__domain_config_setdefault (which are going to be introduced) do not quite set everything. But they will do what is needed. After Xen 4.13 is done, we should move those settings into the right order. No functional change. Signed-off-by: Ian Jackson Reviewed-by: Anthony PERARD --- v2: Add missing error check --- tools/libxl/libxl_create.c | 41 +++++++++++++++++++++++++++++------------ tools/libxl/libxl_internal.h | 3 +++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 099761a2d7..fd8bb22be9 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -862,22 +862,14 @@ static void domcreate_destruction_cb(libxl__egc *egc, libxl__domain_destroy_state *dds, int rc); -static void initiate_domain_create(libxl__egc *egc, - libxl__domain_create_state *dcs) +int libxl__domain_config_setdefault(libxl__gc *gc, + libxl_domain_config *d_config, + uint32_t domid) { - STATE_AO_GC(dcs->ao); libxl_ctx *ctx = libxl__gc_owner(gc); - uint32_t domid; - int i, ret; + int ret; bool pod_enabled = false; - /* convenience aliases */ - libxl_domain_config *const d_config = dcs->guest_config; - const int restore_fd = dcs->restore_fd; - - domid = dcs->domid_soft_reset; - libxl__domain_build_state_init(&dcs->build_state); - if (d_config->c_info.ssid_label) { char *s = d_config->c_info.ssid_label; ret = libxl_flask_context_to_sid(ctx, s, strlen(s), @@ -1008,6 +1000,28 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } + ret = 0; + error_out: + return ret; +} + +static void initiate_domain_create(libxl__egc *egc, + libxl__domain_create_state *dcs) +{ + STATE_AO_GC(dcs->ao); + uint32_t domid; + int i, ret; + + /* convenience aliases */ + libxl_domain_config *const d_config = dcs->guest_config; + const int restore_fd = dcs->restore_fd; + + domid = dcs->domid_soft_reset; + libxl__domain_build_state_init(&dcs->build_state); + + ret = libxl__domain_config_setdefault(gc,d_config,domid); + if (ret) goto error_out; + ret = libxl__domain_make(gc, d_config, &dcs->build_state, &domid); if (ret) { LOGD(ERROR, domid, "cannot make domain: %d", ret); @@ -1019,6 +1033,9 @@ static void initiate_domain_create(libxl__egc *egc, dcs->guest_domid = domid; dcs->sdss.dm.guest_domid = 0; /* means we haven't spawned */ + /* post-4.13 todo: move these next bits of defaulting to + * libxl__domain_config_setdefault */ + /* * Set the dm version quite early so that libxl doesn't have to pass the * build info around just to know if the domain has a device model or not. diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index d2d5af746b..50ac7b64ed 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1440,6 +1440,9 @@ _hidden int libxl__resolve_domid(libxl__gc *gc, const char *name, * All libxl API functions are expected to have arranged for this * to be called before using any values within these structures. */ +_hidden int libxl__domain_config_setdefault(libxl__gc *gc, + libxl_domain_config *d_config, + uint32_t domid /* logging only */); _hidden int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_domain_create_info *c_info); _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc,