public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: "Michal Prívozník" <mprivozn@redhat.com>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: libvir-list@redhat.com, passt-dev@passt.top
Subject: Re: [PATCH v2 4/5] qemu_passt: Deduplicate passt killing code
Date: Thu, 16 Feb 2023 17:38:47 +0100	[thread overview]
Message-ID: <ae5722b6-1824-76a0-1560-8c1997c4a62b@redhat.com> (raw)
In-Reply-To: <20230216170708.6012a7ef@elisabeth>

On 2/16/23 17:07, Stefano Brivio wrote:
> On Thu, 16 Feb 2023 14:32:51 +0100
> Michal Privoznik <mprivozn@redhat.com> 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 <mprivozn@redhat.com>
>> ---
>>  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)
> 
> A minor comment, should you respin: I think it should be made clear that
> this is not the expected/normal way in which passt will terminate --
> here or in the next patch. Removing the PID file is nice, but that's
> (usually) about it.


I can adjust the commit message.

> 
>>  {
>> -    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);
> 
> ...what takes care of terminating passt in case qemu doesn't start, now?
> The fact that the process is in the cgroup, right?

No, it's qemuPasstKill(). Starting a guest is done in
qemuProcessStart(). In here, qemuProcessLaunch() ->
qemuExtDevicesStart() -> qemuPasstStart() is called. Now, in the top
most parent (qemuProcessStart()) - you can see the 'stop' label in which
qemuProcessStop() -> qemuExtDevicesStop() -> qemuPasstStop() is called.

We could go the extra step and use either virCgroupKillRecursive() or
virCgroupKillPainfully() to kill all processes within the CGroup. BUT,
the driver runs on different OSes than Linux (e.g. FreeBSD) or on Linux
with no CGroups.

Michal


  reply	other threads:[~2023-02-16 16:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-16 13:32 [PATCH v2 0/5] qemu_passt: Fix issues with PID file Michal Privoznik
2023-02-16 13:32 ` [PATCH v2 1/5] qemu_passt: Avoid double daemonizing passt Michal Privoznik
2023-02-16 16:06   ` Stefano Brivio
2023-02-16 16:34   ` Laine Stump
2023-02-16 13:32 ` [PATCH v2 2/5] qemu_passt: Report passt's error on failed start Michal Privoznik
2023-02-16 16:06   ` Stefano Brivio
2023-02-16 16:38   ` Laine Stump
2023-02-16 13:32 ` [PATCH v2 3/5] qemu_passt: Make passt report errors to stderr whenever possible Michal Privoznik
2023-02-16 15:42   ` Jonathon Jongsma
2023-02-16 16:21     ` Michal Prívozník
2023-02-16 22:48       ` David Gibson
2023-02-16 16:07   ` Stefano Brivio
2023-02-16 16:27     ` Michal Prívozník
2023-02-16 16:35       ` Stefano Brivio
2023-02-16 16:37       ` Laine Stump
2023-02-16 16:33   ` Laine Stump
2023-02-16 13:32 ` [PATCH v2 4/5] qemu_passt: Deduplicate passt killing code Michal Privoznik
2023-02-16 16:07   ` Stefano Brivio
2023-02-16 16:38     ` Michal Prívozník [this message]
2023-02-16 17:05       ` Stefano Brivio
2023-02-16 16:42   ` Laine Stump
2023-02-16 13:32 ` [PATCH v2 5/5] qemu_passt: Let passt write the PID file Michal Privoznik
2023-02-16 16:47   ` Laine Stump
2023-02-16 16:35 ` [PATCH v2 0/5] qemu_passt: Fix issues with " Laine Stump
2023-02-17 12:51   ` Michal Prívozník

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae5722b6-1824-76a0-1560-8c1997c4a62b@redhat.com \
    --to=mprivozn@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).