Skip to contentSkip to conversation

tools: set Dom0 UUID if requested

PATCH Superseded Wei Liu 5 participants 8 messages Nov 20, 2018 – Nov 26, 2018

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH v3 1/1 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.

---
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(-)
tools/helpers/Makefile +2 -1
index 4f3bbe6a7d..f759528322 100644
@@ -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
 
tools/helpers/xen-init-dom0.c +39 -3

72 lines not on this page · raw message

tools/hotplug/Linux/init.d/sysconfig.xencommons.in +3 -0
index 92569cd61b..0fc6557d4a 100644
@@ -95,3 +95,6 @@ XENSTORE_DOMAIN_ARGS=
 
 # qemu path
 #QEMU_XEN=@qemu_xen_path@
+
+# Dom0 UUID
+#XEN_DOM0_UUID=00000000-0000-0000-0000-000000000000
tools/hotplug/Linux/init.d/xencommons.in +1 -1
index ec42b05587..a33058ed44 100644
@@ -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"
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
index 3befadcea3..beed3126c6 100644
@@ -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
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v3 1/1
#2 lore raw
In reply to Wei Liu
Quoted 6 lines · Wei Liu

Introduce XEN_DOM0_UUID in Xen's global configuration file. Make xen-init-dom0 accept an extra argument for UUID.

---
v3: new approach

Quoted 7 lines
---
 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(-)

Thanks

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Wei Liu
Quoted 4 lines · Wei Liu
tools/helpers/xen-init-dom0.c +0 -0
index 09bc0027f9..a2f31fe9bf 100644

[..]

tools/helpers/xen-init-dom0.c line 39

Quoted 11 lines
     xsh = xs_open(0);
     if (!xsh) {
         fprintf(stderr, "cannot open xenstore connection\n");
tools/helpers/xen-init-dom0.c +7 -1
-        exit(1);
+        rc = 1;
+        goto out;
+    }
+
+    xch = xc_interface_open(NULL, NULL, 0);
+    if (!xch) {
+        fprintf(stderr, "xc_interface_open() failed\n");

It might be usefull to print errno as well. I mean what perror would print.

Quoted 12 lines
tools/helpers/xen-init-dom0.c +4 -1
+        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);
+

tools/helpers/xen-init-dom0.c int main(int argc, char **argv) · line 64

Quoted 10 lines
tools/helpers/xen-init-dom0.c +10 -0
+    /* 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);

Same here, I think it would be more usefull to use perror or strerror instead of printing the errno value.

Quoted 18 lines
tools/hotplug/Linux/init.d/xencommons.in +1 -1
index ec42b05587..a33058ed44 100644
@@ -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"
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +0 -0
index 3befadcea3..beed3126c6 100644

tools/hotplug/Linux/systemd/xen-init-dom0.service.in ConditionPathExists=/proc/xen/capabilities · line 15

Quoted 10 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
@@ -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

Don't you need to modify FreeBSD/rc.d/xencommons.in and NetBSD/rc.d/xencommons.in as well?

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
author
#4 lore raw
Quoted 13 lines · Anthony PERARD
Quoted 13 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
index 3befadcea3..beed3126c6 100644
@@ -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
 
Quoted 5 lines

tools/hotplug/Linux/systemd/xen-init-dom0.service.in ConditionPathExists=/proc/xen/capabilities · line 15

Quoted 2 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +0 -0
 [Install]
 WantedBy=multi-user.target

Don't you need to modify FreeBSD/rc.d/xencommons.in and NetBSD/rc.d/xencommons.in as well?

I didn't want to modify them without having a test setup first. The xen-init-dom0 program already takes into consideration that they don't provide UUID.

I can do it in the next version.

Wei.

Quoted 3 lines
Signature · 2 lines
-- 
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#5 lore raw
Quoted 20 lines · Wei Liu
Quoted 13 lines · Anthony PERARD
Quoted 13 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
index 3befadcea3..beed3126c6 100644
@@ -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
 
Quoted 5 lines

tools/hotplug/Linux/systemd/xen-init-dom0.service.in ConditionPathExists=/proc/xen/capabilities · line 15

Quoted 2 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +0 -0
 [Install]
 WantedBy=multi-user.target

Don't you need to modify FreeBSD/rc.d/xencommons.in and NetBSD/rc.d/xencommons.in as well?

Quoted 5 lines

I didn't want to modify them without having a test setup first. The xen-init-dom0 program already takes into consideration that they don't provide UUID.

I can do it in the next version.

Actually, now I remember. They don't have the same mechanism as Linux to source a system wide config file, so modifying the script without fixing that issue made no sense to me.

Roger, what's your opinion?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
Quoted 25 lines · Wei Liu
Quoted 24 lines · Wei Liu
Quoted 13 lines · Anthony PERARD
Quoted 13 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
index 3befadcea3..beed3126c6 100644
@@ -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
 
Quoted 5 lines

tools/hotplug/Linux/systemd/xen-init-dom0.service.in ConditionPathExists=/proc/xen/capabilities · line 15

Quoted 2 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +0 -0
 [Install]
 WantedBy=multi-user.target

Don't you need to modify FreeBSD/rc.d/xencommons.in and NetBSD/rc.d/xencommons.in as well?

I didn't want to modify them without having a test setup first. The xen-init-dom0 program already takes into consideration that they don't provide UUID.

Quoted 7 lines
Quoted 1 line

I can do it in the next version.

Actually, now I remember. They don't have the same mechanism as Linux to source a system wide config file, so modifying the script without fixing that issue made no sense to me.

Roger, what's your opinion?

I think it's fine to leave them as-is. Since there's no configuration file for BSDs init scripts modifying them to add such parameter is pointless.

If you feel like I guess you could add a placeholder to set the UUID in the init script itself, but that's more like a hack since users are not supposed to modify such scripts.

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author
#7 lore raw
Quoted 34 lines · Roger Pau Monné
Quoted 25 lines · Wei Liu
Quoted 24 lines · Wei Liu
Quoted 13 lines · Anthony PERARD
Quoted 13 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +2 -1
index 3befadcea3..beed3126c6 100644
@@ -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
 
Quoted 5 lines

tools/hotplug/Linux/systemd/xen-init-dom0.service.in ConditionPathExists=/proc/xen/capabilities · line 15

Quoted 2 lines
tools/hotplug/Linux/systemd/xen-init-dom0.service.in +0 -0
 [Install]
 WantedBy=multi-user.target

Don't you need to modify FreeBSD/rc.d/xencommons.in and NetBSD/rc.d/xencommons.in as well?

I didn't want to modify them without having a test setup first. The xen-init-dom0 program already takes into consideration that they don't provide UUID.

Quoted 7 lines
Quoted 1 line

I can do it in the next version.

Actually, now I remember. They don't have the same mechanism as Linux to source a system wide config file, so modifying the script without fixing that issue made no sense to me.

Roger, what's your opinion?

Quoted 7 lines

I think it's fine to leave them as-is. Since there's no configuration file for BSDs init scripts modifying them to add such parameter is pointless.

If you feel like I guess you could add a placeholder to set the UUID in the init script itself, but that's more like a hack since users are not supposed to modify such scripts.

OK. I think I will keep this part as-is.

Wei.

Quoted 2 lines

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel