From nobody Thu May 9 01:17:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1493288224909824.3809429727788; Thu, 27 Apr 2017 03:17:04 -0700 (PDT) Received: from localhost ([::1]:59785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3gTv-0008Tm-HN for importer@patchew.org; Thu, 27 Apr 2017 06:17:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3gSH-0007OI-Ab for qemu-devel@nongnu.org; Thu, 27 Apr 2017 06:15:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3gSC-0001Gr-D9 for qemu-devel@nongnu.org; Thu, 27 Apr 2017 06:15:21 -0400 Received: from 5.mo5.mail-out.ovh.net ([87.98.173.103]:50760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d3gSC-0001FF-6b for qemu-devel@nongnu.org; Thu, 27 Apr 2017 06:15:16 -0400 Received: from player786.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 065B1EA37B for ; Thu, 27 Apr 2017 12:15:12 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player786.ha.ovh.net (Postfix) with ESMTPA id A6CCD80090; Thu, 27 Apr 2017 12:15:10 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 27 Apr 2017 12:15:10 +0200 Message-ID: <149328811036.1628.11119485249329354693.stgit@bahia.lan> User-Agent: StGit/0.17.1-20-gc0b1b-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 14172828029671086513 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeeliedrgeeigddvfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 87.98.173.103 Subject: [Qemu-devel] [PATCH] virtio-9p/xen-9p: move 9p specific bits to core 9p code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 These bits aren't related to the transport so let's move them to the core code. Signed-off-by: Greg Kurz Reviewed-by: Stefano Stabellini --- hw/9pfs/9p.c | 8 +++++++- hw/9pfs/9p.h | 2 +- hw/9pfs/virtio-9p-device.c | 8 +------- hw/9pfs/xen-9p-backend.c | 6 +----- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index c80ba67389ce..b40001e3dea3 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3446,12 +3446,16 @@ static inline bool is_read_only_op(V9fsPDU *pdu) } } =20 -void pdu_submit(V9fsPDU *pdu) +void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr) { Coroutine *co; CoroutineEntry *handler; V9fsState *s =3D pdu->s; =20 + pdu->size =3D le32_to_cpu(hdr->size_le); + pdu->id =3D hdr->id; + pdu->tag =3D le16_to_cpu(hdr->tag_le); + if (pdu->id >=3D ARRAY_SIZE(pdu_co_handlers) || (pdu_co_handlers[pdu->id] =3D=3D NULL)) { handler =3D v9fs_op_not_supp; @@ -3462,6 +3466,8 @@ void pdu_submit(V9fsPDU *pdu) if (is_ro_export(&s->ctx) && !is_read_only_op(pdu)) { handler =3D v9fs_fs_ro; } + + qemu_co_queue_init(&pdu->complete); co =3D qemu_coroutine_create(handler, pdu); qemu_coroutine_enter(co); } diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 5312d8a42405..c886ba78d2ee 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -347,7 +347,7 @@ ssize_t pdu_marshal(V9fsPDU *pdu, size_t offset, const = char *fmt, ...); ssize_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, const char *fmt, ...); V9fsPDU *pdu_alloc(V9fsState *s); void pdu_free(V9fsPDU *pdu); -void pdu_submit(V9fsPDU *pdu); +void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr); void v9fs_reset(V9fsState *s); =20 struct V9fsTransport { diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 3782f437029b..245abd8aaef1 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -70,13 +70,7 @@ static void handle_9p_output(VirtIODevice *vdev, VirtQue= ue *vq) goto out_free_req; } =20 - pdu->size =3D le32_to_cpu(out.size_le); - - pdu->id =3D out.id; - pdu->tag =3D le16_to_cpu(out.tag_le); - - qemu_co_queue_init(&pdu->complete); - pdu_submit(pdu); + pdu_submit(pdu, &out); } =20 return; diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 9c7f41af99da..c0b9d534298a 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -243,14 +243,10 @@ static int xen_9pfs_receive(Xen9pfsRing *ring) =20 /* cannot fail, because we only handle one request per ring at a time = */ pdu =3D pdu_alloc(&ring->priv->state); - pdu->size =3D le32_to_cpu(h.size_le); - pdu->id =3D h.id; - pdu->tag =3D le32_to_cpu(h.tag_le); ring->out_size =3D le32_to_cpu(h.size_le); ring->out_cons =3D cons + le32_to_cpu(h.size_le); =20 - qemu_co_queue_init(&pdu->complete); - pdu_submit(pdu); + pdu_submit(pdu, &h); =20 return 0; }