From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608082061; cv=none; d=zohomail.com; s=zohoarc; b=LfiurbyyyFqxs4CehNZm1+pJ2Cr48J8RriHK+jvJicZRd9EF/ix0V1rktnuhOj7AkPmhl/BFHuyiT6UpPLnyxkIoKfPwrb02pFmfC3YT+JJJqKZ+jDzDentNQu0/2Oqg1AtSd0YnLxnQ55yewWW6Pk9atST1zz47U6W0Gen7SJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608082061; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JYdNf084V/ByGacp2Khy/VUtB90A604dTs2+d166jA8=; b=nAvEhL3qGOfWoSNye5JEzcaUchHJRIyInK7ku2DlDTZsSLbWaTR6AKXa6nCjrp5JYiI4iwwpPXiFgU3P6dLL3w0Vp3CaQ923Gxmqk/dSMMprt2lwU3K4lI47+sDSwyo1t9OfQQB6AusvnU/nwnL7UDRdKLC5h2J7O+AFKDdTgYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608082061950759.2761501182093; Tue, 15 Dec 2020 17:27:41 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196--GTWK-OUNPCmhx01kspdAw-1; Tue, 15 Dec 2020 20:27:38 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CEA1107ACE8; Wed, 16 Dec 2020 01:27:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 312AF60939; Wed, 16 Dec 2020 01:27:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 954B44BB7B; Wed, 16 Dec 2020 01:27:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BG1RTdZ026588 for ; Tue, 15 Dec 2020 20:27:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0905A5D9E3; Wed, 16 Dec 2020 01:27:29 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id A405B5D9D7; Wed, 16 Dec 2020 01:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608082060; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JYdNf084V/ByGacp2Khy/VUtB90A604dTs2+d166jA8=; b=VG6bdYfl8NCxXwia/b8Hyzr2PN0uD3MXvx1DRr6aAJz8YxdTNh1kjXD06T+boKzbEk6eI5 YzhjX5fbxWBt+b/oj3lEdquAtq0/fjOZCY6n0nq9QmMpvz8urwXSoR/Z2FVz9SDpWrDDvY fyNEQhHUkyuAUfW0F/vw0CN5OQhMYbg= X-MC-Unique: -GTWK-OUNPCmhx01kspdAw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 1/5] util: fix tap device name auto-generation for FreeBSD Date: Tue, 15 Dec 2020 20:27:19 -0500 Message-Id: <20201216012723.176100-2-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy , Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The Linux implementation of virNetDevCreate() no longer requires a template ifname (e.g. "vnet%d") when it is called, but just generates a new name if ifname is empty. The FreeBSD implementation requires that the caller actually fill in a template ifname, and will fail if ifname is empty. Since we want to eliminate all the special code in callers that is setting the template name, we need to make the behavior of the FreeBSD virNetDevCreate() match the behavior of the Linux virNetDevCreate(). The simplest way to do this is to use the new virNetDevGenerateName() function - if ifname is empty it generates a new name with the proper prefix, and if it's not empty, it leaves it alone. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virnetdevtap.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 88ad321627..cca2f614fe 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -308,7 +308,6 @@ int virNetDevTapCreate(char **ifname, int s; struct ifreq ifr; int ret =3D -1; - char *newifname =3D NULL; =20 if (tapfdSize > 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -316,6 +315,12 @@ int virNetDevTapCreate(char **ifname, goto cleanup; } =20 + /* auto-generate an unused name for the new device (this + * is NOP if a name has been provided) + */ + if (virNetDevGenerateName(ifname, VIR_NET_DEV_GEN_NAME_VNET) < 0) + return -1; + =20 /* As FreeBSD determines interface type by name, * we have to create 'tap' interface first and * then rename it to 'vnet' @@ -329,34 +334,6 @@ int virNetDevTapCreate(char **ifname, goto cleanup; } =20 - /* In case we were given exact interface name (e.g. 'vnetN'), - * we just rename to it. If we have format string like - * 'vnet%d', we need to find the first available name that - * matches this pattern - */ - if (strstr(*ifname, "%d") !=3D NULL) { - size_t i; - for (i =3D 0; i <=3D IF_MAXUNIT; i++) { - g_autofree char *newname =3D NULL; - - newname =3D g_strdup_printf(*ifname, i); - - if (virNetDevExists(newname) =3D=3D 0) { - newifname =3D g_steal_pointer(&newname); - break; - } - } - if (newifname) { - VIR_FREE(*ifname); - *ifname =3D newifname; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to generate new name for interface %s= "), - ifr.ifr_name); - goto cleanup; - } - } - if (tapfd) { g_autofree char *dev_path =3D NULL; dev_path =3D g_strdup_printf("/dev/%s", ifr.ifr_name); --=20 2.28.0 From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608082084; cv=none; d=zohomail.com; s=zohoarc; b=dy8EMFi4gS0hQ9XWc3BWwzqRvp9TzIoam1sppMKbeQI5pV/M/swtlWBC2CdsDxd79ycyK5FdB2YI3gRtgooCG/Ruz99APqI+jmn/6KCv0G78WK6+ZsMqeBBZkz62MenFa76i5KyGAC0QZOPtnlqlvm8mT1JA8MtDQ2DajnyVVHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608082084; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/pHTVA1f6wG2DGbsQ70HLIq838Jb9/EYfIPbq6d/bsQ=; b=mJpvl2dpZGbNZGBqrOtwXmAf0dn3mDXL2+zcewp6P8o0NzVExVBgYZ2NvchXB2cZlM4lA1R2CCK8ZQhrWyn2UBCY2lQhrSyHxE56dOZ4HyzfHzVxdDzPIFp//RAXCvferr+WXm3Ow+kWK0/IPDO9Fn8k9HtYXR34BuXfyBENWyg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608082084650387.5153052060606; Tue, 15 Dec 2020 17:28:04 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-0Ov-h0sFPIm4CBMrrGsOgQ-1; Tue, 15 Dec 2020 20:27:46 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 676F7190B2A5; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41EF0E70E; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0DEA35002E; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BG1RT2L026601 for ; Tue, 15 Dec 2020 20:27:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 86A6D5D9E4; Wed, 16 Dec 2020 01:27:29 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AA715D9D7; Wed, 16 Dec 2020 01:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608082083; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/pHTVA1f6wG2DGbsQ70HLIq838Jb9/EYfIPbq6d/bsQ=; b=EA4JvmUHQqeYaXGYXROkpenctsDyb+pbW29ISyP6ODrpdlS8l9Qfa50gvoulQEjhIiZyAw 52PH1qd3CL4peJjhmcTqMEzmu0LaICsO9KplvIaFOqM65UiPy1qBvV0h3lVSnl0eKDompV jAMrAUAE2oSiyaPyjN/P2csmEq4ults= X-MC-Unique: 0Ov-h0sFPIm4CBMrrGsOgQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/5] bhyve: remove redundant code that adds "template" netdev name Date: Tue, 15 Dec 2020 20:27:20 -0500 Message-Id: <20201216012723.176100-3-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy , Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The FreeBSD version of virNetDevTapCreate() now calls virNetDevGenerateName(), and virNetDevGenerateName() understands that a blank ifname should be replaced with a generated name based on a device-type-specific template - so there is no longer any need for the higher level functions to stuff a template name ("vnet%d") into ifname. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/bhyve/bhyve_command.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 4cf98c0eb1..daf313c9c1 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -79,13 +79,6 @@ bhyveBuildNetArgStr(const virDomainDef *def, goto cleanup; } =20 - if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_VNET_PREFIX) || - strchr(net->ifname, '%')) { - VIR_FREE(net->ifname); - net->ifname =3D g_strdup(VIR_NET_GENERATED_VNET_PREFIX "%d"); - } - if (!dryRun) { if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac, def->uuid, NULL, NULL, 0, --=20 2.28.0 From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608082154; cv=none; d=zohomail.com; s=zohoarc; b=Bf0YvJK46nT/WjHM/NzJ8fbKa6H0T5Z/EP5fu4nsM8ctU55U6V8cqYR2bCiI6FueauA5jGm3J8HgLKUosxqAk2xt10H5bSQASe2rzxB/HhHDlj9xviIMh0MmKTv2dF6TdQfxVhsQG5o/8Fo5S9YTGy2WuQeqQkHdoFfAJYvkOc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608082154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=n9c1t517flK2sByCYTUZINbut2sUAb13elRecWvXG9w=; b=kspTtxQUYYNFYklX/6T2uDr1FfrPhgYnU5WCXtiBz9DjIwIUJLzyDsoQXQicSs8z/RFILokjaXHMKCxFSlcq0Kk7qyNVooNvRe6wO3HVhDnk0XENrOlc2z090ExUlkfOqCJaajiQJASGHjKH959eMRwIwG1bA1UQaOlGxLgEmYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608082154370716.1948362047742; Tue, 15 Dec 2020 17:29:14 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-310-GQYqJMg4PrCvCXgSQF0vcg-1; Tue, 15 Dec 2020 20:27:50 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EFD8107ACFB; Wed, 16 Dec 2020 01:27:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6699F5D6D3; Wed, 16 Dec 2020 01:27:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3447E50033; Wed, 16 Dec 2020 01:27:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BG1RTF7026606 for ; Tue, 15 Dec 2020 20:27:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id EED755D9E3; Wed, 16 Dec 2020 01:27:29 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id A83D65D9D7; Wed, 16 Dec 2020 01:27:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608082153; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=n9c1t517flK2sByCYTUZINbut2sUAb13elRecWvXG9w=; b=HGDmzpvYRab/rRJuc8rlnq+tvN4qFCDNc6prPVg7slewkhYmsFuVvDzYLYGvUka5BqFUB9 0yXLNcJXByX7tIok9eCNAhQ0pDm3TnHDWE/Zsz/IMOnd+MmVMf7yf+0mRQOYh3dda3ocTE WBexGGx15BAyTkdOMmeb5E5t4Mu6rFg= X-MC-Unique: GQYqJMg4PrCvCXgSQF0vcg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 3/5] qemu: remove redundant code that adds "template" netdev name Date: Tue, 15 Dec 2020 20:27:21 -0500 Message-Id: <20201216012723.176100-4-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The lower level function virNetDevGenerateName() now understands that a blank ifname should be replaced with a generated name based on a template that it knows about itself - there is no need for the higher level functions to stuff a template name ("vnet%d") into ifname. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/qemu/qemu_interface.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c index 197c0aa239..be2f53945c 100644 --- a/src/qemu/qemu_interface.c +++ b/src/qemu/qemu_interface.c @@ -455,14 +455,10 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def, goto cleanup; } } else { - if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_VNET_PREFIX) || - strchr(net->ifname, '%')) { - VIR_FREE(net->ifname); - net->ifname =3D g_strdup(VIR_NET_GENERATED_VNET_PREFIX "%d"); - /* avoid exposing vnet%d in getXMLDesc or error outputs */ + + if (!net->ifname) template_ifname =3D true; - } + if (virNetDevTapCreate(&net->ifname, tunpath, tapfd, tapfdSize, tap_create_flags) < 0) { goto cleanup; @@ -559,14 +555,8 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, goto cleanup; } =20 - if (!net->ifname || - STRPREFIX(net->ifname, VIR_NET_GENERATED_VNET_PREFIX) || - strchr(net->ifname, '%')) { - VIR_FREE(net->ifname); - net->ifname =3D g_strdup(VIR_NET_GENERATED_VNET_PREFIX "%d"); - /* avoid exposing vnet%d in getXMLDesc or error outputs */ + if (!net->ifname) template_ifname =3D true; - } =20 if (qemuInterfaceIsVnetCompatModel(net)) tap_create_flags |=3D VIR_NETDEV_TAP_CREATE_VNET_HDR; --=20 2.28.0 From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608082062; cv=none; d=zohomail.com; s=zohoarc; b=FcnClE4X+6Xe3cKZHPUyk6sxqjxoZW0QMS8lz9VJFkmcNnAm1tA1YoD0Z+P5LFZlgFui9CDuZdyQs76E7o5R0/+YQY4AD+zScY/fdlPxB5JD4KjnEG2u98mlyR7Zg/m2bxbEWXCTnAjql1vh1VXT0XecVoZiYNFojBRoXXIOSxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608082062; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Esim+vkl8/NRT3pGOp0N8P+fOIospkrEn5WpPEOeVVs=; b=Cv7X+QUnb3LD+bIF1AqrV9u3bzwSxubuiPUiJTrVxBFOhUyKY5s0hBsYRsr+8BuSI67wTghO+aKgoK95WlxEbEzbnXk1BcRdOcnZHh2mo3pB3edgDkAxOnVbnZANNn5nmvIFBuUFIZ4XpPfmHo/v1UbRB22cSQUuu2i2Yib8iLw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608082062670744.6992387795364; Tue, 15 Dec 2020 17:27:42 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-s12Mx6ZCOl-3LajPVgjpFw-1; Tue, 15 Dec 2020 20:27:39 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E6BC8030A0; Wed, 16 Dec 2020 01:27:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DCE9D19D9F; Wed, 16 Dec 2020 01:27:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7D52C180954D; Wed, 16 Dec 2020 01:27:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BG1RU1K026614 for ; Tue, 15 Dec 2020 20:27:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 658CC5D9E3; Wed, 16 Dec 2020 01:27:30 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E2DE5D9D7; Wed, 16 Dec 2020 01:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608082061; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Esim+vkl8/NRT3pGOp0N8P+fOIospkrEn5WpPEOeVVs=; b=g/jNwaERAZWURJl/uXfWzQa+RonB3oAA5sOSg+J6UzGI2Z81F2NHsoSgXLPYf69zgWhRrk kAXrG99pv8lMI3y4D2d+bnjA2feAB9wTOZfjbVNz7U4WIr2RoweOZEhmH2znmAf2YbepO3 u7nTgERD5DI3vQj2S5n9N3tPgDF0PDc= X-MC-Unique: s12Mx6ZCOl-3LajPVgjpFw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 4/5] util: simplify virNetDevMacVLanCreateWithVPortProfile() Date: Tue, 15 Dec 2020 20:27:22 -0500 Message-Id: <20201216012723.176100-5-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since commit 282d135ddbb the parser for has cleared out any interface name from the input XML that used the macvtap/macvlan name as a prefix. Along with that, the switch to use the new virNetDevGenerateName() function for auto-generating macvtap/macvlan device names (commit 9b5d741a9), has realized two facts: 1) virNetDevGenerateName() can be called with a name already filled in, and in that case it is an effective NOP. 2) because virNetDevGenerate() will always find an unused name, there is no need to retry device creation in a loop - if it fails the first time, it would fail any subsequent time as well. that, combined with the aforementioned parser change allow us to simplify virNetDevMacVLanCreateWithVPortProfile() - we no longer need any extra code to determine if a template "AutoName" was requested, and don't need a separate code path for creating the device in the case that a specific name was given in the XML - all we need to do is log any requested name, and then call exactly the same code as we would if no name was given. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virnetdevmacvlan.c | 64 ++++++------------------------------- 1 file changed, 10 insertions(+), 54 deletions(-) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index a4ad698335..2deefe6589 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -673,6 +673,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifna= meRequested, uint32_t macvtapMode; int vf =3D -1; bool vnet_hdr =3D flags & VIR_NETDEV_MACVLAN_VNET_HDR; + virNetDevGenNameType type; =20 macvtapMode =3D modeMap[mode]; =20 @@ -706,66 +707,21 @@ virNetDevMacVLanCreateWithVPortProfile(const char *if= nameRequested, } =20 if (ifnameRequested) { - int rc; - bool isAutoName - =3D (STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVTAP_PREF= IX) || - STRPREFIX(ifnameRequested, VIR_NET_GENERATED_MACVLAN_PREFIX= )); - VIR_INFO("Requested macvtap device name: %s", ifnameRequested); - - if ((rc =3D virNetDevExists(ifnameRequested)) < 0) - return -1; - - if (rc) { - /* ifnameRequested is already being used */ - - if (!isAutoName) { - virReportSystemError(EEXIST, - _("Unable to create device '%s'"), - ifnameRequested); - return -1; - } - } else { - - /* ifnameRequested is available. try to open it */ - - virNetDevReserveName(ifnameRequested); - - if (virNetDevMacVLanCreate(ifnameRequested, macaddress, - linkdev, macvtapMode, flags) =3D=3D= 0) { - - /* virNetDevMacVLanCreate() was successful - use this name= */ - ifname =3D g_strdup(ifnameRequested); - - } else if (!isAutoName) { - /* couldn't open ifnameRequested, but it wasn't an - * autogenerated named, so there is nothing else to - * try - fail and return. - */ - return -1; - } - } + ifname =3D g_strdup(ifnameRequested); } =20 - if (!ifname) { - /* ifnameRequested was NULL, or it was an already in use - * autogenerated name, so now we look for an unused - * autogenerated name. - */ - virNetDevGenNameType type; - if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) - type =3D VIR_NET_DEV_GEN_NAME_MACVTAP; - else - type =3D VIR_NET_DEV_GEN_NAME_MACVLAN; + if (flags & VIR_NETDEV_MACVLAN_CREATE_WITH_TAP) + type =3D VIR_NET_DEV_GEN_NAME_MACVTAP; + else + type =3D VIR_NET_DEV_GEN_NAME_MACVLAN; =20 - if (virNetDevGenerateName(&ifname, type) < 0 || - virNetDevMacVLanCreate(ifname, macaddress, - linkdev, macvtapMode, flags) < 0) - return -1; + if (virNetDevGenerateName(&ifname, type) < 0 || + virNetDevMacVLanCreate(ifname, macaddress, + linkdev, macvtapMode, flags) < 0) { + return -1; } =20 - /* all done creating the device */ - if (virNetDevVPortProfileAssociate(ifname, virtPortProfile, macaddress, --=20 2.28.0 From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608082068; cv=none; d=zohomail.com; s=zohoarc; b=U1t6AhW3k4Ew+2qjymv2RchBMSCvOol1Ijkv5lqxZbRtYilHf7TD0jhIj1gAXAyE6mzdptaQRVlTrsff939vH+uOVyAqxMobQHGzIaQdNXtANtA4h8d7Rj54sIRTd6qN3e+TcwNLfZOorR09zUZmm/dWaTNsgeHA0IJT3LJNx7M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608082068; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hFns5KE54hX7T0IYN/vYqPFGvZ7cB/CJk+6PG7G0qcA=; b=eu1BL3sfvj88IJ9LayF7+iETFhKZ1DpgfLNrBwGmggIQaQxrV0YjYgqTgPsm0QjMPX/TFoPxlUGZL5zXE3m5eCaEITNVKmCe5bILvwcv02ShuUjifXDZL4GfMCuAoFCkq5BM8k5Bo0MAaYZtc8RMlyKJGGtbTrQz1SPpwvarLx0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 160808206887348.75123179593402; Tue, 15 Dec 2020 17:27:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-4ukpwdLQMvWfBQ5K9KQlNg-1; Tue, 15 Dec 2020 20:27:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6873D1005D44; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 456A960C17; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0E5421809CA1; Wed, 16 Dec 2020 01:27:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BG1RUL1026619 for ; Tue, 15 Dec 2020 20:27:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id CECE95D9E3; Wed, 16 Dec 2020 01:27:30 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-38.phx2.redhat.com [10.3.112.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 868F05D9D7; Wed, 16 Dec 2020 01:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608082067; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hFns5KE54hX7T0IYN/vYqPFGvZ7cB/CJk+6PG7G0qcA=; b=IBUxV+c4vJ2v+ETNCDd2/l7T9sXhV5U8JPXek4NH6tFzdT1UVZsruJw9k705ifBOy1EMtE s37QszzGFHPY1EyN8G1W9PTsMnS9Shgiu2fMXaJXZml4Pt1bsVAYsaZdzkPM/5eLLoDHyN 5R01sKjxbQ92tK5AVTwlYpCqF8LEcMw= X-MC-Unique: 4ukpwdLQMvWfBQ5K9KQlNg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 5/5] util: minor comment/formatting changes to virNetDevTapCreate() Date: Tue, 15 Dec 2020 20:27:23 -0500 Message-Id: <20201216012723.176100-6-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The comment about auto-generating names was obsoleted by recent changes, and there was an unnecessary set of braces around a single line conditional body. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/util/virnetdevtap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index cca2f614fe..8649978e53 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -174,15 +174,14 @@ int virNetDevTapCreate(char **ifname, int ret =3D -1; int fd =3D -1; =20 - /* if ifname is "vnet%d", then auto-generate a name for the new + /* if ifname is empty, then auto-generate a name for the new * device (the kernel could do this for us, but has a bad habit of * immediately re-using names that have just been released, which - * can lead to race conditions). - * if ifname is just a user-provided name, virNetDevGenerateName - * leaves it unchanged. */ - if (virNetDevGenerateName(ifname, VIR_NET_DEV_GEN_NAME_VNET) < 0) { + * can lead to race conditions). if ifname is just a + * user-provided name, virNetDevGenerateName leaves it + * unchanged. */ + if (virNetDevGenerateName(ifname, VIR_NET_DEV_GEN_NAME_VNET) < 0) return -1; - } =20 if (!tunpath) tunpath =3D "/dev/net/tun"; --=20 2.28.0 From nobody Tue May 14 08:23:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1608149599; cv=none; d=zohomail.com; s=zohoarc; b=LsF2TY5s/A2i8Da3vqy/veUpAuSyVURKgQH611UE8qzjccWAalQv7C5gSdfKH8X1HTcT/ujk4IMCMcg23nd7BQZv0jJ3f/vmt8IfpL0qS0xAxno4m0pzue67hZfbfSDyJq5EgUk1nrvbOC9qqYZgRGcS73xR710clGDyHPpGqE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1608149599; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NTLFrAgxRnW2k2npeK+m/VOjRXMnqrlPvaK/4pQn51E=; b=beEex569zbFfZJOohZzDW4EveBvLLmZQTyBrXMUPacPDNb1otMBlblmm/Itr37JPumKNxNwcvILe08SyHYfwZqHkz/QDHNeU7MW5bE5do1vnGQ7cv7E+tiNJa1OmO9pxx/9NtGj8N4d8DHA1C39lM3gOy9UOZzf2cVyxtF8YFMc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1608149599098901.6019850285827; Wed, 16 Dec 2020 12:13:19 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-312-zqSJ_5rcNgK4LmdytbX5kQ-1; Wed, 16 Dec 2020 15:13:15 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2629210054FF; Wed, 16 Dec 2020 20:13:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7F7825D722; Wed, 16 Dec 2020 20:13:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4A8B1180954D; Wed, 16 Dec 2020 20:13:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0BGKD5o8032099 for ; Wed, 16 Dec 2020 15:13:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9EFC917577; Wed, 16 Dec 2020 20:13:05 +0000 (UTC) Received: from vhost2.laine.org (ovpn-114-237.phx2.redhat.com [10.3.114.237]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54A9A18222; Wed, 16 Dec 2020 20:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608149597; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NTLFrAgxRnW2k2npeK+m/VOjRXMnqrlPvaK/4pQn51E=; b=I1tZxKteS4VfvtUKIpoxHtSCDKgRRrlmIKIqOJDeL1LbmWx6KIE+oHRioQZv+lhi5PH5K2 3vBtjADtuago27gdWnbFxwz03exOfl3nC8AA+Asqreh2p30a/mTqtVR4YbW1b8XxtVlRc9 tIKS7RFfHqvmsyLT9SiiaeD5146ez08= X-MC-Unique: zqSJ_5rcNgK4LmdytbX5kQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 6/5] lxc: skip the netdev autogenerated name counter past existing devices Date: Wed, 16 Dec 2020 15:13:00 -0500 Message-Id: <20201216201300.424382-1-laine@redhat.com> In-Reply-To: <20201216012723.176100-1-laine@redhat.com> References: <20201216012723.176100-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Shi Lei X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" the lxc driver uses virNetDevGenerateName() for its veth device names since patch 2dd0fb492, so it should be using virNetDevReserveName() during daemon restart/reconnect to skip over the device names that are in use. Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- I meant to mention this during review of the abovementioned patch, but forg= ot. (NB: a couple days ago I *removed* similar code from this same spot, but it was trying to reserve the name of macvlan devices; a macvlan device is moved into the container's namespace at startup, so it is not visible to the host anyway. This new case is for the 1/2 of a veth pair that does remain in the host's namespace (type=3D'bridge|network|ethernet' use a veth pair) src/lxc/lxc_process.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 0f7c929535..a842ac91c5 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1640,6 +1640,30 @@ virLXCProcessReconnectNotifyNets(virDomainDefPtr def) for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; =20 + /* type=3D'bridge|network|ethernet' interfaces may be using an + * autogenerated netdev name, so we should update the counter + * for autogenerated names to skip past this one. + */ + switch (virDomainNetGetActualType(net)) { + case VIR_DOMAIN_NET_TYPE_BRIDGE: + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + virNetDevReserveName(net->ifname); + break; + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_VDPA: + case VIR_DOMAIN_NET_TYPE_LAST: + break; + } + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { if (!conn && !(conn =3D virGetConnectNetwork())) continue; --=20 2.29.2