提交 6705d828 编写于 作者: P Peter Krempa

qemu: command: Validate that memory devices slot ID is in range

slot id, if specified, has to be less than the slots count.
上级 406944e4
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册