mirror of
https://github.com/utmapp/UTM.git
synced 2026-10-12 02:24:01 +00:00
macOS: removed ugly hacks for < macOS 11.3
This commit is contained in:
@@ -164,11 +164,7 @@ extension UTMQemuConfigurationNetwork {
|
||||
}
|
||||
}
|
||||
#if os(macOS)
|
||||
if #available(macOS 11.3, *) {
|
||||
mode = .shared
|
||||
} else {
|
||||
mode = .emulated
|
||||
}
|
||||
mode = .shared
|
||||
#else
|
||||
mode = .emulated
|
||||
#endif
|
||||
|
||||
@@ -803,22 +803,6 @@ static size_t sysctl_read(const char *name) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)validateOSSupportWithError:(NSError **)error {
|
||||
if (@available(macOS 11.3, *)) {
|
||||
return YES;
|
||||
} else {
|
||||
if (self.configuration.soundEnabled && self.configuration.displayConsoleOnly) {
|
||||
*error = [NSError errorWithDomain:kUTMErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"This version of macOS does not support audio in console mode. Please change the VM configuration or upgrade macOS.", "UTMQemuSystem")}];
|
||||
return NO;
|
||||
}
|
||||
if (self.isGLOn && !self.configuration.displayConsoleOnly) {
|
||||
*error = [NSError errorWithDomain:kUTMErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"This version of macOS does not support GPU acceleration. Please change the VM configuration or upgrade macOS.", "UTMQemuSystem")}];
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)startWithCompletion:(void (^)(BOOL, NSString * _Nonnull))completion {
|
||||
NSError *err;
|
||||
if (self.configuration.systemBootUefi) {
|
||||
@@ -827,10 +811,6 @@ static size_t sysctl_read(const char *name) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (![self validateOSSupportWithError:&err]) {
|
||||
completion(NO, err.localizedDescription);
|
||||
return;
|
||||
}
|
||||
[self updateArgvWithUserOptions:YES];
|
||||
NSString *name = [NSString stringWithFormat:@"qemu-%@-softmmu", self.configuration.systemArchitecture];
|
||||
[self startQemu:name completion:completion];
|
||||
|
||||
+1
-49
@@ -16,7 +16,6 @@
|
||||
|
||||
#import "QEMUHelper.h"
|
||||
#import <stdio.h>
|
||||
#import "Bootstrap.h"
|
||||
|
||||
@interface QEMUHelper ()
|
||||
|
||||
@@ -100,11 +99,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (@available(macOS 11.3, *)) { // macOS 11.3 fixed sandbox bug for hypervisor to work
|
||||
[self startQemuTask:binName standardOutput:standardOutput standardError:standardError libraryPath:libraryPath argv:argv onExit:onExit];
|
||||
} else { // old deprecated fork() method
|
||||
[self startQemuFork:binName standardOutput:standardOutput standardError:standardError libraryPath:libraryPath argv:argv onExit:onExit];
|
||||
}
|
||||
[self startQemuTask:binName standardOutput:standardOutput standardError:standardError libraryPath:libraryPath argv:argv onExit:onExit];
|
||||
}
|
||||
|
||||
- (void)startQemuTask:(NSString *)binName standardOutput:(NSFileHandle *)standardOutput standardError:(NSFileHandle *)standardError libraryPath:(NSURL *)libraryPath argv:(NSArray<NSString *> *)argv onExit:(void(^)(BOOL,NSString *))onExit {
|
||||
@@ -129,47 +124,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)startQemuFork:(NSString *)binName standardOutput:(NSFileHandle *)standardOutput standardError:(NSFileHandle *)standardError libraryPath:(NSURL *)libraryPath argv:(NSArray<NSString *> *)argv onExit:(void(^)(BOOL,NSString *))onExit {
|
||||
// convert all the Objective-C strings to C strings as we should not use objects in this context after fork()
|
||||
NSString *path = [libraryPath URLByAppendingPathComponent:binName].path;
|
||||
char *cpath = strdup(path.UTF8String);
|
||||
int argc = (int)argv.count + 1;
|
||||
char **cargv = calloc(argc, sizeof(char *));
|
||||
cargv[0] = cpath;
|
||||
for (int i = 0; i < argc-1; i++) {
|
||||
cargv[i+1] = strdup(argv[i].UTF8String);
|
||||
}
|
||||
int newStdOut = standardOutput.fileDescriptor;
|
||||
int newStdErr = standardError.fileDescriptor;
|
||||
pid_t pid = startQemuFork(cpath, argc, (const char **)cargv, newStdOut, newStdErr);
|
||||
// free all resources regardless of error because on success, child has a copy
|
||||
[standardOutput closeFile];
|
||||
[standardError closeFile];
|
||||
for (int i = 0; i < argc; i++) {
|
||||
free(cargv[i]);
|
||||
}
|
||||
free(cargv);
|
||||
if (pid < 0) {
|
||||
NSLog(@"Error starting QEMU: %d", pid);
|
||||
onExit(NO, NSLocalizedString(@"Error starting QEMU.", @"QEMUHelper"));
|
||||
} else {
|
||||
// a new thread to reap the child and wait on its status
|
||||
dispatch_async(self.childWaitQueue, ^{
|
||||
do {
|
||||
int status;
|
||||
if (waitpid(pid, &status, 0) < 0) {
|
||||
NSLog(@"waitpid(%d) returned error: %d", pid, errno);
|
||||
onExit(NO, NSLocalizedString(@"QEMU exited unexpectedly.", @"QEMUHelper"));
|
||||
} else if (WIFEXITED(status)) {
|
||||
NSLog(@"child process %d terminated", pid);
|
||||
onExit(WEXITSTATUS(status) == 0, nil);
|
||||
} else {
|
||||
continue; // another reason, we ignore
|
||||
}
|
||||
} while (0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -435,7 +435,6 @@
|
||||
CE0B6F2F24AD67BE00FE012D /* json-glib-1.0.0.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE2D63E222653C7400FC7E63 /* json-glib-1.0.0.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
CE0B6F3124AD67C100FE012D /* phodav-2.0.0.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE059DC0243BD67100338317 /* phodav-2.0.0.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
CE0B6F5424AD67FA00FE012D /* spice-client-glib-2.0.8.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE2D63FE22653C7500FC7E63 /* spice-client-glib-2.0.8.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
CE0DF17225A80B6300A51894 /* Bootstrap.c in Sources */ = {isa = PBXBuildFile; fileRef = CE0DF17125A80B6300A51894 /* Bootstrap.c */; };
|
||||
CE0DF19425A83C1700A51894 /* qemu-aarch64-softmmu.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE2D63FD22653C7500FC7E63 /* qemu-aarch64-softmmu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
CE0DF19525A83C1700A51894 /* qemu-alpha-softmmu.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE2D641322653C7500FC7E63 /* qemu-alpha-softmmu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
CE0DF19625A83C1700A51894 /* qemu-arm-softmmu.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CE2D640722653C7500FC7E63 /* qemu-arm-softmmu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
@@ -3028,6 +3027,8 @@
|
||||
children = (
|
||||
CE6B241025F1F4B30020D43E /* QEMULauncher.entitlements */,
|
||||
CEF6F5EC26DDD65700BC434D /* QEMULauncher-unsigned.entitlements */,
|
||||
CE0DF17025A80B6300A51894 /* Bootstrap.h */,
|
||||
CE0DF17125A80B6300A51894 /* Bootstrap.c */,
|
||||
CE6B240A25F1F3CE0020D43E /* main.c */,
|
||||
CE6B240F25F1F43A0020D43E /* Info.plist */,
|
||||
FF490790278361780041E4B1 /* QEMULauncher-InfoPlist.strings */,
|
||||
@@ -3161,8 +3162,6 @@
|
||||
children = (
|
||||
CE03D0D024D9A62B00F76B84 /* QEMUHelper.entitlements */,
|
||||
CEF6F5EB26DDD63100BC434D /* QEMUHelper-unsigned.entitlements */,
|
||||
CE0DF17025A80B6300A51894 /* Bootstrap.h */,
|
||||
CE0DF17125A80B6300A51894 /* Bootstrap.c */,
|
||||
CEBDA1DC24D8BDDA0010B5EC /* QEMUHelperProtocol.h */,
|
||||
CEBDA1DD24D8BDDB0010B5EC /* QEMUHelper.h */,
|
||||
CEBDA1DE24D8BDDB0010B5EC /* QEMUHelper.m */,
|
||||
@@ -4429,7 +4428,6 @@
|
||||
files = (
|
||||
CEBDA1E124D8BDDB0010B5EC /* main.m in Sources */,
|
||||
CEBDA1DF24D8BDDB0010B5EC /* QEMUHelper.m in Sources */,
|
||||
CE0DF17225A80B6300A51894 /* Bootstrap.c in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user