Previously, the xenstore "introduced" state was used to avoid running init-dom0less twice on the same domain. With xenstored auto-introduction, that can no longer be used. Instead check of the domain's name has been set and use that to determine whether or not to bail out.
Signed-off-by: Jason Andryuk <jason.andr...@amd.com> --- v3: Move xenstore reading into domain_exists() Reorder --- tools/helpers/init-dom0less.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c index 3906c4b61a..eb793c7aab 100644 --- a/tools/helpers/init-dom0less.c +++ b/tools/helpers/init-dom0less.c @@ -60,6 +60,19 @@ static int get_xs_page(libxl_dominfo *info, uint64_t *xenstore_pfn) return 0; } +static char *do_xs_read_dom(struct xs_handle *xsh, xs_transaction_t t, + domid_t domid, char *path) +{ + char full_path[STR_MAX_LENGTH]; + int rc; + + rc = snprintf(full_path, STR_MAX_LENGTH, + "/local/domain/%u/%s", domid, path); + if (rc < 0 || rc >= STR_MAX_LENGTH) + return NULL; + return xs_read(xsh, t, full_path, NULL); +} + static bool do_xs_write_dom(struct xs_handle *xsh, xs_transaction_t t, domid_t domid, char *path, char *val) { @@ -332,7 +345,13 @@ static int init_domain(libxl_dominfo *info) /* Check if domain has been configured in XS */ static bool domain_exists(int domid) { - return xs_is_domain_introduced(xsh, domid); + char *name = do_xs_read_dom(xsh, XBT_NULL, domid, "name"); + if (name) { + free(name); + return true; + } + + return false; } int main(int argc, char **argv) -- 2.50.1