site  contact  subhomenews

QEMU recompiled in OE with more features

June 17, 2023 — BarryK

We are discussing QEMU in this forum thread:

An issue with the latest package, qemu-6.2.0-r4-nocona-64.tar.xz, is that it does not show 'virglrenderer' as a dependency. In that case, run PKGget to install it.

Federico has tested QEMU in Easy 5.4.1, and has sent me an email, quoting:

2) QEmu.   I managed to install Windows 10 on Easy and it is quite impressive to see it running inside Easy. I have a quad core Tigerlake laptop and on my hardware it runs smoothly. There was no audio coming out from the VM but I managed to solve this audio problem. In order to get audio working, one needs to take note of the pulse audio server string through the command << # pactl info >> and add the following string: << \-audiodev pa,id=hda,server=[server string] >> to the launch command of Qemu. Then, it is necessary to add the environment variable "QEMU_AUDIO_DRV" to the system, with value "pa". Finally the file "qemu.conf" needs to be created inside /etc/libvirt/qemu and the following four text lines needs to be added to it: << nographics_allow_host_audio = 1 >>, << vnc_allow_host_audio = 1 >>, << user = "root" >>, << group = "root" >>. This is obviously not a lack but just a difficult task. I just wanted to tell you about it in case you didn't know. But there are 2 important lacks regarding QEmu: there is no way to share data directly with the host or to connect USB sticks to the guest. Now, since Windows is mainly needed on Linux because of the lack of device drivers for Linux, the usefulness of the virtual machine is greatly reduced if there is no possibility to connect USB devices to the guest or exchange data with it. The reason why no USB devices from the host can be connected to the guest is that the device 'usb-host' is not present inside the QEmu build, and it looks like that is the only way to passthrough USB devices from the host to the guest. Basically, if either the option << -device usb-host,hostbus=X,hostport=X.XX >> or the option << -device usb-host,vendorid=0x0781,productid=0x5530 >> are added to the launch command, you get the error "'usb-host' is not a valid device model name". The same happens if you open the monitor during the execution through Ctrl + Alt + 2 and type in << device_add usb-storage,vendorid=0x0781,productid=0x5530 >>. Then, the reason why it is not possible to exchange data with the host is that one can either create a normal TCP-IP network or use a 9P share. In order to create a normal network, that is to let host and guest ping each other, one should configure a TAP interface on the host, which looks pretty impossible when using a wireless lan network device ("operation not supported" - and most laptops don't even have any wired RJ45 network outlet nowadays - ). The other alternative would be to configure a 9P share on the host and then let QEmu run with the further option: << -fsdev local,id=test_dev,path=[absolute path to the 9P share],security_model=none -device virtio-9p-pci >>, in which case we get the output << qemu-system-x86_64: -device virtio-9p-pci: 'virtio-9p-pci' is not a valid device model name >>. This basically means that also the virtio-9p-pci device is missing from the build. So, long story short: we need a QEmu build containing the usb-host and virtio-9p-pci devices (that is: physical USB connection and 9P functionalities). For completeness I add the command which I use for running my VM: qemu-system-x86_64 -enable-kvm \-m 4G \-smp 2 \-hda [virtual hdd file name].qcow2 \-nic user,id=net0,net=,dhcpstart= \-vga virtio \-device qemu-xhci \-device ich9-intel-hda,id=sound0 \-device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \-audiodev pa,id=hda,server=[pulse audio server string] \-global ICH9-<lPC.disable_s3=1 \-global ICH9-LPC.disable_s4=1 \-cdrom virtio-win-0.1.229.iso \-usb

I have recompiled QEMU in OE, it is now qemu-6.2.0-r5-nocona-64.tar.xz. The github commit shows the extra features added:

..."virtfs" provides device model "virtio-9p-pci" and "libusb" provides "usb-host", required by Federico.

I have updated the repository, so if you already have QEMU installed, run PKGget and uninstall it, then click on "Configuration" button and update the "Packages-oe-kirkstone-official" repository, then install QEMU.

EDIT 2023-06-21:
Federico has tested the new qemu, quoting from his latest email:

I installed the new QEmu build which you released on the repository and I'm very glad to tell you that now it is possible to connect to the guest any USB device attached to the host. Even the laptop WebCam! This makes it possible to efficiently use a Windows VM directly from any EasyOS installation. This is really impressive and we have already started to effectively use this feature. Performance is also quite good: Windows 10 runs obviously smoothly on my Tigerlake with 16 GB of RAM, but it's also more than usable on an average AMD Laptop with 8 GB of RAM. This was the most important point. Thank you very much.

I'm also honored for your citation of my message on the news (this is the 2nd time if I remember well). I will soon sign up on the forum, so that we can communicate more easily and efficiently. And since we have been quite successful in emulating Windows 10 I was also thinking about opening a new thread about Qemu and adding as many instructions as possible about installing and configuring a VM to it.
Regarding the other question, the 9P share for sharing data directly between host and guest, for which the "virtio-9p-pci" device is needed, now if I add to the launch command for example the option: << \-virtfs local,path=[path to the folder to be shared],mount_tag=host0,security_model=passthrough,id=host0 >>, I do no more get the message saying that the virtio-9p-pci device is missing, but I get the following: << qemu-system-x86_64: Failed to encode VirtFS reply type 1 >>.

Now: to troubleshoot this one seems a little bit more difficult to me. Maybe this has to do with the 9P support of the operating system? Does EasyOS support the 9P functionality? If yes, does it need to be configured in any way or is there the need of installing further packages?

Eventually, let me know if you can tell me anything about this, but all in all this is not so important because one can always use a USB stick to move data to the VM, and, more over, some say that this would be a security hole, since the guest would have steadily access to the host file-system. It may be even preferable to keep host and guest strongly separated.

Ah ha! Found what needs to be done to activate 9P:

OK, will recompile the kernel with those extra features enabled.  

Tags: easy