Our implementation was heavily inspired by the glib version so it's a drop-in replacement. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/bhyve/bhyve_command.c | 2 +- src/conf/storage_conf.c | 2 +- src/libxl/libxl_conf.c | 8 ++++---- src/libxl/xen_common.c | 6 +++--- src/libxl/xen_xl.c | 4 ++-- src/lxc/lxc_native.c | 8 ++++---- src/qemu/qemu_driver.c | 2 +- src/qemu/qemu_qapi.c | 2 +- src/rpc/virnetsocket.c | 4 ++-- src/storage/storage_backend_sheepdog.c | 4 ++-- src/storage/storage_backend_zfs.c | 6 +++--- src/storage_file/storage_source_backingstore.c | 4 ++-- src/util/vircgroup.c | 6 +++--- src/util/vircgroupv2.c | 2 +- src/util/vircommand.c | 2 +- src/util/virdevmapper.c | 2 +- src/util/virfile.c | 2 +- src/util/virfirewall.c | 2 +- src/util/virfirmware.c | 4 ++-- src/util/virprocess.c | 2 +- src/vz/vz_sdk.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/vboxsnapshotxmltest.c | 2 +- tools/virsh-completer.c | 2 +- tools/virsh-domain.c | 12 ++++++------ 25 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index daf313c9c1..a963338654 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -806,7 +806,7 @@ virAppendBootloaderArgs(virCommandPtr cmd, virDomainDefPtr def) char **blargs; /* XXX: Handle quoted? */ - blargs = virStringSplit(def->os.bootloaderArgs, " ", 0); + blargs = g_strsplit(def->os.bootloaderArgs, " ", 0); virCommandAddArgSet(cmd, (const char * const *)blargs); g_strfreev(blargs); } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3f06fcaebf..0f515c7cbb 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1305,7 +1305,7 @@ virStorageCheckCompat(const char *compat) if (!compat) return 0; - version = virStringSplit(compat, ".", 2); + version = g_strsplit(compat, ".", 2); if (!version || !version[1] || virStrToLong_ui(version[0], NULL, 10, &result) < 0 || virStrToLong_ui(version[1], NULL, 10, &result) < 0) { diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 37a2c2e3cd..f8db118996 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -698,7 +698,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, b_info->bootloader = g_strdup(def->os.bootloader); if (def->os.bootloaderArgs) { if (!(b_info->bootloader_args = - virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) + g_strsplit(def->os.bootloaderArgs, " \t\n", 0))) return -1; } #endif @@ -714,7 +714,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, } if (def->os.bootloaderArgs) { if (!(b_info->u.pv.bootloader_args = - virStringSplit(def->os.bootloaderArgs, " \t\n", 0))) + g_strsplit(def->os.bootloaderArgs, " \t\n", 0))) return -1; } b_info->u.pv.cmdline = g_strdup(def->os.cmdline); @@ -1896,14 +1896,14 @@ libxlDriverGetDom0MaxmemConf(libxlDriverConfigPtr cfg, int ret = -1; if (cfg->verInfo->commandline == NULL || - !(cmd_tokens = virStringSplit(cfg->verInfo->commandline, " ", 0))) + !(cmd_tokens = g_strsplit(cfg->verInfo->commandline, " ", 0))) goto physmem; for (i = 0; cmd_tokens[i] != NULL; i++) { if (!STRPREFIX(cmd_tokens[i], "dom0_mem=")) continue; - if (!(mem_tokens = virStringSplit(cmd_tokens[i], ",", 0))) + if (!(mem_tokens = g_strsplit(cmd_tokens[i], ",", 0))) break; for (j = 0; mem_tokens[j] != NULL; j++) { if (STRPREFIX(mem_tokens[j], "max:")) { diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index 2d1f5ea5f5..75c65a4135 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -420,7 +420,7 @@ xenParsePCI(char *entry) return NULL; str = nextstr; - if (str && (options = virStringSplit(str, ",", 0))) { + if (str && (options = g_strsplit(str, ",", 0))) { size_t i; for (i = 0; options[i] != NULL; i++) { @@ -1051,7 +1051,7 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge) /* 'bridge' string contains a bridge name and one or more vlan trunks */ size_t i; size_t nvlans = 0; - char **vlanstr_list = virStringSplit(bridge, ":", 0); + char **vlanstr_list = g_strsplit(bridge, ":", 0); if (!vlanstr_list) return -1; @@ -1258,7 +1258,7 @@ xenParseVif(char *entry, const char *vif_typename) goto cleanup; } if (ip[0]) { - char **ip_list = virStringSplit(ip, " ", 0); + char **ip_list = g_strsplit(ip, " ", 0); size_t i; if (!ip_list) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index a8af54a845..a7036ba494 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -268,7 +268,7 @@ xenParseXLCPUID(virConfPtr conf, virDomainDefPtr def) def->cpu->nfeatures_max = 0; } - cpuid_pairs = virStringSplit(cpuid_str, ",", 0); + cpuid_pairs = g_strsplit(cpuid_str, ",", 0); if (!cpuid_pairs) goto cleanup; @@ -285,7 +285,7 @@ xenParseXLCPUID(virConfPtr conf, virDomainDefPtr def) } for (i = 1; cpuid_pairs[i]; i++) { - name_and_value = virStringSplit(cpuid_pairs[i], "=", 2); + name_and_value = g_strsplit(cpuid_pairs[i], "=", 2); if (!name_and_value) goto cleanup; if (!name_and_value[0] || !name_and_value[1]) { diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 4229a9ca7a..b903dc91d6 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -119,7 +119,7 @@ static char ** lxcStringSplit(const char *string) tmp[i] = ' '; } - if (!(parts = virStringSplit(tmp, " ", 0))) + if (!(parts = g_strsplit(tmp, " ", 0))) goto error; /* Append NULL element */ @@ -257,7 +257,7 @@ lxcAddFstabLine(virDomainDefPtr def, lxcFstabPtr fstab) { const char *src = NULL; g_autofree char *dst = NULL; - char **options = virStringSplit(fstab->options, ",", 0); + char **options = g_strsplit(fstab->options, ",", 0); bool readonly; int type = VIR_DOMAIN_FS_TYPE_MOUNT; unsigned long long usage = 0; @@ -567,7 +567,7 @@ lxcNetworkParseDataIPs(const char *name, if (STREQ(name, "ipv6") || STREQ(name, "ipv6.address")) family = AF_INET6; - ipparts = virStringSplit(value->str, "/", 2); + ipparts = g_strsplit(value->str, "/", 2); if (!ipparts || !ipparts[0] || !ipparts[1] || virSocketAddrParse(&ip->address, ipparts[0], family) < 0 || virStrToLong_ui(ipparts[1], NULL, 10, &ip->prefix) < 0) { @@ -1103,7 +1103,7 @@ lxcSetCapDrop(virDomainDefPtr def, virConfPtr properties) size_t i; if (virConfGetValueString(properties, "lxc.cap.drop", &value) > 0) - toDrop = virStringSplit(value, " ", 0); + toDrop = g_strsplit(value, " ", 0); for (i = 0; i < VIR_DOMAIN_PROCES_CAPS_FEATURE_LAST; i++) { capString = virDomainProcessCapsFeatureTypeToString(i); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 80bd27696b..ca4ba8071c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1365,7 +1365,7 @@ qemuGetSchedInfo(unsigned long long *cpuWait, if (virFileReadAll(proc, (1<<16), &data) < 0) goto cleanup; - lines = virStringSplit(data, "\n", 0); + lines = g_strsplit(data, "\n", 0); if (!lines) goto cleanup; diff --git a/src/qemu/qemu_qapi.c b/src/qemu/qemu_qapi.c index b41016f7d8..f7e4ca9324 100644 --- a/src/qemu/qemu_qapi.c +++ b/src/qemu/qemu_qapi.c @@ -440,7 +440,7 @@ virQEMUQAPISchemaPathGet(const char *query, if (entry) *entry = NULL; - if (!(elems = virStringSplit(query, "/", 0))) + if (!(elems = g_strsplit(query, "/", 0))) return -1; if (!*elems) { diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index d0dc59c10c..17aaf86ce3 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -961,7 +961,7 @@ virNetSocketNewConnectLibSSH2(const char *host, virNetSSHSessionSetChannelCommand(sess, command); - if (!(authMethodList = virStringSplit(authMethods, ",", 0))) + if (!(authMethodList = g_strsplit(authMethods, ",", 0))) goto error; for (authMethodNext = authMethodList; *authMethodNext; authMethodNext++) { @@ -1092,7 +1092,7 @@ virNetSocketNewConnectLibssh(const char *host, virNetLibsshSessionSetChannelCommand(sess, command); - if (!(authMethodList = virStringSplit(authMethods, ",", 0))) + if (!(authMethodList = g_strsplit(authMethods, ",", 0))) goto error; for (authMethodNext = authMethodList; *authMethodNext; authMethodNext++) { diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 2db2384e67..8c37947308 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -148,14 +148,14 @@ virStorageBackendSheepdogRefreshAllVol(virStoragePoolObjPtr pool) if (virCommandRun(cmd, NULL) < 0) return -1; - lines = virStringSplit(output, "\n", 0); + lines = g_strsplit(output, "\n", 0); if (lines == NULL) return -1; for (i = 0; lines[i]; i++) { g_auto(GStrv) cells = NULL; - cells = virStringSplit(lines[i], " ", 0); + cells = g_strsplit(lines[i], " ", 0); if (cells != NULL && cells[0] && cells[1]) { if (virStorageBackendSheepdogAddVolume(pool, cells[1]) < 0) diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backend_zfs.c index 31ffcc6f15..e4ef06722f 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -195,7 +195,7 @@ virStorageBackendZFSFindVols(virStoragePoolObjPtr pool, if (virCommandRun(cmd, NULL) < 0) return -1; - if (!(lines = virStringSplit(volumes_list, "\n", 0))) + if (!(lines = g_strsplit(volumes_list, "\n", 0))) return -1; for (i = 0; lines[i]; i++) { @@ -230,7 +230,7 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED) * * Here we just provide a list of properties we want to see */ - if (!(name_tokens = virStringSplit(def->source.name, "/", 0))) + if (!(name_tokens = g_strsplit(def->source.name, "/", 0))) goto cleanup; cmd = virCommandNewArgList(ZPOOL, @@ -242,7 +242,7 @@ virStorageBackendZFSRefreshPool(virStoragePoolObjPtr pool G_GNUC_UNUSED) if (virCommandRun(cmd, NULL) < 0) goto cleanup; - if (!(lines = virStringSplit(zpool_props, "\n", 0))) + if (!(lines = g_strsplit(zpool_props, "\n", 0))) goto cleanup; for (i = 0; lines[i]; i++) { diff --git a/src/storage_file/storage_source_backingstore.c b/src/storage_file/storage_source_backingstore.c index bbcc720af1..8e1606a1fe 100644 --- a/src/storage_file/storage_source_backingstore.c +++ b/src/storage_file/storage_source_backingstore.c @@ -54,7 +54,7 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src, src->hosts = g_new0(virStorageNetHostDef, 1); src->nhosts = 1; - if (!(scheme = virStringSplit(uri->scheme, "+", 2))) + if (!(scheme = g_strsplit(uri->scheme, "+", 2))) return -1; if (!scheme[0] || @@ -165,7 +165,7 @@ virStorageSourceRBDAddHost(virStorageSourcePtr src, goto error; } - parts = virStringSplit(hostport, "\\:", 0); + parts = g_strsplit(hostport, "\\:", 0); if (!parts) goto error; src->hosts[src->nhosts-1].name = virStringListJoin((const char **)parts, ":"); diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 2c418cd84d..a7e2728dd7 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -574,7 +574,7 @@ virCgroupGetValueForBlkDev(const char *str, if (!(prefix = virCgroupGetBlockDevString(path))) return -1; - if (!(lines = virStringSplit(str, "\n", -1))) + if (!(lines = g_strsplit(str, "\n", -1))) return -1; for (tmp = lines; *tmp; tmp++) { @@ -805,7 +805,7 @@ virCgroupSetPartitionSuffix(const char *path, char **res) size_t i; int ret = -1; - if (!(tokens = virStringSplit(path, "/", 0))) + if (!(tokens = g_strsplit(path, "/", 0))) return ret; for (i = 0; tokens[i] != NULL; i++) { @@ -1140,7 +1140,7 @@ virCgroupEnableMissingControllers(char *path, virCgroupPtr *group) { g_autoptr(virCgroup) parent = NULL; - g_auto(GStrv) tokens = virStringSplit(path, "/", 0); + g_auto(GStrv) tokens = g_strsplit(path, "/", 0); size_t i; if (virCgroupNew("/", controllers, &parent) < 0) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index 4a239f067a..c9c3f5b76e 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -279,7 +279,7 @@ virCgroupV2ParseControllersFile(virCgroupPtr group, virTrimSpaces(contStr, NULL); - contList = virStringSplit(contStr, " ", 20); + contList = g_strsplit(contStr, " ", 20); if (!contList) return -1; diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 87a60be201..323f841b98 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -3230,7 +3230,7 @@ virCommandRunRegex(virCommandPtr cmd, goto cleanup; } - if (!(lines = virStringSplit(outbuf, "\n", 0))) + if (!(lines = g_strsplit(outbuf, "\n", 0))) goto cleanup; for (k = 0; lines[k]; k++) { diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c index 15a7eb9fde..d97334bf67 100644 --- a/src/util/virdevmapper.c +++ b/src/util/virdevmapper.c @@ -63,7 +63,7 @@ virDevMapperGetMajor(unsigned int *major) if (virFileReadAll(PROC_DEVICES, BUF_SIZE, &buf) < 0) return -1; - lines = virStringSplit(buf, "\n", 0); + lines = g_strsplit(buf, "\n", 0); if (!lines) return -1; diff --git a/src/util/virfile.c b/src/util/virfile.c index e25cbe797e..5710495bbf 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1711,7 +1711,7 @@ virFindFileInPath(const char *file) * it. return it if found. */ - if (!(paths = virStringSplit(origpath, ":", 0))) + if (!(paths = g_strsplit(origpath, ":", 0))) return NULL; for (pathiter = paths; *pathiter; pathiter++) { diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 8b69a18ecc..6b04a8011f 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -719,7 +719,7 @@ virFirewallApplyRule(virFirewallPtr firewall, } if (rule->queryCB && output) { - if (!(lines = virStringSplit(output, "\n", -1))) + if (!(lines = g_strsplit(output, "\n", -1))) return -1; VIR_DEBUG("Invoking query %p with '%s'", rule->queryCB, output); diff --git a/src/util/virfirmware.c b/src/util/virfirmware.c index d49bea3a55..c0ffcb4392 100644 --- a/src/util/virfirmware.c +++ b/src/util/virfirmware.c @@ -61,7 +61,7 @@ virFirmwareParse(const char *str, virFirmwarePtr firmware) int ret = -1; char **token; - if (!(token = virStringSplit(str, ":", 0))) + if (!(token = g_strsplit(str, ":", 0))) goto cleanup; if (token[0]) { @@ -98,7 +98,7 @@ virFirmwareParseList(const char *list, char **token; size_t i, j; - if (!(token = virStringSplit(list, ":", 0))) + if (!(token = g_strsplit(list, ":", 0))) goto cleanup; for (i = 0; token[i]; i += 2) { diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 4c27f9d771..41c5678537 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1011,7 +1011,7 @@ int virProcessGetStartTime(pid_t pid, return -1; } - tokens = virStringSplit(tmp, " ", 0); + tokens = g_strsplit(tmp, " ", 0); if (!tokens || g_strv_length(tokens) < 20) { diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 9ea0edaf97..f49cd983f0 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -745,7 +745,7 @@ prlsdkGetFSInfo(PRL_HANDLE prldisk, goto cleanup; } - if (!(matches = virStringSplit(uri->path, "/", 0)) || + if (!(matches = g_strsplit(uri->path, "/", 0)) || !matches[0]) { virReportError(VIR_ERR_INTERNAL_ERROR, _("splitting StorageUrl failed %s"), uri->path); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index faa71a7a16..d324921271 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -149,7 +149,7 @@ fakeStorageVolLookupByName(virStoragePoolPtr pool, if (!strchr(name, '+')) goto fallback; - if (!(volinfo = virStringSplit(name, "+", 2))) + if (!(volinfo = g_strsplit(name, "+", 2))) return NULL; if (!volinfo[1]) diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c index d2beb7858d..9298bcb837 100644 --- a/tests/vboxsnapshotxmltest.c +++ b/tests/vboxsnapshotxmltest.c @@ -23,7 +23,7 @@ testFilterXML(char *xml) char **xmlLine; char *ret = NULL; - if (!(xmlLines = virStringSplit(xml, "\n", 0))) { + if (!(xmlLines = g_strsplit(xml, "\n", 0))) { VIR_FREE(xml); goto cleanup; } diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index d3923c4bc7..57e0c3905c 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -108,7 +108,7 @@ virshCommaStringListComplete(const char *input, g_clear_pointer(&inputCopy, g_free); } - if (inputCopy && !(inputList = virStringSplit(inputCopy, ",", 0))) + if (inputCopy && !(inputList = g_strsplit(inputCopy, ",", 0))) return NULL; ret = g_new0(char *, optionsLen + 1); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 05d79a7843..1c58c26d93 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4057,7 +4057,7 @@ cmdStartGetFDs(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "pass-fds", &fdopt) <= 0) return 0; - if (!(fdlist = virStringSplit(fdopt, ",", -1))) { + if (!(fdlist = g_strsplit(fdopt, ",", -1))) { vshError(ctl, _("Unable to split FD list '%s'"), fdopt); return -1; } @@ -5929,7 +5929,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) return false; - if (mode && !(modes = virStringSplit(mode, ",", 0))) { + if (mode && !(modes = g_strsplit(mode, ",", 0))) { vshError(ctl, "%s", _("Cannot parse mode string")); return false; } @@ -6013,7 +6013,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) return false; - if (mode && !(modes = virStringSplit(mode, ",", 0))) { + if (mode && !(modes = g_strsplit(mode, ",", 0))) { vshError(ctl, "%s", _("Cannot parse mode string")); return false; } @@ -10784,7 +10784,7 @@ doMigrate(void *opaque) if (opt) { char **val = NULL; - val = virStringSplit(opt, ",", 0); + val = g_strsplit(opt, ",", 0); if (virTypedParamsAddStringList(¶ms, &nparams, @@ -10801,7 +10801,7 @@ doMigrate(void *opaque) if (vshCommandOptStringReq(ctl, cmd, "comp-methods", &opt) < 0) goto out; if (opt) { - char **val = virStringSplit(opt, ",", 0); + char **val = g_strsplit(opt, ",", 0); if (virTypedParamsAddStringList(¶ms, &nparams, @@ -14388,7 +14388,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (!(keys = virStringSplit(buffer, "\n", -1))) + if (!(keys = g_strsplit(buffer, "\n", -1))) goto cleanup; nkeys = g_strv_length(keys); -- 2.29.2