public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laine Stump <laine@redhat.com>
To: libvir-list@redhat.com
Cc: sbrivio@redhat.com, passt-dev@passt.top,
	Michal Privoznik <mprivozn@redhat.com>
Subject: Re: [PATCH v2 5/5] qemu_passt: Let passt write the PID file
Date: Thu, 16 Feb 2023 11:47:10 -0500	[thread overview]
Message-ID: <1fb39dc5-ac16-f7af-9480-9a2f441e7d9c@redhat.com> (raw)
In-Reply-To: <0d438dabe6479dc8f0f159b3afd3f3656b62cec7.1676554196.git.mprivozn@redhat.com>

On 2/16/23 8:32 AM, Michal Privoznik wrote:
> The way we start passt currently is: we use
> virCommandSetPidFile() to use our virCommand machinery to acquire
> the PID file and leak opened FD into passt. Then, we use
> virPidFile*() APIs to read the PID file (which is needed when
> placing it into CGroups or killing it). But this does not fly
> really because passt daemonizes itself. Thus the process we
> started dies soon and thus the PID file is closed and unlocked.
> 
> We could work around this by passing '--foreground' argument, but
> that weakens passt as it can't create new PID namespace (because
> it doesn't fork()).
> 
> The solution is to let passt write the PID file, but since it
> does not lock the file and closes it as soon as it is written, we
> have to switch to those virPidFile APIs which don't expect PID
> file to be locked.

So *this* is the part that was functionally wrong after my earlier patch 
was applied - I had switched to using an externally-generated pidfile, 
but was still using the APIs that should have only been used for 
pidfiles created by libvirt.

(You had mentioned some sort of cgroup issue last week. Did that solve 
itself? I never saw the problem, and passt has been starting/stopping 
fine for me all along (both before and after I changed the daemonizing) 
as long as selinux is disabled - still need to fix that).

> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Reviewed-by: Laine Stump <laine@redhat.com>

> ---
>   src/qemu/qemu_passt.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c
> index a4cc9e7166..47f4b5fcae 100644
> --- a/src/qemu/qemu_passt.c
> +++ b/src/qemu/qemu_passt.c
> @@ -72,7 +72,7 @@ qemuPasstGetPid(virDomainObj *vm,
>   {
>       g_autofree char *pidfile = qemuPasstCreatePidFilename(vm, net);
>   
> -    return virPidFileReadPathIfLocked(pidfile, pid);
> +    return virPidFileReadPath(pidfile, pid);
>   }
>   
>   
> @@ -106,11 +106,14 @@ static void
>   qemuPasstKill(const char *pidfile)
>   {
>       virErrorPtr orig_err;
> +    pid_t pid = 0;
>   
>       virErrorPreserveLast(&orig_err);
>   
> -    if (virPidFileForceCleanupPath(pidfile) < 0)
> -        VIR_WARN("Unable to kill passt process");
> +    ignore_value(virPidFileReadPath(pidfile, &pid));
> +    if (pid != 0)
> +        virProcessKillPainfully(pid, true);
> +    unlink(pidfile);
>   
>       virErrorRestore(&orig_err);
>   }
> @@ -161,13 +164,13 @@ qemuPasstStart(virDomainObj *vm,
>       cmd = virCommandNew(PASST);
>   
>       virCommandClearCaps(cmd);
> -    virCommandSetPidFile(cmd, pidfile);
>       virCommandSetErrorBuffer(cmd, &errbuf);
>   
>       virCommandAddArgList(cmd,
>                            "--one-off",
>                            "--socket", passtSocketName,
>                            "--mac-addr", virMacAddrFormat(&net->mac, macaddr),
> +                         "--pid", pidfile,
>                            NULL);
>   
>       if (net->mtu) {


  reply	other threads:[~2023-02-16 16:47 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
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 [this message]
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=1fb39dc5-ac16-f7af-9480-9a2f441e7d9c@redhat.com \
    --to=laine@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=mprivozn@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).