From nobody Thu Apr 18 16:49:50 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 1520847163478626.8908496689695; Mon, 12 Mar 2018 02:32:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7BAC8762F; Mon, 12 Mar 2018 09:32:41 +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 25BCE5E1AD; Mon, 12 Mar 2018 09:32:40 +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 4B561181B9FD; Mon, 12 Mar 2018 09:32:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2C9WatO014733 for ; Mon, 12 Mar 2018 05:32:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 421E92026E0E; Mon, 12 Mar 2018 09:32:36 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-18.brq.redhat.com [10.40.204.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3FEE2026E03; Mon, 12 Mar 2018 09:32:35 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 12 Mar 2018 10:32:32 +0100 Message-Id: <7dc43499f0e15bf977acf2f3670d0d4470048dd9.1520847112.git.mprivozn@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: jcfaracco@gmail.com Subject: [libvirt] [PATCH] daemonStreamHandleWriteData: Preserve error when aborting stream 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 12 Mar 2018 09:32:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The daemonStreamHandleWriteData() function is called whenever server side of stream is able to receive some data. Nevertheless, it calls virStreamSend() (to pass data down to virFDStream) and depending on its return value it may abort the stream. However, the functions it called when doing so are public APIs and as such reset any error set previously. Therefore, if there was any error in writing data to stream (i.e. repored in virStreamSend) it is reset before virNetServerProgramSendReplyError() can get to it. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/remote/remote_daemon_stream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 4dd3af9e0..532afd856 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -549,8 +549,9 @@ daemonStreamHandleWriteData(virNetServerClientPtr clien= t, } else if (ret =3D=3D -2) { /* Blocking, so indicate we have more todo later */ return 1; - } else { + } else if (ret < 0) { virNetMessageError rerr; + virErrorPtr err =3D virSaveLastError(); =20 memset(&rerr, 0, sizeof(rerr)); =20 @@ -558,7 +559,10 @@ daemonStreamHandleWriteData(virNetServerClientPtr clie= nt, stream->closed =3D true; virStreamEventRemoveCallback(stream->st); virStreamAbort(stream->st); - + if (err) { + virSetError(err); + virFreeError(err); + } return virNetServerProgramSendReplyError(stream->prog, client, msg, --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list