render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From c4df501b589eb7d4315c13bfe6ba653321135841 Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <c4df501b589eb7d4315c13bfe6ba653321135841@dist-git>
c1c534
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
c1c534
Date: Thu, 30 Nov 2017 17:45:57 +0100
c1c534
Subject: [PATCH] Introduce virDomainDeviceAliasIsUserAlias
c1c534
MIME-Version: 1.0
c1c534
Content-Type: text/plain; charset=UTF-8
c1c534
Content-Transfer-Encoding: 8bit
c1c534
c1c534
Allow parts of code outside domain_conf to decide whether the alias
c1c534
is user-specified or not.
c1c534
c1c534
(cherry picked from commit 309cd46b400d80420615b19adfebf7158492ae3b)
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1518148
c1c534
c1c534
Signed-off-by: Ján Tomko <jtomko@redhat.com>
c1c534
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c1c534
---
c1c534
 src/conf/domain_conf.c   | 9 ++++++++-
c1c534
 src/conf/domain_conf.h   | 2 ++
c1c534
 src/libvirt_private.syms | 1 +
c1c534
 3 files changed, 11 insertions(+), 1 deletion(-)
c1c534
c1c534
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c1c534
index 83392a42c0..bd6d851f21 100644
c1c534
--- a/src/conf/domain_conf.c
c1c534
+++ b/src/conf/domain_conf.c
c1c534
@@ -6662,6 +6662,13 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
c1c534
 #define USER_ALIAS_CHARS \
c1c534
     "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-"
c1c534
 
c1c534
+bool
c1c534
+virDomainDeviceAliasIsUserAlias(const char *aliasStr)
c1c534
+{
c1c534
+    return STRPREFIX(aliasStr, USER_ALIAS_PREFIX);
c1c534
+}
c1c534
+
c1c534
+
c1c534
 /* Parse the XML definition for a device address
c1c534
  * @param node XML nodeset to parse for device address definition
c1c534
  */
c1c534
@@ -6715,7 +6722,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED,
c1c534
 
c1c534
         if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) ||
c1c534
             (xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_USER_ALIAS &&
c1c534
-             STRPREFIX(aliasStr, USER_ALIAS_PREFIX) &&
c1c534
+             virDomainDeviceAliasIsUserAlias(aliasStr) &&
c1c534
              strspn(aliasStr, USER_ALIAS_CHARS) == strlen(aliasStr)))
c1c534
             VIR_STEAL_PTR(info->alias, aliasStr);
c1c534
     }
c1c534
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
c1c534
index 0e97f0437e..479a791f29 100644
c1c534
--- a/src/conf/domain_conf.h
c1c534
+++ b/src/conf/domain_conf.h
c1c534
@@ -2674,6 +2674,8 @@ int virDomainDeviceValidateAliasForHotplug(virDomainObjPtr vm,
c1c534
                                            virDomainDeviceDefPtr dev,
c1c534
                                            unsigned int flags);
c1c534
 
c1c534
+bool virDomainDeviceAliasIsUserAlias(const char *aliasStr);
c1c534
+
c1c534
 int virDomainDefValidate(virDomainDefPtr def,
c1c534
                          virCapsPtr caps,
c1c534
                          unsigned int parseFlags,
c1c534
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
c1c534
index 0449b0185f..19c1ecc408 100644
c1c534
--- a/src/libvirt_private.syms
c1c534
+++ b/src/libvirt_private.syms
c1c534
@@ -292,6 +292,7 @@ virDomainDefVcpuOrderClear;
c1c534
 virDomainDeleteConfig;
c1c534
 virDomainDeviceAddressIsValid;
c1c534
 virDomainDeviceAddressTypeToString;
c1c534
+virDomainDeviceAliasIsUserAlias;
c1c534
 virDomainDeviceDefCopy;
c1c534
 virDomainDeviceDefFree;
c1c534
 virDomainDeviceDefParse;
c1c534
-- 
c1c534
2.15.1
c1c534