1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 06:50:22 +03:00

src: add constants for guest info 'timezone.' parameters

Contrary to most APIs returning typed parameters, there are no constants
defined for the guest info data keys. This is was because many of the
keys needs to be dynamically constructed using one or more array index
values.

It is possible to define constants while still supporting dynamic
array indexes by simply defining the prefixes and suffixes as constants.
The consuming code can then combine the constants with array index
value.

With this approach, it is practical to add constants for the guest info
API keys.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2025-02-27 13:42:08 +00:00
parent 7192539cec
commit e7a122a192
3 changed files with 24 additions and 7 deletions

View File

@ -6601,6 +6601,25 @@ int virDomainSetLaunchSecurityState(virDomainPtr domain,
*/
# define VIR_DOMAIN_GUEST_INFO_OS_VARIANT_ID "os.variant-id"
/**
* VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME:
*
* The name of the timezone as a string.
*
* Since: 11.2.0
*/
# define VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME "timezone.name"
/**
* VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET:
*
* The offset to UTC in seconds as an int.
*
* Since: 11.2.0
*/
# define VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET "timezone.offset"
/**
* virDomainGuestInfoTypes:
*

View File

@ -13213,11 +13213,9 @@ virDomainSetVcpu(virDomainPtr domain,
* keys.
*
* VIR_DOMAIN_GUEST_INFO_TIMEZONE:
* Returns information about the timezone within the domain. The typed
* parameter keys are in this format:
*
* "timezone.name" - the name of the timezone as a string
* "timezone.offset" - the offset to UTC in seconds as an int
* Returns information about the timezone within the domain.
* The VIR_DOMAIN_GUEST_INFO_TIMEZONE_* constants define the known typed parameter
* keys.
*
* VIR_DOMAIN_GUEST_INFO_FILESYSTEM:
* Returns information about the filesystems within the domain. The typed

View File

@ -2316,7 +2316,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
}
if ((name = virJSONValueObjectGetString(data, "zone")))
virTypedParamListAddString(list, name, "timezone.name");
virTypedParamListAddString(list, name, VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME);
if ((virJSONValueObjectGetNumberInt(data, "offset", &offset)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -2324,7 +2324,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
return -1;
}
virTypedParamListAddInt(list, offset, "timezone.offset");
virTypedParamListAddInt(list, offset, VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET);
return 0;
}