From patchwork Fri Jul 29 13:26:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12932463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 190D5C19F29 for ; Fri, 29 Jul 2022 13:27:06 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377532.610777 (Exim 4.92) (envelope-from ) id 1oHQ12-0007OD-5w; Fri, 29 Jul 2022 13:26:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377532.610777; Fri, 29 Jul 2022 13:26:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHQ12-0007Nr-2w; Fri, 29 Jul 2022 13:26:56 +0000 Received: by outflank-mailman (input) for mailman id 377532; Fri, 29 Jul 2022 13:26:54 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHQ10-0006rA-F7 for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 13:26:54 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1bfa000e-0f42-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 15:26:53 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1bfa000e-0f42-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659101213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M7O2Y0l36eqJVxxchKGa1BAarrZpTn8SXsfsBruyas8=; b=eqKdldxxE2qIuEKsHv3YXxhE0u+RW2aVrwjDypukSGG7p2cEcBuExU6Q LCB2rYgFWWO2dqRPUXu+YcnRlqX5zeUB4Y9aM1HbKpXmgIJv0ADHwN6Of Bs3B2YziC86U+8+0JycliGay1iOGdP2QtaoFNmMvmWGn5fsXlqLnZh9MS s=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76933074 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:duOXbKpqIvPf0XvGanazvq+K2C9eBgzWbkUzOEj9NTP0s+dABD8hgsdSaEH9hFxiBwbI0vBa6i2HxjTGFjKJ11DbHMsG61v308FQIZD4FsuOBg5xy3WHeMGe+KXVIU3yRh1DHPk1d2DiRw6Rwqqiji+aBeVlw5Q36PXD4JWT/P+DHIC6akoTAGvZ2VQNXiyc3IptqscBMYdDI92KATdqmfIi2Rn1981nIVpQQ8u0zXnVxMBzpgFnE2ze4U/bWa7arZaDOLHd5U5PUn9xUHRjDU0FCInXZDnLeYv94tTd5V9dXMRAqaTnuBaAuf8J/P7+LZBLtcwB0/6tU0SkutNh/8m+8CeKPEjQ5ikG4JqrrcYrKvpKXOunM7riGglcZPYtRTbWDxYTCtKEq3qbOVLhTitcwD6HPNN1sXq+NsXCxdsyDPVbXd8zKGYFqiSPFW7pJXVnvgjF68JW8Da/Ps3HPAZ8gxV6Wo/k3Z0Z1SeAI2CKlILuEsbMyXJY1cor08YgHGaQtj0GzCPuzAniUqKO2KdIuBXlg7BTcQ8NISH/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DNnlk6Dcik9wVdAhbWPwh6NCYi9GRCjUWZnkryGJNK/jwDZb93C1L7NIq4Tpa4xwqg22KIzJK9IGaOyP5yw== X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="76933074" From: Anthony PERARD To: CC: Juergen Gross , Wei Liu , Jan Beulich , Andrew Cooper , "Anthony PERARD" Subject: [XEN PATCH] tools/libxl: env variable to trusted default Date: Fri, 29 Jul 2022 14:26:41 +0100 Message-ID: <20220729132641.21221-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220729132641.21221-1-anthony.perard@citrix.com> References: <20220729132641.21221-1-anthony.perard@citrix.com> MIME-Version: 1.0 This is a forward port of "tools/libxl: env variable to signal whether disk/nic backend is trusted", to allow the environment variable to still work when upgrading from 4.16 or earlier. Introduce support in libxl for fetching the default backend trusted option for disk and nic devices. This is part of XSA-403. Signed-off-by: Anthony PERARD --- docs/man/xl.1.pod.in | 24 ++++++++++++++++++++++++ tools/libs/light/libxl_disk.c | 6 +++++- tools/libs/light/libxl_nic.c | 5 ++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in index 101e14241d..a5a2af5df9 100644 --- a/docs/man/xl.1.pod.in +++ b/docs/man/xl.1.pod.in @@ -1945,6 +1945,30 @@ shows the decimal value. For non-linear mode, it shows hexadecimal value. =back +=head1 ENVIRONMENT + +=over 4 + +=item B + +Use B or B from L instead for a +more fine grain setting. + +This environment variable allows to changed the default value of B; +if it is set to "1", the default will be B; if the variable is +absent or set to "0", the default will be B. + +=item B + +Use B / B from L instead for a +more fine grain setting. + +This environment variable allows to changed the default value of B; +if it is set to "1", the default will be B; if the variable is +absent or set to "0", the default will be B. + +=back + =head1 IGNORED FOR COMPATIBILITY WITH XM xl is mostly command-line compatible with the old xm utility used with diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c index 9da2b2ed27..7564a12868 100644 --- a/tools/libs/light/libxl_disk.c +++ b/tools/libs/light/libxl_disk.c @@ -155,11 +155,15 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_disk *disk, bool hotplug) { int rc; + const char *envvar; libxl_defbool_setdefault(&disk->discard_enable, !!disk->readwrite); libxl_defbool_setdefault(&disk->colo_enable, false); libxl_defbool_setdefault(&disk->colo_restore_enable, false); - libxl_defbool_setdefault(&disk->trusted, true); + + envvar = getenv("LIBXL_DISK_BACKEND_UNTRUSTED"); + /* Default to trusted if envvar missing or is "0". */ + libxl_defbool_setdefault(&disk->trusted, !envvar || !strcmp("0", envvar)); rc = libxl__resolve_domid(gc, disk->backend_domname, &disk->backend_domid); if (rc < 0) return rc; diff --git a/tools/libs/light/libxl_nic.c b/tools/libs/light/libxl_nic.c index d6bf06fc34..ff3aede6ea 100644 --- a/tools/libs/light/libxl_nic.c +++ b/tools/libs/light/libxl_nic.c @@ -59,6 +59,7 @@ static int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, libxl_device_nic *nic, bool hotplug) { int rc; + const char *envvar; if (!nic->mtu) nic->mtu = LIBXL_DEVICE_NIC_MTU_DEFAULT; @@ -116,7 +117,9 @@ static int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, abort(); } - libxl_defbool_setdefault(&nic->trusted, true); + envvar = getenv("LIBXL_NIC_BACKEND_UNTRUSTED"); + /* Default to trusted if envvar missing or is "0". */ + libxl_defbool_setdefault(&nic->trusted, !envvar || !strcmp("0", envvar)); return rc; }