提交 309cd46b 编写于 作者: J Ján Tomko

Introduce virDomainDeviceAliasIsUserAlias

Allow parts of code outside domain_conf to decide whether the alias
is user-specified or not.
上级 c703913c
......@@ -6660,6 +6660,13 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
#define USER_ALIAS_CHARS \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
bool
virDomainDeviceAliasIsUserAlias(const char *aliasStr)
{
return STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
}
/* Parse the XML definition for a device address
* @param node XML nodeset to parse for device address definition
*/
......@@ -6713,7 +6720,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) &&
virDomainDeviceAliasIsUserAlias(aliasStr) &&
strspn(aliasStr, USER_ALIAS_CHARS) == strlen(aliasStr)))
VIR_STEAL_PTR(info->alias, aliasStr);
}
......
......@@ -2679,6 +2679,8 @@ int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
virDomainDeviceDefPtr dev,
unsigned int flags);
bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);
int virDomainDefValidate(virDomainDefPtr def,
virCapsPtr caps,
unsigned int parseFlags,
......
......@@ -294,6 +294,7 @@ virDomainDefVcpuOrderClear;
virDomainDeleteConfig;
virDomainDeviceAddressIsValid;
virDomainDeviceAddressTypeToString;
virDomainDeviceAliasIsUserAlias;
virDomainDeviceDefCopy;
virDomainDeviceDefFree;
virDomainDeviceDefParse;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册