feat: Add VM manifest system and code clarity improvements

Implement VM configuration manifest system compatible with security-pcc's
VMBundle.Config format, storing VM settings in config.plist.

**Manifest System:**
- Add VPhoneVirtualMachineManifest.swift with security-pcc compatible structure
- Add scripts/vm_manifest.py for manifest generation during vm_new
- Update VPhoneCLI to support --config option with CLI overrides
- Update vm_create.sh to generate config.plist with CPU/memory/screen settings

**Environment Variables:**
- CPU/MEMORY/DISK_SIZE now only used during vm_new (written to manifest)
- boot/boot_dfu automatically read from config.plist
- Remove unused CFW_INPUT variable (overridden by scripts internally)
- Document remaining variables with their usage scope

**Documentation:**
- Update README.md with VM configuration section
- Update docs/README_{zh,ja,ko}.md with translated VM configuration docs
- Update Makefile help output with vm_new options and config.plist usage
- Fix fw_patch_jb description: "dev + JB extensions"
- Fix restore_get_shsh description: "Dump SHSH response from Apple"

**Code Quality:**
- Add VPhoneVirtualMachineRefactored.swift demonstrating code-clarity principles
- Extract 200+ line init into focused configuration methods
- Improve naming: hardwareModel, graphicsConfiguration, soundDevice
- Add BatteryConnectivity enum for magic numbers
- Create research/manifest_and_refactoring_summary.md with full analysis

**Compatibility with security-pcc:**
- Platform type: Fixed vresearch101 (iPhone-only)
- Network: NAT only (no bridging/host-only needed)
- Added: ScreenConfig and SEP storage (iPhone-specific)
- Removed: VirtMesh plugin support (PCC-specific)

docs: add machineIdentifier storage analysis

Research and validate the integration of machineIdentifier into config.plist.

**Findings:**
- security-pcc stores machineIdentifier in config.plist (same approach)
- VZMacAuxiliaryStorage creation is independent of machineIdentifier
- VZMacMachineIdentifier only requires Data representation, not file source
- No binding or validation between components

**Conclusion:**
-  No compatibility issues
-  Matches security-pcc official implementation
-  Proper handling of first-boot creation and data recovery
-  Safe to use

Delete VPhoneVirtualMachineRefactored.swift

refactor: integrate machineIdentifier into config.plist

Move machineIdentifier storage from standalone machineIdentifier.bin file
into the central config.plist manifest for simpler VM configuration.

**Changes:**
- VPhoneVirtualMachineManifest: Remove machineIDFile field
- VPhoneVirtualMachine: Load/create machineIdentifier from manifest
- VPhoneCLI: Remove --machine-id parameter, require --config
- Makefile: Remove --machine-id from boot/boot_dfu targets
- vm_manifest.py: Remove machineIDFile from manifest structure

**Behavior:**
- First boot: Creates machineIdentifier and saves to config.plist
- Subsequent boots: Loads machineIdentifier from config.plist
- Invalid/empty machineIdentifier: Auto-regenerates and updates manifest
- All VM configuration now centralized in single config.plist file

**File cleanup:**
- Move VPhoneVirtualMachineRefactored.swift to research/ as reference

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Lakr
2026-03-10 17:12:13 +08:00
co-authored by Claude Sonnet 4.6
parent 7514e10d06
commit 6d11093152
15 changed files with 1026 additions and 102 deletions
+20 -18
View File
@@ -4,13 +4,12 @@
# ─── Configuration (override with make VAR=value) ─────────────────
VM_DIR ?= vm
CPU ?= 8
MEMORY ?= 8192
DISK_SIZE ?= 64
CFW_INPUT ?= cfw_input
RESTORE_UDID ?=
RESTORE_ECID ?=
IRECOVERY_ECID ?=
CPU ?= 8 # CPU cores (only used during vm_new)
MEMORY ?= 8192 # Memory in MB (only used during vm_new)
DISK_SIZE ?= 64 # Disk size in GB (only used during vm_new)
RESTORE_UDID ?= # UDID for restore operations
RESTORE_ECID ?= # ECID for restore operations
IRECOVERY_ECID ?= # ECID for irecovery operations
# ─── Build info ──────────────────────────────────────────────────
GIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
@@ -57,20 +56,24 @@ help:
@echo " make clean Remove all build artifacts (keeps IPSWs)"
@echo ""
@echo "VM management:"
@echo " make vm_new Create VM directory"
@echo " make boot Boot VM (GUI)"
@echo " make boot_dfu Boot VM in DFU mode"
@echo " make vm_new Create VM directory with manifest (config.plist)"
@echo " Options: VM_DIR=vm VM directory name"
@echo " CPU=8 CPU cores (stored in manifest)"
@echo " MEMORY=8192 Memory in MB (stored in manifest)"
@echo " DISK_SIZE=64 Disk size in GB (stored in manifest)"
@echo " make boot Boot VM (reads from config.plist)"
@echo " make boot_dfu Boot VM in DFU mode (reads from config.plist)"
@echo ""
@echo "Firmware pipeline:"
@echo " make fw_prepare Download IPSWs, extract, merge"
@echo " Options: IPHONE_SOURCE= URL or local path to iPhone IPSW"
@echo " CLOUDOS_SOURCE= URL or local path to cloudOS IPSW"
@echo " make fw_patch Patch boot chain (6 components)"
@echo " make fw_patch_dev Patch boot chain (dev mode TXM patcher)"
@echo " make fw_patch_jb Run fw_patch + JB extension patches"
@echo " make fw_patch Patch boot chain (regular variant)"
@echo " make fw_patch_dev Patch boot chain (dev mode TXM patches)"
@echo " make fw_patch_jb Patch boot chain (dev + JB extensions)"
@echo ""
@echo "Restore:"
@echo " make restore_get_shsh Fetch SHSH blob from device"
@echo " make restore_get_shsh Dump SHSH response from Apple"
@echo " make restore idevicerestore to device"
@echo ""
@echo "Ramdisk:"
@@ -167,25 +170,24 @@ vphoned:
.PHONY: vm_new boot boot_dfu
vm_new:
CPU="$(CPU)" MEMORY="$(MEMORY)" \
zsh $(SCRIPTS)/vm_create.sh --dir $(VM_DIR) --disk-size $(DISK_SIZE)
boot: bundle vphoned
cd $(VM_DIR) && "$(CURDIR)/$(BUNDLE_BIN)" \
--config ./config.plist \
--rom ./AVPBooter.vresearch1.bin \
--disk ./Disk.img \
--nvram ./nvram.bin \
--machine-id ./machineIdentifier.bin \
--cpu $(CPU) --memory $(MEMORY) \
--sep-rom ./AVPSEPBooter.vresearch1.bin \
--sep-storage ./SEPStorage
boot_dfu: build
cd $(VM_DIR) && "$(CURDIR)/$(BINARY)" \
--config ./config.plist \
--rom ./AVPBooter.vresearch1.bin \
--disk ./Disk.img \
--nvram ./nvram.bin \
--machine-id ./machineIdentifier.bin \
--cpu $(CPU) --memory $(MEMORY) \
--sep-rom ./AVPSEPBooter.vresearch1.bin \
--sep-storage ./SEPStorage \
--no-graphics --dfu