+ if (!is_virtual_process_attr(process_attr) &&
+ domain != LTTNG_DOMAIN_KERNEL) {
+ ERR("Non-virtual process attributes can only be used in the kernel domain");
+ ret = LTTNG_ERR_UNSUPPORTED_DOMAIN;
+ goto error;
+ }
+
+ /* Only expect a payload for name value types. */
+ if (is_value_type_name(value_type) &&
+ (!value_view || value_view->size == 0)) {
+ ret = LTTNG_ERR_INVALID_PROTOCOL;
+ goto error;
+ } else if (!is_value_type_name(value_type) && value_view &&
+ value_view->size != 0) {
+ ret = LTTNG_ERR_INVALID_PROTOCOL;
+ goto error;
+ }
+
+ value->type = value_type;
+ switch (process_attr) {
+ case LTTNG_PROCESS_ATTR_PROCESS_ID:
+ case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID:
+ if (value_type != LTTNG_PROCESS_ATTR_VALUE_TYPE_PID) {
+ ERR("Invalid value type used for process ID process attribute");
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+ value->value.pid =
+ GET_INTEGRAL_COMM_VALUE(integral_value, pid_t);
+ break;
+ case LTTNG_PROCESS_ATTR_USER_ID:
+ case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID:
+ switch (value_type) {
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_UID:
+ value->value.uid = GET_INTEGRAL_COMM_VALUE(
+ integral_value, uid_t);
+ break;
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_USER_NAME:
+ if (!name) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
+ value->value.user_name = name;
+ name = NULL;
+ break;
+ default:
+ ERR("Invalid value type used for user ID process attribute");
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+ break;
+ case LTTNG_PROCESS_ATTR_GROUP_ID:
+ case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID:
+ switch (value_type) {
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_GID:
+ value->value.gid = GET_INTEGRAL_COMM_VALUE(
+ integral_value, gid_t);
+ break;
+ case LTTNG_PROCESS_ATTR_VALUE_TYPE_GROUP_NAME:
+ if (!name) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
+ value->value.group_name = name;
+ name = NULL;
+ break;
+ default:
+ ERR("Invalid value type used for group ID process attribute");
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+ break;
+ default:
+ ret = LTTNG_ERR_INVALID_PROTOCOL;