Skip to content

Commit 50e0c45

Browse files
committed
macOS actually boots this time. Woohoo!
1 parent a0930c5 commit 50e0c45

5 files changed

Lines changed: 26 additions & 9 deletions

File tree

Sources/diavirt/ConfigurationBuilder.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ extension DAVirtualMachineConfiguration {
9191
configuration.pointingDevices.append(try pointingDevice.build())
9292
}
9393
}
94-
95-
try configuration.validate()
9694
return configuration
9795
}
9896
}
@@ -175,6 +173,10 @@ extension DAGenericPlatform {
175173
if FileManager.default.fileExists(atPath: machineIdentifierPath) {
176174
let data = try Data(contentsOf: URL(fileURLWithPath: machineIdentifierPath))
177175
machineIdentifier = VZMacMachineIdentifier(dataRepresentation: data)
176+
} else {
177+
machineIdentifier = VZMacMachineIdentifier()
178+
let dataToSave = machineIdentifier!.dataRepresentation
179+
try dataToSave.write(to: URL(fileURLWithPath: machineIdentifierPath))
178180
}
179181

180182
platform.auxiliaryStorage = auxilaryStorage

Sources/diavirt/EntryPoint.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ struct DiavirtCommand: ParsableCommand {
7272
try await Global.machine!.create()
7373
Global.machine?.start()
7474
Global.stateObserverHandle = Global.machine!.watchForState { state in
75-
if state == .error {
76-
DiavirtCommand.exit(withError: ExitCode.failure)
77-
} else if state == .stopped {
78-
DiavirtCommand.exit(withError: ExitCode.success)
75+
Task {
76+
if state == .error {
77+
DiavirtCommand.exit(withError: ExitCode.failure)
78+
} else if state == .stopped {
79+
DiavirtCommand.exit(withError: ExitCode.success)
80+
}
7981
}
8082
}
8183
}

Sources/diavirt/VirtualMachine.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class DAVirtualMachine: NSObject, WireProtocol, VZVirtualMachineDelegate {
3131
writeProtocolEvent(StateEvent("preflight.end"))
3232
writeProtocolEvent(StateEvent("configure.start"))
3333
let config = try configuration.build(wire: self, state: state!)
34-
try config.validate()
3534
writeProtocolEvent(StateEvent("configure.end"))
3635
let machine = VZVirtualMachine(configuration: config)
3736
machine.delegate = self
@@ -40,10 +39,10 @@ class DAVirtualMachine: NSObject, WireProtocol, VZVirtualMachineDelegate {
4039
}
4140

4241
func start() {
42+
writeProtocolEvent(StateEvent("runtime.starting"))
4343
if enableInstallerMode {
4444
doInstallMode()
4545
} else {
46-
writeProtocolEvent(StateEvent("runtime.starting"))
4746
doActualStart()
4847
writeProtocolEvent(StateEvent("runtime.started"))
4948
}
@@ -62,8 +61,9 @@ class DAVirtualMachine: NSObject, WireProtocol, VZVirtualMachineDelegate {
6261
self.writeProtocolEvent(StateEvent("runtime.started"))
6362
}
6463
}
64+
6565
DiavirtCommand.Global.installationObserver = installer.progress.observe(\.fractionCompleted, options: [.initial, .new]) { _, change in
66-
NSLog("Installation progress: \(change.newValue! * 100).")
66+
self.writeProtocolEvent(InstallationProgressEvent(progress: change.newValue! * 100.0))
6767
}
6868
}
6969
}

Sources/diavirt/WireModel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ struct PipeDataEvent: WireEvent {
5353
self.data = data
5454
}
5555
}
56+
57+
struct InstallationProgressEvent: WireEvent {
58+
var type: String = "installation.progress"
59+
let progress: Double
60+
61+
init(progress: Double) {
62+
self.progress = progress
63+
}
64+
}

diavirt.xcodeproj/xcshareddata/xcschemes/diavirt.xcscheme

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
argument = "-v"
6565
isEnabled = "YES">
6666
</CommandLineArgument>
67+
<CommandLineArgument
68+
argument = "-w"
69+
isEnabled = "YES">
70+
</CommandLineArgument>
6771
</CommandLineArguments>
6872
</LaunchAction>
6973
<ProfileAction

0 commit comments

Comments
 (0)