From nobody Thu May 2 08:27:00 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496318933107307.4860342407991; Thu, 1 Jun 2017 05:08:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF2DC448D6B; Thu, 1 Jun 2017 12:08:49 +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 C93EE7ED88; Thu, 1 Jun 2017 12:08:49 +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 736556B5ED; Thu, 1 Jun 2017 12:08:49 +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 v51C8gdW022629 for ; Thu, 1 Jun 2017 08:08:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6630753C32; Thu, 1 Jun 2017 12:08:42 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id E15775279C for ; Thu, 1 Jun 2017 12:08:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF2DC448D6B Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EF2DC448D6B From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 1 Jun 2017 14:08:32 +0200 Message-Id: <43d414ff05bc75123cb67b89f47c4ef498acc500.1496318548.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/3] Make virNetClientStreamEventRemoveCallback's errors optional 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Jun 2017 12:08:50 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There will be new place for this function to be called, but we need not to report error from there. Since the virNetClientStream structure is private, there is no way to check for st->cb from outside this file, so we need to make the error reporting optional. The function name is already long enough to have yet another Quiet suffix like some other functions do, plus it is only called from two places, so just add bool for that. Signed-off-by: Martin Kletzander --- src/remote/remote_driver.c | 2 +- src/rpc/virnetclientstream.c | 10 +++++++--- src/rpc/virnetclientstream.h | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d27e96ffc2b7..968fdfba191c 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5838,7 +5838,7 @@ remoteStreamEventRemoveCallback(virStreamPtr st) remoteDriverLock(priv); - ret =3D virNetClientStreamEventRemoveCallback(privst); + ret =3D virNetClientStreamEventRemoveCallback(privst, false); remoteDriverUnlock(priv); return ret; diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c index a9bf271dc5ba..1f8456f59455 100644 --- a/src/rpc/virnetclientstream.c +++ b/src/rpc/virnetclientstream.c @@ -712,14 +712,18 @@ int virNetClientStreamEventUpdateCallback(virNetClien= tStreamPtr st, return ret; } -int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st) +int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st, bool q= uiet) { int ret =3D -1; virObjectLock(st); if (!st->cb) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("no stream callback registered")); + if (quiet) { + ret =3D 0; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("no stream callback registered")); + } goto cleanup; } diff --git a/src/rpc/virnetclientstream.h b/src/rpc/virnetclientstream.h index c4e01bf1cab0..4f114849e4e9 100644 --- a/src/rpc/virnetclientstream.h +++ b/src/rpc/virnetclientstream.h @@ -79,7 +79,8 @@ int virNetClientStreamEventAddCallback(virNetClientStream= Ptr st, int virNetClientStreamEventUpdateCallback(virNetClientStreamPtr st, int events); -int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st); +int virNetClientStreamEventRemoveCallback(virNetClientStreamPtr st, + bool quiet); bool virNetClientStreamEOF(virNetClientStreamPtr st) ATTRIBUTE_NONNULL(1); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:27:00 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 149631892723465.90121871551571; Thu, 1 Jun 2017 05:08:47 -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 313DC37EEB; Thu, 1 Jun 2017 12:08:45 +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 0333583E8C; Thu, 1 Jun 2017 12:08:45 +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 91D6A4BB7F; Thu, 1 Jun 2017 12:08:44 +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 v51C8h4Z022639 for ; Thu, 1 Jun 2017 08:08:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A6FA5279C; Thu, 1 Jun 2017 12:08:43 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id B48FF53C6F for ; Thu, 1 Jun 2017 12:08:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 313DC37EEB Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 313DC37EEB From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 1 Jun 2017 14:08:33 +0200 Message-Id: <634da3887fa1dd3e28d26686c51f3e1968190857.1496318548.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] remote: Consolidate remoteStream{Abort, Finish} functions 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.29]); Thu, 01 Jun 2017 12:08:46 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" They do the same thing with only one difference. Let's put them together (like we already do with virFDStreamCloseInt) so that future changes don't miss one of the implementations. Also to clean up the code. Signed-off-by: Martin Kletzander --- src/remote/remote_driver.c | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 968fdfba191c..49909bf69747 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5846,7 +5846,7 @@ remoteStreamEventRemoveCallback(virStreamPtr st) static int -remoteStreamFinish(virStreamPtr st) +remoteStreamCloseInt(virStreamPtr st, bool streamAbort) { struct private_data *priv =3D st->conn->privateData; virNetClientStreamPtr privst =3D st->privateData; @@ -5862,7 +5862,7 @@ remoteStreamFinish(virStreamPtr st) ret =3D virNetClientStreamSendPacket(privst, priv->client, - VIR_NET_OK, + streamAbort ? VIR_NET_ERROR : VIR_N= ET_OK, NULL, 0); @@ -5881,37 +5881,16 @@ remoteStreamFinish(virStreamPtr st) static int -remoteStreamAbort(virStreamPtr st) +remoteStreamFinish(virStreamPtr st) { - struct private_data *priv =3D st->conn->privateData; - virNetClientStreamPtr privst =3D st->privateData; - int ret =3D -1; - - remoteDriverLock(priv); - - if (virNetClientStreamRaiseError(privst)) - goto cleanup; - - priv->localUses++; - remoteDriverUnlock(priv); - - ret =3D virNetClientStreamSendPacket(privst, - priv->client, - VIR_NET_ERROR, - NULL, - 0); - - remoteDriverLock(priv); - priv->localUses--; + return remoteStreamCloseInt(st, false); +} - cleanup: - virNetClientRemoveStream(priv->client, privst); - virObjectUnref(privst); - st->privateData =3D NULL; - st->driver =3D NULL; - remoteDriverUnlock(priv); - return ret; +static int +remoteStreamAbort(virStreamPtr st) +{ + return remoteStreamCloseInt(st, true); } --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:27:00 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1496318937166737.4998435473113; Thu, 1 Jun 2017 05:08:57 -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 16345C04B30E; Thu, 1 Jun 2017 12:08:54 +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 88EC17E4C8; Thu, 1 Jun 2017 12:08:53 +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 302AC97013; Thu, 1 Jun 2017 12:08:53 +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 v51C8iK7022649 for ; Thu, 1 Jun 2017 08:08:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B47CD53C6E; Thu, 1 Jun 2017 12:08:44 +0000 (UTC) Received: from caroline.brq.redhat.com (dhcp129-198.brq.redhat.com [10.34.129.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CACE5279C for ; Thu, 1 Jun 2017 12:08:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16345C04B30E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 16345C04B30E From: Martin Kletzander To: libvir-list@redhat.com Date: Thu, 1 Jun 2017 14:08:34 +0200 Message-Id: <6cbc70d03d277d88e4f562b0f2ceac74e1085de0.1496318548.git.mkletzan@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/3] virStream: Remove callbacks on Abort/Finish 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.31]); Thu, 01 Jun 2017 12:08:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Users need to remove their callbacks before calling virStreamAbort() or virStreamFinish() even though that's not documented anywhere. Since it makes no sense to keep those callbacks, we can remove them when the stream is being aborted or finished. That way it is also more intuitive for developers as that removes some confusing errors being reported. Signed-off-by: Martin Kletzander --- src/remote/remote_driver.c | 1 + src/util/virfdstream.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 49909bf69747..0ab70a8761b5 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5870,6 +5870,7 @@ remoteStreamCloseInt(virStreamPtr st, bool streamAbor= t) priv->localUses--; cleanup: + virNetClientStreamEventRemoveCallback(privst, true); virNetClientRemoveStream(priv->client, privst); virObjectUnref(privst); st->privateData =3D NULL; diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 7ee58be136d1..ac1f4a24d60e 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -721,6 +721,15 @@ virFDStreamCloseInt(virStreamPtr st, bool streamAbort) st->privateData =3D NULL; + if (fdst->watch) + virEventRemoveHandle(fdst->watch); + + fdst->watch =3D 0; + fdst->ff =3D NULL; + fdst->cb =3D NULL; + fdst->events =3D 0; + fdst->opaque =3D NULL; + /* call the internal stream closing callback */ if (fdst->icbCb) { /* the mutex is not accessible anymore, as private data is null */ @@ -731,8 +740,11 @@ virFDStreamCloseInt(virStreamPtr st, bool streamAbort) if (fdst->dispatching) { fdst->closed =3D true; + fdst->cbRemoved =3D true; virObjectUnlock(fdst); } else { + if (fdst->ff) + (fdst->ff)(fdst->opaque); virObjectUnlock(fdst); virObjectUnref(fdst); } --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list