On Wed, Oct 26, 2016 at 12:51:36 +0200, Martin Kletzander wrote: > QEMU added support for ivshmem-plain and ivshmem-doorbell. Those are > reworked varians of legacy ivshmem that are compatible from the guest > POV, but not from host's POV and have sane specification and handling. > > Details about the newer device type can be found in qemu's commit > 5400c02b90bb: > > http://git.qemu.org/?p=qemu.git;a=commit;h=5400c02b90bb > > Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> > --- > src/qemu/qemu_command.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++-- > src/qemu/qemu_command.h | 10 +++++ > tests/qemuxml2argvtest.c | 3 ++ > 3 files changed, 109 insertions(+), 3 deletions(-) > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index 558122b4cf7e..972cccee25de 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -8443,6 +8443,50 @@ qemuBuildShmemDevLegacyStr(virDomainDefPtr def, > return NULL; > } > > +char * > +qemuBuildShmemDevStr(virDomainDefPtr def, > + virDomainShmemDefPtr shmem, > + virQEMUCapsPtr qemuCaps) > +{ > + virBuffer buf = VIR_BUFFER_INITIALIZER; > + > + if ((shmem->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN && > + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN)) || > + (shmem->model == VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL && > + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL))) { > + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > + _("shmem model '%s' is not supported " > + "by this QEMU binary"), > + virDomainShmemModelTypeToString(shmem->model)); > + return NULL; > + } > + > + virBufferAsprintf(&buf, "%s", virDomainShmemModelTypeToString(shmem->model)); virBufferAdd. > + virBufferAsprintf(&buf, ",id=%s", shmem->info.alias); > + > + if (shmem->server.enabled) > + virBufferAsprintf(&buf, ",chardev=char%s", shmem->info.alias); > + else > + virBufferAsprintf(&buf, ",memdev=shmmem-%s", shmem->info.alias); > + > + if (shmem->msi.vectors) > + virBufferAsprintf(&buf, ",vectors=%u", shmem->msi.vectors); > + if (shmem->msi.ioeventfd) { > + virBufferAsprintf(&buf, ",ioeventfd=%s", > + virTristateSwitchTypeToString(shmem->msi.ioeventfd)); > + } > + > + if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0) { > + virBufferFreeAndReset(&buf); > + return NULL; > + } > + > + if (virBufferCheckError(&buf) < 0) > + return NULL; > + > + return virBufferContentAndReset(&buf); > +} > + > static char * > qemuBuildShmemBackendChrStr(virLogManagerPtr logManager, > virCommandPtr cmd, > @@ -8463,6 +8507,50 @@ qemuBuildShmemBackendChrStr(virLogManagerPtr logManager, > return devstr; > } > > + > +virJSONValuePtr > +qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem) > +{ > + char *mem_path = NULL; > + virJSONValuePtr ret = NULL; > + > + if (virAsprintf(&mem_path, "/dev/shm/%s", shmem->name) < 0) I was a bit worried that we'd encode a linuxism here, but qemu was doing the same. > + return NULL; > + > + virJSONValueObjectCreate(&ret, > + "s:mem-path", mem_path, > + "U:size", shmem->size, > + NULL); > + > + VIR_FREE(mem_path); > + return ret; > +} ACK
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list