From patchwork Mon Apr 25 18:46:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 66600 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1196428qge; Mon, 25 Apr 2016 11:49:30 -0700 (PDT) X-Received: by 10.28.92.69 with SMTP id q66mr14591798wmb.102.1461610170168; Mon, 25 Apr 2016 11:49:30 -0700 (PDT) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id kh8si25769600wjb.218.2016.04.25.11.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Apr 2016 11:49:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3PIl0O2022621; Mon, 25 Apr 2016 14:47:00 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u3PIkh0W022142 for ; Mon, 25 Apr 2016 14:46:43 -0400 Received: from colepc.redhat.com (ovpn-113-101.phx2.redhat.com [10.3.113.101]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3PIkclE012964; Mon, 25 Apr 2016 14:46:43 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Mon, 25 Apr 2016 14:46:34 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/9] daemon: stream: Don't force error when client aborts 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Every time a client aborts a stream via the virStreamAbort API, the daemon always logs an error like: error : daemonStreamHandleAbort:617 : stream aborted at client request and that same error is returned to the client. Meaning virStreamAbort always returns -1, which seems strange. This reworks the error handling to only raise an error on virStreamAbort if the actual server side abort call raises an error. This is similar to how virStreamFinish works. If the abort code path is triggered by an unexpected message type then we continue to raise an unconditional error. Also drop a redundant VIR_WARN call there, since virReportError will raise a VIR_ERROR anyways --- daemon/stream.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) -- 2.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/daemon/stream.c b/daemon/stream.c index fcec3d0..bd0b5d2 100644 --- a/daemon/stream.c +++ b/daemon/stream.c @@ -611,29 +611,40 @@ daemonStreamHandleAbort(virNetServerClientPtr client, { VIR_DEBUG("client=%p, stream=%p, proc=%d, serial=%u", client, stream, msg->header.proc, msg->header.serial); - virNetMessageError rerr; - - memset(&rerr, 0, sizeof(rerr)); + int ret; + bool raise_error = false; stream->closed = true; virStreamEventRemoveCallback(stream->st); - virStreamAbort(stream->st); + ret = virStreamAbort(stream->st); if (msg->header.status == VIR_NET_ERROR) { - virReportError(VIR_ERR_RPC, - "%s", _("stream aborted at client request")); + VIR_INFO("stream aborted at client request"); + raise_error = (ret < 0); } else { - VIR_WARN("unexpected stream status %d", msg->header.status); virReportError(VIR_ERR_RPC, _("stream aborted with unexpected status %d"), msg->header.status); + raise_error = true; } - return virNetServerProgramSendReplyError(remoteProgram, - client, - msg, - &rerr, - &msg->header); + if (raise_error) { + virNetMessageError rerr; + memset(&rerr, 0, sizeof(rerr)); + return virNetServerProgramSendReplyError(remoteProgram, + client, + msg, + &rerr, + &msg->header); + } else { + /* Send zero-length confirm */ + return virNetServerProgramSendStreamData(stream->prog, + client, + msg, + stream->procedure, + stream->serial, + NULL, 0); + } }