diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4196537324dd9be3c0e4754739e211d24495f2cf..fb6f58d59b176aa53dd764f0c46eb0cf97eed9a0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13167,7 +13167,7 @@ virDomainMemorySourceDefParseXML(xmlNodePtr node, goto cleanup; if ((nodemask = virXPathString("string(./nodemask)", ctxt))) { - if (virBitmapParse(nodemask, 0, &def->sourceNodes, + if (virBitmapParse(nodemask, &def->sourceNodes, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; @@ -14957,7 +14957,7 @@ virDomainVcpuPinDefParseXML(virDomainDefPtr def, goto cleanup; } - if (virBitmapParse(tmp, 0, &vcpu->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &vcpu->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(vcpu->cpumask)) { @@ -15024,7 +15024,7 @@ virDomainIOThreadPinDefParseXML(xmlNodePtr node, goto cleanup; } - if (virBitmapParse(tmp, 0, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(cpumask)) { @@ -15069,7 +15069,7 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node) return NULL; } - if (virBitmapParse(tmp, 0, &def, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &def, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(def)) { @@ -15232,7 +15232,7 @@ virDomainHugepagesParseXML(xmlNodePtr node, } if ((nodeset = virXMLPropString(node, "nodeset"))) { - if (virBitmapParse(nodeset, 0, &hugepage->nodemask, + if (virBitmapParse(nodeset, &hugepage->nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; @@ -15362,7 +15362,7 @@ virDomainSchedulerParse(xmlNodePtr node, goto error; } - if (virBitmapParse(tmp, 0, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &ret, VIR_DOMAIN_CPUMASK_LEN) < 0) goto error; if (virBitmapIsAllClear(ret)) { @@ -15539,8 +15539,7 @@ virDomainVcpuParse(virDomainDefPtr def, if (def->placement_mode != VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) { tmp = virXPathString("string(./vcpu[1]/@cpuset)", ctxt); if (tmp) { - if (virBitmapParse(tmp, 0, &def->cpumask, - VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(def->cpumask)) { diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 48f39c7540873495c5bae8db77ff56a2414ea6b7..02b8cd7039da8cacbc70c79ec0a0cceca02490b0 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -3097,7 +3097,7 @@ virNetworkLoadState(virNetworkObjListPtr nets, ctxt->node = node; if ((class_id = virXPathString("string(./class_id[1]/@bitmap)", ctxt))) { - if (virBitmapParse(class_id, 0, &class_id_map, + if (virBitmapParse(class_id, &class_id_map, CLASS_ID_BITMAP_SIZE) < 0) { VIR_FREE(class_id); goto error; diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index e0d56886bc60d1d255efbfe7c5a0a7a654a71b62..9818d959ca810be21888d4c7d4c54011b8cecd38 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -175,8 +175,7 @@ virDomainNumatuneNodeParseXML(virDomainNumaPtr numa, "in memnode element")); goto cleanup; } - if (virBitmapParse(tmp, 0, &mem_node->nodeset, - VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &mem_node->nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(mem_node->nodeset)) { @@ -241,7 +240,7 @@ virDomainNumatuneParseXML(virDomainNumaPtr numa, tmp = virXMLPropString(node, "nodeset"); if (tmp) { - if (virBitmapParse(tmp, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(tmp, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; if (virBitmapIsAllClear(nodeset)) { @@ -748,7 +747,7 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, goto cleanup; } - if (virBitmapParse(tmp, 0, &def->mem_nodes[cur_cell].cpumask, + if (virBitmapParse(tmp, &def->mem_nodes[cur_cell].cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 32ea906f221d8317d4fa9e4f69d6ae9ef59f40ec..2aee41c19397d660f090199d3f2fb2f58b757212 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -784,7 +784,7 @@ static int virLXCControllerGetNumadAdvice(virLXCControllerPtr ctrl, VIR_DEBUG("Nodeset returned from numad: %s", nodeset); - if (virBitmapParse(nodeset, 0, &nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(nodeset, &nodemask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; } diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c index 5f9e50e15a40fa5bdb5be6afe9edfb2b286d6f2a..7f8e9049f7412f17d001dcc11753f1da14099756 100644 --- a/src/lxc/lxc_native.c +++ b/src/lxc/lxc_native.c @@ -833,7 +833,7 @@ lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties) if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.cpus")) && value->str) { - if (virBitmapParse(value->str, 0, &def->cpumask, + if (virBitmapParse(value->str, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; @@ -842,7 +842,7 @@ lxcSetCpusetTune(virDomainDefPtr def, virConfPtr properties) if ((value = virConfGetValue(properties, "lxc.cgroup.cpuset.mems")) && value->str) { - if (virBitmapParse(value->str, 0, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(value->str, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) return -1; if (virDomainNumatuneSet(def->numa, def->placement_mode == diff --git a/src/nodeinfo.c b/src/nodeinfo.c index b02c29489b5a1849334a86508f655ec463096b1a..f2ded025dc0abd147818d684181db9c0e46ee8bf 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -121,7 +121,7 @@ virNodeGetSiblingsListLinux(const char *dir, int cpu_id) if (virFileReadAll(path, SYSFS_THREAD_SIBLINGS_LIST_LENGTH_MAX, &buf) < 0) goto cleanup; - if (virBitmapParse(buf, 0, &ret, virNumaGetMaxCPUs()) < 0) + if (virBitmapParse(buf, &ret, virNumaGetMaxCPUs()) < 0) goto cleanup; cleanup: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 595ad648d487eb9b1cf9c78bcb8d52edec7d515a..29f6b93e7d761729cabf79a04b01ebb3d75bcd1e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1594,7 +1594,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, goto error; if ((tmp = virXPathString("string(./numad/@nodeset)", ctxt))) { - if (virBitmapParse(tmp, 0, &priv->autoNodeset, + if (virBitmapParse(tmp, &priv->autoNodeset, caps->host.nnumaCell_max) < 0) goto error; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 70217dca378f5f1be15aa7d0bea377968da01aa3..d065e45fe96bf49ef06d252515d45dd52d64612d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -9559,7 +9559,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, } } else if (STREQ(param->field, VIR_DOMAIN_NUMA_NODESET)) { - if (virBitmapParse(param->value.s, 0, &nodeset, + if (virBitmapParse(param->value.s, &nodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 373e7a97e8adb9b6573b0f6544d10ff841f03251..215fe5f2f2109e03ce695b18857216bc2ad72641 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4860,7 +4860,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, VIR_DEBUG("Nodeset returned from numad: %s", nodeset); - if (virBitmapParse(nodeset, 0, &priv->autoNodeset, + if (virBitmapParse(nodeset, &priv->autoNodeset, VIR_DOMAIN_CPUMASK_LEN) < 0) goto cleanup; diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 139e3ba18a27caf39ba71f42035f6723f2598999..3381a3d348eea7ad416e74429f6e472efb3cec60 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -522,7 +522,6 @@ virBitmapParseSeparator(const char *str, /** * virBitmapParse: * @str: points to a string representing a human-readable bitmap - * @terminator: character separating the bitmap to parse * @bitmap: a bitmap created from @str * @bitmapSize: the upper limit of num of bits in created bitmap * @@ -533,21 +532,14 @@ virBitmapParseSeparator(const char *str, * to set, and ^N, which means to unset the bit, and N-M for ranges of bits * to set. * - * To allow parsing of bitmaps within larger strings it is possible to set - * a termination character in the argument @terminator. When the character - * in @terminator is encountered in @str, the parsing of the bitmap stops. - * Pass 0 as @terminator if it is not needed. Whitespace characters may not - * be used as terminators. - * * Returns 0 on success, or -1 in case of error. */ int virBitmapParse(const char *str, - char terminator, virBitmapPtr *bitmap, size_t bitmapSize) { - return virBitmapParseSeparator(str, terminator, bitmap, bitmapSize); + return virBitmapParseSeparator(str, '\0', bitmap, bitmapSize); } /** diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 79922ea782d9484c8ac0bdbd433200bccd8c959f..3356e1e7778462fb4bd66609782e47edbe6e33ff 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -86,10 +86,9 @@ char *virBitmapString(virBitmapPtr bitmap) char *virBitmapFormat(virBitmapPtr bitmap); int virBitmapParse(const char *str, - char sep, virBitmapPtr *bitmap, size_t bitmapSize) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); int virBitmapParseSeparator(const char *str, char terminator, diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index a481be0a1174fd098ddd97abb5929c520b8bf200..4ed7b217d85fbc58687aae906410bb1f6301c891 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -947,7 +947,7 @@ virHostCPUParseMapLinux(int max_cpuid, const char *path) if (virFileReadAll(path, 5 * VIR_HOST_CPU_MASK_LEN, &str) < 0) goto error; - if (virBitmapParse(str, 0, &map, max_cpuid) < 0) + if (virBitmapParse(str, &map, max_cpuid) < 0) goto error; VIR_FREE(str); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 410f2f321237314268589a1d6b9ccf9e42b3c71e..cb06240df9be6bb5215d42a7fb0e8c2711b727cc 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1173,7 +1173,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, goto cleanup; virBitmapSetAll(def->cpumask); } else { - if (virBitmapParse(buf, 0, &def->cpumask, hostcpus) < 0) + if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0) goto cleanup; } diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index e2538b80d6451d130095d1cebedcb7202177a9ac..98a22b8a1e1679a7c3a55881a9afd92ed002007c 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -509,7 +509,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) if (xenConfigGetString(conf, "cpus", &str, NULL) < 0) return -1; - if (str && (virBitmapParse(str, 0, &def->cpumask, 4096) < 0)) + if (str && (virBitmapParse(str, &def->cpumask, 4096) < 0)) return -1; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 1631a14a6f877294c9f8c19b61ec3e3bc44ac506..653b7b3a67cce1345134399280df2426ec6cf224 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -1222,8 +1222,7 @@ xenParseSxpr(const struct sexpr *root, def->mem.cur_balloon = virDomainDefGetMemoryTotal(def); if (cpus != NULL) { - if (virBitmapParse(cpus, 0, &def->cpumask, - VIR_DOMAIN_CPUMASK_LEN) < 0) + if (virBitmapParse(cpus, &def->cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) goto error; if (virBitmapIsAllClear(def->cpumask)) { diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index c406b645313cf2ba041614b5ccbae06894aa42b2..41e0ac4d8bd985302ecc4bd518989d58389bcdc3 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -282,7 +282,7 @@ static int testCompareXMLToArgvFiles(const char *xml, } priv = vm->privateData; - if (virBitmapParse("0-3", '\0', &priv->autoNodeset, 4) < 0) + if (virBitmapParse("0-3", &priv->autoNodeset, 4) < 0) goto out; if (!virDomainDefCheckABIStability(vm->def, vm->def)) { diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 5fa13c27ff4867bb22a50639897865be3c9400af..89c41d00c7c3d53f13077d1f5e1e21f367ba0c13 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -90,7 +90,7 @@ test2(const void *data ATTRIBUTE_UNUSED) int ret = -1; int size = 1025; - if (virBitmapParse(bitsString1, 0, &bitmap, size) < 0) + if (virBitmapParse(bitsString1, &bitmap, size) < 0) goto error; if (testBit(bitmap, 1, 32, true) < 0) @@ -218,7 +218,7 @@ test4(const void *data ATTRIBUTE_UNUSED) /* 2. partial set */ - if (virBitmapParse(bitsString, 0, &bitmap, size) < 0) + if (virBitmapParse(bitsString, &bitmap, size) < 0) goto error; if (!bitmap) goto error; @@ -495,19 +495,19 @@ test9(const void *opaque ATTRIBUTE_UNUSED) int ret = -1; virBitmapPtr bitmap = NULL; - if (virBitmapParse("100000000", 0, &bitmap, 20) != -1) + if (virBitmapParse("100000000", &bitmap, 20) != -1) goto cleanup; if (bitmap) goto cleanup; - if (virBitmapParse("1-1000000000", 0, &bitmap, 20) != -1) + if (virBitmapParse("1-1000000000", &bitmap, 20) != -1) goto cleanup; if (bitmap) goto cleanup; - if (virBitmapParse("1-10^10000000000", 0, &bitmap, 20) != -1) + if (virBitmapParse("1-10^10000000000", &bitmap, 20) != -1) goto cleanup; if (bitmap) @@ -527,9 +527,9 @@ test10(const void *opaque ATTRIBUTE_UNUSED) virBitmapPtr b1 = NULL, b2 = NULL, b3 = NULL, b4 = NULL; if (virBitmapParseSeparator("0-3,5-8,11-15f16", 'f', &b1, 20) < 0 || - virBitmapParse("4,9,10,16-19", 0, &b2, 20) < 0 || - virBitmapParse("15", 0, &b3, 20) < 0 || - virBitmapParse("0,^0", 0, &b4, 20) < 0) + virBitmapParse("4,9,10,16-19", &b2, 20) < 0 || + virBitmapParse("15", &b3, 20) < 0 || + virBitmapParse("0,^0", &b4, 20) < 0) goto cleanup; if (!virBitmapIsAllClear(b4)) @@ -567,9 +567,9 @@ test11(const void *opaque) virBitmapPtr resmap = NULL; int ret = -1; - if (virBitmapParse(data->a, 0, &amap, 256) < 0 || - virBitmapParse(data->b, 0, &bmap, 256) < 0 || - virBitmapParse(data->res, 0, &resmap, 256) < 0) + if (virBitmapParse(data->a, &amap, 256) < 0 || + virBitmapParse(data->b, &bmap, 256) < 0 || + virBitmapParse(data->res, &resmap, 256) < 0) goto cleanup; virBitmapSubtract(amap, bmap); diff --git a/tests/vircapstest.c b/tests/vircapstest.c index 561c13d33601ebce4f5c2b8f0d507ac1b88af73b..27d17bdde9b7860a05655919316afa6c5c83dd1a 100644 --- a/tests/vircapstest.c +++ b/tests/vircapstest.c @@ -104,7 +104,7 @@ test_virCapabilitiesGetCpusForNodemask(const void *data ATTRIBUTE_UNUSED) if (!(caps = buildNUMATopology(3))) goto error; - if (virBitmapParse(nodestr, VIR_ARCH_NONE, &nodemask, mask_size) < 0) + if (virBitmapParse(nodestr, &nodemask, mask_size) < 0) goto error; if (!(cpumap = virCapabilitiesGetCpusForNodemask(caps, nodemask))) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 02be58f19a9ba2f135494f40da075dbbd840e009..bd6db475990a5398e342e74dcd3f93ef9f4ac89a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6476,7 +6476,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, return NULL; virBitmapSetAll(map); } else { - if ((virBitmapParse(cpulist, '\0', &map, 1024) < 0) || + if (virBitmapParse(cpulist, &map, 1024) < 0 || virBitmapIsAllClear(map)) { vshError(ctl, _("Invalid cpulist '%s'"), cpulist); goto cleanup;