diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c index 6c0f00ed8e..db283a41ff 100644 --- a/daemon/libvirtd-config.c +++ b/daemon/libvirtd-config.c @@ -433,7 +433,7 @@ int daemonConfigLoadData(struct daemonConfig *data, virConfPtr conf; int ret; - conf = virConfReadMem(filedata, strlen(filedata), 0); + conf = virConfReadString(filedata, 0); if (!conf) return -1; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 32ac0835e9..183a9194d7 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1520,7 +1520,7 @@ virConfGetValueULLong; virConfLoadConfig; virConfNew; virConfReadFile; -virConfReadMem; +virConfReadString; virConfSetValue; virConfTypeFromString; virConfTypeToString; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 907f1776fc..c261e21556 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -2605,14 +2605,14 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn, goto cleanup; if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XL)) { - if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0))) + if (!(conf = virConfReadString(nativeConfig, 0))) goto cleanup; if (!(def = xenParseXL(conf, cfg->caps, driver->xmlopt))) goto cleanup; } else if (STREQ(nativeFormat, XEN_CONFIG_FORMAT_XM)) { - if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0))) + if (!(conf = virConfReadString(nativeConfig, 0))) goto cleanup; if (!(def = xenParseXM(conf, diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 7bcdf1fb04..5fc6e7cda4 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -1000,7 +1000,7 @@ lxcParseConfigString(const char *config, virConfPtr properties = NULL; virConfValuePtr value; - if (!(properties = virConfReadMem(config, 0, VIR_CONF_FLAG_LXC_FORMAT))) + if (!(properties = virConfReadString(config, VIR_CONF_FLAG_LXC_FORMAT))) return NULL; if (!(vmdef = virDomainDefNew())) diff --git a/src/util/virconf.c b/src/util/virconf.c index c1f41b7e1a..e505848f19 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -807,27 +807,27 @@ virConfReadFile(const char *filename, unsigned int flags) } /** - * virConfReadMem: + * virConfReadString: * @memory: pointer to the content of the configuration file - * @len: length in byte * @flags: combination of virConfFlag(s) * - * Reads a configuration file loaded in memory. The string can be - * zero terminated in which case @len can be 0 + * Reads a configuration file loaded in memory. The string must be + * zero terminated. * * Returns a handle to lookup settings or NULL if it failed to * parse the content, use virConfFree() to free the data. */ virConfPtr -virConfReadMem(const char *memory, int len, unsigned int flags) +virConfReadString(const char *memory, unsigned int flags) { - if ((memory == NULL) || (len < 0)) { + size_t len; + + if (memory == NULL) { virConfError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__); return NULL; } - if (len == 0) - len = strlen(memory); + len = strlen(memory); return virConfParse("memory conf", memory, len, flags); } diff --git a/src/util/virconf.h b/src/util/virconf.h index 23fea49000..f7d9a369c3 100644 --- a/src/util/virconf.h +++ b/src/util/virconf.h @@ -79,8 +79,8 @@ typedef int (*virConfWalkCallback)(const char* name, virConfPtr virConfNew(void); virConfPtr virConfReadFile(const char *filename, unsigned int flags); -virConfPtr virConfReadMem(const char *memory, - int len, unsigned int flags); +virConfPtr virConfReadString(const char *memory, + unsigned int flags); int virConfFree(virConfPtr conf); void virConfFreeValue(virConfValuePtr val); virConfValuePtr virConfGetValue(virConfPtr conf, diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 96507f10f3..3e2f4c3e1b 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1312,7 +1312,7 @@ virVMXParseConfig(virVMXContext *ctx, return NULL; } - conf = virConfReadMem(vmx, strlen(vmx), VIR_CONF_FLAG_VMX_FORMAT); + conf = virConfReadString(vmx, VIR_CONF_FLAG_VMX_FORMAT); if (conf == NULL) return NULL; @@ -1332,7 +1332,7 @@ virVMXParseConfig(virVMXContext *ctx, if (utf8 == NULL) goto cleanup; - conf = virConfReadMem(utf8, strlen(utf8), VIR_CONF_FLAG_VMX_FORMAT); + conf = virConfReadString(utf8, VIR_CONF_FLAG_VMX_FORMAT); VIR_FREE(utf8); diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index b5cd47e02a..dae0f4f289 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1553,7 +1553,7 @@ xenUnifiedConnectDomainXMLFromNative(virConnectPtr conn, } if (STREQ(format, XEN_CONFIG_FORMAT_XM)) { - conf = virConfReadMem(config, strlen(config), 0); + conf = virConfReadString(config, 0); if (!conf) goto cleanup; diff --git a/tests/virconftest.c b/tests/virconftest.c index 1f4b561bb6..9d43465a7a 100644 --- a/tests/virconftest.c +++ b/tests/virconftest.c @@ -89,7 +89,7 @@ static int testConfParseInt(const void *opaque ATTRIBUTE_UNUSED) "string = \"foo\"\n"; int ret = -1; - virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0); + virConfPtr conf = virConfReadString(srcdata, 0); int iv; unsigned int ui; size_t s; @@ -238,7 +238,7 @@ static int testConfParseBool(const void *opaque ATTRIBUTE_UNUSED) "string = \"foo\"\n"; int ret = -1; - virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0); + virConfPtr conf = virConfReadString(srcdata, 0); bool f = true; bool t = false; @@ -302,7 +302,7 @@ static int testConfParseString(const void *opaque ATTRIBUTE_UNUSED) "string = \"foo\"\n"; int ret = -1; - virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0); + virConfPtr conf = virConfReadString(srcdata, 0); char *str = NULL; if (!conf) @@ -342,7 +342,7 @@ static int testConfParseStringList(const void *opaque ATTRIBUTE_UNUSED) "string = \"foo\"\n"; int ret = -1; - virConfPtr conf = virConfReadMem(srcdata, strlen(srcdata), 0); + virConfPtr conf = virConfReadString(srcdata, 0); char **str = NULL; if (!conf) diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 3fe42988de..30468c905e 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -146,7 +146,7 @@ testCompareFormatXML(const char *xlcfg, const char *xml, bool replaceVars) if (virTestLoadFile(xlcfg, &xlcfgData) < 0) goto fail; - if (!(conf = virConfReadMem(xlcfgData, strlen(xlcfgData), 0))) + if (!(conf = virConfReadString(xlcfgData, 0))) goto fail; if (!(def = xenParseXL(conf, caps, xmlopt))) diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 345223ffe4..d8455da669 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -115,7 +115,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml) priv.caps = caps; conn->privateData = &priv; - if (!(conf = virConfReadMem(xmcfgData, strlen(xmcfgData), 0))) + if (!(conf = virConfReadString(xmcfgData, 0))) goto fail; if (!(def = xenParseXM(conf, caps, xmlopt)))