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 9E55C5A0082 for ; Thu, 16 Feb 2023 14:32:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676554378; 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=Y1qbgY17azwIvSZN0bSZAnn5wZELMXL8gKpQu+DXsoQ=; b=Kd6AdDXRNUjThDkA60wCu7XaEVbUCz2Yq9GPRMQMj2agv4uftYpseUoaIJEQ9T73Uc9OJ+ 3d5BuKS7nxMDs5ImnJEHSEs1aCHK4bNU4bVocWAflX1SmzxjuHpniR468SH8WEtXWMByaD rzDdsBGvDl4Gr1vMY+D4uaOz5nNZNcM= 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-662-255vWwXEPU2ERo_RB3BmqA-1; Thu, 16 Feb 2023 08:32:57 -0500 X-MC-Unique: 255vWwXEPU2ERo_RB3BmqA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EBF8B3C10ED9 for ; 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) 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-MailFrom: mprivozn@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: IKFNZSCYKYTJ6YPFH6CHLSACBPWGRQ5Z X-Message-ID-Hash: IKFNZSCYKYTJ6YPFH6CHLSACBPWGRQ5Z X-Mailman-Approved-At: Thu, 16 Feb 2023 18:44:36 +0100 CC: sbrivio@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: 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); - 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"); + } /* Add IP address info */ for (i = 0; i < net->guestIP.nips; i++) { @@ -265,8 +270,19 @@ qemuPasstStart(virDomainObj *vm, goto error; if (cmdret < 0 || exitstatus != 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 error"), + net->backend.logFile); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'passt': exit status = '%d'"), + exitstatus); + } + goto error; } -- 2.39.1