mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: command: Validate that memory devices slot ID is in range
slot id, if specified, has to be less than the slots count.
This commit is contained in:
parent
406944e476
commit
6705d828fc
@ -4946,6 +4946,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
|
|||||||
|
|
||||||
char *
|
char *
|
||||||
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
||||||
|
virDomainDefPtr def,
|
||||||
virQEMUCapsPtr qemuCaps)
|
virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
@ -4972,6 +4973,14 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM &&
|
||||||
|
mem->info.addr.dimm.slot >= def->mem.memory_slots) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
|
_("memory device slot '%u' exceeds slots count '%u'"),
|
||||||
|
mem->info.addr.dimm.slot, def->mem.memory_slots);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "pc-dimm,node=%d,memdev=mem%s,id=%s",
|
virBufferAsprintf(&buf, "pc-dimm,node=%d,memdev=mem%s,id=%s",
|
||||||
mem->targetNode, mem->info.alias, mem->info.alias);
|
mem->targetNode, mem->info.alias, mem->info.alias);
|
||||||
|
|
||||||
@ -8821,7 +8830,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
qemuCaps, cfg)))
|
qemuCaps, cfg)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], qemuCaps))) {
|
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], def, qemuCaps))) {
|
||||||
VIR_FREE(backStr);
|
VIR_FREE(backStr);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,7 @@ int qemuBuildMemoryBackendStr(unsigned long long size,
|
|||||||
bool force);
|
bool force);
|
||||||
|
|
||||||
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
||||||
|
virDomainDefPtr def,
|
||||||
virQEMUCapsPtr qemuCaps);
|
virQEMUCapsPtr qemuCaps);
|
||||||
|
|
||||||
/* Legacy, pre device support */
|
/* Legacy, pre device support */
|
||||||
|
@ -1736,7 +1736,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
|
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv->qemuCaps)))
|
if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
qemuDomainMemoryDeviceAlignSize(mem);
|
qemuDomainMemoryDeviceAlignSize(mem);
|
||||||
|
Loading…
Reference in New Issue
Block a user