From patchwork Fri Jul 29 17:53:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= X-Patchwork-Id: 12932765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BDA60C19F2A for ; Fri, 29 Jul 2022 17:54:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.377688.610996 (Exim 4.92) (envelope-from ) id 1oHUBi-00076l-Fc; Fri, 29 Jul 2022 17:54:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 377688.610996; Fri, 29 Jul 2022 17:54:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBi-00076c-Bx; Fri, 29 Jul 2022 17:54:14 +0000 Received: by outflank-mailman (input) for mailman id 377688; Fri, 29 Jul 2022 17:54:13 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oHUBg-0006a9-SJ for xen-devel@lists.xenproject.org; Fri, 29 Jul 2022 17:54:12 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 73981336-0f67-11ed-924f-1f966e50362f; Fri, 29 Jul 2022 19:54:11 +0200 (CEST) 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 Sender: "Xen-devel" X-Inumbo-ID: 73981336-0f67-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1659117251; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YsqAUruZxEJZb5m63knmpMxcbbh9Lwsahf6qP5J6SRg=; b=csiKeO3Qi3BK7huzdBDZRIfrD21iNnMzO0rF22E5T++Ui8ZVT9tRzwBy y2nSUVUj/bWBsuvmzpY5e5xEqx9ruzhBXOGENRAzIEbPH54lyANAungxW sSjncoCZq4hIek7L3zkruR+dSzBr9Z67/UBY0Uuw5VOA/MLvOxrYBl9t4 M=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 76954909 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:FxXJPawBzM7eICQM0pF6t4n5zX0HO/c/ZkZSj0bt7gibmJ9p5j4zwXa+PPA8n6MSOj+oBzLS1YKs1foezaYk266aquEDHqvKjqCfOsM6bLDre/KbNWdY6s4SBA5s+mKOzHkOM/ISFHkvY9UAfsMjU7+bXqUrzJLSLOobNlPUVXVjmdP4dYsj+QTJro8s6wH8SPKjhKP/YcDZk/OMio2BbITP5Sk/mVEVEC/+6spRb7BO+yISBg7gNFo9fF4k303rZYrP0QGJb7w/GSNHejqEDsOBjtxvSfUyR5ARWgdXeWV3FBaoO3SsojjwVn74Akjg7VDFHt7otLIq4LLWrN6NnvAWNCzNtmH6yy2SQu3grTMhNJLPI6Izdr16gWc34e9VdK2K9LgeEuOl4GZ5WWYZCoi+TUjAx/JGPH+cWD15qx2vw0c598Cu+viJjz2YCMAOPdCtPLKcup8e2HXIjRioyrACeSWohFQXNNjQFnCuaTnwR8dBnuRRuio2HAQoVRwtaDD0OURJcGGl7vRdiWg9fGpp1wPGN6MpnDfpfE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hq8cP3z1lQVDCOOmylyDtQA== X-IronPort-AV: E=Sophos;i="5.93,201,1654574400"; d="scan'208";a="76954909" From: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= To: CC: =?utf-8?b?RWR3aW4gVMO2csO2aw==?= , "Christian Lindig" , David Scott , Wei Liu , Anthony PERARD Subject: [PATCH v1 6/7] tools/ocaml/libs/xb: hide type of Xb.t Date: Fri, 29 Jul 2022 18:53:29 +0100 Message-ID: <74ab9ad3ed031654fbfc343f299cedba2ebe3ac9.1659116941.git.edvin.torok@citrix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 The only user of 'xb' that I can find is in-tree oxenstored. Other code (e.g. xenopsd) would use the mirage 'xenstore' implementation instead, so changing the API here shouldn't require anyone to update their code. Hiding the type will make it easier to change the implementation in the future without breaking code that relies on it. No functional change. Signed-off-by: Edwin Török --- tools/ocaml/libs/xb/xb.ml | 3 +++ tools/ocaml/libs/xb/xb.mli | 9 ++------- tools/ocaml/xenstored/connection.ml | 8 ++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/tools/ocaml/libs/xb/xb.ml b/tools/ocaml/libs/xb/xb.ml index 104d319d77..8404ddd8a6 100644 --- a/tools/ocaml/libs/xb/xb.ml +++ b/tools/ocaml/libs/xb/xb.ml @@ -196,6 +196,9 @@ let peek_output con = Queue.peek con.pkt_out let input_len con = Queue.length con.pkt_in let has_in_packet con = Queue.length con.pkt_in > 0 let get_in_packet con = Queue.pop con.pkt_in +let has_partial_input con = match con.partial_in with + | HaveHdr _ -> true + | NoHdr (n, _) -> n < Partial.header_size () let has_more_input con = match con.backend with | Fd _ -> false diff --git a/tools/ocaml/libs/xb/xb.mli b/tools/ocaml/libs/xb/xb.mli index 3a00da6cdd..794e35bb34 100644 --- a/tools/ocaml/libs/xb/xb.mli +++ b/tools/ocaml/libs/xb/xb.mli @@ -66,13 +66,7 @@ type backend_mmap = { type backend_fd = { fd : Unix.file_descr; } type backend = Fd of backend_fd | Xenmmap of backend_mmap type partial_buf = HaveHdr of Partial.pkt | NoHdr of int * bytes -type t = { - backend : backend; - pkt_in : Packet.t Queue.t; - pkt_out : Packet.t Queue.t; - mutable partial_in : partial_buf; - mutable partial_out : string; -} +type t val init_partial_in : unit -> partial_buf val reconnect : t -> unit val queue : t -> Packet.t -> unit @@ -97,6 +91,7 @@ val has_output : t -> bool val peek_output : t -> Packet.t val input_len : t -> int val has_in_packet : t -> bool +val has_partial_input : t -> bool val get_in_packet : t -> Packet.t val has_more_input : t -> bool val is_selectable : t -> bool diff --git a/tools/ocaml/xenstored/connection.ml b/tools/ocaml/xenstored/connection.ml index a94d47cdc2..0ce54cd7f9 100644 --- a/tools/ocaml/xenstored/connection.ml +++ b/tools/ocaml/xenstored/connection.ml @@ -125,9 +125,7 @@ let get_perm con = let set_target con target_domid = con.perm <- Perms.Connection.set_target (get_perm con) ~perms:[Perms.READ; Perms.WRITE] target_domid -let is_backend_mmap con = match con.xb.Xenbus.Xb.backend with - | Xenbus.Xb.Xenmmap _ -> true - | _ -> false +let is_backend_mmap con = Xenbus.Xb.is_mmap con.xb let send_reply con tid rid ty data = if (String.length data) > xenstore_payload_max && (is_backend_mmap con) then @@ -280,9 +278,7 @@ let get_transaction con tid = let do_input con = Xenbus.Xb.input con.xb let has_input con = Xenbus.Xb.has_in_packet con.xb -let has_partial_input con = match con.xb.Xenbus.Xb.partial_in with - | HaveHdr _ -> true - | NoHdr (n, _) -> n < Xenbus.Partial.header_size () +let has_partial_input con = Xenbus.Xb.has_partial_input con.xb let pop_in con = Xenbus.Xb.get_in_packet con.xb let has_more_input con = Xenbus.Xb.has_more_input con.xb