From nobody Fri May 3 09:57:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1486980643877268.84810784308945; Mon, 13 Feb 2017 02:10:43 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DA7D9n028719; Mon, 13 Feb 2017 05:07:14 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1DA7Bih031385 for ; Mon, 13 Feb 2017 05:07:11 -0500 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1DA7BDs009347 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 13 Feb 2017 05:07:11 -0500 Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89D2F81222; Mon, 13 Feb 2017 10:07:10 +0000 (UTC) Received: from linux-xpcv.apac.novell.com (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Mon, 13 Feb 2017 03:07:00 -0700 From: Lin Ma To: libvir-list@redhat.com Date: Mon, 13 Feb 2017 18:06:51 +0800 Message-Id: <20170213100651.2157-1-lma@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Feb 2017 10:07:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 13 Feb 2017 10:07:10 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'lma@suse.com' RCPT:'' X-RedHat-Spam-Score: -1.501 (BAYES_50, RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH RESEND] Interface: return appropriate status for bridge device 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In function udevInterfaceIsActive, The current design relies on the sys attribute 'operstate' to determine whether the interface is active. For the device node of virtual network(say virbr0), There is already a dummy tap device to maintain a fixed mac on it, So it's available and its status should be considered as active. But if no anyelse tap device connects to it, The value of operstate of virbr0 in sysfs is 'down', So udevInterfaceIsActive returns 0, It causes 'virsh iface-list --all' to report the status of virbr0 as 'inactive'. This patch fixes the issue by counting slave devices for bridge device. Signed-off-by: Lin Ma --- src/interface/interface_backend_udev.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 5d0fc64..9ac4674 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -1127,6 +1127,11 @@ udevInterfaceIsActive(virInterfacePtr ifinfo) struct udev_device *dev; virInterfaceDefPtr def =3D NULL; int status =3D -1; + struct dirent **member_list =3D NULL; + const char *devtype; + int member_count =3D 0; + char *member_path; + size_t i; =20 dev =3D udev_device_new_from_subsystem_sysname(udev, "net", ifinfo->name); @@ -1146,6 +1151,23 @@ udevInterfaceIsActive(virInterfacePtr ifinfo) /* Check if it's active or not */ status =3D STREQ(udev_device_get_sysattr_value(dev, "operstate"), "up"= ); =20 + if (!status) { + devtype =3D udev_device_get_devtype(dev); + if (STREQ_NULLABLE(devtype, "bridge")) { + if (virAsprintf(&member_path, "%s/%s", + udev_device_get_syspath(dev), "brif") < 0) + goto cleanup; + member_count =3D scandir(member_path, &member_list, + udevBridgeScanDirFilter, alphasort); + if (member_count > 0) + status =3D 1; + for (i =3D 0; i < member_count; i++) + VIR_FREE(member_list[i]); + VIR_FREE(member_list); + VIR_FREE(member_path); + } + } + udev_device_unref(dev); =20 cleanup: --=20 2.9.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list