From patchwork Wed Jun 5 13:35:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 801593 Delivered-To: patch@linaro.org Received: by 2002:adf:cf0e:0:b0:35b:5a80:51b4 with SMTP id o14csp436984wrj; Wed, 5 Jun 2024 06:35:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTcfHneh5nMTAbcPNKYO9Y3BfZXoxa95N5TkEfP61qpteTrIIcHqTaPw/MzQOXN5wynLES/WO0xHMoUno8lCW5 X-Google-Smtp-Source: AGHT+IGQQBqEwes6Dwp0x6QqczIWACCsRWfj+syEsJ3Mv2zysxuMpc/VPG4RrF2cvqe5e2i2bYM7 X-Received: by 2002:a05:6102:310d:b0:485:d1bd:64bc with SMTP id ada2fe7eead31-48c0484b16fmr2876655137.12.1717594553147; Wed, 05 Jun 2024 06:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717594553; cv=none; d=google.com; s=arc-20160816; b=x0kUIkl6xmp6LfSGKsCjwMPJSvoPhBzFa+WepPZpgI4BtnC9/ae9roy2LMjGsNY+vO 2+zZUOmkF0t+8Fw6ms+Q9+Aj2f40lZcyVxs7+btOFiQ+LRTMih+tCknGK/C7BLOlhki5 Vr4/oixufjVivCZ4Mv//P02ZXOsgj6VBBVXj9PufYaDSAvfTEh6/tS0uPkPpDVPkMTeg JC6guQ4mqR1t41L5rbNvQyS3P+Myua8UIqG/fi0S4cglGQxizOQ7XyckbqbWMtUdwvdw 4SILAqqu28mymui+Pv6VIivRCpkcPPj9bPUoy+taNrQrCWWmi7zhSi7AEFHBWm/+JCzC /+Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=FwE6PA3YucFEKlF5XYjDfDwwa1ZnwXRI6rnHV+Zj+ic=; fh=IUr4bQqVjgClmNIZboVS252Y4bR+3t+WD6MXYx9SjDA=; b=wppupI1aiOq3yIl6WrjTJ39rlJzyr5mDc2NCgMhaKFYgN8J3GUt2KpEjzf++NPqdfu fVe20JfhhoQiSA66aO/8xl820Kc1GbHohPomPmbTbynM3KAhKMhqjSLkVXLpUlZXjZV8 xariH+03+nTV84C/HWy4kT4ghGYIYBK6cPYK9GvXbW0zTejp2w8k+iHA7E83ZJDdKjkT EHFMe70JeQ4BoDl+4srvL7f0ftM3Vdgut7x5NGIEwCSHTi4coO+Qlf/TyEq/8ef4lIq6 +Hq+Xpn/s2r1Xe+7lGg+K+ulUtAeXxqQBQ7/iDcSHcEbQCFe+SVb+2CYXiPsI7WceZmM +VAA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rgku2Ipc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-48bbd00f19esi2258624137.725.2024.06.05.06.35.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2024 06:35:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rgku2Ipc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEqnl-0002Jk-73; Wed, 05 Jun 2024 09:35:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEqnk-0002Gh-BV for qemu-devel@nongnu.org; Wed, 05 Jun 2024 09:35:40 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEqni-0003N1-CQ for qemu-devel@nongnu.org; Wed, 05 Jun 2024 09:35:40 -0400 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57a6fcb823fso3347457a12.3 for ; Wed, 05 Jun 2024 06:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717594537; x=1718199337; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FwE6PA3YucFEKlF5XYjDfDwwa1ZnwXRI6rnHV+Zj+ic=; b=Rgku2IpcdVyIjJprwOElWtYcktspT9Pn616Lssk9wFp1hPVUtWJpgGpJdiwNsv4uA+ /EYcbeNBzv5oVPAQ/YtKyAGAxSRL3eitqabt0ujMRZ4YYWD1XJNLttIJ4S/D7zPkx+S1 XL8FLhzOOPdFdJr1VxAQdKFqRwqUOUO/YpzhST0jq1Hxg/7jCPILeaiJaV9FIfAAjiLq stp4EofTP8uT58H1++Yw5dx2vaJjv4vax2VKOSxcQCl8qpaxMCXYW8DiueLHR3o8TKiO Ywp3PjHXrmmQyWdZeiKCWG927jwFShxD5YOarTzMqBOZ4mYbKAbptAfg85RTeYyXEgl8 a5Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717594537; x=1718199337; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FwE6PA3YucFEKlF5XYjDfDwwa1ZnwXRI6rnHV+Zj+ic=; b=QAkf1n/KptSK3Jfus5z4Kw6lKw4I4q7vKndVaH/5mqta9MUIG7VKL9+6ub+2Vh57e1 ltYZxWCyO/21mKLr/KdmR4qbUZPMrjOUvMje72ibdr8HPcmaevm57u9ixnkQ5Z6Y+eEa OPJH9IGavetMv5XxmBfOk+6W7677tULOqKwi/8AuAk2jNfO5D7Gnfnr5vUk83ZXtJbUw ee5J3YrVPeeV6SOoxRABriZIeo+hvDTg1YkOUlxxppUpISYrxGmPH8dVXJwsscjtyn/O yklCQ6GZYuPJJll5KLqbzgYWNLzHQWaCCGwvbgPU58x2I6/grK8luKar0bwLhUaDnsif jBBQ== X-Gm-Message-State: AOJu0Yz0thOzmRCoptheyfaZbZIByA2WWiSakD6xkxpuLT5IrVV9ODJz 4cMW7EDv27kYj5cFFtjf42+hB4j1aLO/eUthD172E+RR5dueefVMPpVnjsTNN1M= X-Received: by 2002:a50:8d4e:0:b0:57a:76c1:b14e with SMTP id 4fb4d7f45d1cf-57a8b51f11amr1799819a12.0.1717594536672; Wed, 05 Jun 2024 06:35:36 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57a8b21ae1csm1731593a12.62.2024.06.05.06.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:35:36 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 81DF45F7AE; Wed, 5 Jun 2024 14:35:35 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Manos Pitsidianakis , Dmitry Osipenko , Akihiko Odaki , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [RFC PATCH] subprojects: add a wrapper for libvirglrenderer Date: Wed, 5 Jun 2024 14:35:27 +0100 Message-Id: <20240605133527.529950-1-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52a; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org As the latest features for virtio-gpu need a pretty recent version of libvirglrenderer. When it is not available on the system we can use a meson wrapper and provide it when --download is specified in configure. We have to take some additional care as currently QEMU will hang libvirglrenderer fails to exec the render server. As the error isn't back propagated we make sure we at least test we have a path to an executable before tweaking the environment. Signed-off-by: Alex Bennée Cc: Manos Pitsidianakis Cc: Dmitry Osipenko Cc: Akihiko Odaki --- meson.build | 7 ++++++- hw/display/virtio-gpu-virgl.c | 24 ++++++++++++++++++++++++ subprojects/virglrenderer.wrap | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 subprojects/virglrenderer.wrap diff --git a/meson.build b/meson.build index 1d7346b703..e4e270df78 100644 --- a/meson.build +++ b/meson.build @@ -1203,7 +1203,8 @@ have_vhost_user_gpu = have_tools and host_os == 'linux' and pixman.found() if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu virgl = dependency('virglrenderer', method: 'pkg-config', - required: get_option('virglrenderer')) + required: get_option('virglrenderer'), + default_options: ['default_library=static', 'render-server=true', 'venus=true']) endif rutabaga = not_found if not get_option('rutabaga_gfx').auto() or have_system or have_vhost_user_gpu @@ -2314,6 +2315,10 @@ if virgl.version().version_compare('>=1.0.0') config_host_data.set('HAVE_VIRGL_RESOURCE_BLOB', 1) config_host_data.set('HAVE_VIRGL_VENUS', 1) endif +if virgl.type_name().contains('internal') + config_host_data.set('HAVE_BUNDLED_VIRGL_SERVER', 1) +endif + config_host_data.set('CONFIG_VIRTFS', have_virtfs) config_host_data.set('CONFIG_VTE', vte.found()) config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found()) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index c9d20a8a60..53d6742e79 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/iov.h" +#include "qemu/cutils.h" #include "trace.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" @@ -1122,6 +1123,26 @@ void virtio_gpu_virgl_reset(VirtIOGPU *g) virgl_renderer_reset(); } +/* + * If we fail to spawn the render server things tend to hang so it is + * important to do our due diligence before then. If QEMU has bundled + * the virgl server we want to ensure we can run it from the build + * directory and if installed. + * + * The principle way we can override the libvirglrenders behaviour is + * by setting environment variables. + */ +static void virgl_set_render_env(void) +{ +#ifdef HAVE_BUNDLED_VIRGL_SERVER + g_autofree char *file = get_relocated_path(CONFIG_QEMU_HELPERDIR "/virgl_render_server"); + if (g_file_test(file, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_EXECUTABLE)) { + g_setenv("RENDER_SERVER_EXEC_PATH", file, false); + } +#endif +} + + int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; @@ -1145,6 +1166,9 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } #endif + /* Ensure we can find the render server */ + virgl_set_render_env(); + ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); if (ret != 0) { error_report("virgl could not be initialized: %d", ret); diff --git a/subprojects/virglrenderer.wrap b/subprojects/virglrenderer.wrap new file mode 100644 index 0000000000..3656a478c4 --- /dev/null +++ b/subprojects/virglrenderer.wrap @@ -0,0 +1,6 @@ +[wrap-git] +url = https://gitlab.freedesktop.org/virgl/virglrenderer.git +revision = virglrenderer-1.0.1 + +[provide] +virglrenderer = libvirglrenderer_dep