device_model_user="xen-qemuuser-c6-01"
+If you use this method, you should also allocate one "reaper" user to
+be used for killing device models:
+
+ adduser --system --no-create-home --group xen-qemuuser-reaper
+
NOTE: It is important when using `device_model_user` that EACH VM HAVE
A SEPARATE UID, and that none of these UIDs map to root. xl will
throw an error a uid maps to zero, but not if multiple VMs have the
same uid. Multiple VMs with the same device model uid will cause
problems.
+It is also important that `xen-qemuuser-reaper` not have any processes
+associated with it, as they will be destroyed when deprivileged qemu
+processes are destroyed.
+
## Domain config changes
The core domain config change is to add the following line to the
struct passwd *user_base, user_pwbuf;
int rc;
+ rc = userlookup_helper_getpwnam(gc, LIBXL_QEMU_USER_REAPER,
+ &user_pwbuf, &user_base);
+ /*
+ * Either there was an error, or we found a suitable user; stop
+ * looking
+ */
+ if (rc || user_base)
+ goto out;
+
rc = userlookup_helper_getpwnam(gc, LIBXL_QEMU_USER_RANGE_BASE,
&user_pwbuf, &user_base);
- if (rc)
- return rc;
+ if (rc || user_base)
+ goto out;
- if (!user_base) {
- LOG(WARN, "Couldn't find uid for reaper process");
- return ERROR_INVAL;
- }
-
- if (user_base->pw_uid == 0) {
- LOG(ERROR, "UID for reaper process maps to root!");
- return ERROR_INVAL;
+ LOG(WARN, "Couldn't find uid for reaper process");
+ rc = ERROR_INVAL;
+
+ out:
+ /* First check to see if the discovered user maps to root */
+ if (!rc) {
+ if (user_base->pw_uid == 0) {
+ LOG(ERROR, "UID for reaper process maps to root!");
+ rc = ERROR_INVAL;
+ }
}
- *reaper_uid = user_base->pw_uid;
+ /* If everything is OK, set reaper_uid as appropriate */
+ if (!rc)
+ *reaper_uid = user_base->pw_uid;
- return 0;
+ return rc;
}
const char *libxl__domain_device_model(libxl__gc *gc,
/*
* Get reaper_uid. If we can't find such a uid, return an error.
- *
- * FIXME: This means that domain destruction will fail if
- * device_model_user is set but QEMU_USER_RANGE_BASE doesn't exist.
*/
return libxl__get_reaper_uid(gc, reaper_uid);
}
#define LIBXL_QEMU_USER_PREFIX "xen-qemuuser"
#define LIBXL_QEMU_USER_SHARED LIBXL_QEMU_USER_PREFIX"-shared"
#define LIBXL_QEMU_USER_RANGE_BASE LIBXL_QEMU_USER_PREFIX"-range-base"
+#define LIBXL_QEMU_USER_REAPER LIBXL_QEMU_USER_PREFIX"-reaper"
static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info)
{