From nobody Wed Nov 27 17:29:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1697730100; cv=none; d=zohomail.com; s=zohoarc; b=f3vVyml52IO3s2zYT9XaGJOP1qriFgaw5w6b6xcZfsDgGxUZNXjtKl6iczGsuWxD2TykJVP8B5xyKW4wBzBOkeJjD9qPIUsT/1sEerfD9ORtsA2UUqeCIRsIMmbjQcRHQ0WZRvlK8Nb7nlKmF1wFbqCGmEMDDB03UnHuABAZ4FY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697730100; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hLazHzQr9WU4aKDL3e0cHQ8ZFMzJwP9pBwOEG+7+DoA=; b=RAtKdjgc+KLI6ZYfLmCQG5psg/KGW/CcOPzIaWeLZ8HrqIcEPopG5AkWaldcpO5gdOHKdMgvt9ClMdfX0wnf++qPKuKiX+ySsKzt6uKQHKDXvGhpf5q9M1j4oDry2bhjhUUXN9OxfWUPmm7aY/JcDkL3TlMqIOj1TezAFPMjF/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1697730100857496.97777765702256; Thu, 19 Oct 2023 08:41:40 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.619414.964440 (Exim 4.92) (envelope-from ) id 1qtV8o-0007AL-1N; Thu, 19 Oct 2023 15:40:54 +0000 Received: by outflank-mailman (output) from mailman id 619414.964440; Thu, 19 Oct 2023 15:40:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qtV8n-0007A5-TT; Thu, 19 Oct 2023 15:40:53 +0000 Received: by outflank-mailman (input) for mailman id 619414; Thu, 19 Oct 2023 15:40:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qtV8m-0005v1-7J for xen-devel@lists.xenproject.org; Thu, 19 Oct 2023 15:40:52 +0000 Received: from casper.infradead.org (casper.infradead.org [2001:8b0:10b:1236::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id e0bd07f6-6e95-11ee-98d5-6d05b1d4d9a1; Thu, 19 Oct 2023 17:40:49 +0200 (CEST) Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qtV8M-007osh-9t; Thu, 19 Oct 2023 15:40:26 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1qtV8L-000Pty-36; Thu, 19 Oct 2023 16:40:25 +0100 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: e0bd07f6-6e95-11ee-98d5-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description; bh=hLazHzQr9WU4aKDL3e0cHQ8ZFMzJwP9pBwOEG+7+DoA=; b=mZVHuHGu2yiNHmYQ6lAmxyEZjN e6NSylNjif4ob9D4TnTQeVnUE1lTePYhEsdCI7J46anemdWJCMzjBGU6ztQsfxcdTtlyQER8zRAze sar13P2OM77RUpnRMfNomAGWXl77C3jfsJp+nY6jQeLnkhjLNP3Ey6o5ZGnxbcOnVTPrOyQMvyh6T icRvk0TzuJG1NIKoOMC1qdQLWJGsko7VHDIPJlICHOsG9ds8BfY7FtUgZwd0noA9uaOhkrfYLU7KL uyx63lcS6ETtZjPM4GkmV5/0HG4jDqF3shYhUhWy4stZZ7T/33VQ0O7W0wJg46U63S8BjjpCZMzZD qY8yAUEA==; From: David Woodhouse To: qemu-devel@nongnu.org Cc: Kevin Wolf , Hanna Reitz , Stefano Stabellini , Anthony Perard , Paul Durrant , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , Marcel Apfelbaum , Jason Wang , Marcelo Tosatti , Cleber Rosa , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta , Beraldo Leal , qemu-block@nongnu.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Bernhard Beschow , Joel Upham Subject: [PATCH v2 05/24] hw/xen: fix XenStore watch delivery to guest Date: Thu, 19 Oct 2023 16:40:01 +0100 Message-Id: <20231019154020.99080-6-dwmw2@infradead.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231019154020.99080-1-dwmw2@infradead.org> References: <20231019154020.99080-1-dwmw2@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-ZohoMail-DKIM: pass (identity @infradead.org) X-ZM-MESSAGEID: 1697730101270100020 From: David Woodhouse When fire_watch_cb() found the response buffer empty, it would call deliver_watch() to generate the XS_WATCH_EVENT message in the response buffer and send an event channel notification to the guest=E2=80=A6 without actually *copying* the response buffer into the ring. So there was nothing for the guest to see. The pending response didn't actually get processed into the ring until the guest next triggered some activity from its side. Add the missing call to put_rsp(). It might have been slightly nicer to call xen_xenstore_event() here, which would *almost* have worked. Except for the fact that it calls xen_be_evtchn_pending() to check that it really does have an event pending (and clear the eventfd for next time). And under Xen it's defined that setting that fd to O_NONBLOCK isn't guaranteed to work, so the emu implementation follows suit. This fixes Xen device hot-unplug. Fixes: 0254c4d19df ("hw/xen: Add xenstore wire implementation and implement= ation stubs") Signed-off-by: David Woodhouse --- hw/i386/kvm/xen_xenstore.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c index 660d0b72f9..82a215058a 100644 --- a/hw/i386/kvm/xen_xenstore.c +++ b/hw/i386/kvm/xen_xenstore.c @@ -1357,10 +1357,12 @@ static void fire_watch_cb(void *opaque, const char = *path, const char *token) } else { deliver_watch(s, path, token); /* - * If the message was queued because there was already ring activi= ty, - * no need to wake the guest. But if not, we need to send the evtc= hn. + * Attempt to queue the message into the actual ring, and send + * the event channel notification if any bytes are copied. */ - xen_be_evtchn_notify(s->eh, s->be_port); + if (put_rsp(s) > 0) { + xen_be_evtchn_notify(s->eh, s->be_port); + } } } =20 --=20 2.40.1