mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-09 23:10:08 +00:00
domain_validate: Check for domain address conflicts fully
Current implementation of virDomainMemoryDefCheckConflict() does only a one way comparison, i.e. if there's a memory device within def->mems[] which address falls in [mem->address, mem->address + mem->size] range (mem is basically an iterator within def->mems[]). And for static XML this works just fine. Problem is with hot/cold plugging of a memory device. Then mem points to freshly parsed memory device and these half checks are insufficient. Not only we must check whether an existing memory device doesn't clash with freshly parsed memory device, but also whether freshly parsed memory device does not fall into range of already existing memory device. Resolves: https://issues.redhat.com/browse/RHEL-4452 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
642af05e3e
commit
91f9a9fb4f
@ -2264,6 +2264,7 @@ virDomainMemoryDefCheckConflict(const virDomainMemoryDef *mem,
|
||||
for (i = 0; i < def->nmems; i++) {
|
||||
const virDomainMemoryDef *other = def->mems[i];
|
||||
unsigned long long otherStart = 0;
|
||||
unsigned long long otherEnd = 0;
|
||||
|
||||
if (other == mem)
|
||||
continue;
|
||||
@ -2315,7 +2316,10 @@ virDomainMemoryDefCheckConflict(const virDomainMemoryDef *mem,
|
||||
if (thisStart == 0 || otherStart == 0)
|
||||
continue;
|
||||
|
||||
if (thisStart <= otherStart && thisEnd > otherStart) {
|
||||
otherEnd = otherStart + other->size * 1024;
|
||||
|
||||
if ((thisStart <= otherStart && thisEnd > otherStart) ||
|
||||
(otherStart <= thisStart && otherEnd > thisStart)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("memory device address [0x%1$llx:0x%2$llx] overlaps with other memory device (0x%3$llx)"),
|
||||
thisStart, thisEnd, otherStart);
|
||||
|
Loading…
Reference in New Issue
Block a user