All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Christian Lindig <christian.lindig@citrix.com>,
	David Scott <dave@recoil.org>,
	Edwin Torok <edvin.torok@citrix.com>,
	Rob Hoes <Rob.Hoes@citrix.com>
Subject: [PATCH v2 4/6] tools/oxenstored: Implement Domain.rebind_evtchn
Date: Wed, 30 Nov 2022 16:54:53 +0000	[thread overview]
Message-ID: <20221130165455.31125-5-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <20221130165455.31125-1-andrew.cooper3@citrix.com>

Generally speaking, the event channel local/remote port is fixed for the
lifetime of the associated domain object.  The exception to this is a
secondary XS_INTRODUCE (defined to re-bind to a new event channel) which pokes
around at the domain object's internal state.

We need to refactor the evtchn handling to support live update, so start by
moving the relevant manipulation into Domain.

No practical change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Christian Lindig <christian.lindig@citrix.com>
CC: David Scott <dave@recoil.org>
CC: Edwin Torok <edvin.torok@citrix.com>
CC: Rob Hoes <Rob.Hoes@citrix.com>

Note: This change deliberately doesn't reuse Domain.bind_interdomain, which is
removed by the end of the refactoring.

v2:
 * New.
---
 tools/ocaml/xenstored/domain.ml  | 12 ++++++++++++
 tools/ocaml/xenstored/process.ml |  6 ++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/tools/ocaml/xenstored/domain.ml b/tools/ocaml/xenstored/domain.ml
index ab08dcf37f62..d59a9401e211 100644
--- a/tools/ocaml/xenstored/domain.ml
+++ b/tools/ocaml/xenstored/domain.ml
@@ -63,6 +63,18 @@ let string_of_port = function
 let dump d chan =
 	fprintf chan "dom,%d,%nd,%d\n" d.id d.mfn d.remote_port
 
+let rebind_evtchn d remote_port =
+	begin match d.port with
+	| None -> ()
+	| Some p -> Event.unbind d.eventchn p
+	end;
+	let local = Event.bind_interdomain d.eventchn d.id remote_port in
+	debug "domain %d rebind (l %s, r %d) => (l %d, r %d)"
+	      d.id (string_of_port d.port) d.remote_port
+	      (Xeneventchn.to_int local) remote_port;
+	d.remote_port <- remote_port;
+	d.port <- Some (local)
+
 let notify dom =
 	match dom.port with
 	| None -> warn "domain %d: attempt to notify on unknown port" dom.id
diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index b2973aca2a82..2ea940d7e2d5 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -567,11 +567,9 @@ let do_introduce con t domains cons data =
 	let dom =
 		if Domains.exist domains domid then
 			let edom = Domains.find domains domid in
-			if (Domain.get_mfn edom) = mfn && (Connections.find_domain cons domid) != con then begin
+			if (Domain.get_mfn edom) = mfn && (Connections.find_domain cons domid) != con then
 				(* Use XS_INTRODUCE for recreating the xenbus event-channel. *)
-				edom.remote_port <- remote_port;
-				Domain.bind_interdomain edom;
-			end;
+				Domain.rebind_evtchn edom remote_port;
 			edom
 		else try
 			let ndom = Domains.create domains domid mfn remote_port in
-- 
2.11.0



  parent reply	other threads:[~2022-11-30 16:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 16:54 [PATCH v2 0/6] More Oxenstored live update fixes Andrew Cooper
2022-11-30 16:54 ` [PATCH v2 1/6] tools/oxenstored: Style fixes to Domain Andrew Cooper
2022-11-30 17:14   ` Edwin Torok
2022-12-01 11:11   ` Christian Lindig
2022-11-30 16:54 ` [PATCH v2 2/6] tools/oxenstored: Bind the DOM_EXC VIRQ in in Event.init() Andrew Cooper
2022-11-30 17:16   ` Edwin Torok
2022-12-01 11:27   ` Christian Lindig
2022-11-30 16:54 ` [PATCH v2 3/6] tools/oxenstored: Rename some 'port' variables to 'remote_port' Andrew Cooper
2022-11-30 17:16   ` Edwin Torok
2022-12-01 11:26   ` Christian Lindig
2022-12-01 12:02     ` Andrew Cooper
2022-11-30 16:54 ` Andrew Cooper [this message]
2022-11-30 17:15   ` [PATCH v2 4/6] tools/oxenstored: Implement Domain.rebind_evtchn Edwin Torok
2022-12-01 11:20   ` Christian Lindig
2022-12-01 12:10     ` Andrew Cooper
2022-12-01 13:10       ` Christian Lindig
2022-12-02  9:11       ` Edwin Torok
2022-11-30 16:54 ` [PATCH v2 5/6] tools/oxenstored: Rework Domain evtchn handling to use port_pair Andrew Cooper
2022-11-30 17:17   ` Edwin Torok
2022-12-01 11:59   ` Christian Lindig
2022-12-01 14:22     ` Andrew Cooper
2022-12-01 15:22       ` Edwin Torok
2022-11-30 16:54 ` [PATCH v2 6/6] tools/oxenstored: Keep /dev/xen/evtchn open across live update Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221130165455.31125-5-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Rob.Hoes@citrix.com \
    --cc=christian.lindig@citrix.com \
    --cc=dave@recoil.org \
    --cc=edvin.torok@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.