最大化 Windows 上 QEMU 运行的 Linux 系统性能
因为最近在做 Linux from Scratch,更在意 CPU 和 Memory 性能,对比下在 Windows 宿主机上如何运行 QEMU Linux 虚拟机性能更高。
使用 融合怪评测项目 ECS 对各系统做性能测试,用它主要是支持跨平台,但 CPU 测试在 Windows 用的是 winsat,在 Linux 是 sysbench 仅供参考。所以添加 7z 25.01 来在 CPU 性能做基准。记录取多次测试最高值
| 平台 | CPU 单核 | CPU 16 核 | 内存拷贝 MB/s | 7z 压缩 KiB/s | 7z 解压 KiB/s |
|---|---|---|---|---|---|
| Windows native | - | - | 60101.1 | 119125 | 1575949 |
| WSL2 | 7421.24 | 60180.44 | 53639.9 | 111015 | 1614714 |
-accel kvm on WSL2 | 5898.96 | 49849.86 | 53601.3 | 109144 | 1462513 |
-accel whpx on Windows | 5665.23 | 50660.33 | 49081.3 | 113853 | 1534549 |
结论是 WSL2 没什么性能损失,但给 QEMU 多套一层虚拟化还是会降低约 5% 性能,直接 Windows whpx 跑就好
在 WHPX 上启动方式:
$command = @"
qemu-system-x86_64
-accel whpx
-smp 16
-m 16g
-hda debian.qcow2
-nographic
-monitor telnet:127.0.0.1:2223,server,nowait
-nic user,hostfwd=tcp:127.0.0.1:2222-:22
"@ -replace "`n", " "
Start-Process cmd.exe -ArgumentList "/c", "$command & pause"如何备份 QEMU 虚拟机
qemu-img snapshot disk.qcow2 -c snapshop-tag
qemu-img snapshot \
[--object OBJECTDEF] [--image-opts] [-U] [-q] \
[-l | -a SNAPSHOT | -c SNAPSHOT | -d SNAPSHOT] FILENAME
Parameters to snapshot subcommand:
SNAPSHOT
Is the name of the snapshot to create, apply or delete
-a Applies a snapshot (revert disk to saved state)
-c Creates a snapshot
-d Deletes a snapshot
-l Lists all snapshots in the given image(qemu) info block
ide0-hd0 (#block102): E:\VirtualMachines\LinuxFromScratch\debian.qcow2 (qcow2)
Attached to: /machine/unattached/device[19]
Cache mode: writeback
(qemu) snapshot_blkdev ide0-hd0 E:/debian-overlay.qcow2 qcow2
(qemu) commit ide0-hd0savevm 在 WHPX 下无效,有 Error: State blocked due to non-migratable CPUID feature support,dirty memory tracking support, and XSAVE/XRSTOR support 错误
LFS 中构建 readline 出现 0a1,173: command not found 错误
跟着 8.12. Readline-8.3 做的时候出现这个错误
./config.status: line 533: 0a1,173: command not found
./config.status: line 534: syntax error near unexpected token `newline'
./config.status: line 534: `> # This file is a shell script that caches the results of configure'解决方式在这 Error running configure readline 8.1.2,也在 LFS FAQ 提到。
在 chroot 外用 root 身份用 mount -v --bind /dev $LFS/dev 把 /dev 挂载上。我是因为重启过设备,没有按照 7.4. 进入 Chroot 环境 的说明设置好 chroot 环境。