From: Marc-André Lureau <marcandre.lur...@redhat.com> Pass the vhost-user socket to a chardev, and associate a vhost-user-backend with it for each vhost-user-gpu.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- src/qemu/qemu_command.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e85c5c3c1e..b3a2bba28e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4475,6 +4475,38 @@ qemuBuildVgaVideoCommand(virCommandPtr cmd, } +static char * +qemuBuildVhostUserBackendStr(virDomainVideoDefPtr video, + virCommandPtr cmd, + char **chardev) +{ + virBuffer buf = VIR_BUFFER_INITIALIZER; + + if (virAsprintf(chardev, "socket,id=chr-vu-%s,fd=%d", + video->info.alias, video->info.vhost_user_fd) < 0) + goto error; + + virCommandPassFD(cmd, video->info.vhost_user_fd, + VIR_COMMAND_PASS_FD_CLOSE_PARENT); + + video->info.vhost_user_fd = -1; + + virBufferAsprintf(&buf, "vhost-user-backend,id=vu-%s,chardev=chr-vu-%s", + video->info.alias, video->info.alias); + + if (virBufferCheckError(&buf) < 0) + goto error; + + return virBufferContentAndReset(&buf); + +error: + VIR_FREE(*chardev); + virBufferFreeAndReset(&buf); + return NULL; + +} + + static int qemuBuildVideoCommandLine(virCommandPtr cmd, const virDomainDef *def, @@ -4482,6 +4514,24 @@ qemuBuildVideoCommandLine(virCommandPtr cmd, { size_t i; + for (i = 0; i < def->nvideos; i++) { + char *optstr; + char *chardev = NULL; + virDomainVideoDefPtr video = def->videos[i]; + + if (video->type == VIR_DOMAIN_VIDEO_TYPE_VHOST_USER) { + + if (!(optstr = qemuBuildVhostUserBackendStr(video, cmd, &chardev))) + return -1; + + virCommandAddArgList(cmd, "-chardev", chardev, NULL); + virCommandAddArgList(cmd, "-object", optstr, NULL); + + VIR_FREE(optstr); + VIR_FREE(chardev); + } + } + for (i = 0; i < def->nvideos; i++) { char *str = NULL; virDomainVideoDefPtr video = def->videos[i]; -- 2.18.0.129.ge3331758f1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list