Skip to contentSkip to conversation

xenstored fixes

PATCH In review Jason Andryuk 3 participants 6 messages Nov 24, 2025 – Nov 25, 2025

lore
Share & tools
lore
#0 lore raw

cover xenstored fixes

A fix for running xenstored without a control domain, and the addition of a missing newline.

Jason Andryuk (2):
xenstored: Default priv_domid to store_domid
xenstored: Add newline to error message

 tools/xenstored/domain.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.51.1
#1 lore raw

PATCH 1/2 xenstored: Default priv_domid to store_domid

On a system without a control domain, a hardware|xenstore domain starting xenstored shows:
common/grant_table.c:1041:d2v0 Could not find domain 32756
gnttab: error: mmap failed: Invalid argument
Could not initialize dom32756

setup_structure() does not get called without priv_domid. Subsequent introduce_domain() calls will fault when calling fire_special_watches().

Default priv_domid to store_domid when there is no control domain.

Fixes e5b0a9405571 ("tools/xenstored: Auto-introduce domains")

---
I didn't verify the segfault in fire_watches() in this situation, but I saw that previously when working on this. Regardless of the specific error, xenstored was not working properly without this change.

---
 tools/xenstored/domain.c | 6 ++++++
 1 file changed, 6 insertions(+)
tools/xenstored/domain.c +6 -0
index 5ce539d640..d504e9994b 100644
@@ -1388,6 +1388,12 @@ void init_domains(void)
 	if (store_domid == DOMID_INVALID)
 		barf("Could not determine xenstore domid\n");
 
+	if (priv_domid == DOMID_INVALID)
+	{
+		priv_domid = store_domid;
+		xprintf("priv_domid defaulted to %u\n", priv_domid);
+	}
+
 	snprintf(store_domain_path, sizeof(store_domain_path),
 		 "/local/domain/%u", store_domid);
 
Signature · 1 line
2.51.1
#2 lore raw

Re: [XEN][PATCH 1/2] xenstored: Default priv_domid to store_domid

Quoted 6 lines · Jason Andryuk

On a system without a control domain, a hardware|xenstore domain starting xenstored shows:
common/grant_table.c:1041:d2v0 Could not find domain 32756
gnttab: error: mmap failed: Invalid argument
Could not initialize dom32756

Quoted 7 lines

setup_structure() does not get called without priv_domid. Subsequent introduce_domain() calls will fault when calling fire_special_watches().

Default priv_domid to store_domid when there is no control domain.

Fixes e5b0a9405571 ("tools/xenstored: Auto-introduce domains")

Just to mention - unless told otherwise, the Fixes: tag here won't make me take this change for backport, as I don't think a "system without control domain" was deemed as thing back at the time.

Jan

Reviewed-by on v1 1/2
#3 lore raw

Re: [XEN][PATCH 1/2] xenstored: Default priv_domid to store_domid

In reply to Jason Andryuk
Quoted 6 lines · Jason Andryuk

On a system without a control domain, a hardware|xenstore domain starting xenstored shows:
common/grant_table.c:1041:d2v0 Could not find domain 32756
gnttab: error: mmap failed: Invalid argument
Could not initialize dom32756

Quoted 7 lines

setup_structure() does not get called without priv_domid. Subsequent introduce_domain() calls will fault when calling fire_special_watches().

Default priv_domid to store_domid when there is no control domain.

Fixes e5b0a9405571 ("tools/xenstored: Auto-introduce domains")
Quoted 4 lines

---
I didn't verify the segfault in fire_watches() in this situation, but I saw that previously when working on this. Regardless of the specific error, xenstored was not working properly without this change.

The segfault was probably really related to the missing call of setup_structure() in this case, as the nodes hashtable wouldn't be initialized. This will result in a NULL dereference as soon as any watch is tried to be fired when the existence of the related node (@introduceDomain in this case) is checked.

Juergen

#4 lore raw

PATCH 2/2 xenstored: Add newline to error message

In reply to Jason Andryuk

Unlike barf(), xprintf() does not add a newline. Add one.

Fixes e5b0a9405571 ("tools/xenstored: Auto-introduce domains")
---
 tools/xenstored/domain.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/xenstored/domain.c +1 -1
index d504e9994b..10ac1c1a8f 100644
@@ -1333,7 +1333,7 @@ static bool init_domain(unsigned int domid)
 
 	domain = introduce_domain(NULL, domid, port, false);
 	if (!domain) {
-		xprintf("Could not initialize dom%u", domid);
+		xprintf("Could not initialize dom%u\n", domid);
 		return false;
 	}
 
Signature · 1 line
2.51.1