Compare commits

...
Author SHA1 Message Date
osy b0b83b7f07 darwin: reopen the port when the VM is restored
Virtualization.framework does not restore the open state of the spice
port when it resumes a saved VM. The host then drops whatever the guest
writes to the port and never completes the write, which wedges the port
until the guest reboots: clipboard sharing stops working in both
directions and restarting the agents does not help.

The virtual RTC sends a message as soon as the VM is restored, so watch
for it and reopen the port before anything is written. Reopening tells
the host that the port is open again. Waiting for the clock change that
follows is too late: timed only steps the clock after an NTP round trip.

Resolves utmapp/UTM#7717

Assisted-by: Claude:claude-opus-5-5
2026-10-14 09:39:24 -07:00
osy 03ff810185 github: force universal archive build
xcodebuild does not read build settings from the shell environment, so
the ARCHS variable used to build GLib and gettext for both
architectures never reached the archive step. On the arm64 macos-15
runner this silently produced an arm64-only xcarchive/pkg instead of a
universal x86_64+arm64 binary.

Pass ARCHS and ONLY_ACTIVE_ARCH explicitly to xcodebuild archive so the
override takes effect regardless of the runner's host architecture.

Resolves #5

Assisted-by: Claude:claude-sonnet-5
2026-09-21 20:37:04 -05:00
osy 948db07d95 github: build on macos-15 runner
Newer Xcode versions only support deploying to macOS 12.0 and newer,
which breaks the project's 10.13 deployment target. Pin the runner to
macos-15, which defaults to Xcode 16.

Assisted-by: Claude:claude-opus-5
2026-09-21 19:37:41 -05:00
osy 7a9d859399 github: build GLib from source for arm64 and x86_64
Homebrew no longer supports x86_64, so installing it under Rosetta fails
in CI and the universal build has no x86_64 GLib to link against.

Build GLib and gettext (for libintl) from pinned upstream releases for
both architectures instead, based on Homebrew's glib formula. The
libraries target macOS 10.13 (11.0 on arm64) to match the project, and
availability errors are enabled to catch any use of newer APIs.

The Xcode project now takes the GLib locations from the
GLIB_ARM64_PREFIX and GLIB_X86_64_PREFIX build settings, which default
to the Homebrew paths so local builds are unchanged. The inputs of the
lipo phase are declared so they can be read with script sandboxing.

Assisted-by: Claude:claude-opus-5
2026-09-21 19:26:34 -05:00
osy 07005a1b0e Merge pull request #4 from pointum/fix-package-quarantine
Clear package quarantine
2026-09-21 17:51:12 -05:00
Maxim Ananov 37a74cf356 darwin: clear package quarantine 2026-08-16 16:13:19 -07:00
osy 15e4c3b63f data: update macOS package script to remove xattributes 2024-12-10 13:36:29 -08:00
5 changed files with 239 additions and 15 deletions

No files matched your search

