From nobody Mon Apr 29 06:31:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676554390; cv=none; d=zohomail.com; s=zohoarc; b=FOtzFWd3tsPdyoUE1W3eykDKlY/zxlgVV8IxJvz/TUxshzBz9sl8jYD4i2xoAGtu0QfThgsR4W9MK3nI98bG3T/QImutSD7krfL4aTaZG9dY8JDBztAHhw+hl9l/sn2/rgKjN1PjxpmgKo8rQwz3WG+XZMJ/jwoMlOGanQsTzkU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WdoL+2zDocIqTvVcZDtXea3iinkkuW0TJW1vX+ICS/E=; b=Gbq1Qkm6m16kIex8Aa7RjKZDMRnuPR/0R5PlUofUB/Ohrq2kJuUpDBriYZd8BiQI5JRlTST0dCo2HUL8ka48C0J4bEN78KnSufwYVaIpPN2aO9Y3Nn+hoVxtf0VHaJVmnxeHli+0meFif6bmYlinkH83NiOePJxTEwhBYkGOSO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1676554390831970.095923692697; Thu, 16 Feb 2023 05:33:10 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-475-KeOcqoHMOiqWStCsnuMeoQ-1; Thu, 16 Feb 2023 08:33:01 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C8ED280BCBE; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id B91C2492B0E; Thu, 16 Feb 2023 13:32:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A22341946589; Thu, 16 Feb 2023 13:32:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 64D8B1946588 for ; Thu, 16 Feb 2023 13:32:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5A0522166B32; Thu, 16 Feb 2023 13:32:55 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C01BE2166B30; Thu, 16 Feb 2023 13:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554389; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=WdoL+2zDocIqTvVcZDtXea3iinkkuW0TJW1vX+ICS/E=; b=co2QZQeqjU1Vhzu8bC2CMnWHUDCNfs42sZ4Xa3hc9CbOlL+2C9EIZuIVZOZ6OaasQKDtUY 1pjpz3FTSxfQeHtKB9NL6oad0RPBBKsrQxQ7vGi/oKWefBUo3suxZc6YIpTtCwXkxmw94L hPODlvz1s1APWNbJAEen1DCdKvceBJw= X-MC-Unique: KeOcqoHMOiqWStCsnuMeoQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/5] qemu_passt: Avoid double daemonizing passt Date: Thu, 16 Feb 2023 14:32:48 +0100 Message-Id: <4fa71e685d69f496d481ef51157c1ffa4c85166d.1676554196.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554392059100005 Content-Type: text/plain; charset="utf-8"; x-default="true" When passt is started, it daemonizes itself by default. There's no point in having our virCommand module daemonize it too. Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump Reviewed-by: Stefano Brivio --- src/qemu/qemu_passt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 78830fdc26..adc69fc052 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -156,7 +156,6 @@ qemuPasstStart(virDomainObj *vm, virCommandClearCaps(cmd); virCommandSetPidFile(cmd, pidfile); virCommandSetErrorFD(cmd, &errfd); - virCommandDaemonize(cmd); =20 virCommandAddArgList(cmd, "--one-off", --=20 2.39.1 From nobody Mon Apr 29 06:31:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676554387; cv=none; d=zohomail.com; s=zohoarc; b=NVBfLAK5O9+poQShxGou+z6FRzYzp8JWqHnhm9oi4zMlt/qf177AZxAZ3ro98dSVJcH+O/cPRRJDHPkZO7ShjFKhKyZVDf0uEYoFWPi3mlqphKO+X15zA+VQ1biq7kQLZVbENqu/CyDrJbs03LckW2A4mRBwnWPvReygbY9yc7g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554387; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K5VMDiuM5wTl90liLT12n2w+qa4f1u66egMwviBYO2g=; b=FTFECCWQEM+c+rtjut7xtpFup+1hASPocsral5NVQRpToM/hdizZcYzkSB4NY3+7Fl0mx8UN26GvXYXZzEa/HOjq9y33fSHgQrGnxoQ5fLgMqEI2yUkOltIPiauPlqfEbIcG9Yx+t9jb5NKgNgc4xBkT5BwM1L4Q5GXUmMp93EY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676554387668318.8907276258743; Thu, 16 Feb 2023 05:33:07 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-348-VqUvTYZoMb6P_TeNXSftMw-1; Thu, 16 Feb 2023 08:33:00 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8FE1280AA2F; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 889E7492B11; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D81A7194658D; Thu, 16 Feb 2023 13:32:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 38C8319465BC for ; Thu, 16 Feb 2023 13:32:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2983D2166B31; Thu, 16 Feb 2023 13:32:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 903E02166B30; Thu, 16 Feb 2023 13:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554386; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=K5VMDiuM5wTl90liLT12n2w+qa4f1u66egMwviBYO2g=; b=TuMYiJIeZWs4UFRCRryX3OqwPflCGeYXa6btW+aC3wXNSISuN7OkRX1AWMo0AZosdR0XGO LICjuFJagn12OvaKcVyDsXZXWdN0Cm5azNkKCIAQzR9h5u1UxDMGEsnaR+O/r4AUI2aaiS C5jQxMc6doGrgZUorVBT8LxQFLO9n3k= X-MC-Unique: VqUvTYZoMb6P_TeNXSftMw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/5] qemu_passt: Report passt's error on failed start Date: Thu, 16 Feb 2023 14:32:49 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554389844100003 Content-Type: text/plain; charset="utf-8"; x-default="true" When starting passt, it may write something onto its stderr (convincing it to print even more is addressed later). Pass this string we read to user. Since we're not daemonizing passt anymore (see previous commit), we can let virCommand module do all the heavy lifting and switch to virCommandSetErrorBuffer() instead of reading error from an FD. Signed-off-by: Michal Privoznik Reviewed-by: Laine Stump Reviewed-by: Stefano Brivio --- src/qemu/qemu_passt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index adc69fc052..c082c149cd 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -144,18 +144,18 @@ qemuPasstStart(virDomainObj *vm, g_autofree char *passtSocketName =3D qemuPasstCreateSocketPath(vm, net= ); g_autoptr(virCommand) cmd =3D NULL; g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); + g_autofree char *errbuf =3D NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; size_t i; pid_t pid =3D (pid_t) -1; int exitstatus =3D 0; int cmdret =3D 0; - VIR_AUTOCLOSE errfd =3D -1; =20 cmd =3D virCommandNew(PASST); =20 virCommandClearCaps(cmd); virCommandSetPidFile(cmd, pidfile); - virCommandSetErrorFD(cmd, &errfd); + virCommandSetErrorBuffer(cmd, &errbuf); =20 virCommandAddArgList(cmd, "--one-off", @@ -266,7 +266,7 @@ qemuPasstStart(virDomainObj *vm, =20 if (cmdret < 0 || exitstatus !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'passt'. exitstatus: %d"), exits= tatus); + _("Could not start 'passt': %s"), NULLSTR(errbuf)); goto error; } =20 --=20 2.39.1 From nobody Mon Apr 29 06:31:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676554384; cv=none; d=zohomail.com; s=zohoarc; b=PxJxzV2TtF4GyKt3+MQnT0xxLfGS3n8loYJNizzMQgBrwbbnMPc+kgZwznkU73CXSHADKR1NQY3B0MvviA/L6q3adDl7ix6dLqj9cx1BSgwRd2Nih6lPB2fiUiE9wmM/ONC474gjMyXaiFQ7JFwkJkU6BQIK+Wi2GxQApiBUF70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554384; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y1qbgY17azwIvSZN0bSZAnn5wZELMXL8gKpQu+DXsoQ=; b=GJYAm6FnKe42hqY6C5XDDmqXuubCLqGIwHmV8EvQz98mQkFjwsU5DKAF7yaJDCKsm6fP7jEmJYsDn6REbQp7gknTA1QQxUXS0wZHTc1rTAq8HnbQfz/uVd4TZUMFTz8mWuF0va9mqaLi2AzJl/sWbtadN/2KzfbxybrS6rrxuNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676554384602979.0435589807564; Thu, 16 Feb 2023 05:33:04 -0800 (PST) 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-104-XStEPv5mPDCNbV6si-njDA-1; Thu, 16 Feb 2023 08:33:01 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2FE8100F912; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCCFC492B10; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 565FC19465A0; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0673C1946A4B for ; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EE3342166B34; Thu, 16 Feb 2023 13:32:56 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 606352166B30; Thu, 16 Feb 2023 13:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554383; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Y1qbgY17azwIvSZN0bSZAnn5wZELMXL8gKpQu+DXsoQ=; b=WuPdk3TZAhM9qrb7ZZWKWtg8xkyttdY1AoDTa9sJkb3l4c2phjoy4fA7+0c1siljlltgG4 gjxJfsHeKTfAAmjQaeAOxbSXcl0uuTTjBaKTp8sOnyGN0w0F0tSFm8TuziePKoqfNFm4xg PuxcFMbW0RGKFBo8sphNRXjpjpBPYOs= X-MC-Unique: XStEPv5mPDCNbV6si-njDA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/5] qemu_passt: Make passt report errors to stderr whenever possible Date: Thu, 16 Feb 2023 14:32:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554387715100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Passt has '--stderr' argument which makes it report error onto stderr rather to system log. Unfortunately, it's currently impossible to use both '--log-file' and '--stderr', so pass the latter only if the former isn't passed. Then, use the stderr to produce more user friendly error message on failed start. Signed-off-by: Michal Privoznik --- src/qemu/qemu_passt.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index c082c149cd..881205449b 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -171,8 +171,13 @@ qemuPasstStart(virDomainObj *vm, if (net->sourceDev) virCommandAddArgList(cmd, "--interface", net->sourceDev, NULL); =20 - if (net->backend.logFile) + if (net->backend.logFile) { virCommandAddArgList(cmd, "--log-file", net->backend.logFile, NULL= ); + } else { + /* By default, passt logs into system logger. But we are interested + * into errors too. Make it print errors onto stderr. */ + virCommandAddArg(cmd, "--stderr"); + } =20 /* Add IP address info */ for (i =3D 0; i < net->guestIP.nips; i++) { @@ -265,8 +270,19 @@ qemuPasstStart(virDomainObj *vm, goto error; =20 if (cmdret < 0 || exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'passt': %s"), NULLSTR(errbuf)); + if (STRNEQ_NULLABLE(errbuf, "")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'passt': %s"), errbuf); + } else if (net->backend.logFile) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'passt': look into %s for er= ror"), + net->backend.logFile); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'passt': exit status =3D '%d= '"), + exitstatus); + } + goto error; } =20 --=20 2.39.1 From nobody Mon Apr 29 06:31:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676554391; cv=none; d=zohomail.com; s=zohoarc; b=QZOAr1r0jS0LfRZg9qv5CG29pjYAx05oQsrjn9EqUV3pBPb6oyHIp4tCdukC6jQBMcgHzECEvyUHEm7/srJx5yGz2RxQZ7gjNpgQWN4Ze2plmhipGj7Fig5//B8zUazeN8/OkK72Zs9Mm3RFTkH/t/QwTLeuM0bVp+xlheILK/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554391; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cD0XqH2CsbiKH3w0JChN05KcKDU4a2nowg4/CngzxYE=; b=bBpsK1DSweBYNYxpxplrxf/Zl6/+jMyxeJ+byJ9FX4SxSs+9seABTrlt0ReB+94Lu8fIXmhQSEbSTeQSKT2RLfaRAdV6FA00cHvEhVwB7AfiE1S/8VmpKmS8IWTTmMtjnF/1bKS0q1agma/1gSbGsmdK0ykdOoFFcv8L+QFoz9o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1676554391083120.85067426806211; Thu, 16 Feb 2023 05:33:11 -0800 (PST) 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-479-5RB5ktjUPHaF_Us3HaemoA-1; Thu, 16 Feb 2023 08:33:03 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAB86823D77; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A572B4051E44; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8F4BC1946589; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C9B3A1946588 for ; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BDB822166B32; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 306C22166B31; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554390; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=cD0XqH2CsbiKH3w0JChN05KcKDU4a2nowg4/CngzxYE=; b=OE16BPfacRTbofQXEwKuYzhrzSP8It0+sQpksR3jWXdGm8qZScKuky0XHZfWeSJu9SDr0s hshAoOURyTdLG3QUs8J/CtS00k+43gmtv/eELPfHZRy6Frj8GikQ/kooi7VRkRR0CletTB 7746k8pO9pFV3stwyQP2VVlrFUyNyrw= X-MC-Unique: 5RB5ktjUPHaF_Us3HaemoA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 4/5] qemu_passt: Deduplicate passt killing code Date: Thu, 16 Feb 2023 14:32:51 +0100 Message-Id: <662496e21f07a201eb0ff453306acc286530f1c1.1676554196.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554392101100007 Content-Type: text/plain; charset="utf-8"; x-default="true" 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, } =20 =20 -void -qemuPasstStop(virDomainObj *vm, - virDomainNetDef *net) +static void +qemuPasstKill(const char *pidfile) { - g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); virErrorPtr orig_err; =20 virErrorPreserveLast(&orig_err); @@ -118,6 +116,16 @@ qemuPasstStop(virDomainObj *vm, } =20 =20 +void +qemuPasstStop(virDomainObj *vm, + virDomainNetDef *net) +{ + g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); + + qemuPasstKill(pidfile); +} + + int qemuPasstSetupCgroup(virDomainObj *vm, virDomainNetDef *net, @@ -147,7 +155,6 @@ qemuPasstStart(virDomainObj *vm, g_autofree char *errbuf =3D NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; size_t i; - pid_t pid =3D (pid_t) -1; int exitstatus =3D 0; int cmdret =3D 0; =20 @@ -289,10 +296,6 @@ qemuPasstStart(virDomainObj *vm, return 0; =20 error: - ignore_value(virPidFileReadPathIfLocked(pidfile, &pid)); - if (pid !=3D -1) - virProcessKillPainfully(pid, true); - unlink(pidfile); - + qemuPasstKill(pidfile); return -1; } --=20 2.39.1 From nobody Mon Apr 29 06:31:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676554389; cv=none; d=zohomail.com; s=zohoarc; b=GrrJvvV1F13c+skduUFl3lJq3/yudkayZjP3sLgw3vaxo5gvfS1VczOfxFT5M0/dQ+lXSUyhgpQsjJTfK9gx5YyqiDllbaWbbLuEP+NpAZUecGDavh7uMhDaBJrF/JRRrcA+1Ac+arSIicxozwMlJaYwYtl9hibB+z1gScnjSdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676554389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J3RjkQnREkQqM0zQ+XPCW+NlJN21CooXEdao/RywWW0=; b=fc/JdLQLy0xO9GzvmaKO6nsvftZp0bl4gaFmFULYQntF1RnnSdR9vV7+VBYfI4ncYn1Qzc30EAL3PUJZDUgKOyypKISSbNiTCl2lej/VX0aoaHD1vrxn2Sz2Jfna0p0tswWkmW8F7XoW4wvAGE1ouEvpSEv/mF6BQqpjccijee8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167655438937298.37180089586718; Thu, 16 Feb 2023 05:33:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-198-fovEDA9sOQ-wHlnOKRB5AQ-1; Thu, 16 Feb 2023 08:33:02 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EAB2F3C1486C; Thu, 16 Feb 2023 13:32:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7088140EBF6; Thu, 16 Feb 2023 13:32:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C4E61194658C; Thu, 16 Feb 2023 13:32:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C6B6919465B3 for ; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A87FE2166B32; Thu, 16 Feb 2023 13:32:58 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01B472166B31; Thu, 16 Feb 2023 13:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554388; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=J3RjkQnREkQqM0zQ+XPCW+NlJN21CooXEdao/RywWW0=; b=LbRhUzCzJ50F5oeKlDq+tDxYQUqGWXxRyKsQOBw6ZSpiXegcbD2Y5n60iLiMA5fX8Hasm0 PtpGvNAreVY3JqMp4Yjlo6TMScsn0IKg2WXVPLYIKDvWXl8QtiOdkhoo9gArr+4hO9TdMM jSLHQzVZ7THBto6JFACNP4/87XeHe1Q= X-MC-Unique: fovEDA9sOQ-wHlnOKRB5AQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 5/5] qemu_passt: Let passt write the PID file Date: Thu, 16 Feb 2023 14:32:52 +0100 Message-Id: <0d438dabe6479dc8f0f159b3afd3f3656b62cec7.1676554196.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbrivio@redhat.com, passt-dev@passt.top Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676554392093100006 Content-Type: text/plain; charset="utf-8"; x-default="true" 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. 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 =3D qemuPasstCreatePidFilename(vm, net); =20 - return virPidFileReadPathIfLocked(pidfile, pid); + return virPidFileReadPath(pidfile, pid); } =20 =20 @@ -106,11 +106,14 @@ static void qemuPasstKill(const char *pidfile) { virErrorPtr orig_err; + pid_t pid =3D 0; =20 virErrorPreserveLast(&orig_err); =20 - if (virPidFileForceCleanupPath(pidfile) < 0) - VIR_WARN("Unable to kill passt process"); + ignore_value(virPidFileReadPath(pidfile, &pid)); + if (pid !=3D 0) + virProcessKillPainfully(pid, true); + unlink(pidfile); =20 virErrorRestore(&orig_err); } @@ -161,13 +164,13 @@ qemuPasstStart(virDomainObj *vm, cmd =3D virCommandNew(PASST); =20 virCommandClearCaps(cmd); - virCommandSetPidFile(cmd, pidfile); virCommandSetErrorBuffer(cmd, &errbuf); =20 virCommandAddArgList(cmd, "--one-off", "--socket", passtSocketName, "--mac-addr", virMacAddrFormat(&net->mac, macaddr= ), + "--pid", pidfile, NULL); =20 if (net->mtu) { --=20 2.39.1