rcore-os / virtio-drivers

VirtIO guest drivers in Rust.
MIT License
209 stars 63 forks source link

QEMU Virtio device id is zero #158

Closed BDUG closed 3 weeks ago

BDUG commented 1 month ago

Hi all,

I am trying to access virtio devices in my SeL4 operating system instance, but the devices provide a deviceid of zero.

QEMU call:

qemu-system-aarch64 \ -machine virt,virtualization=on,acpi=on \ -cpu cortex-a57 \ -smp 4 \ -m 2048 \ -nographic \ -append "console=ttyAMA0" \ -drive file=./disk.img,if=none,format=raw,id=blk-device-0 \ -device virtio-blk-device,drive=blk-device-0,scsi=off \ -gdb tcp::3333 \ -S \ -kernel $(image)

I checked it in parallel via volatile reads:

let magic_value = ptr::read_volatile((mapped_address + 0x008) as *const u32);

The "magic" and "version" are given but the device id is zero.

May could it make sense to allow to set the "device id" from external while doing the following calls?

let header = NonNull::new(mapped_address as *mut VirtIOHeader).unwrap(); let transport = unsafe { MmioTransport::new(header) };

If so I am happy to do the PR