Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Give the temporary PCC machine no network device

Jackye91b9073cd36
diff --git a/Documents/Guides/create-and-run.md b/Documents/Guides/create-and-run.md
index 72571602..d9d4046f 100644
--- a/Documents/Guides/create-and-run.md
+++ b/Documents/Guides/create-and-run.md
@@ -21,7 +21,7 @@ By default that pipeline builds a [template](#templates) rather than the VM itse
`--cpu`, `--memory`, `--network` and `--unlock-at-startup` set those `vm config` settings on the new VM (defaults: 8 cores, 8192 MB, nat, off). `--skip-first-boot` leaves out the final boot, for a caller that boots the VM itself.
-`fw prepare` creates a temporary vphone VM, starts it in DFU, and restores the selected cloudOS IPSW using this project's restore backend. It mounts the restored System volume read-only, extracts the GPU bundle, then removes the temporary VM. This first restore supplies the GPU driver for the second, hybrid iPhone restore. The extracted bundle is cached per cloudOS build in `~/.vphone/gpu-drivers/`, so later machines on the same cloudOS skip the temporary restore. `vm create` and `fw prepare` also accept `--gpu-driver-bundle /path/to/AppleParavirtGPUMetalIOGPUFamily.bundle` to reuse a previously extracted bundle without the temporary restore. The CLI checks its iPhoneOS platform version against the selected cloudOS version. Each restore obtains its own ticket online.
+`fw prepare` creates a temporary vphone VM with no network device, starts it in DFU, and restores the selected cloudOS IPSW using this project's restore backend. It mounts the restored System volume read-only, extracts the GPU bundle, then removes the temporary VM. This first restore supplies the GPU driver for the second, hybrid iPhone restore. The extracted bundle is cached per cloudOS build in `~/.vphone/gpu-drivers/`, so later machines on the same cloudOS skip the temporary restore. `vm create` and `fw prepare` also accept `--gpu-driver-bundle /path/to/AppleParavirtGPUMetalIOGPUFamily.bundle` to reuse a previously extracted bundle without the temporary restore. The CLI checks its iPhoneOS platform version against the selected cloudOS version. Each restore obtains its own ticket online.
The build also ships an arm64e GPU compiler plugin in the bundle. `fw prepare` copies it into the staged GPU bundle before firmware patching and installation.
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index 40b4723f..9fcdedce 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -1663,6 +1663,9 @@ volume into the VM restore tree and removes the temporary VM. This is the
default path; `--gpu-driver-bundle` reuses a validated bundle instead. Both
cloudOS 26.1 and 26.4 PCC AEA key URLs returned HTTP 403 on 2026-09-24, so
the preparer no longer requests those keys before the temporary restore.
+The temporary VM has no network device (2026-10-13): the restore runs over
+the virtual USB device, and with the default `nat` NIC the Mac's shared vmnet
+network and DHCP service came up for some seconds after the restore.
Both the JB host-mount installer and the filesystem merge copy this staged
bundle into the iPhone guest. The 26.4 `23E5207q` restored bundle has
`DTPlatformVersion=26.4`, `CFBundleVersion=64.4.4`, and binary SHA-256
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Host/VPhonePCCGPURecovery.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Host/VPhonePCCGPURecovery.swift
index caed5a91..c16b8677 100644
--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Host/VPhonePCCGPURecovery.swift
+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/Host/VPhonePCCGPURecovery.swift
@@ -32,6 +32,9 @@ enum VPhonePCCGPURecovery {
.appending(path: ".pcc-restoration-\(UUID().uuidString)")
let library = VPhoneLibrary(root: temporaryLibrary)
let name = "pcc-\(UUID().uuidString.lowercased())"
+ // The restore runs over the virtual USB device, so the machine needs no
+ // NIC. With the default nat one, the Mac's shared vmnet network and its
+ // DHCP service came up between the end of the restore and the stop.
let vm = try VPhoneBundleOperations.create(.init(
name: name,
cpuCount: 8,
@@ -39,6 +42,7 @@ enum VPhonePCCGPURecovery {
diskSizeGB: 64,
romSource: VPhoneBundleOperations.defaultROMSource(),
sepromSource: VPhoneBundleOperations.defaultSEPROMSource(),
+ networkConfig: .init(mode: .off, macAddress: ""),
), in: library)
var diskMayBeAttached = false
let temporaryRestore = vm.url.appending(path: "iPhonePCC_Restore")
diff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift
index f8209cc1..96d8597e 100644
--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift
+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift
@@ -9,6 +9,7 @@ public enum VPhoneBundleOperations {
public let diskSizeGB: UInt64
public let romSource: URL
public let sepromSource: URL
+ public let networkConfig: VPhoneVirtualMachineManifest.NetworkConfig
public init(
name: String,
@@ -17,9 +18,11 @@ public enum VPhoneBundleOperations {
diskSizeGB: UInt64,
romSource: URL,
sepromSource: URL,
+ networkConfig: VPhoneVirtualMachineManifest.NetworkConfig = .default,
) {
self.name = name; self.cpuCount = cpuCount; self.memoryMB = memoryMB
self.diskSizeGB = diskSizeGB; self.romSource = romSource; self.sepromSource = sepromSource
+ self.networkConfig = networkConfig
}
}
@@ -83,6 +86,7 @@ public enum VPhoneBundleOperations {
let manifest = VPhoneVirtualMachineManifest(
cpuCount: spec.cpuCount,
memorySize: spec.memoryMB * 1024 * 1024,
+ networkConfig: spec.networkConfig,
romImages: .init(avpBooter: "AVPBooter.vresearch1.bin",
avpSEPBooter: "AVPSEPBooter.vresearch1.bin"),
)
diff --git a/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift b/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift
index ecbae664..4ecdeefc 100644
--- a/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift
+++ b/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift
@@ -45,6 +45,39 @@ struct BundleOperationsTests {
)
}
+ @Test func `creates bundle with the requested network`() throws {
+ let root = try makeRoot()
+ defer { try? FileManager.default.removeItem(at: root) }
+ let rom = try fakeROM(); let seprom = try fakeROM()
+ defer { try? FileManager.default.removeItem(at: rom); try? FileManager.default.removeItem(at: seprom) }
+ let lib = VPhoneLibrary(root: root)
+
+ let offline = try VPhoneBundleOperations.create(
+ .init(
+ name: "offline",
+ cpuCount: 2,
+ memoryMB: 2048,
+ diskSizeGB: 1,
+ romSource: rom,
+ sepromSource: seprom,
+ networkConfig: .init(mode: .off, macAddress: ""),
+ ),
+ in: lib,
+ )
+ #expect(offline.manifest.networkConfig.mode == .off)
+ // Persisted, and realized as no NIC at all.
+ let saved = try lib.bundle(named: "offline").manifest.networkConfig
+ #expect(saved.mode == .off)
+ #expect(try VPhoneNetworking.makeNetworkDevice(saved).device == nil)
+
+ // Left out, it is the default.
+ let plain = try VPhoneBundleOperations.create(
+ .init(name: "plain", cpuCount: 2, memoryMB: 2048, diskSizeGB: 1, romSource: rom, sepromSource: seprom),
+ in: lib,
+ )
+ #expect(plain.manifest.networkConfig.mode == .nat)
+ }
+
@Test func `rejects duplicate name`() throws {
let root = try makeRoot()
defer { try? FileManager.default.removeItem(at: root) }