]> xenbits.xensource.com Git - xen.git/commit
tools/oxenstored: Rework Domain evtchn handling to use port_pair
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 30 Nov 2022 11:59:34 +0000 (11:59 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 1 Dec 2022 16:07:17 +0000 (16:07 +0000)
commitdf2db174b36eba67c218763ef621c67912202fc6
tree6fe292e2d7b649864d41792deb0fecde24d97ec0
parentaecdc28d9538ca2a1028ef9bc6550cb171dbbed4
tools/oxenstored: Rework Domain evtchn handling to use port_pair

Inter-domain event channels are always a pair of local and remote ports.
Right now the handling is asymmetric, caused by the fact that the evtchn is
bound after the associated Domain object is constructed.

First, move binding of the event channel into the Domain.make() constructor.
This means the local port no longer needs to be an option.  It also removes
the final callers of Domain.bind_interdomain.

Next, introduce a new port_pair type to encapsulate the fact that these two
should be updated together, and replace the previous port and remote_port
fields.  This refactoring also changes the Domain.get_port interface (removing
an option) so take the opportunity to name it get_local_port instead.

Also, this fixes a use-after-free risk with Domain.close.  Once the evtchn has
been unbound, the same local port number can be reused for a different
purpose, so explicitly invalidate the ports to prevent their accidental misuse
in the future.

This also cleans up some of the debugging, to always print a port pair.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Edwin Török <edvin.torok@citrix.com>
Acked-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/xenstored/connections.ml
tools/ocaml/xenstored/domain.ml
tools/ocaml/xenstored/domains.ml