From nobody Sun Feb 8 19:21:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1626274057; cv=none; d=zohomail.com; s=zohoarc; b=PUwHwawO3Mgcd0/mbwx/f2iG/iSw2auTf2Kp2TK5qyF/DnckGcGjKmuajGMBKVtMwN8U4GjN3OnY7Br9NgDCvfv4NLLACnfDVWk0xkPIn1jjCpN3bySVFeWKW+y7kOKVgopYIcoHFw4QuM2ayJijnz2ttYERcNv3rkX9l7Jcv2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626274057; h=Content-Type:Content-Transfer-Encoding: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=mf6lZUpcafa+iWl1d+BeZiZCPYanHOk4BiPYtyJJoKY=; b=ZZXACAjElyRKxoJ4qOSpZPE24XfPeNWRrEmEB47JtAliZNzE4CJM6DOpsMlwkPYTwOowEqzRp1q5z7RqCvRp81swJj1QEFhFsBiYT6LTwF9UIcAs6Yuhl/6Ht9k9hho59oqQgtdUnY+nLaHaFloWAyXpoVSMQIhqTmky+85+YoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1626274057283845.5471170106822; Wed, 14 Jul 2021 07:47:37 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-161-q8b0nYxpOmeaOVSV8WdcOg-1; Wed, 14 Jul 2021 10:47:34 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6E6A871234; Wed, 14 Jul 2021 14:47:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2E4660C9F; Wed, 14 Jul 2021 14:47:17 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8BA724EA2A; Wed, 14 Jul 2021 14:47:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16EElFUr007376 for ; Wed, 14 Jul 2021 10:47:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 959377E133; Wed, 14 Jul 2021 14:47:15 +0000 (UTC) Received: from 48-A4-72-0B-E8-25.redhat.com (unknown [10.40.195.93]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F57278DFA for ; Wed, 14 Jul 2021 14:47:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626274055; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=mf6lZUpcafa+iWl1d+BeZiZCPYanHOk4BiPYtyJJoKY=; b=MAnaUVcxlm4SV1q/VUN226FwRHTWJ29AHdtoew9zUvtCci/w6p74AhXZqQhit+H1JhKCB+ qIP3IoeVDS8uwjATbHa3oLdASBKRMtgjaCZJYjL4kRx9ZfUAK+rgPN+ReG50RFJTCcaUSH Deqdsulh/QWBvdcFiQtWsrHjocXG/vE= X-MC-Unique: q8b0nYxpOmeaOVSV8WdcOg-1 From: Kristina Hanicova To: libvir-list@redhat.com Subject: [PATCH v2 2/3] virprocess: Return retval of the child on success, not 0 Date: Wed, 14 Jul 2021 16:46:53 +0200 Message-Id: <8a964d0ece08cffd5e57f37ca48d0092fec14eb6.1626270217.git.khanicov@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1626274058196100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Kristina Hanicova --- src/util/virprocess.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 01d5d01d02..67dd599b3e 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1244,7 +1244,7 @@ static int virProcessNamespaceHelper(pid_t pid G_GNUC= _UNUSED, /* Run cb(opaque) in the mount namespace of pid. Return -1 with error * message raised if we fail to run the child, if the child dies from * a signal, or if the child has status EXIT_CANCELED; otherwise return - * the exit status of the child. The callback will be run in a child + * value is the retval of the callback. The callback will be run in a child * process so must be careful to only use async signal safe functions. */ int @@ -1298,7 +1298,9 @@ virProcessRunInForkHelper(int errfd, virProcessForkCallback cb, void *opaque) { - if (cb(ppid, opaque) < 0) { + int ret =3D 0; + + if ((ret =3D cb(ppid, opaque)) < 0) { virErrorPtr err =3D virGetLastError(); =20 if (err) { @@ -1323,7 +1325,7 @@ virProcessRunInForkHelper(int errfd, return -1; } =20 - return 0; + return ret; } =20 =20 @@ -1344,7 +1346,7 @@ virProcessRunInForkHelper(int errfd, * On return, the returned value is either -1 with error message * reported if something went bad in the parent, if child has * died from a signal or if the child returned EXIT_CANCELED. - * Otherwise the returned value is the exit status of the child. + * Otherwise the returned value is the retval of the callback. */ int virProcessRunInFork(virProcessForkCallback cb, @@ -1377,7 +1379,7 @@ virProcessRunInFork(virProcessForkCallback cb, ret =3D virProcessWait(child, &status, false); if (ret =3D=3D 0) { ret =3D status =3D=3D EXIT_CANCELED ? -1 : status; - if (ret) { + if (ret < 0) { if (nread =3D=3D sizeof(*bin)) { bin =3D g_new0(errorDataBin, 1); memcpy(bin->bindata, buf, sizeof(*bin)); --=20 2.31.1