From 6ffb8fff9e0a4fd22b303ecc8dbd6a3d8c61c2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 30 Sep 2019 12:39:17 +0100 Subject: [PATCH] qemu: sanity check vhost user FD before passing to QEMU MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that the FD we're passing to QEMU is actually open, so we get a sane error message upfront instead of telling QEMU to use a closed FD. Reviewed-by: Michal Privoznik Signed-off-by: Daniel P. Berrangé --- src/qemu/qemu_command.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 77470a6037..8c979fdf65 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4704,6 +4704,12 @@ qemuBuildVhostUserChardevStr(const char *alias, { char *chardev = NULL; + if (*fd == -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Attempt to pass closed vhostuser FD")); + return NULL; + } + if (virAsprintf(&chardev, "socket,id=chr-vu-%s,fd=%d", alias, *fd) < 0) return NULL; -- GitLab