Alex Bennée alex.bennee@linaro.org writes:
Hi,
It actually turned out to be relatively easy to enable a new vhost-user device in crosvm. It worked the second time it successfully compiled (only because I hadn't wired up the command line in the first commit). You can find the branch here:
https://github.com/stsquad/crosvm/commits/add-vhost-user-rng
If you disable the internal virtio-rng device you can see the only one RNG device is the one provided by vhost-user:
# from vhost-device repo ./target/debug/vhost-device-rng --socket-path /tmp/rng.sock -c 1 -m 2048 -p 1000 # from the crosvm repo ./target/debug/crosvm run \ --disable-sandbox \ --no-rng \ --vhost-user-rng /tmp/rng.sock0 \ --rwdisk ./rootfs \ --initrd ./initrd.img-* \ -p "root=/dev/vda5" \ ./vmlinuz-*
However for some reason it's not consuming the data. I think this is due to a missing the feature negotiation of VIRTIO_F_NOTIFY_ON_EMPTY (24) but it could be something else I missed. However rather than head-bang on my own I thought I should get the branch out there so any crosvm experts can weigh in.
OK it looks like it was a problem with a bad branch of vhost-device and a missing driver on the extracted kernel from the example usage. I've re-built an x86_64 kernel with 6.0-rc1 and the Chromium config + adding VIRTIO_HWRNG. Running with:
env RUST_LOG=debug ./target/debug/crosvm run \ --disable-sandbox \ --no-rng \ --vhost-user-rng /tmp/rng.sock0 \ --rwdisk ./rootfs \ -p "root=/dev/vda5" \ -m 512 \ ~/lsrc/linux.git/builds/x86_64/arch/x86_64/boot/bzImage
And:
./target/debug/vhost-device-rng --socket-path /tmp/rng.sock -c 1 -m 8192 -p 1000
I get the following in the root shell:
dd if=/dev/hwrng of=/dev/null status=progress 1769472 bytes (1.8 MB, 1.7 MiB) copied, 216 s, 8.2 kB/s
which gives me confidence that we are consuming randomness from the vhost-device daemon at the 8k/s it was configured for.
So I guess the next step it to merge my crosvm patches into your crosvm branch and test under Gunyah?