Compare commits

..
Author SHA1 Message Date
YXC0915 9d9be66a68 🐛 Pin the Win32 user NAT socket fix
Use the QEMU maintenance merge that removes Winsock fd_set truncation in Windows user networking.
2026-12-02 01:15:32 +08:00
5 changed files with 9 additions and 90 deletions

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
[submodule "vendor/qemu"]
path = vendor/qemu
url = https://github.com/reims-go/qemu-reims-vgpu.git
branch = intel-vm-suspend
url = https://github.com/yxc0915/qemu-reims-vgpu.git
branch = codex/intel-vm-suspend
+6 -74
View File
@@ -146,8 +146,6 @@ pub struct Ctx {
/// Whether QEMU takes `-smbios type=17`'s `memory_type`
/// ([`crate::install::smbios_takes_memory_type`]).
pub smbios_memory_type: bool,
/// Whether this Windows QEMU has the repaired native block AIO backend.
pub win32_native_aio: bool,
/// Whether QEMU's own window can open ([`crate::host::has_screen`]).
pub screen: bool,
/// The option ROM of reims-vgpu's own device, which its `romfile` names
@@ -197,13 +195,14 @@ pub fn opt(s: &str) -> String {
s.replace(',', ",,")
}
/// Size the qcow2 L2 cache for the full disk, capped at 32 MiB, when it needs more
/// than QEMU's 8 MiB non-Linux default.
/// Compute the qcow2 L2 cache size in MiB needed to cover the full virtual disk
/// (`virtual_size / cluster_size * 8` bytes), clamped to `..=32 MiB`, returning `Some(mib)` only
/// when the image needs more than QEMU's 8 MiB non-Linux default.
fn qcow2_l2_cache_mib(path: &Path) -> Option<u64> {
use std::io::Read;
let mut hdr = [0u8; 80];
let mut hdr = [0u8; 32];
let mut f = std::fs::File::open(path).ok()?;
f.read_exact(&mut hdr[..32]).ok()?;
f.read_exact(&mut hdr).ok()?;
if &hdr[0..4] != b"QFI\xfb" {
return None;
}
@@ -218,15 +217,7 @@ fn qcow2_l2_cache_mib(path: &Path) -> Option<u64> {
let virtual_size = u64::from_be_bytes(hdr[24..32].try_into().ok()?);
let cluster_size = 1u64 << cluster_bits;
let clusters = virtual_size.div_ceil(cluster_size);
let mut entry_bytes = 8;
if version == 3 {
f.read_exact(&mut hdr[32..]).ok()?;
let incompatible_features = u64::from_be_bytes(hdr[72..80].try_into().ok()?);
if incompatible_features & (1 << 4) != 0 {
entry_bytes = 16;
}
}
let l2_bytes = clusters.saturating_mul(entry_bytes);
let l2_bytes = clusters.saturating_mul(8);
let mib = l2_bytes.div_ceil(1024 * 1024).min(32);
(mib > 8).then_some(mib)
}
@@ -421,14 +412,6 @@ fn q35(vm: &Vm, ctx: &Ctx, a: &mut Vec<String>) -> Result<()> {
disk.push_str(&format!(",l2-cache-size={mib}M"));
}
}
if ctx.win32_native_aio
&& matches!(
q.disk_controller,
DiskController::Nvme | DiskController::Virtio
)
{
disk.push_str(",aio=native");
}
// An install's flushes, which the module's doc measures, are dropped while the installer is
// attached.
if q.installer.is_some() {
@@ -910,7 +893,6 @@ pub(crate) mod tests {
nested_vmx: false,
avx512_xstate: false,
smbios_memory_type: true,
win32_native_aio: false,
screen: true,
graphics_rom: "/d/firmware/ReimsGraphics-0123456789abcdef.rom".into(),
arm64: None,
@@ -1890,56 +1872,6 @@ pub(crate) mod tests {
));
}
#[test]
fn only_patched_windows_qemu_gets_native_aio_on_the_system_disk() {
let mut vm = q35_vm();
for controller in [
DiskController::Nvme,
DiskController::Virtio,
DiskController::Ahci,
] {
vm.config.q35.as_mut().unwrap().disk_controller = controller;
for supported in [false, true] {
let c = Ctx {
win32_native_aio: supported,
..ctx(Host {
os: Os::Windows,
..linux()
})
};
let args = invocation(&vm, &c).unwrap().args;
let disk = args.iter().find(|arg| arg.starts_with("id=disk,")).unwrap();
assert_eq!(
disk.split(',').any(|opt| opt == "aio=native"),
supported
&& matches!(controller, DiskController::Nvme | DiskController::Virtio),
);
assert!(args.iter().filter(|arg| arg.contains("aio=native")).count() <= 1);
assert!(!disk.contains("cache.no-flush"));
}
}
}
#[test]
fn extended_l2_uses_twice_the_cache_per_cluster() {
let path = std::env::temp_dir().join(format!(
"reims-ctl-extended-l2-{}.qcow2",
std::process::id()
));
let mut hdr = [0u8; 104];
hdr[..4].copy_from_slice(b"QFI\xfb");
hdr[4..8].copy_from_slice(&3u32.to_be_bytes());
hdr[20..24].copy_from_slice(&16u32.to_be_bytes());
hdr[24..32].copy_from_slice(&(128u64 << 30).to_be_bytes());
std::fs::write(&path, hdr).unwrap();
assert_eq!(qcow2_l2_cache_mib(&path), Some(16));
hdr[72..80].copy_from_slice(&(1u64 << 4).to_be_bytes());
std::fs::write(&path, hdr).unwrap();
let extended_size = qcow2_l2_cache_mib(&path);
std::fs::remove_file(path).unwrap();
assert_eq!(extended_size, Some(32));
}
#[test]
fn installer_disk_goes_on_its_own_port_through_an_overlay() {
let mut vm = q35_vm();
-12
View File
@@ -524,7 +524,6 @@ pub fn context(vm: &Vm, host: Host) -> Result<Ctx> {
};
let avx512_xstate = avx512_xstate(vm, host, &qemu);
let smbios_memory_type = smbios_memory_type(vm, &qemu);
let win32_native_aio = win32_native_aio(vm, host, &qemu);
Ok(Ctx {
host,
qemu,
@@ -533,7 +532,6 @@ pub fn context(vm: &Vm, host: Host) -> Result<Ctx> {
nested_vmx: crate::host::kvm_nested_vmx(),
avx512_xstate,
smbios_memory_type,
win32_native_aio,
screen,
graphics_rom: graphics_rom(vm)?,
arm64,
@@ -558,14 +556,6 @@ fn smbios_memory_type(vm: &Vm, qemu: &Path) -> bool {
vm.config.profile == Profile::Q35X86_64 && crate::install::smbios_takes_memory_type(qemu)
}
/// A version number alone does not distinguish the fixed Windows block backend.
fn win32_native_aio(vm: &Vm, host: Host, qemu: &Path) -> bool {
host.os == Os::Windows
&& vm.config.profile == Profile::Q35X86_64
&& crate::install::qemu_version(qemu)
.is_some_and(|version| version.ends_with(" [reims-win32-native-aio]"))
}
/// The option ROM of reims-vgpu's own device, written into the data directory for an x86-64 VM
/// on it ([`crate::prebuilt::graphics_rom`]); an empty path, which no command names, for another
/// VM. An arm64 VM's device has no option ROM: Ambrosia drives it with its module.
@@ -619,7 +609,6 @@ pub fn invocation_for_print(vm: &Vm, host: Host) -> Result<Invocation> {
let qemu = crate::install::qemu_binary_or_default(vm.config.profile);
let avx512_xstate = avx512_xstate(vm, host, &qemu);
let smbios_memory_type = smbios_memory_type(vm, &qemu);
let win32_native_aio = win32_native_aio(vm, host, &qemu);
Ctx {
host,
qemu,
@@ -628,7 +617,6 @@ pub fn invocation_for_print(vm: &Vm, host: Host) -> Result<Invocation> {
nested_vmx: crate::host::kvm_nested_vmx(),
avx512_xstate,
smbios_memory_type,
win32_native_aio,
screen: crate::host::has_screen(&vm.config.extra_env),
graphics_rom: graphics_rom(vm).unwrap_or_else(|_| crate::prebuilt::graphics_rom_path()),
arm64: (vm.config.profile == Profile::VmappleArm64).then(|| qemu::Arm64Boot {
-1
View File
@@ -7,7 +7,6 @@
"win10-compat",
"win10-startup-ipis",
"win32-coroutine-fiber",
"win32-native-aio",
"win32-unicode-input"
]
}
Vendored
+1 -1
Submodule vendor/qemu updated: 51e8c2d3b5...e6d7cb7422.