From c9c35133c3a0041c7bf9269791a2caebfb04ddf0 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 30 Sep 2016 16:44:17 +0200 Subject: [PATCH] Add support for --device=kvm Solves: https://github.com/flatpak/flatpak/issues/332 --- common/flatpak-run.c | 8 ++++++++ doc/flatpak-build-finish.xml | 4 ++-- doc/flatpak-build.xml | 4 ++-- doc/flatpak-metadata.xml | 2 +- doc/flatpak-override.xml | 4 ++-- doc/flatpak-run.xml | 4 ++-- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/common/flatpak-run.c b/common/flatpak-run.c index e741d4f2f..176da5210 100644 --- a/common/flatpak-run.c +++ b/common/flatpak-run.c @@ -93,11 +93,13 @@ const char *dont_mount_in_root[] = { typedef enum { FLATPAK_CONTEXT_DEVICE_DRI = 1 << 0, FLATPAK_CONTEXT_DEVICE_ALL = 1 << 1, + FLATPAK_CONTEXT_DEVICE_KVM = 1 << 2, } FlatpakContextDevices; const char *flatpak_context_devices[] = { "dri", "all", + "kvm", NULL }; @@ -2006,6 +2008,12 @@ flatpak_run_add_environment_args (GPtrArray *argv_array, NULL); } } + if (context->devices & FLATPAK_CONTEXT_DEVICE_KVM) + { + g_debug ("Allowing kvm access"); + if (g_file_test ("/dev/kvm", G_FILE_TEST_EXISTS)) + add_args (argv_array, "--dev-bind", "/dev/kvm", "/dev/kvm", NULL); + } } fs_mode = (FlatpakFilesystemMode) g_hash_table_lookup (context->filesystems, "host"); diff --git a/doc/flatpak-build-finish.xml b/doc/flatpak-build-finish.xml index 248fbfc13..3b75d498a 100644 --- a/doc/flatpak-build-finish.xml +++ b/doc/flatpak-build-finish.xml @@ -136,7 +136,7 @@ Expose a device to the application. This updates the [Context] group in the metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. @@ -147,7 +147,7 @@ Don't expose a device to the application. This updates the [Context] group in the metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. diff --git a/doc/flatpak-build.xml b/doc/flatpak-build.xml index a802753c7..4692030ac 100644 --- a/doc/flatpak-build.xml +++ b/doc/flatpak-build.xml @@ -161,7 +161,7 @@ Expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. @@ -172,7 +172,7 @@ Don't expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. diff --git a/doc/flatpak-metadata.xml b/doc/flatpak-metadata.xml index 6749af0ad..b6078b86e 100644 --- a/doc/flatpak-metadata.xml +++ b/doc/flatpak-metadata.xml @@ -121,7 +121,7 @@ (list) List of devices to make available in the sandbox. - Possible values: dri, all. + Possible values: dri, kvm, all. diff --git a/doc/flatpak-override.xml b/doc/flatpak-override.xml index 5946f3320..e8bbac292 100644 --- a/doc/flatpak-override.xml +++ b/doc/flatpak-override.xml @@ -117,7 +117,7 @@ Expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. @@ -128,7 +128,7 @@ Don't expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. diff --git a/doc/flatpak-run.xml b/doc/flatpak-run.xml index 2497d72b6..b047f0b35 100644 --- a/doc/flatpak-run.xml +++ b/doc/flatpak-run.xml @@ -195,7 +195,7 @@ Expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times. @@ -206,7 +206,7 @@ Don't expose a device to the application. This overrides to the Context section from the application metadata. - DEVICE must be one of: dri, all. + DEVICE must be one of: dri, kvm, all. This option can be used multiple times.