From nobody Thu Jan 2 14:58:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=solinno.co.uk Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1733242059350501.0791792090306; Tue, 3 Dec 2024 08:07:39 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 3267C1608; Tue, 3 Dec 2024 11:07:38 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id AFFCE1613; Tue, 3 Dec 2024 11:07:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 16B4615F7; Tue, 3 Dec 2024 11:07:11 -0500 (EST) Received: from doppler.solinno.uk (doppler.solinno.uk [81.2.106.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B9B8214E8 for ; Tue, 3 Dec 2024 11:07:09 -0500 (EST) Received: from folly.solinno.co.uk (f.2.2.1.7.4.2.9.2.0.a.d.3.d.4.b.a.c.f.8.6.f.d.1.0.b.8.0.1.0.0.2.ip6.arpa [IPv6:2001:8b0:1df6:8fca:b4d3:da02:9247:122f]) by doppler.solinno.uk (Postfix) with ESMTPSA id 837BA20BB1; Tue, 3 Dec 2024 16:02:14 +0000 (GMT) Received: by folly.solinno.co.uk (Postfix, from userid 1000) id 392C32016A; Tue, 3 Dec 2024 16:02:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 X-Greylist: delayed 293 seconds by postgrey-1.37 at lists.libvirt.org; Tue, 03 Dec 2024 11:07:09 EST DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=solinno.co.uk; s=mail; t=1733241734; bh=HxNCNMpdPeO2EcOxzFDwRCk/cB73VBzKuUn97hLwHGE=; h=From:To:Cc:Subject:Date:From; b=pVdbK0XpjpUClp9+T80biDmd5qIcCZnxHKgOCnFOqk7vyzNNTeANc7NXCud/P7YiN zCiRVym+U5tuotqi7JU88cZB9uehw01vl5fy87YzcSqhkSP/ARo5LU/lVnSrVIFGvW 83DY2vdNTZiCrLUbSZYGn7UOl8xq3cnkcmJUSatQ= From: Leigh Brown To: devel@lists.libvirt.org Subject: [libvirt PATCH] lxc: remove no longer working netns check Date: Tue, 3 Dec 2024 16:02:08 +0000 Message-Id: <20241203160208.31678-1-leigh@solinno.co.uk> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UO2M726GGCQRIJ7UIMPU3BVQ5JMVQPDZ X-Message-ID-Hash: UO2M726GGCQRIJ7UIMPU3BVQ5JMVQPDZ X-MailFrom: leigh@solinno.co.uk X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Leigh Brown X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Computed bodyhash is different from the expected one) X-ZM-MESSAGEID: 1733242062074116600 Content-Type: text/plain; charset="utf-8" Since iproute2 v6.12.0, the command "ip link set lo netns -1" can no longer be used to check for netns support, as it now validates PIDs are not less than zero. Since every kernel we care about has the support, just remove the check. Signed-off-by: Leigh Brown Reviewed-by: Daniel P. Berrang=C3=A9 --- src/lxc/lxc_conf.h | 1 - src/lxc/lxc_driver.c | 36 ------------------------------------ 2 files changed, 37 deletions(-) diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index c0967ac63b..a639e3989f 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -49,7 +49,6 @@ struct _virLXCDriverConfig { char *stateDir; char *logDir; bool log_libvirtd; - int have_netns; =20 char *securityDriverName; bool securityDefaultConfined; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index d682e7168a..2488940feb 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -422,12 +422,6 @@ lxcDomainDefineXMLFlags(virConnectPtr conn, const char= *xml, unsigned int flags) if (virSecurityManagerVerify(driver->securityManager, def) < 0) goto cleanup; =20 - if ((def->nets !=3D NULL) && !(cfg->have_netns)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("System lacks NETNS support")); - goto cleanup; - } - if (!(vm =3D virDomainObjListAdd(driver->domains, &def, driver->xmlopt, 0, &oldDef))) @@ -974,12 +968,6 @@ static int lxcDomainCreateWithFiles(virDomainPtr dom, if (virDomainCreateWithFilesEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if ((vm->def->nets !=3D NULL) && !(cfg->have_netns)) { - virReportError(VIR_ERR_OPERATION_INVALID, - "%s", _("System lacks NETNS support")); - goto cleanup; - } - if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; =20 @@ -1088,13 +1076,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, if (virSecurityManagerVerify(driver->securityManager, def) < 0) goto cleanup; =20 - if ((def->nets !=3D NULL) && !(cfg->have_netns)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("System lacks NETNS support")); - goto cleanup; - } - - if (!(vm =3D virDomainObjListAdd(driver->domains, &def, driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | @@ -1386,22 +1367,6 @@ lxcDomainDestroy(virDomainPtr dom) return lxcDomainDestroyFlags(dom, 0); } =20 -static int lxcCheckNetNsSupport(void) -{ - g_autoptr(virCommand) cmd =3D virCommandNewArgList("ip", "link", "set"= , "lo", - "netns", "-1", NULL); - int ip_rc; - - if (virCommandRun(cmd, &ip_rc) < 0 || ip_rc =3D=3D 255) - return 0; - - if (virProcessNamespaceAvailable(VIR_PROCESS_NAMESPACE_NET) < 0) - return 0; - - return 1; -} - - static virSecurityManager * lxcSecurityInit(virLXCDriverConfig *cfg) { @@ -1481,7 +1446,6 @@ lxcStateInitialize(bool privileged, goto cleanup; =20 cfg->log_libvirtd =3D false; /* by default log to container logfile */ - cfg->have_netns =3D lxcCheckNetNsSupport(); =20 /* Call function to load lxc driver configuration information */ if (virLXCLoadDriverConfig(cfg, SYSCONFDIR "/libvirt/lxc.conf") < 0) --=20 2.39.5