From nobody Sat Apr 20 05:04:32 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=1610120349; cv=none; d=zohomail.com; s=zohoarc; b=LDgjii5kRH6VhTmzQojbLiIeekI5bpRb8OR/ibqTtXMg2lRf8IsEngQaB04LWrZ4l34NIRVehq8G102I+ohxbidq0/0xPTkmOG96hKkBLFn23XrSVrSnxG4TWA4ZfPn/1gGdPx1+n3eaWos4ZrfhCMLMxcJk71Da9ihHk8CV7VU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610120349; h=Content-Type:Content-Transfer-Encoding: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=4UAk2GyW5FZcB4igViBJ1asZsfuRq5WlFDjSEVQqg0A=; b=SZ599ntGn2pOgYERSBIbVCtLGCUkIuxXbmDsolL/j7tAW4k6eqTOgi1flGYVTXa4/V08bFQ+PizYFm+RKUtPX4hebZi4tCSk4WCsNXFKjq+xR8Cs7TWa0rgVupwaDwAePaLMRDCea5665OVNCI9j1qs4TjZSOLXwvIEuTCGF9Io= 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 1610120349037639.513730983537; Fri, 8 Jan 2021 07:39:09 -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-529-_mQpqOPNMOSI0CAIg2gaZw-1; Fri, 08 Jan 2021 10:39:05 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32BF31005513; Fri, 8 Jan 2021 15:38:59 +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 D8A7318035; Fri, 8 Jan 2021 15:38:58 +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 BBE9C180954D; Fri, 8 Jan 2021 15:38:56 +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 108FctVm013876 for ; Fri, 8 Jan 2021 10:38:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5FB8C18035; Fri, 8 Jan 2021 15:38:55 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-90.phx2.redhat.com [10.3.112.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2891B5E1A7 for ; Fri, 8 Jan 2021 15:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610120347; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=4UAk2GyW5FZcB4igViBJ1asZsfuRq5WlFDjSEVQqg0A=; b=He2G7/zUJa8lMdJJOAA0nCr10erZuRBSZZj2j7wWgGX3/VDTSikFKiKZN85dxZGm5RcLYZ HEylqcA3nmS7ZvtTKFTM+/W8h9keFQ0+INHbB1ea5cbO6A+ZK66T9g3i0ES+4tFO8T/FbF RlP99wYpAUheqHx06mDucepZig0VUSk= X-MC-Unique: _mQpqOPNMOSI0CAIg2gaZw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt Patch v2 1/4] conf: make virDomainNetNotifyActualDevice() callable for all interface types Date: Fri, 8 Jan 2021 10:38:46 -0500 Message-Id: <20210108153849.105584-2-laine@redhat.com> In-Reply-To: <20210108153849.105584-1-laine@redhat.com> References: <20210108153849.105584-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 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.16 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 bridge reattach functionality in this function should be called for interface types other than just type=3D'network', so make it callable for any type - it just becomes a NOP for types where no action is needed. In the case of we need to create a port in the network driver, and for both type=3D'network and type=3D'bridge' we need to reattach the bridge device (note that virDomainNetGetActualBridgeName() gets the bridge name from the appropriate (and different!) location for either type of interface). All other interfaces currently require no action. modifying callers of this function to actually call it for all interface types is in the next patch. For now the behavior should be identical pre and post-patch. (NB: the conn argument can now legitimately be NULL, so we need to change the ATTRIBUTE_NONNULL() directive for the function's declaration - I noticed when making this change that argument 3 (the NetDefPtr) could never be NULL, so I added ATTRIBUTE_NONNULL(3) while removing ATTRIBUTE_NONNULL(1) (conn)). Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 7 ++++--- src/conf/domain_conf.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 472ce79e67..40ca20be33 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30933,8 +30933,9 @@ virDomainNetNotifyActualDevice(virConnectPtr conn, { virDomainNetType actualType =3D virDomainNetGetActualType(iface); =20 - if (virDomainNetCreatePort(conn, dom, iface, - VIR_NETWORK_PORT_CREATE_RECLAIM) < 0) { + if (iface->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && conn + && virDomainNetCreatePort(conn, dom, iface, + VIR_NETWORK_PORT_CREATE_RECLAIM) < 0) { return; } =20 @@ -30946,7 +30947,7 @@ virDomainNetNotifyActualDevice(virConnectPtr conn, * (final arg to virNetDevTapReattachBridge()) */ ignore_value(virNetDevTapReattachBridge(iface->ifname, - iface->data.network.actual= ->data.bridge.brname, + virDomainNetGetActualBridg= eName(iface), &iface->mac, dom->uuid, virDomainNetGetActualVirtP= ortProfile(iface), virDomainNetGetActualVlan(= iface), diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 59bf8a12b3..ec43bbe186 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3875,7 +3875,7 @@ void virDomainNetNotifyActualDevice(virConnectPtr conn, virDomainDefPtr dom, virDomainNetDefPtr iface) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 int virDomainNetReleaseActualDevice(virConnectPtr conn, --=20 2.29.2 From nobody Sat Apr 20 05:04:32 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=1610120362; cv=none; d=zohomail.com; s=zohoarc; b=RuP0lpliozVQDWPfTuw+zUr3TDyd13JitPd/ATHT1k2iA/gu1/N3aSksSQF0GJN9hKeOXP2nuTuIsO9ui1F9+AL9anFCtYGnlWxGFEWeTPHrxpTnLcijCoBnHnXlnFQksCHM7w25jcGH4ucrIE8wU3FJ8h95gThrSkA5u/e3764= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610120362; h=Content-Type:Content-Transfer-Encoding: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=2q+y7K3jJ51DV3mBrKqLsaN6e1n7X2XeiOWM/zgiUtM=; b=i1xaipo2dodFCcOD5rRmF3f0b6uKh3EY8lNSoilaLAoWKCRTr6y/wsogdnCPECELNOefSjeP32RHeNnxvvz36tkSj9W8zy4eN/lA1dO5YPN2+rGyhWsqcc5Ej6ODxZ+4xmg/ZdyY92VZjn78ZrpEn4BSz2mN0bMrHBuWo/Gm0SQ= 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 1610120362335697.8097467603016; Fri, 8 Jan 2021 07:39:22 -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-52-m6ilHLfzNbu8gjKrOd8SRA-1; Fri, 08 Jan 2021 10:39:18 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B724107ACE4; Fri, 8 Jan 2021 15:39:13 +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 157235D9C0; Fri, 8 Jan 2021 15:39:13 +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 D1C981809CA1; Fri, 8 Jan 2021 15:39:12 +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 108Fct7i013881 for ; Fri, 8 Jan 2021 10:38:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id B922418035; Fri, 8 Jan 2021 15:38:55 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-90.phx2.redhat.com [10.3.112.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 827871B058 for ; Fri, 8 Jan 2021 15:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610120361; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=2q+y7K3jJ51DV3mBrKqLsaN6e1n7X2XeiOWM/zgiUtM=; b=HWm1ekyTdB83uOkXP9rkfuq4Sqq9VNMPRS4objxcVY3epercayV36yPEYBQ6Pe6xVO+cnP mGCYKbihMffsMdE8+BI7/mwV77yThYlTSGqnU5DslaK3lBwTkhJ7n7E63jPB6behj/k4Rh PTMb7SDDbdjj5CxbQUo0prPy5SbK+oc= X-MC-Unique: m6ilHLfzNbu8gjKrOd8SRA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt Patch v2 2/4] call virDomainNetNotifyActualDevice() for all interface types Date: Fri, 8 Jan 2021 10:38:47 -0500 Message-Id: <20210108153849.105584-3-laine@redhat.com> In-Reply-To: <20210108153849.105584-1-laine@redhat.com> References: <20210108153849.105584-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 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.14 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" Now that this function can be called regardless of interface type (and whether or not we have a conn for the network driver), let's actually call it for all interface types. This will assure that we re-connect any disconnected bridge devices for as mentioned in https://bugzilla.redhat.com/show_bug.cgi?id=3D1730084#c26 (until now we've only been reconnecting bridge devices for ) Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/libxl/libxl_driver.c | 9 ++++----- src/lxc/lxc_process.c | 9 ++++----- src/qemu/qemu_process.c | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d58af1a869..40d8c3d174 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -367,11 +367,10 @@ libxlReconnectNotifyNets(virDomainDefPtr def) if (virDomainNetGetActualType(net) =3D=3D VIR_DOMAIN_NET_TYPE_DIRE= CT) virNetDevReserveName(net->ifname); =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (!conn && !(conn =3D virGetConnectNetwork())) - continue; - virDomainNetNotifyActualDevice(conn, def, net); - } + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && !conn) + conn =3D virGetConnectNetwork(); + + virDomainNetNotifyActualDevice(conn, def, net); } =20 virObjectUnref(conn); diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 2266e2cc40..0b6895bbd4 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1663,11 +1663,10 @@ virLXCProcessReconnectNotifyNets(virDomainDefPtr de= f) break; } =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (!conn && !(conn =3D virGetConnectNetwork())) - continue; - virDomainNetNotifyActualDevice(conn, def, net); - } + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && !conn) + conn =3D virGetConnectNetwork(); + + virDomainNetNotifyActualDevice(conn, def, net); } =20 virObjectUnref(conn); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f0a698ba3d..202d867289 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3411,11 +3411,10 @@ qemuProcessNotifyNets(virDomainDefPtr def) break; } =20 - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - if (!conn && !(conn =3D virGetConnectNetwork())) - continue; - virDomainNetNotifyActualDevice(conn, def, net); - } + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && !conn) + conn =3D virGetConnectNetwork(); + + virDomainNetNotifyActualDevice(conn, def, net); } } =20 --=20 2.29.2 From nobody Sat Apr 20 05:04:32 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=1610120365; cv=none; d=zohomail.com; s=zohoarc; b=GqPqSj1xHOiDQ5hLzr/2NT1RBNLVzRsVXShAGlMKH8UN+fzZj2EV1YvRnmaX0yBXZgSDUkFjGqazidARRpVQxpjo1xs9JemNan8hbtB9M3RuxlGWgkCp+4Npt9pmTfY2bvT6srF3PSY+g81ABW6C0B9D4Gmd58uY1vL/IYXM8AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610120365; h=Content-Type:Content-Transfer-Encoding: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=xaLNyUpp4/CceTVJH/qoCv4nOONPA6/D80qKFUaY6sE=; b=GHlHuXBdRFHYR8t7s5OqagSW7+SwPfHei3IPIPyxkV0lHXTCaDt6a9rc9wvcphdaW6Re+OvGTfYtaRiWe5s9NQil3EUDkCVl3eh2ikyhN3QhjrI8nFRsePhlxZxnj2AqXuS1F5JcDAAtoejW+s679tqgwNVMPqcJ3ho+mMVfsPY= 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 1610120365281754.2016680715406; Fri, 8 Jan 2021 07:39:25 -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-330-iqTA2CKkMySkVo_GBszJqw-1; Fri, 08 Jan 2021 10:39:21 -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 0CC50801B1D; Fri, 8 Jan 2021 15:39:16 +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 DF6BF60D79; Fri, 8 Jan 2021 15:39:15 +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 A894D1809CA4; Fri, 8 Jan 2021 15:39:15 +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 108FcuGN013886 for ; Fri, 8 Jan 2021 10:38:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 203FB18035; Fri, 8 Jan 2021 15:38:56 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-90.phx2.redhat.com [10.3.112.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCB015E1A7 for ; Fri, 8 Jan 2021 15:38:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610120364; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=xaLNyUpp4/CceTVJH/qoCv4nOONPA6/D80qKFUaY6sE=; b=Pj4zQCPSneAFO0++oCqCHPBiRkz6x1ga1JZxxLRv6O5T02moWUM+Gs1iZ1pqzarFXkSWRi RhJEwJAU7pYH4VkKiltNawJa51bkYX97JspXavtbClKEu9txa0glXXbg4+dKpEWuP/AZnx CXbQ9kkZgn2MPZDXnUsil16JD5Lt+00= X-MC-Unique: iqTA2CKkMySkVo_GBszJqw-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt Patch v2 3/4] use g_autoptr for all virConnectPtrs used with virGetConnectNetwork() Date: Fri, 8 Jan 2021 10:38:48 -0500 Message-Id: <20210108153849.105584-4-laine@redhat.com> In-Reply-To: <20210108153849.105584-1-laine@redhat.com> References: <20210108153849.105584-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 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik Signed-off-by: Laine Stump --- src/conf/domain_conf.c | 3 +-- src/libxl/libxl_domain.c | 7 +++---- src/libxl/libxl_driver.c | 15 +++++---------- src/lxc/lxc_driver.c | 17 +++++------------ src/lxc/lxc_process.c | 10 +++------- 5 files changed, 17 insertions(+), 35 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 40ca20be33..349fc28c2a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31040,7 +31040,7 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr ifac= e, virNetworkPortPtr port =3D NULL; virTypedParameterPtr params =3D NULL; int nparams =3D 0; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int ret =3D -1; =20 if (!(conn =3D virGetConnectNetwork())) @@ -31060,7 +31060,6 @@ virDomainNetBandwidthUpdate(virDomainNetDefPtr ifac= e, =20 ret =3D 0; cleanup: - virObjectUnref(conn); virTypedParamsFree(params, nparams); virObjectUnref(port); virObjectUnref(net); diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ab838b317c..c046fcb3f7 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -25,6 +25,7 @@ #include "libxl_domain.h" #include "libxl_capabilities.h" =20 +#include "datatypes.h" #include "viralloc.h" #include "virfile.h" #include "virerror.h" @@ -849,7 +850,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, char *file; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; unsigned int hostdev_flags =3D VIR_HOSTDEV_SP_PCI; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; =20 #ifdef LIBXL_HAVE_PVUSB hostdev_flags |=3D VIR_HOSTDEV_SP_USB; @@ -936,7 +937,6 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, } =20 virDomainObjRemoveTransientDef(vm); - virObjectUnref(conn); } =20 /* @@ -1050,7 +1050,7 @@ static int libxlNetworkPrepareDevices(virDomainDefPtr def) { size_t i; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; int ret =3D -1; =20 for (i =3D 0; i < def->nnets; i++) { @@ -1096,7 +1096,6 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) =20 ret =3D 0; cleanup: - virObjectUnref(conn); return ret; } =20 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 40d8c3d174..5bd3614e21 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -355,7 +355,7 @@ static void libxlReconnectNotifyNets(virDomainDefPtr def) { size_t i; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; =20 for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; @@ -372,8 +372,6 @@ libxlReconnectNotifyNets(virDomainDefPtr def) =20 virDomainNetNotifyActualDevice(conn, def, net); } - - virObjectUnref(conn); } =20 =20 @@ -3403,7 +3401,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, libxl_device_nic nic; int ret =3D -1; char mac[VIR_MAC_STRING_BUFLEN]; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; virErrorPtr save_err =3D NULL; =20 libxl_device_nic_init(&nic); @@ -3478,7 +3476,6 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && conn) virDomainNetReleaseActualDevice(conn, vm->def, net); } - virObjectUnref(conn); virObjectUnref(cfg); virErrorRestore(&save_err); return ret; @@ -3904,13 +3901,11 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr dr= iver, libxl_device_nic_dispose(&nic); if (!ret) { if (detach->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - virConnectPtr conn =3D virGetConnectNetwork(); - if (conn) { + g_autoptr(virConnect) conn =3D virGetConnectNetwork(); + if (conn) virDomainNetReleaseActualDevice(conn, vm->def, detach); - virObjectUnref(conn); - } else { + else VIR_WARN("Unable to release network device '%s'", NULLSTR(= detach->ifname)); - } } virDomainNetRemove(vm->def, detachidx); } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 88d3890de7..4416acf923 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3463,14 +3463,9 @@ lxcDomainAttachDeviceNetLive(virLXCDriverPtr driver, * to the one defined in the network definition. */ if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - virConnectPtr netconn =3D virGetConnectNetwork(); - if (!netconn) + g_autoptr(virConnect) netconn =3D virGetConnectNetwork(); + if (!netconn || virDomainNetAllocateActualDevice(netconn, vm->def,= net) < 0) return -1; - if (virDomainNetAllocateActualDevice(netconn, vm->def, net) < 0) { - virObjectUnref(netconn); - return -1; - } - virObjectUnref(netconn); } =20 /* final validation now that actual type is known */ @@ -4028,13 +4023,11 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, if (!ret) { virErrorPreserveLast(&save_err); if (detach->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { - virConnectPtr conn =3D virGetConnectNetwork(); - if (conn) { + g_autoptr(virConnect) conn =3D virGetConnectNetwork(); + if (conn) virDomainNetReleaseActualDevice(conn, vm->def, detach); - virObjectUnref(conn); - } else { + else VIR_WARN("Unable to release network device '%s'", NULLSTR(= detach->ifname)); - } } virDomainNetRemove(vm->def, detachidx); virDomainNetDefFree(detach); diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 0b6895bbd4..cbc04a3dcd 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -172,7 +172,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, virLXCDomainObjPrivatePtr priv =3D vm->privateData; const virNetDevVPortProfile *vport =3D NULL; virLXCDriverConfigPtr cfg =3D virLXCDriverGetConfig(driver); - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; =20 VIR_DEBUG("Cleanup VM name=3D%s pid=3D%d reason=3D%d flags=3D0x%x", vm->def->name, (int)vm->pid, (int)reason, flags); @@ -281,7 +281,6 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, virDomainObjRemoveTransientDef(vm); =20 virObjectUnref(cfg); - virObjectUnref(conn); } =20 =20 @@ -571,7 +570,7 @@ virLXCProcessSetupInterfaces(virLXCDriverPtr driver, size_t niface =3D 0; virDomainNetDefPtr net; virDomainNetType type; - virConnectPtr netconn =3D NULL; + g_autoptr(virConnect) netconn =3D NULL; virErrorPtr save_err =3D NULL; =20 *veths =3D g_new0(char *, def->nnets + 1); @@ -680,7 +679,6 @@ virLXCProcessSetupInterfaces(virLXCDriverPtr driver, } virErrorRestore(&save_err); } - virObjectUnref(netconn); return ret; } =20 @@ -1634,7 +1632,7 @@ static void virLXCProcessReconnectNotifyNets(virDomainDefPtr def) { size_t i; - virConnectPtr conn =3D NULL; + g_autoptr(virConnect) conn =3D NULL; =20 for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; @@ -1668,8 +1666,6 @@ virLXCProcessReconnectNotifyNets(virDomainDefPtr def) =20 virDomainNetNotifyActualDevice(conn, def, net); } - - virObjectUnref(conn); } =20 =20 --=20 2.29.2 From nobody Sat Apr 20 05:04:32 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=1610120347; cv=none; d=zohomail.com; s=zohoarc; b=WpZcNJJ0DXBoA9R1aKYeROZ453r7Pll2uCNc25euiZ6wMjRu431jWHtxA4K3YbPkl68MC3SV4rGT6Lrw6IDc+JrVx142kyi5gBmTxfMh2e5zNnQ/xGz0nG0jfGMknwvWX1NWeu/T2oBReLeJmF4sLunSP4AvLeSuLO4kSCaVRdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610120347; h=Content-Type:Content-Transfer-Encoding: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=v9vIXWp0mU+ZppfwDyw8VbE6vLSVd+vtK3u3WjlwLeI=; b=b2SdTreI9uHKG3Qhqb8jhbS96HbfJORTBpl+9NW++L2KvDEy+TBz2qd/vLOHmoRy/bFd/5DABkELgp4cEO2n864+QQasDHtk27cvs86wkuacfBTr4265S+aUeijNODZckqqYOKz4d8rqps6WgTT9FNI3iuCLEVHIyt7OvOQ4948= 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 1610120347955238.86770214705587; Fri, 8 Jan 2021 07:39:07 -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-404-2CRvT9DHNGuClbl1K6WIAg-1; Fri, 08 Jan 2021 10:39:04 -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 89234800D53; Fri, 8 Jan 2021 15:38:59 +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 D967460CEE; Fri, 8 Jan 2021 15:38:58 +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 58F0B4A7C6; Fri, 8 Jan 2021 15:38:58 +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 108FcuBa013891 for ; Fri, 8 Jan 2021 10:38:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7958E18035; Fri, 8 Jan 2021 15:38:56 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-90.phx2.redhat.com [10.3.112.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 432B45E1A7 for ; Fri, 8 Jan 2021 15:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610120346; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=v9vIXWp0mU+ZppfwDyw8VbE6vLSVd+vtK3u3WjlwLeI=; b=hmsi2S+z6RThSO5w9JHpJwXxOMgGpoaVq7vksE5KH9MK38Wn5lgbvQ5s6t8l0nlCGVBQIA ko5FB+gLcAaeSKNZJnB9CCcs6+ChuBcS5bbJvSmzS18mg17OoXh7o2VSv+JE1S9P3fMw62 cAPgT0yX3nuKl5CDXEkev5sQ1aU7MBA= X-MC-Unique: 2CRvT9DHNGuClbl1K6WIAg-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt Patch v2 4/4] libxl: remove a now-unnecessary ret variable and cleanup: label. Date: Fri, 8 Jan 2021 10:38:49 -0500 Message-Id: <20210108153849.105584-5-laine@redhat.com> In-Reply-To: <20210108153849.105584-1-laine@redhat.com> References: <20210108153849.105584-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 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" Signed-off-by: Laine Stump Reviewed-by: Michal Privoznik --- src/libxl/libxl_domain.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index c046fcb3f7..afa21bf02e 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1051,7 +1051,6 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) { size_t i; g_autoptr(virConnect) conn =3D NULL; - int ret =3D -1; =20 for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr net =3D def->nets[i]; @@ -1063,9 +1062,9 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) */ if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { if (!conn && !(conn =3D virGetConnectNetwork())) - goto cleanup; + return -1; if (virDomainNetAllocateActualDevice(conn, def, net) < 0) - goto cleanup; + return -1; } =20 /* final validation now that actual type is known */ @@ -1090,13 +1089,11 @@ libxlNetworkPrepareDevices(virDomainDefPtr def) pcisrc->backend =3D VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN; =20 if (virDomainHostdevInsert(def, hostdev) < 0) - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 static void --=20 2.29.2