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@amd.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
Jason Andryuk authored and Jan Beulich committed 2025-08-19 11:04:02 +02:00
1 parent c67def341a
commit 9947e2ad88
4 files changed
+17 -16

No files matched your search

+6 -3
View File
@@ -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);
+2 -4
View File
@@ -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)
+7 -7
View File
@@ -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");
/*
+2 -2
View File
@@ -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);
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.