[libvirt] [PATCH 1/4] Move USER_ALIAS_PREFIX to the header file
John Ferlan
jferlan at redhat.com
Thu Nov 30 15:05:38 UTC 2017
On 11/29/2017 09:58 AM, Ján Tomko wrote:
> Allow other parts of code to decide whether the alias is user-specified
> or not.
> ---
> src/conf/domain_conf.c | 3 +--
> src/conf/domain_conf.h | 2 ++
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
Why not a convenience API instead? e.g.
bool virDomainDeviceUsingUserAlias(const char *aliasStr)
{
return STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
}
Hopefully it never changes or gets added to, but keeping UA- hidden in
the .c file perhaps works out better longer term...
John
BTW: Nit - isn't this series a v2 of the first rejected attempt...
https://www.redhat.com/archives/libvir-list/2017-November/msg01139.html
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b31917dad..41c94ed18 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -6656,7 +6656,6 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
> }
>
>
> -#define USER_ALIAS_PREFIX "ua-"
> #define USER_ALIAS_CHARS \
> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
>
> @@ -6713,7 +6712,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
>
> if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) ||
> (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_USER_ALIAS &&
> - STRPREFIX(aliasStr, USER_ALIAS_PREFIX) &&
> + STRPREFIX(aliasStr, VIR_DOMAIN_USER_ALIAS_PREFIX) &&
> strspn(aliasStr, USER_ALIAS_CHARS) == strlen(aliasStr)))
> VIR_STEAL_PTR(info->alias, aliasStr);
> }
> diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
> index 48b07226e..afba0ede3 100644
> --- a/src/conf/domain_conf.h
> +++ b/src/conf/domain_conf.h
> @@ -57,6 +57,8 @@
> # include "virtypedparam.h"
> # include "virsavecookie.h"
>
> +# define VIR_DOMAIN_USER_ALIAS_PREFIX "ua-"
> +
> /* forward declarations of all device types, required by
> * virDomainDeviceDef
> */
>
More information about the libvir-list
mailing list