qemu_command: Move dimm into qemuBuildDeviceAddressStr()

So far our memory modules could go only into DIMM slots. But with
virtio model this assumption is no longer true - virtio-pmem goes
onto PCI bus. But for formatting PCI address onto command line we
already have a function - qemuBuildDeviceAddressStr(). Therefore,
mode DIMM address generation into it so that we don't have to
special case address building later on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Tested-by: Han Han <hhan@redhat.com>
This commit is contained in:
Michal Privoznik 2020-11-03 17:31:27 +01:00
parent 2df92ec4e5
commit d76d7d7d68
3 changed files with 14 additions and 10 deletions

View File

@ -393,6 +393,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
virBufferAsprintf(buf, ",iobase=0x%x,irq=0x%x",
info->addr.isa.iobase,
info->addr.isa.irq);
} else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
virBufferAsprintf(buf, ",slot=%d", info->addr.dimm.slot);
if (info->addr.dimm.base)
virBufferAsprintf(buf, ",addr=%llu", info->addr.dimm.base);
}
return 0;
@ -3269,7 +3273,9 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
char *
qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
qemuBuildMemoryDeviceStr(const virDomainDef *def,
virDomainMemoryDefPtr mem,
virQEMUCapsPtr qemuCaps)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
const char *device;
@ -3311,12 +3317,7 @@ qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem)
virBufferAsprintf(&buf, "memdev=mem%s,id=%s",
mem->info.alias, mem->info.alias);
if (mem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
virBufferAsprintf(&buf, ",slot=%d", mem->info.addr.dimm.slot);
if (mem->info.addr.dimm.base)
virBufferAsprintf(&buf, ",addr=%llu", mem->info.addr.dimm.base);
}
qemuBuildDeviceAddressStr(&buf, def, &mem->info, qemuCaps);
break;
case VIR_DOMAIN_MEMORY_MODEL_NONE:
@ -7456,7 +7457,7 @@ qemuBuildMemoryDeviceCommandLine(virCommandPtr cmd,
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
if (!(dimmStr = qemuBuildMemoryDeviceStr(def->mems[i])))
if (!(dimmStr = qemuBuildMemoryDeviceStr(def, def->mems[i], priv->qemuCaps)))
return -1;
virCommandAddArgList(cmd, "-device", dimmStr, NULL);

View File

@ -155,7 +155,10 @@ int qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
const virDomainMemoryDef *mem,
bool force);
char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem);
char *
qemuBuildMemoryDeviceStr(const virDomainDef *def,
virDomainMemoryDefPtr mem,
virQEMUCapsPtr qemuCaps);
/* Current, best practice */
char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,

View File

@ -2412,7 +2412,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
objalias = g_strdup_printf("mem%s", mem->info.alias);
if (!(devstr = qemuBuildMemoryDeviceStr(mem)))
if (!(devstr = qemuBuildMemoryDeviceStr(vm->def, mem, priv->qemuCaps)))
goto cleanup;
if (qemuBuildMemoryBackendProps(&props, objalias, cfg,