diff mbox series

[v4,25/32] tools/xenstored: get own domid in stubdom case

Message ID 20240205105001.24171-26-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series tools: enable xenstore-stubdom to use 9pfs | expand

Commit Message

Jürgen Groß Feb. 5, 2024, 10:49 a.m. UTC
Obtain own domid when running as stubdom.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
---
V2:
- replacement of V1 patch (Andrew Cooper)
V3:
- rename called function to get_domid() (Julien Grall)
- change stub_domid type to domid_t (Julien Grall)
---
 tools/xenstored/core.c   | 1 +
 tools/xenstored/core.h   | 1 +
 tools/xenstored/minios.c | 4 ++++
 3 files changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index c045a6e5db..9eb3cdf446 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2557,6 +2557,7 @@  static struct option options[] = {
 int dom0_domid = 0;
 int dom0_event = 0;
 int priv_domid = 0;
+domid_t stub_domid = DOMID_INVALID;
 
 static unsigned int get_optval_uint(const char *arg)
 {
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 6180ec8b5c..f6af086f01 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -361,6 +361,7 @@  do {						\
 extern int dom0_domid;
 extern int dom0_event;
 extern int priv_domid;
+extern domid_t stub_domid;
 extern bool keep_orphans;
 
 extern struct pollfd *poll_fds;
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 6d0c11423c..22ac8defbd 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -20,6 +20,7 @@ 
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
+#include <mini-os/lib.h>
 
 void finish_daemonize(void)
 {
@@ -48,6 +49,9 @@  void unmap_xenbus(void *interface)
 
 void early_init(bool live_update, bool dofork, const char *pidfile)
 {
+	stub_domid = get_domid();
+	if (stub_domid == DOMID_INVALID)
+		barf("could not get own domid");
 }
 
 void late_init(bool live_update)