Repository: utmapp/UTM
File: Managers/UTMQemuSystem.m (Objective-C)

Code before:
    [self pushArgv:[self.configuration.systemMemory stringValue]];
    [self argsForSound];
    [self pushArgv:@"-name"];
    [self pushArgv:self.configuration.name];
    if (self.usbSupported) {
        [self argsForUsb];
    }
    [self argsForDrives];
    [self argsForNetwork];
    if (self.snapshot) {
        [self pushArgv:@"-loadvm"];
        [self pushArgv:self.snapshot];
    }
    
    [self argsForSharing];
    
    if (self.configuration.systemUUID.length > 0) {
        [self pushArgv:@"-uuid"];
        [self pushArgv:self.configuration.systemUUID];
    }
    
    // fix windows time issues
    [self pushArgv:@"-rtc"];
    [self pushArgv:@"base=localtime"];
    
    if (self.configuration.runAsSnapshot) {
        [self pushArgv:@"-snapshot"];
    }
}
    
- (void)argsFromUser {
    if (self.configuration.systemArguments.count != 0) {
        NSArray *addArgs = self.configuration.systemArguments;
        // Splits all spaces into their own, except when between quotes.
        NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(\"[^\"]+\"|\\+|\\S+)" options:0 error:nil];
        
        for (NSString *arg in addArgs) {
            // No need to operate on empty arguments.
            if (arg.length == 0) {
                continue;
            }
            
            NSArray *splitArgsArray = [regex matchesInString:arg
                                              options:0
                                                range:NSMakeRange(0, [arg length])];
            
            
            for (NSTextCheckingResult *match in splitArgsArray) {
                NSRange matchRange = [match rangeAtIndex:1];
                NSString *argFragment = [arg substringWithRange:matchRange];
                if ([argFragment hasPrefix:@"\""] && [argFragment hasSuffix:@"\""]) {

Review comment (suggestion):
So actually, it may make more sense to add a new @ property to UTMQemuSystem for runAsSnapshot and to UTMVirtualMachine where the property in UTMVirtualMachine is called `isNextRunAsSnapshot`, which the set handler will set UTMQemuSystem's property.

Code after:
        }
    }
    if ([target isEqualToString:@"mac99"]) {
        properties = [self appendDefaultPropertyName:@"via" value:@"pmu" toProperties:properties];
    }
    return properties;
}

- (BOOL)isGLOn {
    // GL supported devices have contains GL moniker
    return [self.configuration.displayCard containsString:@"-gl-"] ||
           [self.configuration.displayCard hasSuffix:@"-gl"];
}

- (BOOL)isSparc {
    return [self.configuration.systemArchitecture isEqualToString:@"sparc"];
}

- (void)argsRequired {
    [self clearArgv];
    [self pushArgv:@"-L"];
    [self accessDataWithBookmark:[self.resourceURL bookmarkDataWithOptions:0
                                            includingResourceValuesForKeys:nil
                                                             relativeToURL:nil
                                                                     error:nil]];
    [self pushArgv:self.resourceURL.path];
    [self pushArgv:@"-S"]; // startup stopped
    [self pushArgv:@"-qmp"];
    [self pushArgv:[NSString stringWithFormat:@"tcp:127.0.0.1:%lu,server,nowait", self.qmpPort]];
    if (self.isSparc) { // SPARC uses -vga
        if (!self.configuration.displayConsoleOnly) {
            [self pushArgv:@"-vga"];
            [self pushArgv:self.configuration.displayCard];
        }
    } else { // disable -vga and other default devices
        // prevent QEMU default devices, which leads to duplicate CD drive (fix #2538)
        // see https://github.com/qemu/qemu/blob/6005ee07c380cbde44292f5f6c96e7daa70f4f7d/docs/qdev-device-use.txt#L382
        [self pushArgv:@"-nodefaults"];
        [self pushArgv:@"-vga"];
        [self pushArgv:@"none"];// -vga none, avoid adding duplicate graphics cards
    }
    if (self.configuration.displayConsoleOnly) {
        [self pushArgv:@"-nographic"];
        // terminal character device
        NSURL* ioFile = [self.configuration terminalInputOutputURL];
        [self pushArgv: @"-chardev"];
        [self pushArgv: [NSString stringWithFormat: @"pipe,id=term0,path=%@", ioFile.path]];
        [self pushArgv: @"-serial"];
        [self pushArgv: @"chardev:term0"];
    } else {
        NSURL *spiceSocketURL = self.configuration.spiceSocketURL;