|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tools/xenstored: Rename dom0_domid to store_domid
commit 9947e2ad889cd111b3a1a1afb9f401928d8f5dda
Author: Jason Andryuk <jason.andryuk@xxxxxxx>
AuthorDate: Fri Aug 15 17:35:54 2025 -0400
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Aug 19 11:04:02 2025 +0200
tools/xenstored: Rename dom0_domid to store_domid
The dom0_domid variable is misnamed and conflates purposes. If we have
xenstored running in a Linux domain that is not dom0, this variable
controls the lookup of /proc/xen/xsd_kva and the event channel.
Rename to store_domid to better show its purpose.
One implication of this change is that the xenstore domain is not
privileged by virtue of considering store_domid as privileged.
domain_is_unprivileged() removes the dom0_domid/store_domid check, so
xenstore domain is no longer considered privileged.
onearg_domain() is updated to return EINVAL for store_domid or priv_domid
to maintain the ability to call XS_RESUME.
xenbus_master_domid() is removed with store_domid being used instead.
Add a description of the -m/--master-domid options while
doing this.
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
---
tools/xenstored/core.c | 9 ++++++---
tools/xenstored/core.h | 6 ++----
tools/xenstored/domain.c | 14 +++++++-------
tools/xenstored/posix.c | 4 ++--
4 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 7a65ddb585..64c478a801 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2539,7 +2539,10 @@ static void usage(void)
" allowed timeout candidates are:\n"
" watch-event: time a watch-event is kept pending\n"
" -K, --keep-orphans don't delete nodes owned by a domain when the\n"
-" domain is deleted (this is a security risk!)\n");
+" domain is deleted (this is a security risk!)\n"
+" -m, --master-domid specify the domid of the domain where xenstored\n"
+" is running. defaults to 0\n"
+);
}
@@ -2567,7 +2570,7 @@ static struct option options[] = {
#endif
{ NULL, 0, NULL, 0 } };
-int dom0_domid = DOMID_INVALID;
+int store_domid = DOMID_INVALID;
int dom0_event = 0;
int priv_domid = DOMID_INVALID;
domid_t stub_domid = DOMID_INVALID;
@@ -2736,7 +2739,7 @@ int main(int argc, char *argv[])
dom0_event = get_optval_uint(optarg);
break;
case 'm':
- dom0_domid = get_optval_uint(optarg);
+ store_domid = get_optval_uint(optarg);
break;
case 'p':
priv_domid = get_optval_uint(optarg);
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index cef3c71eb0..e0b48e4978 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -365,7 +365,7 @@ do { \
trace("tdb: " __VA_ARGS__); \
} while (0)
-extern int dom0_domid;
+extern int store_domid;
extern int dom0_event;
extern int priv_domid;
extern domid_t stub_domid;
@@ -382,11 +382,9 @@ uint64_t get_now_msec(void);
void *xenbus_map(void);
void unmap_xenbus(void *interface);
-static inline int xenbus_master_domid(void) { return dom0_domid; }
-
static inline bool domid_is_unprivileged(unsigned int domid)
{
- return domid != dom0_domid && domid != priv_domid;
+ return domid != priv_domid;
}
static inline bool domain_is_unprivileged(const struct connection *conn)
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index bcc63104b7..e282b5c5ed 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -509,7 +509,7 @@ static const struct interface_funcs domain_funcs = {
static void *map_interface(domid_t domid)
{
- if (domid == xenbus_master_domid())
+ if (domid == store_domid)
return xenbus_map();
#ifdef __MINIOS__
@@ -524,7 +524,7 @@ static void *map_interface(domid_t domid)
static void unmap_interface(domid_t domid, void *interface)
{
- if (domid == xenbus_master_domid())
+ if (domid == store_domid)
unmap_xenbus(interface);
else if (domid != stub_domid)
xengnttab_unmap(*xgt_handle, interface, 1);
@@ -1158,7 +1158,7 @@ static struct domain *onearg_domain(struct connection
*conn,
return ERR_PTR(-EINVAL);
domid = atoi(domid_str);
- if (domid == dom0_domid)
+ if (domid == store_domid || domid == priv_domid)
return ERR_PTR(-EINVAL);
return find_connected_domain(domid);
@@ -1381,14 +1381,14 @@ void init_domains(void)
* have 1 domain. stubdom there will be dom0 and dom1,
* so this will take the second for stubdom.
*/
- dom0_domid = domid;
+ store_domid = domid;
}
}
- if (dom0_domid == DOMID_INVALID)
- dom0_domid = priv_domid;
+ if (store_domid == DOMID_INVALID)
+ store_domid = priv_domid;
- if (dom0_domid == DOMID_INVALID)
+ if (store_domid == DOMID_INVALID)
barf("Could not determine xenstore domid\n");
/*
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 4a97f53dc0..0ec7babb7a 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -174,7 +174,7 @@ static evtchn_port_t get_xenbus_evtchn(void)
*/
evtchn_port_t get_domain_evtchn(unsigned int domid)
{
- if (domid == xenbus_master_domid())
+ if (domid == store_domid)
return get_xenbus_evtchn();
return 0;
@@ -280,7 +280,7 @@ static void accept_connection(int sock)
conn = new_connection(&socket_funcs);
if (conn) {
conn->fd = fd;
- conn->id = dom0_domid;
+ conn->id = store_domid;
} else
close(fd);
}
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |