From patchwork Wed Oct 23 13:00:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206751 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 215201390 for ; Wed, 23 Oct 2019 13:02:01 +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 E973521872 for ; Wed, 23 Oct 2019 13:02:00 +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="I+JGMnHa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E973521872 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 1iNGFU-0005tU-Gh; Wed, 23 Oct 2019 13:00:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFS-0005tK-VJ for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:22 +0000 X-Inumbo-ID: 1261d9a0-f595-11e9-beca-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1261d9a0-f595-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 13:00:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835622; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Z2wcBcBGG/Y/drK4rHShO5xZz9+eTKQjLFNrm0BeVIw=; b=I+JGMnHauSTRdWL6BtXTR5kaan3zmFbODOK/6oE4zZ/PluMvgyoKZQF9 dWlcbqg4WNTZp0GdfRuZLJ1jryng1yM2AucypllKZYw8wHBDJnCVxhVom 9pD0fzesjodRqtKtj4quvsk1QRtobnAjCYzDmqqbNRKsoZ9aQvQKNZIjb 0=; Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 390N8CJU3yUiYOuRa0Byukb/Flw4MAM6Bf9aETFgqhziRjfn3B6ehMIxOuDhcgQIa8qNyETWy5 GFbWZBdXkXASmss0xq/PNS2oyHe8rZf31357aD/cC+tneR/K+I5WjkinbQruOZVq5f4McYpd22 e/Lbnrw0pxpEyiap0J9uoEFScYDZKKHP0ajrY/en83s0LaL4k3VRpkg1T8tVWszXQU7ACgL6J9 nbFYxbIbE16SHcusPwDrSx++FlO+4pOe+hqf+xk7iEqSo+YTnnhijoevqbvyxl5YM0xWUknarU jSk= X-SBRS: 2.7 X-MesageID: 7660563 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,220,1569297600"; d="scan'208";a="7660563" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:03 +0100 Message-ID: <20191023130013.32382-2-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 01/11] libxl: Offer API versions 0x040700 and 0x040800 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" According to git log -G: 0x040700 was introduced in 304400459ef0 (aka 4.7.0-rc1~481) "tools/libxl: rename remus device to checkpoint device" 0x040800 was introduced in 57f8b13c7240 (aka 4.8.0-rc1~437) "libxl: memory size in kb requires 64 bit variable" It is surprising that no-one noticed this. Anyway, in the meantime, we should fix it. Backporting this is probably a good idea: it won't change the behaviour for existing callers but it will avoid errors for some older correct uses. Signed-off-by: Ian Jackson Acked-by: Anthony PERARD --- v2: Adjusted commit message slightly. --- tools/libxl/libxl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 2555e9cd3b..518fc9e47f 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -655,6 +655,7 @@ typedef struct libxl__ctx libxl_ctx; #ifdef LIBXL_API_VERSION #if LIBXL_API_VERSION != 0x040200 && LIBXL_API_VERSION != 0x040300 && \ LIBXL_API_VERSION != 0x040400 && LIBXL_API_VERSION != 0x040500 && \ + LIBXL_API_VERSION != 0x040700 && LIBXL_API_VERSION != 0x040800 && \ LIBXL_API_VERSION != 0x041300 #error Unknown LIBXL_API_VERSION #endif From patchwork Wed Oct 23 13:00:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206741 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 A412B1390 for ; Wed, 23 Oct 2019 13:01: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 7F2E221872 for ; Wed, 23 Oct 2019 13:01: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="fM5O45k7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F2E221872 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 1iNGFV-0005tb-Ox; Wed, 23 Oct 2019 13:00:25 +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 1iNGFT-0005tP-Ty for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:23 +0000 X-Inumbo-ID: 129cbdaf-f595-11e9-947c-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 129cbdaf-f595-11e9-947c-12813bfff9fa; Wed, 23 Oct 2019 13:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Zzusm/RjFNRE7hHrONeMgqDs0JYfYY3tV4/RvhfMiVc=; b=fM5O45k7aTEED5rzXamwk3GY5OUACc5GbOpaQPow/ZuYBs0C6wbvDmke SdaIoeYlJB3fwVDOrCF/gRjtA8R65tAmhZjcyqOJVTEHOE/8E5KSystx2 JMnbLfTfEZUCSFbLjZAE7ouXnJmU7RHOh1rK/RO0ZtSlxQ3yUTxv11jTE o=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: X/4Gn0cguiAyVNNvqcMzR1m1/kqMUq4+80mkVvFKG5NXM/O0ej4IK+9ZpLb67Jrd0U1rreD4zh Uj/viI6PQykq4pwA5wVtcHvk2OSs5clE6HKU1AN2yt9fITE6A+/8yz705DqlrLqbD+JypeDd1v H/aqR5CfcyNrq2kUpTuDaWGsOGUDNSUBNMZrcdHuvz7J8ZTEQ0eaXqL0YONKuLzNAzzvdCFmuc gNpJ8UivpgZNIYoSv9TkzFyZNIQjglQWB/0YjDqwDcI7a2FZ5xpUWA/1t/79qAWuy27C+CAdNk o+k= X-SBRS: 2.7 X-MesageID: 7317937 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.68,220,1569297600"; d="scan'208";a="7317937" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:04 +0100 Message-ID: <20191023130013.32382-3-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 02/11] xl: Pass libxl_domain_config to freemem(), instead of b_info 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: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We are going to change the libxl API in a moment and this change will make it simpler. Signed-off-by: Ian Jackson Reviewed-by: Anthony PERARD --- tools/xl/xl_vmcontrol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index b20582e15b..d33c6b38c9 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -314,7 +314,7 @@ static int domain_wait_event(uint32_t domid, libxl_event **event_r) * Returns true in case there is already, or we manage to free it, enough * memory, but also if autoballoon is false. */ -static bool freemem(uint32_t domid, libxl_domain_build_info *b_info) +static bool freemem(uint32_t domid, libxl_domain_config *d_config) { int rc, retries = 3; uint64_t need_memkb, free_memkb; @@ -322,7 +322,7 @@ static bool freemem(uint32_t domid, libxl_domain_build_info *b_info) if (!autoballoon) return true; - rc = libxl_domain_need_memory(ctx, b_info, &need_memkb); + rc = libxl_domain_need_memory(ctx, &d_config->b_info, &need_memkb); if (rc < 0) return false; @@ -879,7 +879,7 @@ start: goto error_out; if (domid_soft_reset == INVALID_DOMID) { - if (!freemem(domid, &d_config.b_info)) { + if (!freemem(domid, &d_config)) { fprintf(stderr, "failed to free memory for the domain\n"); ret = ERROR_FAIL; goto error_out; From patchwork Wed Oct 23 13:00: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: 11206743 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 6C50F1390 for ; Wed, 23 Oct 2019 13:01:56 +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 47FEC21872 for ; Wed, 23 Oct 2019 13:01:56 +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="UMCGP2bh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47FEC21872 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 1iNGFf-0005we-1E; Wed, 23 Oct 2019 13:00:35 +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 1iNGFd-0005vs-UO for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:33 +0000 X-Inumbo-ID: 13a61241-f595-11e9-947c-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 13a61241-f595-11e9-947c-12813bfff9fa; Wed, 23 Oct 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=1jKUJSikxB9yiqNmqcnpVueJx6HmmRvphhPyUj0dFVU=; b=UMCGP2bhC1hOhsYVoelxkB0JKBvtA4WAvAeabqV7auq2D1xC6WcFEYr1 sdV6+L0yG0eqhc2b1TqlzfTxb1go7gwI+RjfCWu5T5ZutzjT9r91xjxkr SAFPr4XMA7G51Bhb6KTBDjVRZ/IM7Ieh3NgNiZQqAe1V7iZHmVwptSS6a I=; Authentication-Results: esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.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=esa4.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 (esa4.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=esa4.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 5CyYoNtYd9dv4MmUqEK+/vD1N3/fA/PENCNlby8YJnbw0vK97hL3WkRxo+utWdJWsjD5wSL/yu PmqxuvCwXR5hFX9xxt3mDUVSKoewztwskzzBlVK0cOAasdU0RMj9tX8zAosg2wwRneM3YxT+uS N6yLM+4f9nb9YV+ICCSjFh+3NNEjkan7VpwewL7EuK9sv59ARhNOoTUpEpRfiegFbAslugZrcl 6IIgjfvXXQ2nQoMUdT/TSw9Y41+Jx10/dW4pX65JkRlFfQd/f2GEYQ8qVabc5MVYdf/kyhQ6E0 Fzg= X-SBRS: 2.7 X-MesageID: 7754872 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,220,1569297600"; d="scan'208";a="7754872" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:05 +0100 Message-ID: <20191023130013.32382-4-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 03/11] 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: Anthony PERARD , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu 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, From patchwork Wed Oct 23 13:00:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206757 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 2BB4B1390 for ; Wed, 23 Oct 2019 13:02:07 +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 F011D21872 for ; Wed, 23 Oct 2019 13:02:06 +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="bGRLboC2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F011D21872 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 1iNGFZ-0005tx-1b; Wed, 23 Oct 2019 13:00:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFX-0005tn-V4 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:27 +0000 X-Inumbo-ID: 13138a10-f595-11e9-bbab-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 13138a10-f595-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 13:00:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=mcnHNnuobJVIoAVNjV2dKd+l7QxXNdod66g53zaBt+0=; b=bGRLboC2IxcwSnRoS8VlnmqQMbF7a0WlnT5Inpv/gOHBB52IlZL106r3 UqW0DgnF+DSqblPA1JTgOYqgYAOvY7+rj7RBcEtrEwYOJRp7royeX/RN1 addPag7hJWGbxVqSxZXt8znAclr1zLU2Ume6AmFQ82Fug9mx6Wq5Q/7EZ M=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Tn4clvFqwy5xE3PwXhdSLlYqL2VnWGALOprmeSCLfgDZYuWLAakamTXtuHJONMrDIEr1TOt7Uz qwdQx+3jecdisdJboleU+kghHug7i8yH2xBv6JXTa1TtS0zJGWycalPTjZwL9+WdUJkOGMJgHc 1um/rL0HdbcKACV/o2pTYPXJOaaj9UNTGdWRTuAb7550Rb6E1eCrVAQaX1emIl1IP9lb0SELq9 SYyIyunzN94elbgmezgUknqv3htPp54g9oxsbqdXgIC9Hhf5Oe9RaoDaiVNqgcEYA/3IowSEGh +go= X-SBRS: 2.7 X-MesageID: 7623493 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.68,220,1569297600"; d="scan'208";a="7623493" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:06 +0100 Message-ID: <20191023130013.32382-5-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 04/11] libxl: libxl_domain_need_memory: Make it take a domain_config 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This should calculate the extra memory needed for shadow and iommu, the defaults for which depend on values in c_info. So we need this to have the complete domain config available. And the defaults should actually be updated and stored. So make it non-const. We provide the usual kind of compatibility function for callers expecting 4.12 and earlier. This function becomes responsible for the clone-and-modify of the b_info. No overall functional change for external libxl callers which use the API version system to request a particular API version. Other external libxl callers will need to update their calling code, and will then find that the new version of this function fills in most of the defaults in d_config. Because libxl__domain_config_setdefault doesn't quite do all of the defaults, that's only partial. For present purposes that doesn't matter because none of the missing settings are used by the memory calculations. It does mean we need to document in the API spec that the defaulting is only partial. This lack of functional change is despite the fact that numa_place_domain now no longer calls libxl__domain_build_info_setdefault (via libxl_domain_need_memory). That is OK because it's idempotent and numa_place_domain's one call site is libxl__build_pre which is called from libxl__domain_build which is called from domcreate_bootloader_done, well after the defaults are set by initiate_domain_create. Signed-off-by: Ian Jackson Reviewed-by: Anthony PERARD --- v2: Drop now-erroneous GC_FREE as well as the corresponding GC_INIT. --- tools/libxl/libxl.h | 23 +++++++++++++++- tools/libxl/libxl_dom.c | 7 +++-- tools/libxl/libxl_internal.h | 4 +++ tools/libxl/libxl_mem.c | 65 +++++++++++++++++++++++++++++++++++--------- tools/xl/xl_vmcontrol.c | 2 +- 5 files changed, 83 insertions(+), 18 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 518fc9e47f..49b56fa1a3 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1245,6 +1245,20 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const libxl_mac *src); */ #define LIBXL_HAVE_FN_USING_QMP_ASYNC 1 +/* + * LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG + * + * If this is set, libxl_domain_need_memory takes a + * libxl_domain_config* (non-const) and uint32_t domid_for_logging + * (instead of a const libxl_domain_build_info*). + * + * If this is set, there is no need to call + * libxl_get_required_shadow_memory and instead the caller should + * simply leave shadow_memkb set to LIBXL_MEMKB_DEFAULT and allow + * libxl to fill in a suitable default in the usual way. + */ +#define LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG + typedef char **libxl_string_list; void libxl_string_list_dispose(libxl_string_list *sl); int libxl_string_list_length(const libxl_string_list *sl); @@ -1723,8 +1737,13 @@ int libxl_get_memory_target_0x040700(libxl_ctx *ctx, uint32_t domid, */ /* how much free memory in the system a domain needs to be built */ int libxl_domain_need_memory(libxl_ctx *ctx, - const libxl_domain_build_info *b_info_in, + libxl_domain_config *config + /* ^ will be partially defaulted */, + uint32_t domid_for_logging /* INVALID_DOMID ok */, uint64_t *need_memkb); +int libxl_domain_need_memory_0x041200(libxl_ctx *ctx, + const libxl_domain_build_info *b_info_in, + uint64_t *need_memkb); int libxl_domain_need_memory_0x040700(libxl_ctx *ctx, const libxl_domain_build_info *b_info_in, uint32_t *need_memkb) @@ -1754,6 +1773,8 @@ int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs); #define libxl_get_memory_target libxl_get_memory_target_0x040700 #define libxl_domain_need_memory libxl_domain_need_memory_0x040700 #define libxl_get_free_memory libxl_get_free_memory_0x040700 +#elif defined(LIBXL_API_VERSION) && LIBXL_API_VERSION < 0x041300 +#define libxl_domain_need_memory libxl_domain_need_memory_0x041200 #endif int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass); diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index c5685b061c..cdb294ab8d 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -140,8 +140,9 @@ static int numa_cmpf(const libxl__numa_candidate *c1, /* The actual automatic NUMA placement routine */ static int numa_place_domain(libxl__gc *gc, uint32_t domid, - libxl_domain_build_info *info) + libxl_domain_config *d_config) { + libxl_domain_build_info *info = &d_config->b_info; int found; libxl__numa_candidate candidate; libxl_bitmap cpumap, cpupool_nodemap, *map; @@ -195,7 +196,7 @@ static int numa_place_domain(libxl__gc *gc, uint32_t domid, } } - rc = libxl_domain_need_memory(CTX, info, &memkb); + rc = libxl__domain_need_memory_calculate(gc, info, &memkb); if (rc) goto out; if (libxl_node_bitmap_alloc(CTX, &cpupool_nodemap, 0)) { @@ -432,7 +433,7 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid, if (rc) return rc; - rc = numa_place_domain(gc, domid, info); + rc = numa_place_domain(gc, domid, d_config); if (rc) { libxl_bitmap_dispose(&cpumap_soft); return rc; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 50ac7b64ed..01de5576d9 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1450,6 +1450,10 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, _hidden void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); +_hidden int libxl__domain_need_memory_calculate(libxl__gc *gc, + libxl_domain_build_info *b_info, + uint64_t *need_memkb); + _hidden const char *libxl__device_nic_devname(libxl__gc *gc, uint32_t domid, uint32_t devid, diff --git a/tools/libxl/libxl_mem.c b/tools/libxl/libxl_mem.c index fd6f33312e..6042299393 100644 --- a/tools/libxl/libxl_mem.c +++ b/tools/libxl/libxl_mem.c @@ -446,20 +446,12 @@ int libxl_get_memory_target_0x040700( return libxl__memkb_64to32(ctx, rc, my_out_target, out_target); } -int libxl_domain_need_memory(libxl_ctx *ctx, - const libxl_domain_build_info *b_info_in, - uint64_t *need_memkb) +int libxl__domain_need_memory_calculate(libxl__gc *gc, + libxl_domain_build_info *b_info, + uint64_t *need_memkb) { - GC_INIT(ctx); - libxl_domain_build_info b_info[1]; int rc; - libxl_domain_build_info_init(b_info); - libxl_domain_build_info_copy(ctx, b_info, b_info_in); - - rc = libxl__domain_build_info_setdefault(gc, b_info); - if (rc) goto out; - *need_memkb = b_info->target_memkb; *need_memkb += b_info->shadow_memkb + b_info->iommu_memkb; @@ -481,10 +473,57 @@ int libxl_domain_need_memory(libxl_ctx *ctx, *need_memkb += (2 * 1024) - (*need_memkb % (2 * 1024)); rc = 0; out: + return rc; +} + +int libxl_domain_need_memory(libxl_ctx *ctx, + libxl_domain_config *d_config, + uint32_t domid_for_logging, + uint64_t *need_memkb) +{ + GC_INIT(ctx); + int rc; + + rc = libxl__domain_config_setdefault(gc, + d_config, + domid_for_logging); + if (rc) goto out; + + rc = libxl__domain_need_memory_calculate(gc, + &d_config->b_info, + need_memkb); + if (rc) goto out; + + rc = 0; + out: GC_FREE; - libxl_domain_build_info_dispose(b_info); return rc; +} + +int libxl_domain_need_memory_0x041200(libxl_ctx *ctx, + const libxl_domain_build_info *b_info_in, + uint64_t *need_memkb) +{ + GC_INIT(ctx); + int rc; + + libxl_domain_build_info b_info[1]; + libxl_domain_build_info_init(b_info); + libxl_domain_build_info_copy(ctx, b_info, b_info_in); + + rc = libxl__domain_build_info_setdefault(gc, b_info); + if (rc) goto out; + rc = libxl__domain_need_memory_calculate(gc, + b_info, + need_memkb); + if (rc) goto out; + + rc = 0; + out: + libxl_domain_build_info_dispose(b_info); + GC_FREE; + return rc; } int libxl_domain_need_memory_0x040700(libxl_ctx *ctx, @@ -494,7 +533,7 @@ int libxl_domain_need_memory_0x040700(libxl_ctx *ctx, uint64_t my_need_memkb; int rc; - rc = libxl_domain_need_memory(ctx, b_info_in, &my_need_memkb); + rc = libxl_domain_need_memory_0x041200(ctx, b_info_in, &my_need_memkb); return libxl__memkb_64to32(ctx, rc, my_need_memkb, need_memkb); } diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index d33c6b38c9..e520b1da79 100644 --- a/tools/xl/xl_vmcontrol.c +++ b/tools/xl/xl_vmcontrol.c @@ -322,7 +322,7 @@ static bool freemem(uint32_t domid, libxl_domain_config *d_config) if (!autoballoon) return true; - rc = libxl_domain_need_memory(ctx, &d_config->b_info, &need_memkb); + rc = libxl_domain_need_memory(ctx, d_config, domid, &need_memkb); if (rc < 0) return false; From patchwork Wed Oct 23 13:00:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206749 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 89E7D1515 for ; Wed, 23 Oct 2019 13:02:00 +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 5A64E21872 for ; Wed, 23 Oct 2019 13:02:00 +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="d+tC7sIv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A64E21872 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 1iNGFe-0005wI-N6; Wed, 23 Oct 2019 13:00:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFd-0005vX-0F for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:33 +0000 X-Inumbo-ID: 1385abea-f595-11e9-a531-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1385abea-f595-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=UK8D8SXQlm+rrYSLRdhzAFRqrVgJXLVpfsEELklIuFA=; b=d+tC7sIvWZKXtvOPScAO9MuJ9yrFi24BQqyhe6kBuaMEnVGaEeiJBHR6 6o9KE5QYezluPabUq74X5ig3mCrPFHdndx5Gz1ZG2bOj2CSbQpkS5GFBt 58D+eyI1Pakwz1XI3rUmoeDqF26l24wTXozMkAO7nJ2LDrJeelXZNpEPz c=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: gJafkAAsC8F8DsrrFFaB1NXm2RjVAasWfshpPrMYM70Bd+1HwUenIo9Ac5B16LyATnJUr5/Nmc C7hwA/J/XWZ+qBF8sgyEfFXNWYbvifhTo7OvBvSNuH/+ZZ/nWmdlJ5hcaHsZz5LWrAvsIHP3lg 0ustwvYQMVSxWPSQmvf+lu7JMk19nd9EzLxBXti93ArA0Vz4+c9ACq5YrTYp1M5mPortUoPalM REPr1WSmjXC+ftEYzRG/eSSN6UswPRZi3UPEkL37r4tG39xY4gPK/cid/MfaaqaUlwhQEoLAOL qYc= X-SBRS: 2.7 X-MesageID: 7411222 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.68,220,1569297600"; d="scan'208";a="7411222" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:07 +0100 Message-ID: <20191023130013.32382-6-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 05/11] libxl: Move shadow_memkb and iommu_memkb defaulting 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Defaulting is supposed to be done by libxl. So these calculations should be here in libxl. libxl__domain_config_setdefault has all the necessary information including the values of max_memkb and max_vcpus. The overall functional effect depends on the caller: For xl, no change. The code moves from xl to libxl. For callers who set one or both shadow_memkb and iommu_memkb (whether from libxl_get_required_shadow_memory or otherwise) before calling libxl_domain_need_memory (any version): the new code will leave their setting(s) unchanged. For callers who do not call libxl_domain_need_memory at all, and who fail to set one of these memory values: now they are both are properly set. The shadow and iommu memory to be properly accounted for as intended. For callers which call libxl_domain_need_memory and request the current API (4.13) or which track libxl, the default values are also now right and everything works as intended. For callers which call libxl_domain_need_memory, and request an old pre-4.13 libxl API, and which leave one of these memkb settings unset, we take special measures to preserve the old behaviour. This means that they don't get the additional iommu memory and are at risk of the domain running out of memory as a result of f89f555827a6 "remove late (on-demand) construction of IOMMU page tables". But this is no worse than the state just after f89f555827a6, which already broke such callers in that way. This is perhaps justifiable because of the API stability warning next to libxl_domain_need_memory. An alternative would be to drop the special-casing of these callers. That would cause a discrepancy between libxl_domain_need_memory and libxl_domain_create: the former would not include the iommu memory and the latter would. That seems worse, but it's debateable. Signed-off-by: Ian Jackson Reviewed-by: Anthony PERARD --- v4: Provide a fallback default for iommu_memkb too, for old callers. v2: Replace _Bool with bool Fix logic sense in ok_to_default_memkb_in_create --- tools/libxl/libxl_create.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_internal.h | 3 +++ tools/libxl/libxl_mem.c | 4 ++++ tools/xl/xl_parse.c | 15 ++------------- 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index fd8bb22be9..3b3b6ec381 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -247,9 +247,14 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl__arch_domain_build_info_setdefault(gc, b_info); libxl_defbool_setdefault(&b_info->dm_restrict, false); + if (b_info->iommu_memkb == LIBXL_MEMKB_DEFAULT) + /* Normally defaulted in libxl__domain_create_info_setdefault */ + b_info->iommu_memkb = 0; + switch (b_info->type) { case LIBXL_DOMAIN_TYPE_HVM: if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT) + /* Normally defaulted in libxl__domain_create_info_setdefault */ b_info->shadow_memkb = 0; if (b_info->u.hvm.mmio_hole_memkb == LIBXL_MEMKB_DEFAULT) b_info->u.hvm.mmio_hole_memkb = 0; @@ -395,6 +400,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, if (b_info->video_memkb == LIBXL_MEMKB_DEFAULT) b_info->video_memkb = 0; if (b_info->shadow_memkb == LIBXL_MEMKB_DEFAULT) + /* Normally defaulted in libxl__domain_create_info_setdefault */ b_info->shadow_memkb = 0; if (b_info->u.pv.slack_memkb == LIBXL_MEMKB_DEFAULT) b_info->u.pv.slack_memkb = 0; @@ -862,6 +868,30 @@ static void domcreate_destruction_cb(libxl__egc *egc, libxl__domain_destroy_state *dds, int rc); +static bool ok_to_default_memkb_in_create(libxl__gc *gc) +{ + /* + * This is a fudge. We are trying to find whether the caller + * calls the old version of libxl_domain_need_memory. If they do + * then, because it only gets the b_info, and because it can't + * update the b_info (because it's const), it will base its + * calculations on defaulting shadow_memkb and iommu_memkb to 0 + * In that case we probably shouldn't default them differently + * during libxl_domain_create. + * + * The result is that the behaviour with old callers is the same + * as in 4.13: no additional memory is allocated for shadow and + * iommu (unless the caller set shadow_memkb, eg from a call to + * libxl_get_required_shadow_memory). + */ + return !CTX->libxl_domain_need_memory_0x041200_called || + CTX->libxl_domain_need_memory_called; + /* + * Treat mixed callers as new callers. Presumably they know what + * they are doing. + */ +} + int libxl__domain_config_setdefault(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid) @@ -974,6 +1004,20 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } + if (d_config->b_info.shadow_memkb == LIBXL_MEMKB_DEFAULT + && ok_to_default_memkb_in_create(gc)) + d_config->b_info.shadow_memkb = + libxl_get_required_shadow_memory(d_config->b_info.max_memkb, + d_config->b_info.max_vcpus); + + /* No IOMMU reservation is needed if passthrough mode is not 'sync_pt' */ + if (d_config->b_info.iommu_memkb == LIBXL_MEMKB_DEFAULT + && ok_to_default_memkb_in_create(gc)) + d_config->b_info.iommu_memkb = + (d_config->c_info.passthrough == LIBXL_PASSTHROUGH_SYNC_PT) + ? libxl_get_required_iommu_memory(d_config->b_info.max_memkb) + : 0; + ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info); if (ret) { LOGD(ERROR, domid, "Unable to set domain build info defaults"); diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 01de5576d9..0185b8ff01 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -637,6 +637,9 @@ struct libxl__ctx { LIBXL_LIST_ENTRY(libxl_ctx) sigchld_users_entry; libxl_version_info version_info; + + bool libxl_domain_need_memory_0x041200_called, + libxl_domain_need_memory_called; }; /* diff --git a/tools/libxl/libxl_mem.c b/tools/libxl/libxl_mem.c index 6042299393..7c01fac7e5 100644 --- a/tools/libxl/libxl_mem.c +++ b/tools/libxl/libxl_mem.c @@ -484,6 +484,8 @@ int libxl_domain_need_memory(libxl_ctx *ctx, GC_INIT(ctx); int rc; + ctx->libxl_domain_need_memory_called = 1; + rc = libxl__domain_config_setdefault(gc, d_config, domid_for_logging); @@ -507,6 +509,8 @@ int libxl_domain_need_memory_0x041200(libxl_ctx *ctx, GC_INIT(ctx); int rc; + ctx->libxl_domain_need_memory_0x041200_called = 1; + libxl_domain_build_info b_info[1]; libxl_domain_build_info_init(b_info); libxl_domain_build_info_copy(ctx, b_info, b_info_in); diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 03a2c54dd2..79871c22d0 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1572,19 +1572,8 @@ void parse_config_data(const char *config_source, exit(-ERROR_FAIL); } - /* libxl_get_required_shadow_memory() and - * libxl_get_required_iommu_memory() must be called after final values - * (default or specified) for vcpus and memory are set, because the - * calculations depend on those values. */ - b_info->shadow_memkb = !xlu_cfg_get_long(config, "shadow_memory", &l, 0) - ? l * 1024 - : libxl_get_required_shadow_memory(b_info->max_memkb, - b_info->max_vcpus); - - /* No IOMMU reservation is needed if passthrough mode is not 'sync_pt' */ - b_info->iommu_memkb = (c_info->passthrough == LIBXL_PASSTHROUGH_SYNC_PT) - ? libxl_get_required_iommu_memory(b_info->max_memkb) - : 0; + if (!xlu_cfg_get_long(config, "shadow_memory", &l, 0)) + b_info->shadow_memkb = l * 1024; xlu_cfg_get_defbool(config, "nomigrate", &b_info->disable_migrate, 0); From patchwork Wed Oct 23 13:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206759 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 25A9B1515 for ; Wed, 23 Oct 2019 13:02:15 +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 0169F21906 for ; Wed, 23 Oct 2019 13:02:15 +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="au1rGKfH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0169F21906 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 1iNGFx-0006Ai-Vz; Wed, 23 Oct 2019 13:00:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFw-00069a-Vk for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:53 +0000 X-Inumbo-ID: 1471570c-f595-11e9-a531-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1471570c-f595-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=CGsCVvA9C5CHOtZ4CTQQ9jiw/fTOwqzG4idefXSC/GY=; b=au1rGKfHQBxGj6116AHfOJ+p0jrDGhR0Q8AI2+kvC8L2FYBXU3trDigv 5z2fkCqJgfVagJF2BC9MlkJybnzuPKj3xhO08lGyXIedIMOKFX8caLe6n I6KqLjKAaCjkbPVVQeXLxXOMgJz7wTLEiwZ9EljYsfL1UWbYmeLBD7l+R k=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: YchAr3PRPOCa9veYsbc4nSzMt4PdAOGMZlx+gjGaeTbJAxRsHgnd7fUH9zHNCfcMfXdl3jV6sX CW+FBckJBBH++RabRS+0Sj/1fPK4m7Ho8uKoDWa/j2+66Gom1uk3CaQmd8mIp7yuJIBq6ygK2o m4ik2RRZ7BqqF6M0tc0JKOqtrzp20MvbUUNu2gmRiKSE07FIEnv58qLSorVVU8IJh3xHqHKSkV gdikwmOODk4jprZXpv5a3V9q0QqcGBZw90JIWI82THghbStn1UuZwbY5AmQPtCBk7Q/SFxvf0N NOo= X-SBRS: 2.7 X-MesageID: 7411227 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.68,220,1569297600"; d="scan'208";a="7411227" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:08 +0100 Message-ID: <20191023130013.32382-7-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 06/11] libxl: Remove/deprecate libxl_get_required_*_memory from the API 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" These are now redundant because shadow_memkb and iommu_memkb are now defaulted automatically by libxl_domain_need_memory and libxl_domain_create etc. Callers should not now call these; instead, they should just let libxl take care of it. libxl_get_required_shadow_memory was introduced in f89f555827a6 "remove late (on-demand) construction of IOMMU page tables" We can freely remove it because it was never in any release. libxl_get_required_shadow_memory has been in libxl approximately forever. It should probably not have survived the creation of libxl_domain_create, but it seems the API awkwardnesses we see in recent commits prevented this. So we have to keep it. It remains functional but we can deprecate it. Hopefully we can get rid of it completely before we find the need to change the calculation to use additional information which its arguments do not currently supply. Signed-off-by: Ian Jackson Acked-by: Anthony PERARD --- tools/libxl/libxl_create.c | 17 ++++++++++++++++- tools/libxl/libxl_utils.c | 15 --------------- tools/libxl/libxl_utils.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 3b3b6ec381..e4ddfd067f 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -892,6 +892,21 @@ static bool ok_to_default_memkb_in_create(libxl__gc *gc) */ } +static unsigned long libxl__get_required_iommu_memory(unsigned long maxmem_kb) +{ + unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4; + unsigned int level; + + /* Assume a 4 level page table with 512 entries per level */ + for (level = 0; level < 4; level++) + { + mem_pages = DIV_ROUNDUP(mem_pages, 512); + iommu_pages += mem_pages; + } + + return iommu_pages * 4; +} + int libxl__domain_config_setdefault(libxl__gc *gc, libxl_domain_config *d_config, uint32_t domid) @@ -1015,7 +1030,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, && ok_to_default_memkb_in_create(gc)) d_config->b_info.iommu_memkb = (d_config->c_info.passthrough == LIBXL_PASSTHROUGH_SYNC_PT) - ? libxl_get_required_iommu_memory(d_config->b_info.max_memkb) + ? libxl__get_required_iommu_memory(d_config->b_info.max_memkb) : 0; ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info); diff --git a/tools/libxl/libxl_utils.c b/tools/libxl/libxl_utils.c index 405733b7e1..f360f5e228 100644 --- a/tools/libxl/libxl_utils.c +++ b/tools/libxl/libxl_utils.c @@ -48,21 +48,6 @@ unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned return 4 * (256 * smp_cpus + 2 * (maxmem_kb / 1024)); } -unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb) -{ - unsigned long iommu_pages = 0, mem_pages = maxmem_kb / 4; - unsigned int level; - - /* Assume a 4 level page table with 512 entries per level */ - for (level = 0; level < 4; level++) - { - mem_pages = DIV_ROUNDUP(mem_pages, 512); - iommu_pages += mem_pages; - } - - return iommu_pages * 4; -} - char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid) { unsigned int len; diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h index 630ccbe28a..46918aea84 100644 --- a/tools/libxl/libxl_utils.h +++ b/tools/libxl/libxl_utils.h @@ -24,7 +24,7 @@ const char *libxl_basename(const char *name); /* returns string from strdup */ unsigned long libxl_get_required_shadow_memory(unsigned long maxmem_kb, unsigned int smp_cpus); -unsigned long libxl_get_required_iommu_memory(unsigned long maxmem_kb); + /* deprecated; see LIBXL_HAVE_DOMAIN_NEED_MEMORY_CONFIG in libxl.h */ int libxl_name_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); int libxl_domain_qualifier_to_domid(libxl_ctx *ctx, const char *name, uint32_t *domid); char *libxl_domid_to_name(libxl_ctx *ctx, uint32_t domid); From patchwork Wed Oct 23 13:00:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206747 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 B659B1515 for ; Wed, 23 Oct 2019 13:01:59 +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 9241021872 for ; Wed, 23 Oct 2019 13:01:59 +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="OubHm2x+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9241021872 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 1iNGFo-00063w-AH; Wed, 23 Oct 2019 13:00:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFm-000634-W6 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:43 +0000 X-Inumbo-ID: 13a72770-f595-11e9-a531-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 13a72770-f595-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=oQSOfhArtlO3bwUuH/V4jT2AeG2GwRZpRhSiBnBelUo=; b=OubHm2x+1QC5bXIVj8tosQnSRAZJ46UHYLLniz88J4xbJBY9iWXMUTLy zytKBvL+DJ+tANI1Ewdgu/MktJShb9NL2XamnEWpsdt6xEQfRK8a0iIhr UJ8EpxEdc06GGY8Atp+ty7Yq5/CDoks2L3cNaZ+3/72uQvMl9TbLEhxCI 8=; 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: dUTXuuWIJ61fu1WZlB6a/6MzJJoBNXCY3ubkclFJI+/PugCEYwm77BxQSp3ktb84H3JuycJ4w8 PFJ6JlyheSblvnWhYfDmuLzmhZh0/lxXc8k4aj0fo5++648aLeYof8yVfv/H54rr4yLCDkgDse 1+YwkoMc8Cef97+EhcbnlPWzh6JQ4Fle5NWk63LgP7DqR1Vh/dtDwq5rS7UX6TaJ+vg6D0A9/i 48HH71sUEcECzTLlFY7e4pMkPtJEhQqggyRkJx+4hWBImhz/gtDvdJyiUMwsH6XMNwwBLw5B8e e5M= X-SBRS: 2.7 X-MesageID: 7316444 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.68,220,1569297600"; d="scan'208";a="7316444" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:09 +0100 Message-ID: <20191023130013.32382-8-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 07/11] libxl: create: setdefault: Make libxl_physinfo info[1] 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional change. This will let us make it into a pointer without textual change other than to the definition. While we are here, fix some style errors (missing { }). Signed-off-by: Ian Jackson Acked-by: Wei Liu --- v2: New patch in this version of the series. --- tools/libxl/libxl_create.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index e4ddfd067f..d65df7924d 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -30,10 +30,10 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_domain_create_info *c_info) { - libxl_physinfo info; + libxl_physinfo info[1]; int rc; - rc = libxl_get_physinfo(CTX, &info); + rc = libxl_get_physinfo(CTX, info); if (rc) return rc; @@ -45,11 +45,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl__arch_domain_create_info_setdefault(gc, c_info); if (c_info->type != LIBXL_DOMAIN_TYPE_PV) { - if (info.cap_hap) + if (info->cap_hap) { libxl_defbool_setdefault(&c_info->hap, true); - else if (info.cap_shadow) + } else if (info->cap_shadow) { libxl_defbool_setdefault(&c_info->hap, false); - else { + } else { LOG(ERROR, "neither hap nor shadow paging available"); return ERROR_INVAL; } @@ -63,12 +63,12 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, if (!c_info->ssidref) c_info->ssidref = SECINITSID_DOMU; - if (info.cap_hvm_directio && + if (info->cap_hvm_directio && (c_info->passthrough == LIBXL_PASSTHROUGH_UNKNOWN)) { c_info->passthrough = ((c_info->type == LIBXL_DOMAIN_TYPE_PV) || - !info.cap_iommu_hap_pt_share) ? + !info->cap_iommu_hap_pt_share) ? LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; - } else if (!info.cap_hvm_directio) { + } else if (!info->cap_hvm_directio) { c_info->passthrough = LIBXL_PASSTHROUGH_DISABLED; } From patchwork Wed Oct 23 13:00:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206745 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 68B601390 for ; Wed, 23 Oct 2019 13:01:58 +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 44B2121872 for ; Wed, 23 Oct 2019 13:01:58 +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="KaaqeEg9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44B2121872 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 1iNGFj-0005zz-Du; Wed, 23 Oct 2019 13:00:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGFh-0005zC-VI for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:37 +0000 X-Inumbo-ID: 13f303c0-f595-11e9-beca-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 13f303c0-f595-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=swnojc7p8tZlUMVSFiHA8JZpgY6zZQc/i4P8oEhC9ww=; b=KaaqeEg998Em+sT9fxy1qDTaQO1bSpdm1C8mA3Q9uxxN7MEQBEn0j73i R229KAeegzZEPECCRgXDkFItq2WA2JBOrdcr1fCbItj6SNTFR3Cm792fi P06BVddebvAjXSOuaPy8M+9isSt3SFEvDUEPqo6tW6nhCsR9US7EOh4fw g=; Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: HNdMwtFItnMdASZld7adWY1MVumpOF+bmhRLJC183NJLA4UPJDQSKCvQGTahXKwZJy6nn1eBpj gRbe48LPtM8WOHVI9vHGnBDLD+ycl0dKGWTGQpMp0PBQQM8aVncLsaFQmK+z5qKx2dddCHPSP9 QgZanq5yQWgG/KYpUtoMriKHC49q2/WCk9Bzl7Rvx4apUdRyGwSOqDGfypCWZNXho4ZboM81bK 87m1o+bqlt5vukDK+ysw8mNIx+7rxltEASWGgMWjYkp8UzB1EYpEzfjm4+vykWppxd9lSPbWoX LUM= X-SBRS: 2.7 X-MesageID: 7660568 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,220,1569297600"; d="scan'208";a="7660568" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:10 +0100 Message-ID: <20191023130013.32382-9-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 08/11] libxl: create: setdefault: Move physinfo into config_setdefault 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" No functional change. This will let us refer to it in code we are about to add to this function. Signed-off-by: Ian Jackson Acked-by: Wei Liu --- v2: New patch in this version of the series. --- tools/libxl/libxl_create.c | 17 ++++++++--------- tools/libxl/libxl_dm.c | 7 ++++++- tools/libxl/libxl_internal.h | 3 ++- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index d65df7924d..0670ef90ed 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -28,15 +28,9 @@ #include int libxl__domain_create_info_setdefault(libxl__gc *gc, - libxl_domain_create_info *c_info) + libxl_domain_create_info *c_info, + const libxl_physinfo *info) { - libxl_physinfo info[1]; - int rc; - - rc = libxl_get_physinfo(CTX, info); - if (rc) - return rc; - if (!c_info->type) { LOG(ERROR, "domain type unspecified"); return ERROR_INVAL; @@ -915,6 +909,10 @@ int libxl__domain_config_setdefault(libxl__gc *gc, int ret; bool pod_enabled = false; + libxl_physinfo physinfo; + ret = libxl_get_physinfo(CTX, &physinfo); + if (ret) goto error_out; + 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), @@ -1013,7 +1011,8 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } - ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info); + ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info, + &physinfo); if (ret) { LOGD(ERROR, domid, "Unable to set domain create info defaults"); goto error_out; diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index c00356a2f1..e6a48974f8 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -2167,7 +2167,12 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) dm_config->c_info.run_hotplug_scripts = guest_config->c_info.run_hotplug_scripts; - ret = libxl__domain_create_info_setdefault(gc, &dm_config->c_info); + libxl_physinfo physinfo; + ret = libxl_get_physinfo(CTX, &physinfo); + if (ret) goto out; + + ret = libxl__domain_create_info_setdefault(gc, &dm_config->c_info, + &physinfo); if (ret) goto out; ret = libxl__domain_build_info_setdefault(gc, &dm_config->b_info); if (ret) goto out; diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 0185b8ff01..6a614658c2 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1447,7 +1447,8 @@ _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); + libxl_domain_create_info *c_info, + const libxl_physinfo *info); _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); _hidden void libxl__rdm_setdefault(libxl__gc *gc, From patchwork Wed Oct 23 13:00:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206755 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 39AD01390 for ; Wed, 23 Oct 2019 13:02:03 +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 15EC721872 for ; Wed, 23 Oct 2019 13:02:03 +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="BRg+1WuQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15EC721872 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 1iNGFs-000678-LI; Wed, 23 Oct 2019 13:00: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 1iNGFr-00066Z-Vg for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:47 +0000 X-Inumbo-ID: 13d87a5a-f595-11e9-beca-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 13d87a5a-f595-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 13:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835624; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=CkgMpeIsW3IyunynNO0/sGnSmpzrNnEvXVsPqh/9w6s=; b=BRg+1WuQD+aET3vSve4pO1ZGCsWEHGDGX3FtIYRVsZFCXC5AZ8WRDhZ3 73pBaVoD3U7pMVKVcJSTekvzZhvfck3ELesTZyxhtqpFdzftGuRegDEK0 8eId+rGFx33PARuRq9GNL+Mx6CGLKGfW9m7qKk1FbVR7eF2AdNGfnnCEM I=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: +DG0QRnC7rKrEwCLr0f1HxUMsVclSBzJox+3Rqfxb6xLnm+kI7o1sAzhgIJa/JjCqnfreGtvzH yhIkZw/lHD6jjsa0Fmv3+e+NKpGcrc8GmZ+4cIbtqJTOojbfU6NMOXPngS78RvneO5YbfxFlzF 3XyYxuq2SgqceIA8vFk46t0VeJlTZa3/GP8bPI0TPWTyr2Wwl3d1p22QMsFU+LrnV8hlupd9XR 41s8AbR36CmFZayF/ORU/FQ3WszKHR1svGXy6bb+cTjFljSRJO7ojvxVa21vU8oexxxU3+uel8 4H4= X-SBRS: 2.7 X-MesageID: 7623496 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.68,220,1569297600"; d="scan'208";a="7623496" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:11 +0100 Message-ID: <20191023130013.32382-10-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 09/11] libxl: Move domain_create_info_setdefault earlier 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 , =?utf-8?b?SsO8cmdlbiBHcm8=?= =?utf-8?b?w58=?= , Ian Jackson , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We need this before we start to figure out the passthrough mode. I have checked that nothing in libxl__domain_create_info_setdefault nor the two implementations of ..._arch_... accesses anything else, other than (i) the domain type (which this function is responsible for setting and nothing before it looks at) (ii) c_info->ssidref (which is defaulted by flask code near the top of libxl__domain_config_setdefault and not accessed afterwards). So no functional change. Signed-off-by: Ian Jackson Acked-by: Anthony PERARD --- v3: New patch in this version of the series. --- tools/libxl/libxl_create.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 0670ef90ed..7869d54b32 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -972,6 +972,13 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } + ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info, + &physinfo); + if (ret) { + LOGD(ERROR, domid, "Unable to set domain create info defaults"); + goto error_out; + } + /* If target_memkb is smaller than max_memkb, the subsequent call * to libxc when building HVM domain will enable PoD mode. */ @@ -1011,13 +1018,6 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } - ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info, - &physinfo); - if (ret) { - LOGD(ERROR, domid, "Unable to set domain create info defaults"); - goto error_out; - } - if (d_config->b_info.shadow_memkb == LIBXL_MEMKB_DEFAULT && ok_to_default_memkb_in_create(gc)) d_config->b_info.shadow_memkb = From patchwork Wed Oct 23 13:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206761 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 2CEA91920 for ; Wed, 23 Oct 2019 13:02:15 +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 F197221872 for ; Wed, 23 Oct 2019 13:02:14 +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="bp8ozpeQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F197221872 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 1iNGFk-000612-NT; Wed, 23 Oct 2019 13:00:40 +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 1iNGFi-0005zk-VC for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:39 +0000 X-Inumbo-ID: 13dacf59-f595-11e9-947c-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 13dacf59-f595-11e9-947c-12813bfff9fa; Wed, 23 Oct 2019 13:00:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835626; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=zJ505CVIc7EboI0NLvSJ4NNuvkfu18tz73mUbyNQaI8=; b=bp8ozpeQJKxH+EocL1cIaKWUkDeKjKROaM8szr7PRgHU7WqhV8R0jqsB vIXokwCiChEFXrPGZBegqOFfujuwVNYS0SselWOnKJMUVxSSM9L6/EPMe iKFyjzdG1jbonTP95U8E6f6NwHA3Y3tSqvk+IAS+u8f2haWwPJlao6g5m 8=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: +NRA48aCTtxRTJDMtf6EUYoUl9O4H9eKjldATMaLKXEy4cjBrZXQlsuJOivowGRrDkYZjJVyve Lz1n/sztfSbgZmKWm5TQu4Aq6qX3vKmUEMHQ75CsH1r0QnP8ngJhybIonvLLWppLHXegSWQDWh le9rhHpDpkzJKNh7EjKlHLYbeRsHayTHeU+K9QDGgcPZhU/LWWKU3bB2zNOlYUVOdCJpRUJgIB SUczNS2Zc61aCXMnqwlU4Fb7NSNkMya/s5ESppAEkS/F8xcq0w6K1MCwn6jLFMy3U8nPI1Be4G oPs= X-SBRS: 2.7 X-MesageID: 7411231 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.68,220,1569297600"; d="scan'208";a="7411231" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:12 +0100 Message-ID: <20191023130013.32382-11-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 10/11] libxl/xl: Overhaul passthrough setting logic 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: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= , Stefano Stabellini , Julien Grall , Wei Liu , Andrew Cooper , Ian Jackson , Paul Durrant , Jan Beulich , Anthony PERARD , Volodymyr Babchuk Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" LIBXL_PASSTHROUGH_UNKNOWN (aka "ENABLED" in an earlier uncommitted version of this code) is doing double duty. We actually need all of the following to be specifiable: * "default": enable PT iff we have devices to pass through specified in the initial config file. * "enabled" (and fail if the platform doesn't support it). * "disabled" (and reject future PT hotplug). * "share_pt"/"sync_pt": enable PT and set a specific PT mode. Defaulting and error checking should be done in libxl. So, we make several changes here. We introduce "enabled", and rename "unknown" to "default". We move all of the error checking and defaulting code from xl into libxl. Now, libxl__domain_config_setdefault has all of the necessary information to get this right. So we can do it all there. Choosing the specific mode is arch-specific. We can also arrange to have only one place each which calculates (i) whether passthrough needs to be enabled because pt devices were specified (ii) whether pt_share can be used (for each arch). xl now only has to parse the enum in the same way as it parses all other enums. This change fixes a regression from earlier 4.13-pre: until recent changes, passthrough was only enabled by default if passthrough devices were specified. We restore this behaviour. Signed-off-by: Ian Jackson CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Andrew Cooper CC: Paul Durrant CC: Jan Beulich Acked-by: Anthony PERARD --- v5: Change "unknown" to "default". In the manpage too. v4: Fix trailing whitespace No longer change "unknown" to "unspecified". v3: Drop paragraph about masking another osstest regression, as that's now fixed. Drop redundant "ERROR:" in two log messages. Add a comment about the way "enabled" gets changed to a specific value. Split passthrough mode defaulting into arch specific functions. On ARM, always choose (and insist on) share_pt. Reject share_pt for non-HAP guests. Reject passthrough for PVH guests. Actually document "unspecified" option in xl.cfg(5) Rename "unknown" to "unspecified" v2: New patch in this version of the series. --- docs/man/xl.cfg.5.pod.in | 6 ++++ tools/libxl/libxl_arch.h | 6 ++++ tools/libxl/libxl_arm.c | 24 ++++++++++++++++ tools/libxl/libxl_create.c | 43 ++++++++++++++++++++--------- tools/libxl/libxl_types.idl | 7 +++-- tools/libxl/libxl_x86.c | 41 +++++++++++++++++++++++++++ tools/xl/xl_parse.c | 67 ++++----------------------------------------- 7 files changed, 116 insertions(+), 78 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 64bed30bce..245d3f9472 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -660,6 +660,12 @@ in preference. However, the availability of this option is hardware specific. If B reports B containing B then this option may be used. +=item B + +The default, which chooses between B and B +according to whether passthrough devices are enabled in the config +file. + =back =back diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index d624159e53..ee6641b3e6 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -73,6 +73,12 @@ void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); _hidden +int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, + uint32_t domid, + libxl_domain_config *d_config, + const libxl_physinfo *physinfo); + +_hidden int libxl__arch_extra_memory(libxl__gc *gc, const libxl_domain_build_info *info, uint64_t *out); diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index bf31b9b3ca..2f1ca69431 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1191,6 +1191,30 @@ void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PVH); } +int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, + uint32_t domid, + libxl_domain_config *d_config, + const libxl_physinfo *physinfo) +{ + int rc; + libxl_domain_create_info *const c_info = &d_config->c_info; + + if (c_info->passthrough == LIBXL_PASSTHROUGH_ENABLED) { + c_info->passthrough = LIBXL_PASSTHROUGH_SHARE_PT; + } + + if (c_info->passthrough == LIBXL_PASSTHROUGH_SYNC_PT) { + LOGD(ERROR, domid, + "passthrough=\"sync_pt\" not supported on ARM\n"); + rc = ERROR_INVAL; + goto out; + } + + rc = 0; + out: + return rc; +} + /* * Local variables: * mode: C diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 7869d54b32..d59ac2ab05 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -57,18 +57,6 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, if (!c_info->ssidref) c_info->ssidref = SECINITSID_DOMU; - if (info->cap_hvm_directio && - (c_info->passthrough == LIBXL_PASSTHROUGH_UNKNOWN)) { - c_info->passthrough = ((c_info->type == LIBXL_DOMAIN_TYPE_PV) || - !info->cap_iommu_hap_pt_share) ? - LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; - } else if (!info->cap_hvm_directio) { - c_info->passthrough = LIBXL_PASSTHROUGH_DISABLED; - } - - /* An explicit setting should now have been chosen */ - assert(c_info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN); - return 0; } @@ -591,7 +579,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config, libxl_defbool_val(info->oos) ? 0 : XEN_DOMCTL_CDF_oos_off; } - assert(info->passthrough != LIBXL_PASSTHROUGH_UNKNOWN); + assert(info->passthrough != LIBXL_PASSTHROUGH_DEFAULT); LOG(DETAIL, "passthrough: %s", libxl_passthrough_to_string(info->passthrough)); @@ -908,6 +896,7 @@ int libxl__domain_config_setdefault(libxl__gc *gc, libxl_ctx *ctx = libxl__gc_owner(gc); int ret; bool pod_enabled = false; + libxl_domain_create_info *c_info = &d_config->c_info; libxl_physinfo physinfo; ret = libxl_get_physinfo(CTX, &physinfo); @@ -979,6 +968,34 @@ int libxl__domain_config_setdefault(libxl__gc *gc, goto error_out; } + bool need_pt = d_config->num_pcidevs || d_config->num_dtdevs; + if (c_info->passthrough == LIBXL_PASSTHROUGH_DEFAULT) { + c_info->passthrough = need_pt + ? LIBXL_PASSTHROUGH_ENABLED : LIBXL_PASSTHROUGH_DISABLED; + } + + bool iommu_enabled = physinfo.cap_hvm_directio; + if (c_info->passthrough != LIBXL_PASSTHROUGH_DISABLED && !iommu_enabled) { + LOGD(ERROR, domid, + "passthrough not supported on this platform\n"); + ret = ERROR_INVAL; + goto error_out; + } + + if (c_info->passthrough == LIBXL_PASSTHROUGH_DISABLED && need_pt) { + LOGD(ERROR, domid, + "passthrough disabled but devices are specified"); + ret = ERROR_INVAL; + goto error_out; + } + + ret = libxl__arch_passthrough_mode_setdefault(gc,domid,d_config,&physinfo); + if (ret) goto error_out; + + /* An explicit setting should now have been chosen */ + assert(c_info->passthrough != LIBXL_PASSTHROUGH_DEFAULT); + assert(c_info->passthrough != LIBXL_PASSTHROUGH_ENABLED); + /* If target_memkb is smaller than max_memkb, the subsequent call * to libxc when building HVM domain will enable PoD mode. */ diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 3ac9494b80..0546d7865a 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -264,10 +264,11 @@ libxl_vkb_backend = Enumeration("vkb_backend", [ ]) libxl_passthrough = Enumeration("passthrough", [ - (0, "unknown"), + (0, "default"), (1, "disabled"), - (2, "sync_pt"), - (3, "share_pt"), + (2, "enabled"), # becomes {sync,share}_pt once defaults are evaluated + (3, "sync_pt"), + (4, "share_pt"), ]) # diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index c0f88a7eaa..8b804537ba 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -631,6 +631,47 @@ void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&b_info->acpi, true); } +int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, + uint32_t domid, + libxl_domain_config *d_config, + const libxl_physinfo *physinfo) +{ + int rc; + libxl_domain_create_info *const c_info = &d_config->c_info; + + if (c_info->passthrough != LIBXL_PASSTHROUGH_DISABLED && + c_info->type == LIBXL_DOMAIN_TYPE_PVH) { + LOGD(ERROR, domid, + "passthrough not yet supported for x86 PVH guests\n"); + rc = ERROR_INVAL; + goto out; + } + + const char *whynot_pt_share = + c_info->type == LIBXL_DOMAIN_TYPE_PV ? "not valid for PV domain" : + !physinfo->cap_iommu_hap_pt_share ? "not supported on this platform" : + !libxl_defbool_val(d_config->c_info.hap) ?"only valid for HAP guests": + NULL; + + if (c_info->passthrough == LIBXL_PASSTHROUGH_ENABLED) { + c_info->passthrough = whynot_pt_share + ? LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; + } + + if (c_info->passthrough == LIBXL_PASSTHROUGH_SHARE_PT && whynot_pt_share) { + LOGD(ERROR, domid, + "passthrough=\"share_pt\" %s\n", + whynot_pt_share); + rc = ERROR_INVAL; + goto out; + } + + rc = 0; + out: + return rc; +} + + /* * Local variables: * mode: C diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 79871c22d0..112f8ee026 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1222,7 +1222,6 @@ void parse_config_data(const char *config_source, int pci_seize = 0; int i, e; char *kernel_basename; - bool iommu_enabled, iommu_hap_pt_share; libxl_domain_create_info *c_info = &d_config->c_info; libxl_domain_build_info *b_info = &d_config->b_info; @@ -1234,8 +1233,6 @@ void parse_config_data(const char *config_source, exit(EXIT_FAILURE); } - iommu_enabled = physinfo.cap_hvm_directio; - iommu_hap_pt_share = physinfo.cap_iommu_hap_pt_share; libxl_physinfo_dispose(&physinfo); config= xlu_cfg_init(stderr, config_source); @@ -1509,67 +1506,13 @@ void parse_config_data(const char *config_source, } } - if (xlu_cfg_get_string(config, "passthrough", &buf, 0)) { - c_info->passthrough = - (d_config->num_pcidevs || d_config->num_dtdevs) - ? LIBXL_PASSTHROUGH_UNKNOWN : LIBXL_PASSTHROUGH_DISABLED; - } else { - if (!strcasecmp("enabled", buf)) - c_info->passthrough = LIBXL_PASSTHROUGH_UNKNOWN; - else { - libxl_passthrough o; - - e = libxl_passthrough_from_string(buf, &o); - if (e || !strcasecmp("unknown", buf)) { - fprintf(stderr, - "ERROR: unknown passthrough option '%s'\n", - buf); - exit(-ERROR_FAIL); - } - - c_info->passthrough = o; - } - } - - switch (c_info->passthrough) { - case LIBXL_PASSTHROUGH_UNKNOWN: - /* - * Choose a suitable default. libxl would also do this but - * choosing here allows the code calculating 'iommu_memkb' - * below make an informed decision. - */ - c_info->passthrough = - (c_info->type == LIBXL_DOMAIN_TYPE_PV) || !iommu_hap_pt_share - ? LIBXL_PASSTHROUGH_SYNC_PT : LIBXL_PASSTHROUGH_SHARE_PT; - break; - - case LIBXL_PASSTHROUGH_DISABLED: - if (d_config->num_pcidevs || d_config->num_dtdevs) { + if (!xlu_cfg_get_string(config, "passthrough", &buf, 0)) { + if (libxl_passthrough_from_string(buf, &c_info->passthrough)) { fprintf(stderr, - "ERROR: passthrough disabled but devices are specified\n"); - exit(-ERROR_FAIL); - } - break; - case LIBXL_PASSTHROUGH_SHARE_PT: - if (c_info->type == LIBXL_DOMAIN_TYPE_PV) { - fprintf(stderr, - "ERROR: passthrough=\"share_pt\" not valid for PV domain\n"); - exit(-ERROR_FAIL); - } else if (!iommu_hap_pt_share) { - fprintf(stderr, - "ERROR: passthrough=\"share_pt\" not supported on this platform\n"); - exit(-ERROR_FAIL); + "ERROR: unknown passthrough option '%s'\n", + buf); + exit(1); } - break; - case LIBXL_PASSTHROUGH_SYNC_PT: - break; - } - - if ((c_info->passthrough != LIBXL_PASSTHROUGH_DISABLED) && - !iommu_enabled) { - fprintf(stderr, - "ERROR: passthrough not supported on this platform\n"); - exit(-ERROR_FAIL); } if (!xlu_cfg_get_long(config, "shadow_memory", &l, 0)) From patchwork Wed Oct 23 13:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 11206763 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 33B7B1390 for ; Wed, 23 Oct 2019 13:02:15 +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 100E621920 for ; Wed, 23 Oct 2019 13:02:15 +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="eE1ldlbL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 100E621920 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 1iNGG2-0006FY-Cv; Wed, 23 Oct 2019 13:00:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNGG2-0006F5-09 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:00:58 +0000 X-Inumbo-ID: 150ed3e2-f595-11e9-a531-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 150ed3e2-f595-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571835627; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=hc7BW0gamVDxfQE27Bbza9HoJMjjSPTEL8Iub+Ut1+A=; b=eE1ldlbL7uNOGNFC4qShmejKUHwTiXC5afkw77jqZ0BplfPHGqz0VFIF hk8PS+86T659xPXRSY1zfkuhY3wprr0KTfZgNTmKTALrWpqXqUNvUkM4/ gX4JGwCJQnMnvLoywfz3L39bqGcVoahWPO4LWkIa+RaP5BeNHOs0UzU2z M=; Authentication-Results: esa1.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 (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="Ian.Jackson@citrix.com"; x-sender="ian.jackson@eu.citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.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=esa1.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 (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="Ian.Jackson@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: jgojwduv6wyatx1NFrB0Ex2Ujm9IBmZHQYUkmzCXN/anb9qCKxNZALLvHWrJ8820piJcTwbx3x usgWc3qiT4gEjIHJkb+INiZkRsTM7WS/EKBkWCfo4quYi1qIyExvZGeFH9nKjc3NHAt05PY5X0 sQd2a/mpVBu+esbQ4kxqPDMlayjZf0W17pFOCrqliozN98AIRDTmfokF/gSXEBg7JQ5s/fATs2 ZxR66Q6npiBAxe9+EOQkN9YRdqKVENX8omfifMuNELNQ2Oy/A0kOLvcjDcwGdU7WcN5cgCNk6c N2M= X-SBRS: 2.7 X-MesageID: 7411235 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.68,220,1569297600"; d="scan'208";a="7411235" From: Ian Jackson To: Date: Wed, 23 Oct 2019 14:00:13 +0100 Message-ID: <20191023130013.32382-12-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191023130013.32382-1-ian.jackson@eu.citrix.com> References: <20191023130013.32382-1-ian.jackson@eu.citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [XEN PATCH for-4.13 v7 11/11] libxl: On ARM, reject future new passthrough modes too 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: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= , Stefano Stabellini , Julien Grall , Wei Liu , Ian Jackson , Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This is most pleasantly done by also changing the if to a switch. Suggested-by: Julien Grall CC: Julien Grall CC: Stefano Stabellini Signed-off-by: Ian Jackson Acked-by: Anthony PERARD Signed-off-by: Ian Jackson Acked-by: Anthony PERARD --- v7: New patch in this version of the series. --- tools/libxl/libxl_arm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 2f1ca69431..0b3025a9ed 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1203,9 +1203,15 @@ int libxl__arch_passthrough_mode_setdefault(libxl__gc *gc, c_info->passthrough = LIBXL_PASSTHROUGH_SHARE_PT; } - if (c_info->passthrough == LIBXL_PASSTHROUGH_SYNC_PT) { + switch (c_info->passthrough) { + case LIBXL_PASSTHROUGH_DISABLED; + case LIBXL_PASSTHROUGH_SHARE_PT: + break; + + default: LOGD(ERROR, domid, - "passthrough=\"sync_pt\" not supported on ARM\n"); + "passthrough=\"%s\" not supported on ARM\n", + libxl__passthrough_mode_to_string(c_info->passthrough); rc = ERROR_INVAL; goto out; }