From nobody Thu Apr 18 10:35:41 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=1610091798; cv=none; d=zohomail.com; s=zohoarc; b=QxFUvNdKlDMdBRcMq2MmxeQtXEXLWDau7vqSfsGBbup7V38YJsb1iM9K8aYin8f8tZbLSVeTNsHt2dgTNGHNV4PsJ4UqiF0GFO05zc3+EP82JFVPO2KqrjuPkVrI/+60QhCA7lRXerNRaKjEPfZvbCIIROVnNIvly+tTEgY9xqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610091798; 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=J/bJCqG6pwK0GucEPMgU9KQ3zn0JriqgN3wS+IOHf+1sQIiD9AQf+tzrBMwpLcS1W2ZJYJoYfJ7oKA/KryOHe1zv1a8ttjhyHASDB1B9eW10L6NW1wt1d0d4doz/fuxTpWoaIyKp6sD56vssUBdKSCExF4nVZpp7RC5ZebFnAwY= 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 1610091798206926.3322222736637; Thu, 7 Jan 2021 23:43:18 -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-7dsImKRSNueTsq7-mmsNhQ-1; Fri, 08 Jan 2021 02:43:14 -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 2905D1572A; Fri, 8 Jan 2021 07:43:08 +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 D01D6629C0; Fri, 8 Jan 2021 07:43:07 +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 880B34A7C6; Fri, 8 Jan 2021 07:43:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1087gvmh031309 for ; Fri, 8 Jan 2021 02:42:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 047292C305; Fri, 8 Jan 2021 07:42:57 +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 C0D845B6A7 for ; Fri, 8 Jan 2021 07:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610091797; 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=NntAtkkpjI3c0ewP3So3KfvioSXMkqQSvvXktPBfecnHcI/7MfpxZW8j8E9+4/y7S7MZ6m eRwssAeg95qbfli8Eo5y14YBsvyd9CzD1LHOjCond/YHgkovh1DDai/gHOoQDgQFacdjrE x6A4A7h+/dJldGEXnFGcDxBYP5XykHc= X-MC-Unique: 7dsImKRSNueTsq7-mmsNhQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 1/2] call virDomainNetNotifyActualDevice() for all interface types Date: Fri, 8 Jan 2021 02:42:47 -0500 Message-Id: <20210108074248.60395-2-laine@redhat.com> In-Reply-To: <20210108074248.60395-1-laine@redhat.com> References: <20210108074248.60395-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.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" 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 Thu Apr 18 10:35:41 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=1610091800; cv=none; d=zohomail.com; s=zohoarc; b=Lp6yiAaLt5PmVyZImjGFBx5yG7a/jn/KKpSmTQsJpF+08LRCbDYGz3jDmGgmxrhdQ0IReDutFww2ElzS0cNV2RPZ0lFo6OpfgUSFRYpuYGg+RgB9C2i04Z4TMEluroipJdwLgj6o16ExUhJ5fy+Fs1cdLI1/7d36Ug6wpjnck54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610091800; 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=uZ30VnnztvX/L4dHY4VO6xvgPMhdmhUToc7Z1Ps5D8g=; b=i9sodtO5uUFVLwiLwC2v8t0Tk/6SCO3YUlu/FFyMh6zJGR/JDR0dNJNEbS1dmaMyuDYPEBH9+lfjdUhWAowvIDEncd11qRPyJ+HYIYIj58VRFDMgpgv/GFc8mYfahFBul5+IYy26TZMXiB6SaO8xJbeFbORHotBq/8DaWy1S0U8= 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 1610091800658188.27842380614038; Thu, 7 Jan 2021 23:43:20 -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-498-B3ujlQJlPkSyq6NsCx6mPQ-1; Fri, 08 Jan 2021 02:43:17 -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 ED8F11842144; Fri, 8 Jan 2021 07:43:11 +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 CACDF7092B; Fri, 8 Jan 2021 07:43:11 +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 89A7C1809CA0; Fri, 8 Jan 2021 07:43:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1087gvgP031314 for ; Fri, 8 Jan 2021 02:42:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5F24E2C305; Fri, 8 Jan 2021 07:42:57 +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 277E25B6A7 for ; Fri, 8 Jan 2021 07:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610091799; 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=uZ30VnnztvX/L4dHY4VO6xvgPMhdmhUToc7Z1Ps5D8g=; b=bYi2bCrssCLY4SEXedidNCQhutjMPgXwjxB5w1rQCIiYqOGy9vfW5VQno4JzELmc0EFAtf 5zHRgBqS5elJwruWY5mGFoDH+4gRhmNIwdE6m0eO2O3HvXipdnRsSY3Xtp6pqKnc+zCfSY RJgtScH7v1OwABmHQ5lvD0i0jGpmARE= X-MC-Unique: B3ujlQJlPkSyq6NsCx6mPQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 2/2] use g_autoptr for (almost) all virConnectPtrs used with virGetConnectNetwork() Date: Fri, 8 Jan 2021 02:42:48 -0500 Message-Id: <20210108074248.60395-3-laine@redhat.com> In-Reply-To: <20210108074248.60395-1-laine@redhat.com> References: <20210108074248.60395-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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" two occurences (in libxl_domain.c) couldn't be changed due to a compile error. I'll send those in a separate mail looking for an explanation... Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 3 +-- src/libxl/libxl_driver.c | 15 +++++---------- src/lxc/lxc_driver.c | 17 +++++------------ src/lxc/lxc_process.c | 10 +++------- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d90945b1d8..bdd695322b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30966,7 +30966,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())) @@ -30986,7 +30986,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_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