mirror of
https://github.com/Lakr233/vphone-cli.git
synced 2026-04-05 04:59:05 +08:00
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 <noreply@anthropic.com>
128 lines
3.2 KiB
Python
Executable File
128 lines
3.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
vm_manifest.py — Generate VM manifest plist for vphone-cli.
|
|
|
|
Compatible with security-pcc's VMBundle.Config format.
|
|
"""
|
|
import argparse
|
|
import plistlib
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def create_manifest(
|
|
vm_dir: Path,
|
|
cpu_count: int,
|
|
memory_mb: int,
|
|
disk_size_gb: int,
|
|
platform_fusing: str | None = None,
|
|
):
|
|
"""
|
|
Create a VM manifest plist file.
|
|
|
|
Args:
|
|
vm_dir: Path to VM directory
|
|
cpu_count: Number of CPU cores
|
|
memory_mb: Memory size in MB
|
|
disk_size_gb: Disk size in GB
|
|
platform_fusing: Platform fusing mode (prod/dev) or None for auto-detect
|
|
"""
|
|
# Convert to manifest units
|
|
memory_bytes = memory_mb * 1024 * 1024
|
|
|
|
# ROM filenames
|
|
rom_file = "AVPBooter.vresearch1.bin"
|
|
sep_rom_file = "AVPSEPBooter.vresearch1.bin"
|
|
|
|
manifest = {
|
|
"platformType": "vresearch101",
|
|
"platformFusing": platform_fusing, # None = auto-detect from host OS
|
|
"machineIdentifier": b"", # Generated on first boot, then persisted to manifest
|
|
"cpuCount": cpu_count,
|
|
"memorySize": memory_bytes,
|
|
"screenConfig": {
|
|
"width": 1290,
|
|
"height": 2796,
|
|
"pixelsPerInch": 460,
|
|
"scale": 3.0,
|
|
},
|
|
"networkConfig": {
|
|
"mode": "nat",
|
|
"macAddress": "", # Auto-generated by Virtualization framework
|
|
},
|
|
"diskImage": "Disk.img",
|
|
"nvramStorage": "nvram.bin",
|
|
"romImages": {
|
|
"avpBooter": rom_file,
|
|
"avpSEPBooter": sep_rom_file,
|
|
},
|
|
"sepStorage": "SEPStorage",
|
|
}
|
|
|
|
# Write to config.plist
|
|
config_path = vm_dir / "config.plist"
|
|
with open(config_path, "wb") as f:
|
|
plistlib.dump(manifest, f)
|
|
|
|
print(f"[5/4] Created VM manifest: {config_path}")
|
|
return config_path
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="Generate VM manifest plist for vphone-cli"
|
|
)
|
|
parser.add_argument(
|
|
"--vm-dir",
|
|
type=Path,
|
|
default=Path("vm"),
|
|
help="VM directory path (default: vm)",
|
|
)
|
|
parser.add_argument(
|
|
"--cpu",
|
|
type=int,
|
|
default=8,
|
|
help="CPU core count (default: 8)",
|
|
)
|
|
parser.add_argument(
|
|
"--memory",
|
|
type=int,
|
|
default=8192,
|
|
help="Memory size in MB (default: 8192)",
|
|
)
|
|
parser.add_argument(
|
|
"--disk-size",
|
|
type=int,
|
|
default=64,
|
|
help="Disk size in GB (default: 64)",
|
|
)
|
|
parser.add_argument(
|
|
"--platform-fusing",
|
|
type=str,
|
|
choices=["prod", "dev"],
|
|
default=None,
|
|
help="Platform fusing mode (default: auto-detect from host OS)",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
if not args.vm_dir.exists():
|
|
print(f"Error: VM directory does not exist: {args.vm_dir}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
try:
|
|
create_manifest(
|
|
vm_dir=args.vm_dir,
|
|
cpu_count=args.cpu,
|
|
memory_mb=args.memory,
|
|
disk_size_gb=args.disk_size,
|
|
platform_fusing=args.platform_fusing,
|
|
)
|
|
except Exception as e:
|
|
print(f"Error creating manifest: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|