+static int get_virtualization(char **v) {
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
+ _cleanup_bus_unref_ sd_bus *bus = NULL;
+ const char *t;
+ char *b;
+ int r;
+
+ r = sd_bus_open_system(&bus);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_new_method_call(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ &m);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_append(m, "ss", "org.freedesktop.systemd1.Manager", "Virtualization");
+ if (r < 0)
+ return r;
+
+ r = sd_bus_send_with_reply_and_block(bus, m, 0, NULL, &reply);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_read(reply, "v", "s", &t);
+ if (r < 0)
+ return r;
+
+ if (isempty(t)) {
+ *v = NULL;
+ return 0;
+ }
+
+ b = strdup(t);
+ if (!b)
+ return -ENOMEM;
+
+ *v = b;
+ return 1;
+}
+