[mutter/wip/smcv/dev-dri-access] backend/native: Don't warn on EACCES if headless




commit bf1c6ffd8fa5576e37362e34867be3c1514cd3a2
Author: Simon McVittie <smcv debian org>
Date:   Thu Aug 18 10:41:01 2022 +0100

    backend/native: Don't warn on EACCES if headless
    
    Since commit 1bf70334 "tests/runner: Make test runner use the headless
    backend", tests are run with the native backend in headless mode, which
    will attempt to open each GPU and show a warning (fatal during tests)
    if it cannot.
    
    However, in headless mode we might not be logged in on any seat (for
    example we might be logged in via ssh instead), which means we might
    legitimately not have permission to use any GPUs, even if they exist.
    Downgrade the warning to a debug message in this case.
    
    Resolves: https://gitlab.gnome.org/GNOME/mutter/-/issues/2381
    Signed-off-by: Simon McVittie <smcv debian org>

 src/backends/native/meta-backend-native.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 8c6658cc91..8e6bc78292 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -525,8 +525,15 @@ on_udev_device_added (MetaUdev          *udev,
   new_gpu_kms = create_gpu_from_udev_device (native, device, &error);
   if (!new_gpu_kms)
     {
-      g_warning ("Failed to hotplug secondary gpu '%s': %s",
-                 device_path, error->message);
+      if (meta_backend_is_headless (backend) &&
+          g_error_matches (error, G_IO_ERROR,
+                           G_IO_ERROR_PERMISSION_DENIED))
+        g_debug ("Ignoring unavailable secondary gpu '%s': %s",
+                   device_path, error->message);
+      else
+        g_warning ("Failed to hotplug secondary gpu '%s': %s",
+                   device_path, error->message);
+
       return;
     }
 
@@ -563,9 +570,17 @@ init_gpus (MetaBackendNative  *native,
 
       if (!gpu_kms)
         {
-          g_warning ("Failed to open gpu '%s': %s",
+          if (meta_backend_is_headless (backend) &&
+              g_error_matches (local_error, G_IO_ERROR,
+                               G_IO_ERROR_PERMISSION_DENIED))
+            g_debug ("Ignoring unavailable gpu '%s': %s'",
                      g_udev_device_get_device_file (device),
                      local_error->message);
+          else
+            g_warning ("Failed to open gpu '%s': %s",
+                       g_udev_device_get_device_file (device),
+                       local_error->message);
+
           g_clear_error (&local_error);
           continue;
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]