mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
util: bitmap: Tolerate NULL bitmaps in virBitmapEqual
After virBitmapEqual is able to compare NULL bitmaps few bits of code can be cleaned up.
This commit is contained in:
parent
9bbbb91216
commit
20448c2a72
@ -15637,18 +15637,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (src_huge->nodemask && dst_huge->nodemask) {
|
||||
if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Target huge page nodemask does not match source"));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (src_huge->nodemask || dst_huge->nodemask) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Target huge page nodemask does not match source"));
|
||||
goto error;
|
||||
}
|
||||
if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Target huge page nodemask does not match source"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19138,20 +19130,12 @@ virDomainIsAllVcpupinInherited(virDomainDefPtr def)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!def->cpumask) {
|
||||
if (def->cputune.nvcpupin)
|
||||
for (i = 0; i < def->cputune.nvcpupin; i++) {
|
||||
if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask, def->cpumask))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
} else {
|
||||
for (i = 0; i < def->cputune.nvcpupin; i++) {
|
||||
if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask,
|
||||
def->cpumask))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -19489,9 +19473,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
||||
for (i = 0; i < def->cputune.nvcpupin; i++) {
|
||||
char *cpumask;
|
||||
/* Ignore the vcpupin which inherit from "cpuset of "<vcpu>." */
|
||||
if (def->cpumask &&
|
||||
virBitmapEqual(def->cpumask,
|
||||
def->cputune.vcpupin[i]->cpumask))
|
||||
if (virBitmapEqual(def->cpumask, def->cputune.vcpupin[i]->cpumask))
|
||||
continue;
|
||||
|
||||
virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
|
||||
@ -19518,9 +19500,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
||||
for (i = 0; i < def->cputune.niothreadspin; i++) {
|
||||
char *cpumask;
|
||||
/* Ignore the iothreadpin which inherit from "cpuset of "<vcpu>." */
|
||||
if (def->cpumask &&
|
||||
virBitmapEqual(def->cpumask,
|
||||
def->cputune.iothreadspin[i]->cpumask))
|
||||
if (virBitmapEqual(def->cpumask, def->cputune.iothreadspin[i]->cpumask))
|
||||
continue;
|
||||
|
||||
virBufferAsprintf(buf, "<iothreadpin iothread='%u' ",
|
||||
|
@ -542,9 +542,6 @@ virDomainNumatuneNodesEqual(virDomainNumatunePtr n1,
|
||||
if (!nd1->nodeset && !nd2->nodeset)
|
||||
continue;
|
||||
|
||||
if (!nd1->nodeset || !nd2->nodeset)
|
||||
return false;
|
||||
|
||||
if (nd1->mode != nd2->mode)
|
||||
return false;
|
||||
|
||||
|
@ -504,6 +504,12 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
|
||||
virBitmapPtr tmp;
|
||||
size_t i;
|
||||
|
||||
if (!b1 && !b2)
|
||||
return true;
|
||||
|
||||
if (!b1 || !b2)
|
||||
return false;
|
||||
|
||||
if (b1->max_bit > b2->max_bit) {
|
||||
tmp = b1;
|
||||
b1 = b2;
|
||||
|
@ -84,8 +84,7 @@ virBitmapPtr virBitmapNewData(void *data, int len) ATTRIBUTE_NONNULL(1);
|
||||
int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2);
|
||||
|
||||
size_t virBitmapSize(virBitmapPtr bitmap)
|
||||
ATTRIBUTE_NONNULL(1);
|
||||
|
Loading…
Reference in New Issue
Block a user