[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 3/6] tools/oxenstored: Rename some 'port' variables to 'remote_port'


  • To: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • From: Christian Lindig <christian.lindig@xxxxxxxxxx>
  • Date: Thu, 1 Dec 2022 11:26:16 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1Aqy0MZ9IAOZpNXFwlHlIPsi2nmbKD9KDE9zcUf9O7k=; b=dquSSfdfwPqQR4SRH46AZl8Yy0EBC1uNWqd9hTKG/uODR/MAKwqcK6uNYk1XK+15TaOts126Dk2tZOx/2svp7sC4B6JLwpp1FaS+8CCSDxWRPMhwvHMiPnPM09xV1GAvfiTABV3jEzEWCR8tH4guRrbBh9QRetCaliyzU02CITZbokyyzISdsrO9A4yJJdyJf82ZGgFepsB+qpEcKsXRDEmobg5ZA8hK78VMQ4Oe5Lf+WtRJof1wrO/MVOnjwfiXp9HTcSejOxkn4JVqGYhDzc6ylRIzkgG7pwFReaGIDkNnbPfyw6pdD0phn2c1akBx/d+/flvVAQ70BMyyoAxR4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=itVPV0MocV/g2jX17cVYIC2Ow7NFkzKLlzD0wNznFt7OPOma6t8Nd3og6lT/YSIVdx2Lr0r9AkDr46OXcXvLEAqYSy87vSWC+r5M4X5pyZV5szt/GJPNMIiS6Dg2aDialicmJjdFihNzVpPc/fEiufkMAJ/00sjaJM6IPvyyzSp5YlWAdohYWsbGAtninWgh16ZAZPDbc3s5zetrIrYQGou5gu5WqvAq0OoabncYuAGLZv2+Xzl35zPA97p4NJ1PUWtUw2mdJWlx4TUKyiAK7g67FFZYzrkmZaewWdVF1gkn0cZWkOAO2v5NiKMQ9i5OaEuw1QJdYXyc3qIbyHDs4g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Edwin Torok <edvin.torok@xxxxxxxxxx>, Rob Hoes <Rob.Hoes@xxxxxxxxxx>
  • Delivery-date: Thu, 01 Dec 2022 11:26:35 +0000
  • Ironport-data: A9a23:MPb2AqJ26lXE1F+UFE+RzpQlxSXFcZb7ZxGr2PjKsXjdYENShDwFm GQZXWrUM6uDN2b3eY90Oom18hkCvJaDm9JrQANlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5ARnPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5xQj9z9 NBDAQoGLU65t8SEzpuiSftj05FLwMnDZOvzu1lG5BSAV7MDfsqGRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/RppTSIpOBy+OGF3N79cdyQRN5Jn0+e4 GbH+Wj4DTkRNcCFyCrD+XWp7gPKtXOrBdxCT+3gnhJsqFO55WsNMU0Pb0q2u8C/oRS1dPBcK mVBr0LCqoB3riRHVOLVTxC+5XKJoBMYc95RCPE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S8dfh/yPPX1X1GGKYgByVNnXFg k3nSUqxYuna4GLgT04A9ikMmWVy3sfzUj6NKshpg==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHZBNyG3m7L7jSbr0+plHBtk/aEza5Y5boA
  • Thread-topic: [PATCH v2 3/6] tools/oxenstored: Rename some 'port' variables to 'remote_port'


> On 30 Nov 2022, at 16:54, Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx> wrote:
> 
> This will make the logic clearer when we plumb local_port through these
> functions.
> 
> While changing this, simplify the construct in Domains.create0 to separate the
> remote port handling from the interface.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Christian Lindig <christian.lindig@xxxxxxxxxx>
> CC: David Scott <dave@xxxxxxxxxx>
> CC: Edwin Torok <edvin.torok@xxxxxxxxxx>
> CC: Rob Hoes <Rob.Hoes@xxxxxxxxxx>

Acked-by: Christian Lindig <christian.lindig@xxxxxxxxxx>


> 
> v2:
> * New.
> ---
> tools/ocaml/xenstored/domains.ml   | 26 ++++++++++++--------------
> tools/ocaml/xenstored/process.ml   | 12 ++++++------
> tools/ocaml/xenstored/xenstored.ml |  8 ++++----
> 3 files changed, 22 insertions(+), 24 deletions(-)
> 
> diff --git a/tools/ocaml/xenstored/domains.ml 
> b/tools/ocaml/xenstored/domains.ml
> index 17fe2fa25772..26018ac0dd3d 100644
> --- a/tools/ocaml/xenstored/domains.ml
> +++ b/tools/ocaml/xenstored/domains.ml
> @@ -122,9 +122,9 @@ let cleanup doms =
> let resume _doms _domid =
>       ()
> 
> -let create doms domid mfn port =
> +let create doms domid mfn remote_port =
>       let interface = Xenctrl.map_foreign_range xc domid 
> (Xenmmap.getpagesize()) mfn in
> -     let dom = Domain.make domid mfn port interface doms.eventchn in
> +     let dom = Domain.make domid mfn remote_port interface doms.eventchn in
>       Hashtbl.add doms.table domid dom;
>       Domain.bind_interdomain dom;
>       dom
> @@ -133,18 +133,16 @@ let xenstored_kva = ref ""
> let xenstored_port = ref ""
> 
> let create0 doms =
> -     let port, interface =
> -             (
> -                     let port = Utils.read_file_single_integer 
> !xenstored_port
> -                     and fd = Unix.openfile !xenstored_kva
> -                                            [ Unix.O_RDWR ] 0o600 in
> -                     let interface = Xenmmap.mmap fd Xenmmap.RDWR 
> Xenmmap.SHARED
> -                                               (Xenmmap.getpagesize()) 0 in
> -                     Unix.close fd;
> -                     port, interface
> -             )
> -             in
> -     let dom = Domain.make 0 Nativeint.zero port interface doms.eventchn in
> +     let remote_port = Utils.read_file_single_integer !xenstored_port in
> +
> +     let interface =
> +             let fd = Unix.openfile !xenstored_kva [ Unix.O_RDWR ] 0o600 in
> +             let interface = Xenmmap.mmap fd Xenmmap.RDWR Xenmmap.SHARED 
> (Xenmmap.getpagesize()) 0 in

