Run a virtual iPhone on an Apple Silicon Mac.
Swift
Size and show VM disks in decimal GB
Lakr6a8d2c76696d
diff --git a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swiftindex d5bc0bde..5af48b10 100644--- a/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift+++ b/VPhoneExecutable/VPhoneCommand/VPhoneCommand/VirtualMachine/VPhoneVirtualMachineCommand.swift@@ -122,7 +122,7 @@ struct VPhoneVirtualMachineListCommand: ParsableCommand {print("No VMs in \(library.root.path). Create one with vm create.")} else {for r in reports {- let diskGB = r.diskSizeBytes / (1024 * 1024 * 1024)+ let diskGB = r.diskSizeBytes / 1_000_000_000if let info = r.restoreInfo {print("\(r.name) \(r.cpuCount) CPU \(r.memoryMB) MB \(diskGB) GB disk iOS \(info.ios.version) / cloudOS \(info.cloudOS.version)",diff --git a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swiftindex 04fcda78..c7843885 100644--- a/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift+++ b/VPhoneKit/VPhoneCoreKit/Bundle/VPhoneBundleOperations.swift@@ -59,11 +59,13 @@ public enum VPhoneBundleOperations {// alreadyExists check.do {// Sparse disk image: create then truncate to size (no bytes written).+ // Decimal GB, the unit iOS reports, so "128 GB" shows as 128 GB+ // in the guest rather than 137.let disk = dir.appendingPathComponent("Disk.img")fm.createFile(atPath: disk.path, contents: nil)let handle = try FileHandle(forWritingTo: disk)do {- try handle.truncate(atOffset: spec.diskSizeGB * 1024 * 1024 * 1024)+ try handle.truncate(atOffset: spec.diskSizeGB * 1_000_000_000)try handle.close()} catch {try? handle.close()diff --git a/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift b/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swiftindex 980343f4..6a6b9b14 100644--- a/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift+++ b/VPhoneKit/VPhoneCoreKitTests/Bundle/BundleOperationsTests.swift@@ -38,7 +38,7 @@ struct BundleOperationsTests {#expect(bundle.manifest.memorySize == 8192 * 1024 * 1024)let disk = bundle.url.appendingPathComponent("Disk.img")let size = try (FileManager.default.attributesOfItem(atPath: disk.path)[.size] as? NSNumber)?.int64Value- #expect(size == Int64(64 * 1024 * 1024 * 1024))+ #expect(size == Int64(64 * 1_000_000_000))#expect(FileManager.default.fileExists(atPath: bundle.url.appendingPathComponent("SEPStorage").path))#expect(FileManager.default.fileExists(atPath: bundle.url.appendingPathComponent("AVPBooter.vresearch1.bin").path),diff --git a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swiftindex 5c7afdc8..a7e361b1 100644--- a/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift+++ b/VPhoneLaunchpad/VPhoneLaunchpad/Machines/VPhoneLaunchpadMachinesView.swift@@ -409,6 +409,7 @@ struct VPhoneLaunchpadMachinesView: View {}static func disk(_ bytes: Int64) -> String {- "\(bytes / 1_073_741_824) GB"+ // Decimal, as iOS and the creation stepper count it.+ "\(bytes / 1_000_000_000) GB"}}