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.133.124]) by passt.top (Postfix) with ESMTP id 040C15A0082 for ; Thu, 16 Feb 2023 17:47:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676566054; 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=+oey+4jF6LRCCPnyB/zLYDnUbEXURY2MnzNBo9fMJuk=; b=ePtNCjU61VocCXQhO/kVd4Pzj/IS2H5MXXNDUyViz0SgLKjUoFgaXhP2nyUSYdUstND2VQ 63q2hgFjOHVZ6L91sL9aqn5AaBbKPheIb1weMBwb0kgAmGiASgmq++pq2XbPXjK7aX1wdL AOzQamy70Px5tlIzFSc4P95prRGBuro= Received: from mail-vs1-f70.google.com (mail-vs1-f70.google.com [209.85.217.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-596-YbGfURzxNeinzJUbwzYomA-1; Thu, 16 Feb 2023 11:47:33 -0500 X-MC-Unique: YbGfURzxNeinzJUbwzYomA-1 Received: by mail-vs1-f70.google.com with SMTP id e7-20020a67c507000000b00414085847a2so862323vsk.3 for ; Thu, 16 Feb 2023 08:47:33 -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=+oey+4jF6LRCCPnyB/zLYDnUbEXURY2MnzNBo9fMJuk=; b=brDL+kSPGk1KFu7N3Oy6k93Bbb42AvaJ3zcXstxtb8PGIsRWdVyk8M5zQfUY+0cBXW F4x77hEzDdP9R8OhKLfBayt2Of+qMSUguKrl4qH0AlTkR2C2wqiKopET+HYs/bn4cz4W INAwV+9SBy4LdLn60eP8HN3fLNut78qLFldiNhdqz7LoFz0reYtu6o8lhtadH69Ms8of DB2yDuxFp/FsFi7WouYbMinPwXL83Ej97dG99Abf8tYnBnuOTXkzmgCImRAbhlJH1kc6 eYlEKio3Yk/XHsS6sr8er9alfrNVAcbRzG7G1zGW868Jlovf325N5EgTkQhvf5kx3IQ8 Kfww== X-Gm-Message-State: AO0yUKW3fU9o2ZP8sCozXwJGRwjaD1HUpA6cGiUwNlgUGCr392SAy+Nk 80WSC1r9snhlR+SOL5fzglrv1GtDekgmURNOBgvGTSgZtBp9Iy33m6q4ls/ew+5E7S4r1pVO7z6 PXavTyblpNVN9QmaBtg== X-Received: by 2002:a67:c881:0:b0:410:4abb:cf0f with SMTP id v1-20020a67c881000000b004104abbcf0fmr6327046vsk.23.1676566052121; Thu, 16 Feb 2023 08:47:32 -0800 (PST) X-Google-Smtp-Source: AK7set/zJVyzWKUZmNRkO0pWdjLIHPWANlnOMP/XnDb3Yj2HvsQheCFBHrHdHPUEtwpAhuVqOFv9lQ== X-Received: by 2002:a05:622a:170a:b0:3bd:16cf:2f37 with SMTP id h10-20020a05622a170a00b003bd16cf2f37mr783904qtk.60.1676566031045; Thu, 16 Feb 2023 08:47:11 -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 e4-20020ac84e44000000b003b9bca1e093sm1627478qtw.27.2023.02.16.08.47.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 08:47:10 -0800 (PST) Message-ID: <1fb39dc5-ac16-f7af-9480-9a2f441e7d9c@redhat.com> Date: Thu, 16 Feb 2023 11:47:10 -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 5/5] qemu_passt: Let passt write the PID file To: libvir-list@redhat.com References: <0d438dabe6479dc8f0f159b3afd3f3656b62cec7.1676554196.git.mprivozn@redhat.com> From: Laine Stump Organization: Red Hat In-Reply-To: <0d438dabe6479dc8f0f159b3afd3f3656b62cec7.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: I6VUA35SSYES6Z5FEFGUMMBYLBMNF5Q6 X-Message-ID-Hash: I6VUA35SSYES6Z5FEFGUMMBYLBMNF5Q6 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: > 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 Reviewed-by: Laine Stump > --- > 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) {