+122 -7
View File
@@ -6,20 +6,135 @@ on:
jobs:
build-macos:
name: Build macOS
runs-on: macos-latest
runs-on: macos-15
env:
GLIB_VERSION: "2.90.0"
GLIB_SHA256: 17d15cac2af80a33271127408e0abc2748eb297c595c2a26409e81e14e7d1b8f
GETTEXT_VERSION: "1.0"
GETTEXT_SHA256: 71132a3fb71e68245b8f2ac4e9e97137d3e5c02f415636eb508ae607bc01add7
# must be <= the project's deployment target
MACOSX_DEPLOYMENT_TARGET: "10.13"
ARCHS: arm64 x86_64
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Install GLib
run: brew install glib
- name: Install GLib (x86_64)
- name: Install build tools
run: |
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
/usr/local/bin/brew install glib || true # this can error on linking
brew install meson ninja pkgconf
echo "GLIB_PREFIX=$RUNNER_TEMP/glib" >> "$GITHUB_ENV"
- name: Cache GLib
id: cache
uses: actions/cache@v4
with:
path: ${{ runner.temp }}/glib
key: glib-${{ env.GLIB_VERSION }}-gettext-${{ env.GETTEXT_VERSION }}-${{ hashFiles('.github/workflows/build.yaml') }}
- name: Build gettext
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ runner.temp }}
run: |
curl -fsSLO "https://ftp.gnu.org/gnu/gettext/gettext-$GETTEXT_VERSION.tar.xz"
echo "$GETTEXT_SHA256 gettext-$GETTEXT_VERSION.tar.xz" | shasum -a 256 -c -
for arch in $ARCHS; do
rm -rf "gettext-$GETTEXT_VERSION"
tar xf "gettext-$GETTEXT_VERSION.tar.xz"
pushd "gettext-$GETTEXT_VERSION/gettext-runtime"
./configure --host="${arch/arm64/aarch64}-apple-darwin" \
--prefix="$GLIB_PREFIX/$arch" \
--enable-static \
--disable-shared \
--with-included-gettext \
--disable-java \
--disable-csharp \
--disable-libasprintf \
--without-libintl-prefix \
--without-libiconv-prefix \
CC="clang -arch $arch"
make -C intl -j"$(sysctl -n hw.ncpu)"
make -C intl install
popd
done
- name: Build GLib
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ runner.temp }}
run: |
curl -fsSLO "https://download.gnome.org/sources/glib/${GLIB_VERSION%.*}/glib-$GLIB_VERSION.tar.xz"
echo "$GLIB_SHA256 glib-$GLIB_VERSION.tar.xz" | shasum -a 256 -c -
tar xf "glib-$GLIB_VERSION.tar.xz"
# girepository is unused and requires macOS 10.15
sed -i '' "/^subdir('girepository')$/d" "glib-$GLIB_VERSION/meson.build"
sdk="$(xcrun --sdk macosx --show-sdk-path)"
for arch in $ARCHS; do
prefix="$GLIB_PREFIX/$arch"
mkdir -p "$prefix/lib/pkgconfig"
cat > "$prefix/lib/pkgconfig/libffi.pc" <<EOF
Name: libffi
Description: Library supporting Foreign Function Interfaces
Version: 3.4
Cflags: -I$sdk/usr/include/ffi
Libs: -lffi
EOF
# don't depend on Rosetta
[ "$arch" = "$(uname -m)" ] && needs_exe_wrapper=false || needs_exe_wrapper=true
cat > "cross-$arch.ini" <<EOF
[binaries]
c = ['clang', '-arch', '$arch']
cpp = ['clang++', '-arch', '$arch']
objc = ['clang', '-arch', '$arch']
ar = 'ar'
strip = 'strip'
pkg-config = 'pkg-config'
[built-in options]
c_args = ['-I$prefix/include', '-Werror=unguarded-availability-new']
cpp_args = ['-I$prefix/include']
objc_args = ['-I$prefix/include', '-Werror=unguarded-availability-new']
c_link_args = ['-L$prefix/lib']
cpp_link_args = ['-L$prefix/lib']
objc_link_args = ['-L$prefix/lib']
[properties]
needs_exe_wrapper = $needs_exe_wrapper
pkg_config_libdir = ['$prefix/lib/pkgconfig']
# macOS 27+, meson's check ignores availability
has_function_pipe2 = false
[host_machine]
system = 'darwin'
subsystem = 'macos'
kernel = 'xnu'
cpu_family = '${arch/arm64/aarch64}'
cpu = '${arch/arm64/aarch64}'
endian = 'little'
EOF
# SDK has no pcre2 headers; other fallbacks would silently stub out deps (e.g. libintl)
meson setup "build-$arch" "glib-$GLIB_VERSION" \
--cross-file "cross-$arch.ini" \
--prefix="$prefix" \
--buildtype=release \
--default-library=static \
--wrap-mode=nofallback \
--force-fallback-for=libpcre2-8 \
-Dbsymbolic_functions=false \
-Ddtrace=disabled \
-Dintrospection=disabled \
-Dnls=disabled \
-Dman-pages=disabled \
-Ddocumentation=false \
-Dtests=false
meson compile -C "build-$arch"
meson install -C "build-$arch"
done
- name: Build
run: xcodebuild archive -scheme vd_agent -archivePath vd_agent.xcarchive
run: |
xcodebuild archive -scheme vd_agent -archivePath vd_agent.xcarchive \
ARCHS="$ARCHS" ONLY_ACTIVE_ARCH=NO \
GLIB_ARM64_PREFIX="$GLIB_PREFIX/arm64" \
GLIB_X86_64_PREFIX="$GLIB_PREFIX/x86_64"
- name: Archive
run: tar -acf vd_agent.xcarchive.tgz vd_agent.xcarchive
- name: Upload
+4
View File
@@ -60,6 +60,10 @@ architectures at the default location.
$ /usr/local/bin/brew install glib # x86_64
>>>
Alternatively, GLib can be built from source for each architecture (see
`.github/workflows/build.yaml`) and the install prefixes passed to Xcode
with `GLIB_ARM64_PREFIX=... GLIB_X86_64_PREFIX=...`.
Then, you can build the project with Xcode or `xcodebuild`
>>>
+2
View File
@@ -16,6 +16,8 @@ BASEDIR="$(dirname "$(realpath $0)")"
cp -a "$INPUT_ARCHIVE/Products" "$TMP_ROOT"
xattr -cr "$TMP_ROOT"
codesign --sign "Developer ID Application" \
--force \
--identifier com.redhat.spice.vdagentd \
+75
View File
@@ -33,6 +33,10 @@
#include <sys/stat.h>
#include <spice/vd_agent.h>
#include <glib-unix.h>
#ifdef __APPLE__
#include <dispatch/dispatch.h>
#include <IOKit/IOKitLib.h>
#endif
#ifdef WITH_SYSTEMD_SOCKET_ACTIVATION
#include <systemd/sd-daemon.h>
@@ -888,6 +892,63 @@ static void check_xorg_resolution(void)
}
}
#ifdef __APPLE__
static gboolean reopen_virtio_port(gpointer user_data)
{
check_xorg_resolution();
return G_SOURCE_REMOVE;
}
static gboolean restart_virtio_port(gpointer user_data)
{
if (virtio_port) {
syslog(LOG_INFO, "VM restored, reopening vdagent virtio channel");
g_clear_pointer(&virtio_port, vdagent_connection_destroy);
do_client_disconnect();
/* the old port's cancelled read must release its file descriptor first */
g_idle_add(reopen_virtio_port, NULL);
}
return G_SOURCE_REMOVE;
}
/* Virtualization.framework forgets that the port is open when it restores a
saved VM, then drops whatever the guest writes to it and never completes
the write, which leaves the port unusable until the guest reboots. The
virtual RTC sends a message as soon as the VM is restored, so reopen the
port then, before anything is written, to tell the host it is open again. */
static void rtc_interest_cb(void *refcon, io_service_t service,
natural_t message_type, void *message_argument)
{
g_idle_add(restart_virtio_port, NULL);
}
static IONotificationPortRef watch_vm_restore(io_object_t *notification)
{
io_service_t rtc;
IONotificationPortRef port;
kern_return_t kr;
rtc = IOServiceGetMatchingService(MACH_PORT_NULL,
IOServiceMatching("AppleVirtualPlatformRTC"));
if (!rtc) {
/* not running in Virtualization.framework */
return NULL;
}
port = IONotificationPortCreate(MACH_PORT_NULL);
IONotificationPortSetDispatchQueue(port,
dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0));
kr = IOServiceAddInterestNotification(port, rtc, kIOGeneralInterest,
rtc_interest_cb, NULL, notification);
IOObjectRelease(rtc);
if (kr != KERN_SUCCESS) {
syslog(LOG_WARNING, "could not watch for VM restore: 0x%x", kr);
IONotificationPortDestroy(port);
return NULL;
}
return port;
}
#endif
static int connection_matches_active_session(UdscsConnection *conn,
void *priv)
{
@@ -1293,6 +1354,10 @@ int main(int argc, char *argv[])
gboolean own_socket = TRUE;
GIOChannel *si_io_channel = NULL;
guint si_watch_id = 0;
#ifdef __APPLE__
IONotificationPortRef restore_notify_port;
io_object_t restore_notification;
#endif
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, cmd_entries, NULL);
@@ -1379,6 +1444,10 @@ int main(int argc, char *argv[])
active_xfers = g_hash_table_new(g_direct_hash, g_direct_equal);
#ifdef __APPLE__
restore_notify_port = watch_vm_restore(&restore_notification);
#endif
udscs_server_start(server);
loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
@@ -1391,6 +1460,12 @@ int main(int argc, char *argv[])
if (si_watch_id > 0) {
g_source_remove(si_watch_id);
}
#ifdef __APPLE__
if (restore_notify_port) {
IOObjectRelease(restore_notification);
IONotificationPortDestroy(restore_notify_port);
}
#endif
g_clear_pointer(&session_info, session_info_destroy);
g_clear_pointer(&server, udscs_destroy_server);
if (virtio_port) {
+36 -8
View File
@@ -51,6 +51,7 @@
CE03A1302CEA8FBA006884EE /* libresolv.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A12F2CEA8FBA006884EE /* libresolv.tbd */; };
CE03A1322CEA8FCE006884EE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A1312CEA8FCE006884EE /* Foundation.framework */; };
CE03A1342CEA8FE4006884EE /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A1332CEA8FE4006884EE /* AppKit.framework */; };
CE77170B2EC0000000A1B2C3 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE77170A2EC0000000A1B2C3 /* IOKit.framework */; };
CE54BD8E2CEA90F200FE3930 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A1332CEA8FE4006884EE /* AppKit.framework */; };
CE54BD8F2CEA90F400FE3930 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A1312CEA8FCE006884EE /* Foundation.framework */; };
CE54BD902CEA90F600FE3930 /* libgmodule-2.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE03A12B2CEA8F60006884EE /* libgmodule-2.0.a */; };
@@ -142,6 +143,7 @@
CE03A12F2CEA8FBA006884EE /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
CE03A1312CEA8FCE006884EE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
CE03A1332CEA8FE4006884EE /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
CE77170A2EC0000000A1B2C3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -151,6 +153,7 @@
files = (
CE03A1342CEA8FE4006884EE /* AppKit.framework in Frameworks */,
CE03A1322CEA8FCE006884EE /* Foundation.framework in Frameworks */,
CE77170B2EC0000000A1B2C3 /* IOKit.framework in Frameworks */,
CE03A1302CEA8FBA006884EE /* libresolv.tbd in Frameworks */,
CE03A12E2CEA8F75006884EE /* libintl.a in Frameworks */,
CE03A12A2CEA8F18006884EE /* libffi.tbd in Frameworks */,
@@ -258,6 +261,7 @@
children = (
CE03A1332CEA8FE4006884EE /* AppKit.framework */,
CE03A1312CEA8FCE006884EE /* Foundation.framework */,
CE77170A2EC0000000A1B2C3 /* IOKit.framework */,
CE03A12B2CEA8F60006884EE /* libgmodule-2.0.a */,
CE03A12D2CEA8F75006884EE /* libintl.a */,
CE03A12F2CEA8FBA006884EE /* libresolv.tbd */,
@@ -402,6 +406,16 @@
inputFileListPaths = (
);
inputPaths = (
"$(GLIB_X86_64_PREFIX)/lib/libgio-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libglib-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libgobject-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libgmodule-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libintl.a",
"$(GLIB_ARM64_PREFIX)/lib/libgio-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libglib-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libgobject-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libgmodule-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libintl.a",
);
name = "Build universal GLib";
outputFileListPaths = (
@@ -415,7 +429,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\nfor ((i=0; i<$SCRIPT_OUTPUT_FILE_COUNT; i++)); do\n output_var=\"SCRIPT_OUTPUT_FILE_$i\"\n output_path=\"${!output_var}\"\n output_dir=\"$(dirname \"$output_path\")\"\n name=\"$(basename \"$output_path\")\"\n intel_input=\"/usr/local/lib/$name\"\n arm64_input=\"/opt/homebrew/lib/$name\"\n tmp_output=\"/tmp/$name.$$\"\n \n echo \"Creating $output_path\"\n lipo -output \"$tmp_output\" -create \"$intel_input\" \"$arm64_input\"\n if [ ! -d \"$output_dir\" ]; then\n mkdir -p \"$output_dir\"\n fi\n mv \"$tmp_output\" \"$output_path\"\ndone\n";
shellScript = "set -e\n\nfor ((i=0; i<$SCRIPT_OUTPUT_FILE_COUNT; i++)); do\n output_var=\"SCRIPT_OUTPUT_FILE_$i\"\n output_path=\"${!output_var}\"\n output_dir=\"$(dirname \"$output_path\")\"\n name=\"$(basename \"$output_path\")\"\n intel_input=\"$GLIB_X86_64_PREFIX/lib/$name\"\n arm64_input=\"$GLIB_ARM64_PREFIX/lib/$name\"\n tmp_output=\"/tmp/$name.$$\"\n \n echo \"Creating $output_path\"\n lipo -output \"$tmp_output\" -create \"$intel_input\" \"$arm64_input\"\n if [ ! -d \"$output_dir\" ]; then\n mkdir -p \"$output_dir\"\n fi\n mv \"$tmp_output\" \"$output_path\"\ndone\n";
showEnvVarsInLog = 0;
};
CE54BD972CEA914E00FE3930 /* Build universal GLib */ = {
@@ -426,6 +440,16 @@
inputFileListPaths = (
);
inputPaths = (
"$(GLIB_X86_64_PREFIX)/lib/libgio-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libglib-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libgobject-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libgmodule-2.0.a",
"$(GLIB_X86_64_PREFIX)/lib/libintl.a",
"$(GLIB_ARM64_PREFIX)/lib/libgio-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libglib-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libgobject-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libgmodule-2.0.a",
"$(GLIB_ARM64_PREFIX)/lib/libintl.a",
);
name = "Build universal GLib";
outputFileListPaths = (
@@ -439,7 +463,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "set -e\n\nfor ((i=0; i<$SCRIPT_OUTPUT_FILE_COUNT; i++)); do\n output_var=\"SCRIPT_OUTPUT_FILE_$i\"\n output_path=\"${!output_var}\"\n output_dir=\"$(dirname \"$output_path\")\"\n name=\"$(basename \"$output_path\")\"\n intel_input=\"/usr/local/lib/$name\"\n arm64_input=\"/opt/homebrew/lib/$name\"\n tmp_output=\"/tmp/$name.$$\"\n \n echo \"Creating $output_path\"\n lipo -output \"$tmp_output\" -create \"$intel_input\" \"$arm64_input\"\n if [ ! -d \"$output_dir\" ]; then\n mkdir -p \"$output_dir\"\n fi\n mv \"$tmp_output\" \"$output_path\"\ndone\n";
shellScript = "set -e\n\nfor ((i=0; i<$SCRIPT_OUTPUT_FILE_COUNT; i++)); do\n output_var=\"SCRIPT_OUTPUT_FILE_$i\"\n output_path=\"${!output_var}\"\n output_dir=\"$(dirname \"$output_path\")\"\n name=\"$(basename \"$output_path\")\"\n intel_input=\"$GLIB_X86_64_PREFIX/lib/$name\"\n arm64_input=\"$GLIB_ARM64_PREFIX/lib/$name\"\n tmp_output=\"/tmp/$name.$$\"\n \n echo \"Creating $output_path\"\n lipo -output \"$tmp_output\" -create \"$intel_input\" \"$arm64_input\"\n if [ ! -d \"$output_dir\" ]; then\n mkdir -p \"$output_dir\"\n fi\n mv \"$tmp_output\" \"$output_path\"\ndone\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -542,11 +566,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GLIB_ARM64_PREFIX = /opt/homebrew;
GLIB_X86_64_PREFIX = /usr/local;
HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/src/darwin/include",
"/opt/homebrew/include/glib-2.0",
"/opt/homebrew/include/gio-unix-2.0",
"/opt/homebrew/lib/glib-2.0/include",
"$(GLIB_ARM64_PREFIX)/include/glib-2.0",
"$(GLIB_ARM64_PREFIX)/include/gio-unix-2.0",
"$(GLIB_ARM64_PREFIX)/lib/glib-2.0/include",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
@@ -608,11 +634,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
GLIB_ARM64_PREFIX = /opt/homebrew;
GLIB_X86_64_PREFIX = /usr/local;
HEADER_SEARCH_PATHS = (
"$(PROJECT_DIR)/src/darwin/include",
"/opt/homebrew/include/glib-2.0",
"/opt/homebrew/include/gio-unix-2.0",
"/opt/homebrew/lib/glib-2.0/include",
"$(GLIB_ARM64_PREFIX)/include/glib-2.0",
"$(GLIB_ARM64_PREFIX)/include/gio-unix-2.0",
"$(GLIB_ARM64_PREFIX)/lib/glib-2.0/include",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",