qemu: sanity check vhost user FD before passing to QEMU

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 <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-09-30 12:39:17 +01:00
parent 227925a2e5
commit 6ffb8fff9e

View File

@ -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;