Can we be sure that this never throws an exception such that the close can't be 
missed? Otherwise a Fun.protect (or equivalent) should be used.

> +             Unix.close fd;
> +             interface
> +     in
> +
> +     let dom = Domain.make 0 Nativeint.zero remote_port interface 
> doms.eventchn in
>       Hashtbl.add doms.table 0 dom;
>       Domain.bind_interdomain dom;
>       Domain.notify dom;
> diff --git a/tools/ocaml/xenstored/process.ml 
> b/tools/ocaml/xenstored/process.ml
> index 72a79e9328dd..b2973aca2a82 100644
> --- a/tools/ocaml/xenstored/process.ml
> +++ b/tools/ocaml/xenstored/process.ml
> @@ -558,10 +558,10 @@ let do_transaction_end con t domains cons data =
> let do_introduce con t domains cons data =
>       if not (Connection.is_dom0 con)
>       then raise Define.Permission_denied;
> -     let (domid, mfn, port) =
> +     let (domid, mfn, remote_port) =
>               match (split None '\000' data) with
> -             | domid :: mfn :: port :: _ ->
> -                     int_of_string domid, Nativeint.of_string mfn, 
> int_of_string port
> +             | domid :: mfn :: remote_port :: _ ->
> +                     int_of_string domid, Nativeint.of_string mfn, 
> int_of_string remote_port
>               | _                         -> raise Invalid_Cmd_Args;
>               in
>       let dom =
> @@ -569,18 +569,18 @@ let do_introduce con t domains cons data =
>                       let edom = Domains.find domains domid in
>                       if (Domain.get_mfn edom) = mfn && 
> (Connections.find_domain cons domid) != con then begin
>                               (* Use XS_INTRODUCE for recreating the xenbus 
> event-channel. *)
> -                             edom.remote_port <- port;
> +                             edom.remote_port <- remote_port;
>                               Domain.bind_interdomain edom;
>                       end;
>                       edom
>               else try
> -                     let ndom = Domains.create domains domid mfn port in
> +                     let ndom = Domains.create domains domid mfn remote_port 
> in
>                       Connections.add_domain cons ndom;
>                       Connections.fire_spec_watches (Transaction.get_root t) 
> cons Store.Path.introduce_domain;
>                       ndom
>               with _ -> raise Invalid_Cmd_Args
>       in
> -     if (Domain.get_remote_port dom) <> port || (Domain.get_mfn dom) <> mfn 
> then
> +     if (Domain.get_remote_port dom) <> remote_port || (Domain.get_mfn dom) 
> <> mfn then
>               raise Domain_not_match
> 
> let do_release con t domains cons data =
> diff --git a/tools/ocaml/xenstored/xenstored.ml 
> b/tools/ocaml/xenstored/xenstored.ml
> index 55071b49eccb..1f11f576b515 100644
> --- a/tools/ocaml/xenstored/xenstored.ml
> +++ b/tools/ocaml/xenstored/xenstored.ml
> @@ -167,10 +167,10 @@ let from_channel_f chan global_f socket_f domain_f 
> watch_f store_f =
>                                       global_f ~rw
>                               | "socket" :: fd :: [] ->
>                                       socket_f ~fd:(int_of_string fd)
> -                             | "dom" :: domid :: mfn :: port :: []->
> +                             | "dom" :: domid :: mfn :: remote_port :: []->
>                                       domain_f (int_of_string domid)
>                                                (Nativeint.of_string mfn)
> -                                              (int_of_string port)
> +                                              (int_of_string remote_port)
>                               | "watch" :: domid :: path :: token :: [] ->
>                                       watch_f (int_of_string domid)
>                                               (unhexify path) (unhexify token)
> @@ -209,10 +209,10 @@ let from_channel store cons doms chan =
>               else
>                       warn "Ignoring invalid socket FD %d" fd
>       in
> -     let domain_f domid mfn port =
> +     let domain_f domid mfn remote_port =
>               let ndom =
>                       if domid > 0 then
> -                             Domains.create doms domid mfn port
> +                             Domains.create doms domid mfn remote_port
>                       else
>                               Domains.create0 doms
>                       in
> -- 
> 2.11.0
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.