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 1E9905A005E for ; Thu, 9 Feb 2023 10:09:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675933784; 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=1Oe+p49F7gRvrKsayz0JqCjBdUByqGFS6ZncCHhcLc0=; b=GSgw3m34CYybbPLiD7AWCKI/rXl5p+40V4t9J3OsrnqZSrIbMaI0jiMwxVsKo/e/PC57rH gpKOaZ2ryEnKe4LB/is/KShSqRqK4ni3LKsqcmcPNSr9pF2fYJ+qG4lmxxC+W7A7tqtwJE NLNabbvt+4mAa/v4l9PNInp3YO9rt8o= 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-655-P50h2JESNWm0zsR65eXTKA-1; Thu, 09 Feb 2023 04:09:42 -0500 X-MC-Unique: P50h2JESNWm0zsR65eXTKA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9ACFC800B23 for ; Thu, 9 Feb 2023 09:09:42 +0000 (UTC) Received: from angien.pipo.sk (ovpn-208-29.brq.redhat.com [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2643440398A0; Thu, 9 Feb 2023 09:09:40 +0000 (UTC) Date: Thu, 9 Feb 2023 10:09:38 +0100 From: Peter Krempa To: Michal =?iso-8859-1?B?UHLtdm96bu1r?= Subject: Re: [libvirt PATCH] qemu: allow passt to self-daemonize Message-ID: References: <20230208231310.1728051-1-laine@redhat.com> <30ce5926-e7ee-2bdf-33c2-5964032c117e@redhat.com> MIME-Version: 1.0 In-Reply-To: <30ce5926-e7ee-2bdf-33c2-5964032c117e@redhat.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation Message-ID-Hash: U45WOY4576HET72MHALR4AOTNLEW32UI X-Message-ID-Hash: U45WOY4576HET72MHALR4AOTNLEW32UI X-Mailman-Approved-At: Thu, 09 Feb 2023 10:29:07 +0100 CC: Laine Stump , libvir-list@redhat.com, passt-dev@passt.top 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 Thu, Feb 09, 2023 at 09:59:54 +0100, Michal Pr=EDvozn=EDk wrote: > On 2/9/23 09:36, Peter Krempa wrote: > > On Wed, Feb 08, 2023 at 18:13:10 -0500, Laine Stump wrote: > >> I initially had the passt process being started in an identical > >> fashion to the slirp-helper - libvirt was daemonizing the new process > >> and recording its pid in a pidfile. The problem with this is that, > >> since it is daemonized immediately, any startup error in passt happens > >> after the daemonization, and thus isn't seen by libvirt - libvirt > >> believes that the process has started successfully and continues on > >> its merry way. The result was that sometimes a guest would be started, > >> but there would be no passt process for qemu to use for network > >> traffic. > >> > >> Instead, we should be starting passt in the same manner we start > >> dnsmasq - we just exec it as normal (along with a request that passt > >> create the pidfile, which is just another option on the passt > >> commandline) and wait for the child process to exit; passt then has a > >> chance to parse its commandline and complete all the setup prior to > >> daemonizing itself; if it encounters an error and exits with a non-0 > >> code, libvirt will see the code and know about the failure. We can > >> then grab the output from stderr, log that so the "user" has some idea > >> of what went wrong, and then fail the guest startup. > >> > >> Signed-off-by: Laine Stump > >> --- > >> src/qemu/qemu_passt.c | 9 ++++----- > >> 1 file changed, 4 insertions(+), 5 deletions(-) > >=20 > > [..] > >=20 > >> if (cmdret < 0 || exitstatus !=3D 0) { > >> virReportError(VIR_ERR_INTERNAL_ERROR, > >> - _("Could not start 'passt'. exitstatus: %d"), = exitstatus); > >> + _("Could not start 'passt': %s"), errbuf); > >> goto error; > >> } > >=20 > > So the 'passt' binary doesn't do any logging later on during runtime > > which we'd have to capture into a specific log file? >=20 > It does: >=20 > -e, --stderr Log to stderr too > default: log to system logger only if started from a TTY > -l, --log-file PATH Log (only) to given file > --log-size BYTES Maximum size of log file > default: 1 MiB >=20 > Maybe, we can keep the errfd and let our event loop read from it? But > that looks like a stretch, unnecessary - what would we do with the error > if it's reported after guest is started, there's no client connected and > no API running? The best we could do is to relay the error into our > logs. Which is probably as good as '-l' option then. Well, the stdout/err FDs can be passed to virtlogd so that the output is in the appropriate log file and rotated as needed. > BTW: I don't see us passing --stderr. Is that intentional? Maybe I don't > understand the default. I don't know the default either, but in this case logging to the system journal would be not very good as it would be hard for the user to identify which instance the log belongs to.