From nobody Sun Feb 8 23:26:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1676554391; cv=none; d=zohomail.com; s=zohoarc; b=QZOAr1r0jS0LfRZg9qv5CG29pjYAx05oQsrjn9EqUV3pBPb6oyHIp4tCdukC6jQBMcgHzECEvyUHEm7/srJx5yGz2RxQZ7gjNpgQWN4Ze2plmhipGj7Fig5//B8zUazeN8/OkK72Zs9Mm3RFTkH/t/QwTLeuM0bVp+xlheILK/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554391; h=Content-Type:Content-Transfer-Encoding:Cc: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=cD0XqH2CsbiKH3w0JChN05KcKDU4a2nowg4/CngzxYE=; b=bBpsK1DSweBYNYxpxplrxf/Zl6/+jMyxeJ+byJ9FX4SxSs+9seABTrlt0ReB+94Lu8fIXmhQSEbSTeQSKT2RLfaRAdV6FA00cHvEhVwB7AfiE1S/8VmpKmS8IWTTmMtjnF/1bKS0q1agma/1gSbGsmdK0ykdOoFFcv8L+QFoz9o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676554391083120.85067426806211; Thu, 16 Feb 2023 05:33:11 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-5RB5ktjUPHaF_Us3HaemoA-1; Thu, 16 Feb 2023 08:33:03 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAB86823D77; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A572B4051E44; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8F4BC1946589; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C9B3A1946588 for ; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BDB822166B32; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 306C22166B31; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554390; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=cD0XqH2CsbiKH3w0JChN05KcKDU4a2nowg4/CngzxYE=; b=OE16BPfacRTbofQXEwKuYzhrzSP8It0+sQpksR3jWXdGm8qZScKuky0XHZfWeSJu9SDr0s hshAoOURyTdLG3QUs8J/CtS00k+43gmtv/eELPfHZRy6Frj8GikQ/kooi7VRkRR0CletTB 7746k8pO9pFV3stwyQP2VVlrFUyNyrw= X-MC-Unique: 5RB5ktjUPHaF_Us3HaemoA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/5] qemu_passt: Deduplicate passt killing code Date: Thu, 16 Feb 2023 14:32:51 +0100 Message-Id: <662496e21f07a201eb0ff453306acc286530f1c1.1676554196.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554392101100007 Content-Type: text/plain; charset="utf-8"; x-default="true" There are two places where we kill passt: 1) qemuPasstStop() - called transitively from qemuProcessStop(), 2) qemuPasstStart() - after failed start. Now, the code from 2) lack error preservation (so if there's another error during cleanup we might overwrite the original error). Therefore, move the internals of qemuPasstStop() into a separate function and call it from both places. Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump --- src/qemu/qemu_passt.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 881205449b..a4cc9e7166 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -102,11 +102,9 @@ qemuPasstAddNetProps(virDomainObj *vm, } =20 =20 -void -qemuPasstStop(virDomainObj *vm, - virDomainNetDef *net) +static void +qemuPasstKill(const char *pidfile) { - g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); virErrorPtr orig_err; =20 virErrorPreserveLast(&orig_err); @@ -118,6 +116,16 @@ qemuPasstStop(virDomainObj *vm, } =20 =20 +void +qemuPasstStop(virDomainObj *vm, + virDomainNetDef *net) +{ + g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); + + qemuPasstKill(pidfile); +} + + int qemuPasstSetupCgroup(virDomainObj *vm, virDomainNetDef *net, @@ -147,7 +155,6 @@ qemuPasstStart(virDomainObj *vm, g_autofree char *errbuf =3D NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; size_t i; - pid_t pid =3D (pid_t) -1; int exitstatus =3D 0; int cmdret =3D 0; =20 @@ -289,10 +296,6 @@ qemuPasstStart(virDomainObj *vm, return 0; =20 error: - ignore_value(virPidFileReadPathIfLocked(pidfile, &pid)); - if (pid !=3D -1) - virProcessKillPainfully(pid, true); - unlink(pidfile); - + qemuPasstKill(pidfile); return -1; } --=20 2.39.1