mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00: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 *
|
||||
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
||||
virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
@ -4972,6 +4973,14 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
||||
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",
|
||||
mem->targetNode, mem->info.alias, mem->info.alias);
|
||||
|
||||
@ -8821,7 +8830,7 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
qemuCaps, cfg)))
|
||||
goto error;
|
||||
|
||||
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], qemuCaps))) {
|
||||
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i], def, qemuCaps))) {
|
||||
VIR_FREE(backStr);
|
||||
goto error;
|
||||
}
|
||||
|
@ -175,6 +175,7 @@ int qemuBuildMemoryBackendStr(unsigned long long size,
|
||||
bool force);
|
||||
|
||||
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
|
||||
virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps);
|
||||
|
||||
/* Legacy, pre device support */
|
||||
|
@ -1736,7 +1736,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
if (virAsprintf(&objalias, "mem%s", mem->info.alias) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv->qemuCaps)))
|
||||
if (!(devstr = qemuBuildMemoryDeviceStr(mem, vm->def, priv->qemuCaps)))
|
||||
goto cleanup;
|
||||
|
||||
qemuDomainMemoryDeviceAlignSize(mem);
|
||||
|
Loading…
Reference in New Issue
Block a user