macos: Allow coredump generation
RFC PATCH 1/1 macos: Allow coredump generation
QEMU is allowed to generate coredump on other POSIX OSes, bring that functionality to macOS. Admin users still need to enable the kern.coredump sysctl manually running:
% sudo sysctl kern.coredump=1
the normal users have to enable their shell running:
% ulimit -c unlimited
Reference used:
https://nasa.github.io/trick/howto_guides/How-to-dump-core-file-on-MacOS.html
---
Cc: Alexander Graf <[email protected]>
Cc: Akihiko Odaki <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Phil Dennis-Jordan <[email protected]>
Cc: Roman Bolshakov <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Francesco Cagnin <[email protected]>
--- MAINTAINERS | 2 ++ meson.build | 6 ++++-- accel/hvf/entitlements.plist | 2 ++ accel/tcg/entitlements.plist | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 accel/tcg/entitlements.plist
MAINTAINERS +2 -0
@@ -611,6 +611,8 @@ M: Philippe Mathieu-Daudé <[email protected]> S: Odd Fixes F: .gitlab-ci.d/cirrus/macos-* F: */*.m +F: accel/tcg/entitlements.plist +F: accel/hvf/entitlements.plist F: scripts/entitlement.sh Alpha Machines
meson.build +4 -2
@@ -3983,9 +3983,11 @@ foreach target : target_dirs ] if 'CONFIG_HVF' in config_target entitlements = 'accel/hvf/entitlements.plist' - build_input += files(entitlements) - install_input += meson.current_source_dir() / entitlements + else + entitlements = 'accel/tcg/entitlements.plist' endif + build_input += files(entitlements) + install_input += meson.current_source_dir() / entitlements emulators += {exe['name'] : custom_target(exe['name'], input: build_input,
accel/hvf/entitlements.plist +2 -0
@@ -4,5 +4,7 @@ <dict> <key>com.apple.security.hypervisor</key> <true/> + <key>com.apple.security.get-task-allow</key> + <true/> </dict> </plist>
accel/tcg/entitlements.plist new file +8 -0
@@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.get-task-allow</key> + <true/> +</dict> +</plist>
Signature · 1 line
2.41.0
This can certainly be useful in various situations! However, wholesale enabling get-task-allow will enable other processes on the system to inject code, connect a debugger, etc. to the Qemu process. Normally, this is only something you'd enable for builds that are specifically intended for debugging. I'm not sure users running Qemu in production environments will necessarily appreciate this - do we perhaps want to gate this behind a build configuration flag?
(Related: Would it perhaps make more sense to dynamically generate/preprocess the entitlements file based on configuration flags than have a bunch of variants of the file? You'll end up with a combinatorial explosion sooner or later - I'm also thinking of com.apple.vm.networking and com.apple.vm.device-access which we can't enable by default because they require Apple to grant the entitlement but which currently require patching if you have those entitlements.)
What do you think?
Phil
Quoted 93 lines · Philippe Mathieu-Daudé
QEMU is allowed to generate coredump on other POSIX OSes, bring that functionality to macOS. Admin users still need to enable the kern.coredump sysctl manually running:
% sudo sysctl kern.coredump=1
the normal users have to enable their shell running:
% ulimit -c unlimited
Reference used:
https://nasa.github.io/trick/howto_guides/How-to-dump-core-file-on-MacOS.html
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Alexander Graf <[email protected]>
Cc: Akihiko Odaki <[email protected]>
Cc: Peter Maydell <[email protected]>
Cc: Phil Dennis-Jordan <[email protected]>
Cc: Roman Bolshakov <[email protected]>
Cc: Paolo Bonzini <[email protected]>
Cc: Francesco Cagnin <[email protected]>--- MAINTAINERS | 2 ++ meson.build | 6 ++++-- accel/hvf/entitlements.plist | 2 ++ accel/tcg/entitlements.plist | 8 ++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 accel/tcg/entitlements.plistMAINTAINERS +2
-0@@ -611,6 +611,8 @@ M: Philippe Mathieu-Daudé <[email protected]> S: Odd Fixes F: .gitlab-ci.d/cirrus/macos-* F: */*.m +F: accel/tcg/entitlements.plist +F: accel/hvf/entitlements.plist F: scripts/entitlement.sh Alpha Machinesmeson.build +4
-2@@ -3983,9 +3983,11 @@ foreach target : target_dirs ] if 'CONFIG_HVF' in config_target entitlements = 'accel/hvf/entitlements.plist' - build_input += files(entitlements) - install_input += meson.current_source_dir() / entitlements + else + entitlements = 'accel/tcg/entitlements.plist' endif + build_input += files(entitlements) + install_input += meson.current_source_dir() / entitlements emulators += {exe['name'] : custom_target(exe['name'], input: build_input,accel/hvf/entitlements.plist +2
-0@@ -4,5 +4,7 @@ <dict> <key>com.apple.security.hypervisor</key> <true/> + <key>com.apple.security.get-task-allow</key> + <true/> </dict> </plist>accel/tcg/entitlements.plist new file +2
-0@@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>accel/tcg/entitlements.plist new file +4
-1+ <key>com.apple.security.get-task-allow</key> + <true/> +</dict> +</plist> --2.41.0
Quoted 1 line · Phil Dennis-Jordan
This can certainly be useful in various situations! However, wholesale enabling get-task-allow will enable other processes on the system to inject code, connect a debugger, etc. to the Qemu process. Normally, this is only something you'd enable for builds that are specifically intended for debugging. I'm not sure users running Qemu in production environments will necessarily appreciate this - do we perhaps want to gate this behind a build configuration flag?
Yes, it is useful but shouldn't be enabled by default for a non-debug build.
Quoted 2 lines
(Related: Would it perhaps make more sense to dynamically generate/preprocess the entitlements file based on configuration flags than have a bunch of variants of the file? You'll end up with a combinatorial explosion sooner or later - I'm also thinking of com.apple.vm.networking and com.apple.vm.device-access which we can't enable by default because they require Apple to grant the entitlement but which currently require patching if you have those entitlements.)
I agree. It's better to generate a plist.
Quoted 15 lines
What do you think?
Phil
On Tue, 23 Jul 2024 at 10:59, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>> wrote:
QEMU is allowed to generate coredump on other POSIX OSes, bring that functionality to macOS. Admin users still need
to enable the kern.coredump sysctl manually running:
Quoted 8 lines
% sudo sysctl kern.coredump=1
the normal users have to enable their shell running:
% ulimit -c unlimited
Reference used:
https://nasa.github.io/trick/howto_guides/How-to-dump-core-file-on-MacOS.html <https://nasa.github.io/trick/howto_guides/How-to-dump-core-file-on-MacOS.html>
It is better to note the implication of adding com.apple.security.get-task-allow in the commit message.
Regards,
Akihiko Odaki