Rename qemuSafeSerialParamValue to virSafeSerialParamValue and move it to utils
Signed-off-by: Maxim Nestratov <mnestratov(a)virtuozzo.com>
---
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 19 +------------------
src/util/virutil.c | 16 ++++++++++++++++
src/util/virutil.h | 2 ++
4 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 55b6a24..ec9fe1c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2649,6 +2649,7 @@ virParseVersionString;
virPipeReadUntilEOF;
virReadFCHost;
virReadSCSIUniqueId;
+virSafeSerialParamValue;
virScaleInteger;
virSetBlocking;
virSetCloseExec;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8282162..0be2ffa 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -427,23 +427,6 @@ qemuBuildIoEventFdStr(virBufferPtr buf,
return 0;
}
-#define QEMU_SERIAL_PARAM_ACCEPTED_CHARS \
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
-
-static int
-qemuSafeSerialParamValue(const char *value)
-{
- if (strspn(value, QEMU_SERIAL_PARAM_ACCEPTED_CHARS) != strlen(value)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("driver serial '%s' contains unsafe
characters"),
- value);
- return -1;
- }
-
- return 0;
-}
-
-
static int
qemuNetworkDriveGetPort(int protocol,
const char *port)
@@ -1600,7 +1583,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
if (disk->serial &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_SERIAL)) {
- if (qemuSafeSerialParamValue(disk->serial) < 0)
+ if (virSafeSerialParamValue(disk->serial) < 0)
goto error;
if (disk->bus == VIR_DOMAIN_DISK_BUS_SCSI &&
disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 844c947..58ace3f 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2684,3 +2684,19 @@ virMemoryMaxValue(bool capped)
else
return LLONG_MAX;
}
+
+#define VIR_SERIAL_PARAM_ACCEPTED_CHARS \
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_ "
+
+int
+virSafeSerialParamValue(const char *value)
+{
+ if (strspn(value, VIR_SERIAL_PARAM_ACCEPTED_CHARS) != strlen(value)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("driver serial '%s' contains unsafe
characters"),
+ value);
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 8c0d83c..f9b4831 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -252,6 +252,8 @@ unsigned long long virMemoryLimitTruncate(unsigned long long value);
bool virMemoryLimitIsSet(unsigned long long value);
unsigned long long virMemoryMaxValue(bool ulong);
+int virSafeSerialParamValue(const char *value);
+
/**
* VIR_ASSIGN_IS_OVERFLOW:
* @rvalue: value that is checked (evaluated twice)
--
2.4.11