From nobody Sat May 4 23:31:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528294681760467.0021105772091; Wed, 6 Jun 2018 07:18:01 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2916E3082A27; Wed, 6 Jun 2018 14:17:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 08ADF600CC; Wed, 6 Jun 2018 14:17:58 +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 047FC1800FC1; Wed, 6 Jun 2018 14:17:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w56EG1ZV012836 for ; Wed, 6 Jun 2018 10:16:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 94B4E608F0; Wed, 6 Jun 2018 14:16:01 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-51.phx2.redhat.com [10.3.117.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67F1F608F6 for ; Wed, 6 Jun 2018 14:15:56 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 6 Jun 2018 10:15:46 -0400 Message-Id: <20180606141546.14944-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] fdstream: Report error from the I/O thread 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 06 Jun 2018 14:18:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1529059 Commit id 0fe4aa14 added the thread specific error message reporting (or save) to virFDStreamEvent; however, as processing goes via virStream{Send|SendHole|Recv} via calls from daemonStreamHandle{WriteData|Hole|Read} the last error gets reset in the main libvirt API's thus, whatever error may have been set as last error will be cleared prior to the error paths using it resulting in the generic error on the client side. For each of the paths that check threadQuit or threadErr, check if threadErr was set and set it agian if there isn't a last error (e.g. some other failure) set so that the message can be provided back to the client. Signed-off-by: John Ferlan --- src/util/virfdstream.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index e4973a2bd0..8189559964 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -795,8 +795,13 @@ static int virFDStreamWrite(virStreamPtr st, const cha= r *bytes, size_t nbytes) char *buf; =20 if (fdst->threadQuit || fdst->threadErr) { - virReportSystemError(EBADF, "%s", - _("cannot write to stream")); + + /* virStreamSend will virResetLastError possibly set + * by virFDStreamEvent */ + if (fdst->threadErr && !virGetLastError()) + virSetError(fdst->threadErr); + else + virReportSystemError(EBADF, "%s", _("cannot write to strea= m")); goto cleanup; } =20 @@ -875,8 +880,13 @@ static int virFDStreamRead(virStreamPtr st, char *byte= s, size_t nbytes) while (!(msg =3D fdst->msg)) { if (fdst->threadQuit || fdst->threadErr) { if (nbytes) { - virReportSystemError(EBADF, "%s", - _("stream is not open")); + /* virStreamRecv will virResetLastError possibly set + * by virFDStreamEvent */ + if (fdst->threadErr && !virGetLastError()) + virSetError(fdst->threadErr); + else + virReportSystemError(EBADF, "%s", + _("stream is not open")); } else { ret =3D 0; } @@ -976,8 +986,12 @@ virFDStreamSendHole(virStreamPtr st, * might mess up file position for the thread. */ =20 if (fdst->threadQuit || fdst->threadErr) { - virReportSystemError(EBADF, "%s", - _("stream is not open")); + /* virStreamSendHole will virResetLastError possibly set + * by virFDStreamEvent */ + if (fdst->threadErr && !virGetLastError()) + virSetError(fdst->threadErr); + else + virReportSystemError(EBADF, "%s", _("stream is not open")); goto cleanup; } =20 --=20 2.14.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list