$(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)
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
#include <string.h>
#include <stdio.h>
+#include <xenctrl.h>
#include <xenstore.h>
+#include <libxl.h>
#include "init-dom-json.h"
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);
+ perror("cannot open xenstore connection");
+ rc = 1;
+ goto out;
+ }
+
+ xch = xc_interface_open(NULL, NULL, 0);
+ if (!xch) {
+ perror("xc_interface_open() failed");
+ rc = 1;
+ goto out;
}
/* Sanity check: this program can only be run once. */
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))) {
+ perror("failed to set Dom0 UUID");
+ rc = 1;
+ goto out;
+ }
+
+ rc = gen_stub_json_config(0, &uuid);
if (rc)
goto out;
free(domid_string);
free(domname_string);
xs_close(xsh);
+ xc_interface_close(xch);
return rc;
}
@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"