This will be needed by future patches adding appid API to allow changing
it for running VMs.
Signed-off-by: Pavel Hrdina <phrdina(a)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 1bc62c364d..3ab864bbeb 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 430d61fd3c..02fc16b17d 100644
--- a/src/conf/domain_validate.h
+++ b/src/conf/domain_validate.h
@@ -42,3 +42,5 @@ int virDomainDeviceDefValidate(const virDomainDeviceDef *dev,
int virDomainDiskDefValidateSource(const virStorageSource *src);
int virDomainDiskDefSourceLUNValidate(const virStorageSource *src);
+
+int virDomainDefResourceAppidValidate(const char *appid);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2778fe7f8f..d1f5dc2080 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -765,6 +765,7 @@ virDomainConfVMNWFilterTeardown;
# conf/domain_validate.h
virDomainActualNetDefValidate;
+virDomainDefResourceAppidValidate;
virDomainDefValidate;
virDomainDeviceValidateAliasForHotplug;
virDomainDiskDefSourceLUNValidate;
--
2.31.1