[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3] tools: set Dom0 UUID if requested
Introduce XEN_DOM0_UUID in Xen's global configuration file. Make xen-init-dom0 accept an extra argument for UUID. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- v3: new approach --- tools/helpers/Makefile | 3 +- tools/helpers/xen-init-dom0.c | 42 ++++++++++++++++++++-- tools/hotplug/Linux/init.d/sysconfig.xencommons.in | 3 ++ tools/hotplug/Linux/init.d/xencommons.in | 2 +- .../hotplug/Linux/systemd/xen-init-dom0.service.in | 3 +- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile index 4f3bbe6a7d..f759528322 100644 --- a/tools/helpers/Makefile +++ b/tools/helpers/Makefile @@ -14,6 +14,7 @@ XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxentoollog) $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenlight) +$(XEN_INIT_DOM0_OBJS): CFLAGS += $(CFLAGS_libxenctrl) INIT_XENSTORE_DOMAIN_OBJS = init-xenstore-domain.o init-dom-json.o $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxentoollog) @@ -26,7 +27,7 @@ $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenlight) all: $(PROGS) xen-init-dom0: $(XEN_INIT_DOM0_OBJS) - $(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS) + $(CC) $(LDFLAGS) -o $@ $(XEN_INIT_DOM0_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS) $(INIT_XENSTORE_DOMAIN_OBJS): _paths.h diff --git a/tools/helpers/xen-init-dom0.c b/tools/helpers/xen-init-dom0.c index 09bc0027f9..a2f31fe9bf 100644 --- a/tools/helpers/xen-init-dom0.c +++ b/tools/helpers/xen-init-dom0.c @@ -3,7 +3,9 @@ #include <string.h> #include <stdio.h> +#include <xenctrl.h> #include <xenstore.h> +#include <libxl.h> #include "init-dom-json.h" @@ -13,13 +15,30 @@ int main(int argc, char **argv) { int rc; - struct xs_handle *xsh; + struct xs_handle *xsh = NULL; + xc_interface *xch = NULL; char *domname_string = NULL, *domid_string = NULL; + libxl_uuid uuid; + + /* Accept 0 or 1 argument */ + if (argc > 2) { + fprintf(stderr, "too many arguments\n"); + rc = 1; + goto out; + } xsh = xs_open(0); if (!xsh) { fprintf(stderr, "cannot open xenstore connection\n"); - exit(1); + rc = 1; + goto out; + } + + xch = xc_interface_open(NULL, NULL, 0); + if (!xch) { + fprintf(stderr, "xc_interface_open() failed\n"); + rc = 1; + goto out; } /* Sanity check: this program can only be run once. */ @@ -31,7 +50,23 @@ int main(int argc, char **argv) goto out; } - rc = gen_stub_json_config(0, NULL); + libxl_uuid_clear(&uuid); + + /* If UUID is supplied, parse it. */ + if (argc == 2 && libxl_uuid_from_string(&uuid, argv[1])) { + fprintf(stderr, "failed to parse UUID %s\n", argv[1]); + rc = 1; + goto out; + } + + if (!libxl_uuid_is_nil(&uuid) && + xc_domain_sethandle(xch, 0, libxl_uuid_bytearray(&uuid))) { + fprintf(stderr, "failed to set Dom0 UUID, errno %d\n", errno); + rc = 1; + goto out; + } + + rc = gen_stub_json_config(0, &uuid); if (rc) goto out; @@ -55,6 +90,7 @@ out: free(domid_string); free(domname_string); xs_close(xsh); + xc_interface_close(xch); return rc; } diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in index 92569cd61b..0fc6557d4a 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -95,3 +95,6 @@ XENSTORE_DOMAIN_ARGS= # qemu path #QEMU_XEN=@qemu_xen_path@ + +# Dom0 UUID +#XEN_DOM0_UUID=00000000-0000-0000-0000-000000000000 diff --git a/tools/hotplug/Linux/init.d/xencommons.in b/tools/hotplug/Linux/init.d/xencommons.in index ec42b05587..a33058ed44 100644 --- a/tools/hotplug/Linux/init.d/xencommons.in +++ b/tools/hotplug/Linux/init.d/xencommons.in @@ -63,7 +63,7 @@ do_start () { @XEN_SCRIPT_DIR@/launch-xenstore || exit 1 echo Setting domain 0 name, domid and JSON config... - ${LIBEXEC_BIN}/xen-init-dom0 + ${LIBEXEC_BIN}/xen-init-dom0 ${XEN_DOM0_UUID} echo Starting xenconsoled... test -z "$XENCONSOLED_TRACE" || XENCONSOLED_ARGS=" --log=$XENCONSOLED_TRACE" diff --git a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in index 3befadcea3..beed3126c6 100644 --- a/tools/hotplug/Linux/systemd/xen-init-dom0.service.in +++ b/tools/hotplug/Linux/systemd/xen-init-dom0.service.in @@ -7,8 +7,9 @@ ConditionPathExists=/proc/xen/capabilities [Service] Type=oneshot RemainAfterExit=true +EnvironmentFile=@CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons ExecStartPre=/bin/grep -q control_d /proc/xen/capabilities -ExecStart=@LIBEXEC_BIN@/xen-init-dom0 +ExecStart=@LIBEXEC_BIN@/xen-init-dom0 $XEN_DOM0_UUID [Install] WantedBy=multi-user.target -- 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |