qemuBuildDimmDeviceStr being introduced is responsible for creating command line argument for '-device' for given dimm device. Signed-off-by: Zhu Guihua <zhugh.fnst@xxxxxxxxxxxxxx> --- src/qemu/qemu_command.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_command.h | 4 ++++ 2 files changed, 54 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 68fdab7..ff72f46 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7735,6 +7735,49 @@ qemuBuildChrDeviceCommandLine(virCommandPtr cmd, return 0; } +int +qemuBuildDimmDeviceStr(char **deviceStr, + virDomainDimmDefPtr dev, + virQEMUCapsPtr qemuCaps) +{ + virBuffer buf = VIR_BUFFER_INITIALIZER; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("%s not supported in this QEMU binary"), dev->driver); + goto error; + } + + virBufferAsprintf(&buf, "%s,id=%s,addr=%d,node=%d,slot=%d,memdev=obj%s", + dev->driver, dev->info.alias, dev->addr, + dev->node, dev->slot, dev->info.alias); + + if (virBufferCheckError(&buf) < 0) + goto error; + + *deviceStr = virBufferContentAndReset(&buf); + return 0; + + error: + virBufferFreeAndReset(&buf); + return -1; +} + +static int +qemuBuildDimmDeviceCommandLine(virCommandPtr cmd, + virDomainDimmDefPtr dev, + virQEMUCapsPtr qemuCaps) +{ + char *devstr = NULL; + + if (qemuBuildDimmDeviceStr(&devstr, dev, qemuCaps) < 0) + return -1; + + virCommandAddArgList(cmd, "-device", devstr, NULL); + VIR_FREE(devstr); + return 0; +} + static int qemuBuildDomainLoaderCommandLine(virCommandPtr cmd, virDomainDefPtr def, @@ -9887,6 +9930,13 @@ qemuBuildCommandLine(virConnectPtr conn, goto error; } + if (def->ndimms) { + for (i = 0; i < def->ndimms; i++) { + if (qemuBuildDimmDeviceCommandLine(cmd, def->dimms[i], qemuCaps) < 0) + goto error; + } + } + if (def->nvram) { if (ARCH_IS_PPC64(def->os.arch) && STRPREFIX(def->os.machine, "pseries")) { diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 512d444..c9d2eb7 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -148,6 +148,10 @@ char *qemuBuildMemballoonDevStr(virDomainDefPtr domainDef, virDomainMemballoonDefPtr dev, virQEMUCapsPtr qemuCaps); +int qemuBuildDimmDeviceStr(char **deviceStr, + virDomainDimmDefPtr dimm, + virQEMUCapsPtr qemuCaps); + char *qemuBuildUSBInputDevStr(virDomainDefPtr domainDef, virDomainInputDefPtr dev, virQEMUCapsPtr qemuCaps); -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list