mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
Remove separator argument from virBitmapParse
Most the callers pass 0 in one form or another, including vircapstest which used VIR_ARCH_NONE.
This commit is contained in:
parent
d728689d9b
commit
ff52e9d43a
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 ==
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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)))
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user