From nobody Sun Feb 8 20:17:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1584980048; cv=none; d=zohomail.com; s=zohoarc; b=kJOtXjEI8tGq8ir2vcGNYz3oOQ4Gv77dclurkWdexY5TkHCQKk64o4smetzevpYc7IbOVpVci7mF9PV1OTdW78AjWlDnlPIJ0jfTvEjsJXi62UxQHzrMNhe5hDD95+LU4LlIySoQxviXLGB7BCOXSA9rGKOG26F1tzE6AThpTWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584980048; 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=/XuJMXlfP0xwHa0bl0c6QK17odL9lsZaoqyxGhODWMw=; b=HiSnzy0n4wNVMRn3e6LTDMcv4vi1J50h3KZl1wIIwCbmriF3nUtC9ly1JfUc19HYBZ+W4Cu5bV2bdLiCW/quDDuitB6emJQDlv9pJVh/0QqoheQ5VND2KO9QvsZ9iyGhamBdTfCJKMi+QOPzgYn1DGNyo3iJ8+5inJ+vhhPsK+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1584980048341264.1602420310521; Mon, 23 Mar 2020 09:14:08 -0700 (PDT) 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-477-yHKyph8vOO--Uf6St4x-cg-1; Mon, 23 Mar 2020 12:14:00 -0400 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 1A120107ACCD; Mon, 23 Mar 2020 16:13:53 +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 DCF28BBBE6; Mon, 23 Mar 2020 16:13:52 +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 8597A863A8; Mon, 23 Mar 2020 16:13:52 +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 02NGDil0005250 for ; Mon, 23 Mar 2020 12:13:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B41294B30; Mon, 23 Mar 2020 16:13:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD39B9497F for ; Mon, 23 Mar 2020 16:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584980047; 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=/XuJMXlfP0xwHa0bl0c6QK17odL9lsZaoqyxGhODWMw=; b=dazpEMm7Q8yc2poVcEp2rSpVbAu2BOyu6dbBuF0LqWKwzPU8kwBKbK0DRpWUkJOct9ZeQg u8bEnsh7RUssq6qw5sPve13JIpNMx0kUGmGd6Rjs2NGMS3/2/9OrXIVJcA0N/dJxS34cvE FjWt5XqvNtJKU+w1VJ5jp5+PMxHBENA= X-MC-Unique: yHKyph8vOO--Uf6St4x-cg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH RESEND 5/5] bridge_driver: Replace and drop networkKillDaemon Date: Mon, 23 Mar 2020 17:13:34 +0100 Message-Id: In-Reply-To: References: 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 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" In the network driver code there's networkKillDaemon() which is the same as virProcessKillPainfully(). Replace the former with the later and drop what becomes unused function. Signed-off-by: Michal Privoznik Reviewed-by: Marc-Andr=C3=A9 Lureau --- src/network/bridge_driver.c | 106 ++++++------------------------------ 1 file changed, 18 insertions(+), 88 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ae52455761..f06099297a 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -966,67 +966,6 @@ static int networkConnectIsAlive(virConnectPtr conn G_= GNUC_UNUSED) } =20 =20 -/* networkKillDaemon: - * - * kill the specified pid/name, and wait a bit to make sure it's dead. - */ -static int -networkKillDaemon(pid_t pid, - const char *daemonName, - const char *networkName) -{ - size_t i; - int ret =3D -1; - const char *signame =3D "TERM"; - - /* send SIGTERM, then wait up to 3 seconds for the process to - * disappear, send SIGKILL, then wait for up to another 2 - * seconds. If that fails, log a warning and continue, hoping - * for the best. - */ - for (i =3D 0; i < 25; i++) { - int signum =3D 0; - if (i =3D=3D 0) { - signum =3D SIGTERM; - } else if (i =3D=3D 15) { - signum =3D SIGKILL; - signame =3D "KILL"; - } - if (kill(pid, signum) < 0) { - if (errno =3D=3D ESRCH) { - ret =3D 0; - } else { - VIR_WARN("Failed to terminate %s process %d " - "for network '%s' with SIG%s: %s", - daemonName, pid, networkName, signame, - g_strerror(errno)); - } - return ret; - } - /* NB: since networks have no reference count like - * domains, there is no safe way to unlock the network - * object temporarily, and so we can't follow the - * procedure used by the qemu driver of 1) unlock driver - * 2) sleep, 3) add ref to object 4) unlock object, 5) - * re-lock driver, 6) re-lock object. We may need to add - * that functionality eventually, but for now this - * function is rarely used and, at worst, leaving the - * network driver locked during this loop of sleeps will - * have the effect of holding up any other thread trying - * to make modifications to a network for up to 5 seconds; - * since modifications to networks are much less common - * than modifications to domains, this seems a reasonable - * tradeoff in exchange for less code disruption. - */ - g_usleep(20 * 1000); - } - VIR_WARN("Timed out waiting after SIG%s to %s process %d " - "(network '%s')", - signame, daemonName, pid, networkName); - return ret; -} - - /* the following does not build a file, it builds a list * which is later saved into a file */ @@ -1832,12 +1771,11 @@ static int networkRestartDhcpDaemon(virNetworkDriverStatePtr driver, virNetworkObjPtr obj) { - virNetworkDefPtr def =3D virNetworkObjGetDef(obj); pid_t dnsmasqPid =3D virNetworkObjGetDnsmasqPid(obj); =20 /* if there is a running dnsmasq, kill it */ if (dnsmasqPid > 0) { - networkKillDaemon(dnsmasqPid, "dnsmasq", def->name); + virProcessKillPainfully(dnsmasqPid, false); virNetworkObjSetDnsmasqPid(obj, -1); } /* now start dnsmasq if it should be started */ @@ -2066,23 +2004,19 @@ networkRefreshRadvd(virNetworkDriverStatePtr driver, { virNetworkDefPtr def =3D virNetworkObjGetDef(obj); dnsmasqCapsPtr dnsmasq_caps =3D networkGetDnsmasqCaps(driver); - char *radvdpidbase; + g_autofree char *radvdpidbase =3D NULL; + g_autofree char *pidfile =3D NULL; pid_t radvdPid; =20 /* Is dnsmasq handling RA? */ if (DNSMASQ_RA_SUPPORT(dnsmasq_caps)) { virObjectUnref(dnsmasq_caps); - radvdPid =3D virNetworkObjGetRadvdPid(obj); - if (radvdPid <=3D 0) - return 0; - /* radvd should not be running but in case it is */ - if ((networkKillDaemon(radvdPid, "radvd", def->name) >=3D 0) && - ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) - !=3D NULL)) { - virPidFileDelete(driver->pidDir, radvdpidbase); - VIR_FREE(radvdpidbase); + if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) && + (pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase)= )) { + /* radvd should not be running but in case it is */ + virPidFileForceCleanupPath(pidfile); + virNetworkObjSetRadvdPid(obj, -1); } - virNetworkObjSetRadvdPid(obj, -1); return 0; } virObjectUnref(dnsmasq_caps); @@ -2110,23 +2044,19 @@ static int networkRestartRadvd(virNetworkObjPtr obj) { virNetworkDefPtr def =3D virNetworkObjGetDef(obj); - char *radvdpidbase; - pid_t radvdPid =3D virNeworkObjGetRadvdPid(obj); + g_autofree char *radvdpidbase =3D NULL; + g_autofree char *pidfile =3D NULL; =20 - /* if there is a running radvd, kill it */ - if (radvdPid > 0) { - /* essentially ignore errors from the following two functions, - * since there's really no better recovery to be done than to - * just push ahead (and that may be exactly what's needed). - */ - if ((networkKillDaemon(radvdPid, "radvd", def->name) >=3D 0) && - ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) - !=3D NULL)) { - virPidFileDelete(driver->pidDir, radvdpidbase); - VIR_FREE(radvdpidbase); - } + /* If there is a running radvd, kill it. Essentially ignore errors fro= m the + * following two functions, since there's really no better recovery to= be + * done than to just push ahead (and that may be exactly what's needed= ). + */ + if ((radvdpidbase =3D networkRadvdPidfileBasename(def->name)) && + (pidfile =3D virPidFileBuildPath(driver->pidDir, radvdpidbase))) { + virPidFileForceCleanupPath(pidfile); virNetworkObjSetRadvdPid(obj, -1); } + /* now start radvd if it should be started */ return networkStartRadvd(obj); } --=20 2.24.1