From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id BDA105A0082 for ; Thu, 16 Feb 2023 17:42:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676565763; h=from:from: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; bh=bxoogcRRBf/Mgfa2DGYkH3RvErTzhkdXNd4UdG/Npd0=; b=YwpqsIelvoY9/M9+VWXPX4K0WjtGaVWDlfmO0WbSdb/pdtFfli2qdodHiAdG/x4LbqXYny HHc820iYJPDd13+O252Vs5zPI5bsYL46rcKVbZdemJr9mPtixx6o5MPliZG/sEC8Jl2y6a NmsLMNnU8r60Izhe8J0eJftzW32jt5c= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-227-RlETMHTzO1S1OOfXhbGzlw-1; Thu, 16 Feb 2023 11:42:42 -0500 X-MC-Unique: RlETMHTzO1S1OOfXhbGzlw-1 Received: by mail-qt1-f198.google.com with SMTP id t5-20020a05622a180500b003b9c03cd525so1513744qtc.20 for ; Thu, 16 Feb 2023 08:42:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bxoogcRRBf/Mgfa2DGYkH3RvErTzhkdXNd4UdG/Npd0=; b=zutJfMmWeErKcL73UFLRofLS8Lfb3yOXoGM/wQhq6H1XBiW1bNB2BLQHuUilkH4+hY anj5Qi6RdW51iEQGqH7ZwEhzF0sezBCC54ah3I/zI0hzcfGPnwRP9+8cmLE7RtzsDq4w ytBDREtIqR5FvG4wheYXkF2jf2qUEWAu/Y5hEK6BT4o/0Lxs7HEUABj/G6XGUem5kP6t PNpf7oxCvKw00Dzv3bZ5qv0CE+SutLrUfgGUDoPqvK1cLb2wlGz7vAr5BrF3IIS+j29X H9pFTPPB5YfC0DSTdtCRJDO+DTIyZ9dflTYgPTT1r9oRVZenQqN/gLEKs0hpKieo0SBi xtWg== X-Gm-Message-State: AO0yUKUtzeI3IGG6ci9sBeseBLClCdtfmDDT5hDDsQkCRA0ncVfYaMz0 etkA5cocKkQadzbKaDy+Rna6Q4bGDvTAxT1ZcH6ne3Hw7uLuj+r+qODIFAcXGieQY+alG/XjBPc /qFyYbr/zIbRD X-Received: by 2002:ac8:5e4b:0:b0:3a8:a84:7ffa with SMTP id i11-20020ac85e4b000000b003a80a847ffamr9615730qtx.57.1676565761773; Thu, 16 Feb 2023 08:42:41 -0800 (PST) X-Google-Smtp-Source: AK7set+9JWruwwzSl9Phmrec91cWuZg5opAeMJw9Cj9hygf9B89ZF6D2kE3bsQ2mpZzE7i7Ch8XKCA== X-Received: by 2002:ac8:5e4b:0:b0:3a8:a84:7ffa with SMTP id i11-20020ac85e4b000000b003a80a847ffamr9615706qtx.57.1676565761536; Thu, 16 Feb 2023 08:42:41 -0800 (PST) Received: from ?IPV6:2600:8805:3a00:3:3b4f:6d3c:92c4:a5c7? ([2600:8805:3a00:3:3b4f:6d3c:92c4:a5c7]) by smtp.gmail.com with ESMTPSA id eq13-20020a05622a5e0d00b003a7e38055c9sm1442380qtb.63.2023.02.16.08.42.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 08:42:41 -0800 (PST) Message-ID: Date: Thu, 16 Feb 2023 11:42:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH v2 4/5] qemu_passt: Deduplicate passt killing code To: libvir-list@redhat.com References: <662496e21f07a201eb0ff453306acc286530f1c1.1676554196.git.mprivozn@redhat.com> From: Laine Stump Organization: Red Hat In-Reply-To: <662496e21f07a201eb0ff453306acc286530f1c1.1676554196.git.mprivozn@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: PIT4OL6CRW2AVOGEFBVEY6CTF4RWIHFH X-Message-ID-Hash: PIT4OL6CRW2AVOGEFBVEY6CTF4RWIHFH X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, passt-dev@passt.top, Michal Privoznik X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 2/16/23 8:32 AM, Michal Privoznik wrote: > 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, > } > > > -void > -qemuPasstStop(virDomainObj *vm, > - virDomainNetDef *net) > +static void > +qemuPasstKill(const char *pidfile) > { > - g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net); > virErrorPtr orig_err; > > virErrorPreserveLast(&orig_err); > @@ -118,6 +116,16 @@ qemuPasstStop(virDomainObj *vm, > } > > > +void > +qemuPasstStop(virDomainObj *vm, > + virDomainNetDef *net) > +{ > + g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net); > + > + qemuPasstKill(pidfile); > +} > + > + > int > qemuPasstSetupCgroup(virDomainObj *vm, > virDomainNetDef *net, > @@ -147,7 +155,6 @@ qemuPasstStart(virDomainObj *vm, > g_autofree char *errbuf = NULL; > char macaddr[VIR_MAC_STRING_BUFLEN]; > size_t i; > - pid_t pid = (pid_t) -1; > int exitstatus = 0; > int cmdret = 0; > > @@ -289,10 +296,6 @@ qemuPasstStart(virDomainObj *vm, > return 0; > > error: > - ignore_value(virPidFileReadPathIfLocked(pidfile, &pid)); > - if (pid != -1) > - virProcessKillPainfully(pid, true); > - unlink(pidfile); > - > + qemuPasstKill(pidfile); > return -1; > }