1*c47d4fa0SMathieu PoirierQEMU vhost-user-rng - RNG emulation 2*c47d4fa0SMathieu Poirier=================================== 3*c47d4fa0SMathieu Poirier 4*c47d4fa0SMathieu PoirierBackground 5*c47d4fa0SMathieu Poirier---------- 6*c47d4fa0SMathieu Poirier 7*c47d4fa0SMathieu PoirierWhat follows builds on the material presented in vhost-user.rst - it should 8*c47d4fa0SMathieu Poirierbe reviewed before moving forward with the content in this file. 9*c47d4fa0SMathieu Poirier 10*c47d4fa0SMathieu PoirierDescription 11*c47d4fa0SMathieu Poirier----------- 12*c47d4fa0SMathieu Poirier 13*c47d4fa0SMathieu PoirierThe vhost-user-rng device implementation was designed to work with a random 14*c47d4fa0SMathieu Poiriernumber generator daemon such as the one found in the vhost-device crate of 15*c47d4fa0SMathieu Poirierthe rust-vmm project available on github [1]. 16*c47d4fa0SMathieu Poirier 17*c47d4fa0SMathieu Poirier[1]. https://github.com/rust-vmm/vhost-device 18*c47d4fa0SMathieu Poirier 19*c47d4fa0SMathieu PoirierExamples 20*c47d4fa0SMathieu Poirier-------- 21*c47d4fa0SMathieu Poirier 22*c47d4fa0SMathieu PoirierThe daemon should be started first: 23*c47d4fa0SMathieu Poirier 24*c47d4fa0SMathieu Poirier:: 25*c47d4fa0SMathieu Poirier 26*c47d4fa0SMathieu Poirier host# vhost-device-rng --socket-path=rng.sock -c 1 -m 512 -p 1000 27*c47d4fa0SMathieu Poirier 28*c47d4fa0SMathieu PoirierThe QEMU invocation needs to create a chardev socket the device can 29*c47d4fa0SMathieu Poirieruse to communicate as well as share the guests memory over a memfd. 30*c47d4fa0SMathieu Poirier 31*c47d4fa0SMathieu Poirier:: 32*c47d4fa0SMathieu Poirier 33*c47d4fa0SMathieu Poirier host# qemu-system \ 34*c47d4fa0SMathieu Poirier -chardev socket,path=$(PATH)/rng.sock,id=rng0 \ 35*c47d4fa0SMathieu Poirier -device vhost-user-rng-pci,chardev=rng0 \ 36*c47d4fa0SMathieu Poirier -m 4096 \ 37*c47d4fa0SMathieu Poirier -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ 38*c47d4fa0SMathieu Poirier -numa node,memdev=mem \ 39*c47d4fa0SMathieu Poirier ... 40