A hardware+xenstore domain will not be able to read HVM params, and init-dom0less reads HVM_PARAM_STORE_EVTCHN to determine whether or not a domain has xenstore.
xenstored had a similar issue, and it just tries to map a domain's reserved grant, GNTTAB_RESERVED_XENSTORE, to see if it is accessible. If successful, xenstored introduces the domain. Use the existing introduced state to determine if init-dom0less should try and read the param. If already introduced, initialization (and reading the HVM_PARAM) is skipped. This allows for running init-dom0less from a xenstored+hardware domain. It relies on the local socket xenstore connections being considered privileged. oxenstored has not been updated, so the exist code remains for backwards compatibility. Signed-off-by: Jason Andryuk <jason.andr...@amd.com> --- v3: New --- tools/helpers/init-dom0less.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index eb793c7aab..a4de40aeac 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -309,16 +309,20 @@ static int configure_xenstore(libxl_dominfo *info, static int init_domain(libxl_dominfo *info) { - uint64_t xenstore_evtchn, xenstore_pfn = 0; + uint64_t xenstore_evtchn = 0, xenstore_pfn = 0; + bool introduced; libxl_uuid uuid; int rc; - rc = configure_xenstore(info, &xenstore_evtchn, &xenstore_pfn); - if (rc) - return rc; + introduced = xs_is_domain_introduced(xsh, info->domid); + if (!introduced) { + rc = configure_xenstore(info, &xenstore_evtchn, &xenstore_pfn); + if (rc) + return rc; - if (xenstore_evtchn == 0) { - return 0; + if (xenstore_evtchn == 0) { + return 0; + } } libxl_uuid_generate(&uuid); @@ -332,7 +336,7 @@ static int init_domain(libxl_dominfo *info) if (rc) err(1, "writing to xenstore"); - if (!xs_is_domain_introduced(xsh, info->domid)) { + if (!introduced) { rc = xs_introduce_domain(xsh, info->domid, xenstore_pfn, xenstore_evtchn); if (!rc) -- 2.50.1