From nobody Sat Feb 7 05:48:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1584116984; cv=none; d=zohomail.com; s=zohoarc; b=IiSjMsTTUUUPK/JGPecLHqTmjRYo2b1Q70dQ1aG4DckvJTVLuaY1zI4oE7Hu0JcH3237XRIg7ST3oSNgFYznlGzFZP7RJjs7ZwJ0i8g5SnRoHLJVYlaQt+YLQ+VsCQHE6JYW89WBRdpkwp/Bf5pRoqHhyhDW/b4BKS4lKAe0aOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584116984; 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=b5gogqGTifZlcGdAgbZyRrvoL2YufhxNQMVOimEWfWo=; b=KVZIeFh30QJUKUOvcKVn+r0ktW4WZlXcDkVsAguQPV1rjqXAtc4E2mPUHzrX6OwahhX/KihXzJomnr0R2lZ1SjktFrR4r0BWshJTgCSu5oATZ9mat5w0UgoCy05U2AsEjeu1HH8Gm/i5bmG+K0Y79dz/wTtj41+2/iFkNYv3hoU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 158411698471168.58496932911203; Fri, 13 Mar 2020 09:29:44 -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-432--7YsTlv_Nlq4ASq_7o7DXQ-1; Fri, 13 Mar 2020 12:29:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3464107ACC7; Fri, 13 Mar 2020 16:29:35 +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 75B968FC06; Fri, 13 Mar 2020 16:29:35 +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 0CA8185EC0; Fri, 13 Mar 2020 16:29:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02DGT2BN010904 for ; Fri, 13 Mar 2020 12:29:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8ACF3100164D; Fri, 13 Mar 2020 16:29:02 +0000 (UTC) Received: from moe.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10F651001902 for ; Fri, 13 Mar 2020 16:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584116983; 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=b5gogqGTifZlcGdAgbZyRrvoL2YufhxNQMVOimEWfWo=; b=LXDFJnD+jeES4ZWqeESS7AcfPub17GWJuPM+uR3Nj703keAItoiDKpKTugnVitDFs82nW8 SEJbCpnsq2gfgsKRGhlcrthDzHJrnC3hXVGfr4teW+FSN3t58z8ND8xPWOjmJK71MTWvlc hcux6M5pogDQgItKiCGwBfxiSI9k9fI= X-MC-Unique: -7YsTlv_Nlq4ASq_7o7DXQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/5] bridge_driver: Replace and drop networkKillDaemon Date: Fri, 13 Mar 2020 17:28:53 +0100 Message-Id: <26ec634fea69404e6496810d68c5ea9b0ecb1027.1584116228.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 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 --- src/network/bridge_driver.c | 107 ++++++------------------------------ 1 file changed, 18 insertions(+), 89 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 369e80a889..f06099297a 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -966,68 +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 { - char ebuf[1024]; - VIR_WARN("Failed to terminate %s process %d " - "for network '%s' with SIG%s: %s", - daemonName, pid, networkName, signame, - virStrerror(errno, ebuf, sizeof(ebuf))); - } - 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 */ @@ -1833,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 */ @@ -2067,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); @@ -2111,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