int nparams,
unsigned int flags);
+/**
+ * VIR_DOMAIN_GUEST_INFO_USER_COUNT:
+ *
+ * The number of active users on this domain as an unsigned int.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_USER_COUNT "user.count"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_USER_PREFIX:
+ *
+ * The parameter name prefix to access each user entry. Concatenate the
+ * prefix, the entry number formatted as an unsigned integer and one of the
+ * user suffix parameters to form a complete parameter name.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_USER_PREFIX "user."
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_NAME:
+ *
+ * Username of the user as a string.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_NAME ".name"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_DOMAIN:
+ *
+ * Domain of the user as a string (may only be present on certain guest
+ * types).
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_DOMAIN ".domain"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_LOGIN_TIME:
+ *
+ * The login time of a user in milliseconds since the epoch as unsigned long
+ * long.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_LOGIN_TIME ".login-time"
+
/**
* virDomainGuestInfoTypes:
*
* (although not necessarily implemented for each hypervisor):
*
* VIR_DOMAIN_GUEST_INFO_USERS:
- * returns information about users that are currently logged in within the
- * guest domain. The typed parameter keys are in this format:
- *
- * "user.count" - the number of active users on this domain as an
- * unsigned int
- * "user.<num>.name" - username of the user as a string
- * "user.<num>.domain" - domain of the user as a string (may only be
- * present on certain guest types)
- * "user.<num>.login-time" - the login time of a user in milliseconds
- * since the epoch as unsigned long long
+ * Return information about users that are currently logged in within the
+ * guest domain.
+ * The VIR_DOMAIN_GUEST_INFO_USER_* constants define the known typed parameter
+ * keys.
*
* VIR_DOMAIN_GUEST_INFO_OS:
* Return information about the operating system running within the guest. The
ndata = virJSONValueArraySize(data);
- virTypedParamListAddUInt(list, ndata, "user.count");
+ virTypedParamListAddUInt(list, ndata, VIR_DOMAIN_GUEST_INFO_USER_COUNT);
for (i = 0; i < ndata; i++) {
virJSONValue *entry = virJSONValueArrayGet(data, i);
return -1;
}
- virTypedParamListAddString(list, strvalue, "user.%zu.name", i);
+ virTypedParamListAddString(list, strvalue,
+ VIR_DOMAIN_GUEST_INFO_USER_PREFIX "%zu" VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_NAME, i);
/* 'domain' is only present for windows guests */
if ((strvalue = virJSONValueObjectGetString(entry, "domain")))
- virTypedParamListAddString(list, strvalue, "user.%zu.domain", i);
+ virTypedParamListAddString(list, strvalue,
+ VIR_DOMAIN_GUEST_INFO_USER_PREFIX "%zu" VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_DOMAIN, i);
if (virJSONValueObjectGetNumberDouble(entry, "login-time", &logintime) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'login-time' missing in reply of guest-get-users"));
return -1;
}
- virTypedParamListAddULLong(list, logintime * 1000, "user.%zu.login-time", i);
+ virTypedParamListAddULLong(list, logintime * 1000,
+ VIR_DOMAIN_GUEST_INFO_USER_PREFIX "%zu" VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_LOGIN_TIME, i);
}
return 0;