This will be needed by future patches adding appid API to allow changing
it for running VMs.

Signed-off-by: Pavel Hrdina <phrd...@redhat.com>
---
 src/conf/domain_validate.c | 42 +++++++++++++++++++++++---------------
 src/conf/domain_validate.h |  2 ++
 src/libvirt_private.syms   |  1 +
 3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 60f7ccdddd..47e53f197d 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -58,29 +58,37 @@ virDomainDefBootValidate(const virDomainDef *def)
 #define APPID_LEN_MIN 1
 #define APPID_LEN_MAX 128
 
+int
+virDomainDefResourceAppidValidate(const char *appid)
+{
+    int len;
+
+    if (!virStringIsPrintable(appid)) {
+        virReportError(VIR_ERR_XML_ERROR, "%s",
+                       _("Fibre Channel 'appid' is not a printable string"));
+        return -1;
+    }
+
+    len = strlen(appid);
+    if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("Fibre Channel 'appid' string length must be between 
[%d, %d]"),
+                       APPID_LEN_MIN, APPID_LEN_MAX);
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static int
 virDomainDefResourceValidate(const virDomainDef *def)
 {
     if (!def->resource)
         return 0;
 
-    if (def->resource->appid) {
-        int len;
-
-        if (!virStringIsPrintable(def->resource->appid)) {
-            virReportError(VIR_ERR_XML_ERROR, "%s",
-                           _("Fibre Channel 'appid' is not a printable 
string"));
-            return -1;
-        }
-
-        len = strlen(def->resource->appid);
-        if (len < APPID_LEN_MIN || len > APPID_LEN_MAX) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("Fibre Channel 'appid' string length must be 
between [%d, %d]"),
-                           APPID_LEN_MIN, APPID_LEN_MAX);
-            return -1;
-        }
-    }
+    if (def->resource->appid)
+        return virDomainDefResourceAppidValidate(def->resource->appid);
 
     return 0;
 }
diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h
index 38a1abcc8f..6013488ccf 100644
--- a/src/conf/domain_validate.h
+++ b/src/conf/domain_validate.h
@@ -40,3 +40,5 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *dev,
                                void *parseOpaque);
 
 int virDomainDiskDefValidateSource(const virStorageSource *src);
+
+int virDomainDefResourceAppidValidate(const char *appid);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index fa11ee3df5..e13dacf590 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -765,6 +765,7 @@ virDomainConfVMNWFilterTeardown;
 
 # conf/domain_validate.h
 virDomainActualNetDefValidate;
+virDomainDefResourceAppidValidate;
 virDomainDefValidate;
 virDomainDeviceValidateAliasForHotplug;
 
-- 
2.31.1

Reply via email to