vhost-user-gpu: fix vugbm_device_init fallback

vugbm implements GBM device wrapping, udmabuf and memory fallback.
However, the fallback/detection logic is flawed, as if "/dev/udmabuf"
failed to be opened, it will not initialize vugbm and crash later.

Rework the vugbm_device_init() logic to initialize correctly in all
cases.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210312100108.2706195-4-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Marc-André Lureau 2021-03-12 14:00:44 +04:00 committed by Gerd Hoffmann
parent 0c27b9c568
commit 96ee096a13
3 changed files with 22 additions and 30 deletions

View file

@ -1186,11 +1186,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
if (g.drm_rnode_fd >= 0) {
if (!vugbm_device_init(&g.gdev, g.drm_rnode_fd)) {
g_warning("Failed to init DRM device, using fallback path");
}
}
vugbm_device_init(&g.gdev, g.drm_rnode_fd);
if ((!!opt_socket_path + (opt_fdnum != -1)) != 1) {
g_printerr("Please specify either --fd or --socket-path\n");