qemu/kvm, lauching a vm i get a black screen

Hello

I created a vm for android-x86 7.1-r5 with virt-manager. All is ok and better than with Vbox when using it.

First question. What are all the tools to manage a vm ?

I want to use a scrip to launch and stop the vm when i log out or shut down.

I tried to use virt-manager or virsh but we must get root privileges. This is a nogo in a script.

I tried qemu-kvm but i get at start a black screen after the grub menu.

I know this problem. It is a screen settings problem. With Vbox if i get this problem i uncheck “accel 3d” or i change vmvga or vboxvga to vboxsvga.

Hi
So this setup is just a single intel GPU laptop?

Running as your user, look at a policy, see: https://major.io/2015/04/11/run-virsh-and-access-libvirt-as-a-regular-user/ however, once you get the machine setup libvirt will take care of all that (startup/shutdown). The machine will run in the background and can connect to it as your user on demand.

As a test did you try the example in your other thread with just qemu, if so same graphics issue?

@malcomlewis

thanks

>> So this setup is just a single intel GPU laptop?

Yes my PC is a single intel GPU desktop.

Configuration graphique : X11
Processeurs : 4 × Intel® Core™ i5-7400 CPU @ 3.00GHz
Mémoire : 15,5 Gio de mémoire vive
Processeur graphique : Mesa DRI Intel® HD Graphics 630

I found the solution.

When I created the vm with virt-manager I set “OS type” to “Generic” (This is the one for android 7.1) and I set 2 GB for memory. virt-nager did not warn me.

It seems that qemu-kvm does not accept 2 GB for a “generic” OS. I can launch android 7.1 without any problem
[li] with[/li]

qemu-kvm -enable-kvm -m 1024 ~/QEMU_VM/android_x86_7.1-r5

[li] I must change the owner from “root,root” to “<my userid>, users”.[/li]
I am a bit disappointed with qemu-kvm.
When launching the vm with virt-manager then the mouse cursor is captured by the vm or my PC seamlessly.
When launching the vm with qemu-kvm then I must click in vm screen and i must manually (Ctrl+Alt+G) capture for my PC the mouse cursor. Is there a way to get a seamless capture ?

Hi
It’s either in the overview → input settings change from virtual mouse to virtual tablet, should remove the key press. Else from memory console options to turn things off…

If starting in a script its;


-device virtio-tablet-pci
rather than
-device virtio-mouse-pci

No issues running as my user though… img is owned by my user…


rw-r--r-- 1 username users 2490433536 Mar 16 15:44 cm-x86-14.1-r5-k419.img
-rw-r--r-- 1 username users  598736896 Mar 16 11:14 cm-x86-14.1-r5-k419.iso
-rwxr-xr-x 1 username users        333 Mar 18 10:38 start_android

I found the solution.

When I created the vm with virt-manager I set “OS type” to “Generic” (This is the one for android 7.1) and I set 2 GB for memory. virt-nager did not warn me.

It seems that qemu-kvm does not accept 2 GB for a “generic” OS

It’s false.

If you set “memory” to “2048” then you must use “m” parameter and the value must be the same as in virt-manager.

Your solution for the mouse works well. Now I use this command



qemu-kvm -enable-kvm -m 2048  -device virtio-tablet-pci ~/QEMU_VM/android_x86_7.1-r5



It seems virt-manager and qemu-kvm are independent. quemu-kvm does not use the definition of the vm generated by virt-manager. I don’t understand this choice.

There is a side effect using “-device virtio-tablet-pci”: the keyboard is partially captured. If the mouse cursor is over the vm screen, and you type “Ctl+Alt+Del” then it is sent to plasma and plasma begins a log-out.

Hi
Add the keyboard as well…

My full script is;


#!/usr/bin/bash

qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-smp 2 \
-cpu host \
-device virtio-tablet-pci -device virtio-keyboard-pci \
-serial mon:stdio \
-boot menu=on \
-net nic \
-net user,hostfwd=tcp::5555-:22 \
-device virtio-vga,virgl=on \
-display gtk,gl=on \
-hda cm-x86-14.1-r5-k419.img
#Needed for install only
#-cdrom cm-x86-14.1-r5-k419.iso \

Add the keyboard as well…

I did this with no success.

I will try your script.

I created the vm disk with your script.

I installed android-x86-7.1-r5 with your script.

If I launch with your script the vm I get a black screen.

If I delete "-display gtk,gl=on " then i get “android #” prompt and that’s all.

I assume there is a setting problem around the monitor of the vm.

I use plasma (Qt) environment.

With Vbox i must use SVGA and no graphical acceleration for the vm. If not I get a black screen.

The script to install


#!/bin/bash

qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-smp 2 \
-cpu host \
-device virtio-tablet-pci -device virtio-keyboard-pci \
-serial mon:stdio \
-boot menu=on \
-net nic \
-net user,hostfwd=tcp::5555-:22 \
-device virtio-vga,virgl=on \
-display gtk,gl=on \
-hda ~/QEMU_VM/android_x86_7.1-r5.img \
-cdrom ~/rpmd/iso/android_x86/android-x86-7.1-r5.iso \


The script to launch


#!/bin/bash

qemu-system-x86_64 \
-enable-kvm \
-m 2048 \
-smp 2 \
-cpu host \
-device virtio-tablet-pci -device virtio-keyboard-pci \
-serial mon:stdio \
-boot menu=on \
-net nic \
-net user,hostfwd=tcp::5555-:22 \
-device virtio-vga,virgl=on \
-display gtk,gl=on \
-hda ~/QEMU_VM/android_x86_7.1-r5.img \

Hi
Not sure, are you running Wayland? I only use Xorg/GNOME here…

Hi

I use “-ga qxl” instead of “-display gtk,gl=on” and there is no more problem. I don’t know if it is optimal but it works.

I use xorg, not wayland in plasma (kde) environment.

Also with your script keyboard is partially captured.

If i type “a” in a filed for example there is no problem.
If i type “Ctrl+Alt+del” then plasma begins a log-out. of my kde session.

Hi
AFAIK, keyboard needs to be configured, top left in android instance or settings;

https://forums.opensuse.org/attachment.php?attachmentid=998&stc=1

Must be a setting somewhere to disable those keys…

I did this i changed the langage (the only settings i access) with no success.

If I use virt-manager there is no problem.

Hi
Not sure, need to look at the xml file for the virt-manager to see what is does, only workaround is the infamous ctrl+alt+G when in the qemu machine…

A new problem.

i want a bridge not a nat. I tried several solutions but no success. qemu-system-x86_64 does not start.

for example

-nic bridge
-net nic
-net user …

Hi
I’m still using a tap device on Tumbleweed for my main qemu machines as well as wicked on the host;


-nic tap,ifname=tap0,script=no,downscript=no

See: https://bugzilla.opensuse.org/show_bug.cgi?id=1177273

If your using NetworkManager, then some nmcli foo is needed to create the bridge etc.

I don’t unsderstand qemu-kvm. It is so simple with vrt-manager.

Just choose “eth0:macvtap”, “bridge”, “e1000”. That’s all. You get an address in the local network 192.168.0.44. Then the vm is a member of the local network.

the xlml


<interface type="direct">
  <mac address="52:54:00:b1:e9:14"/>
  <source dev="eth0" mode="bridge"/>
  <model type="e1000"/>
  <address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
</interface>

I tried to translate this for qemu-kvm. No success.

Hi
Have a read here…
https://virt.kernelnewbies.org/MacVTap

I have to step in here,
I do not recommend you set up ordinary networking using MacVtap, that is a way to set up networking, but is a side option… Not the recommended “ordinary” way.
If you have no special requirements like connecting to wireless or needing direct hardware access eg. doing doing some pentesting, this is NOT generally recommended.

Instead,
The ordinary way practically everyone uses is to create bridge devices which act as virtual networking connection points.
That way, Guest network connections are as simple as selecting the bridge device with the desired network configuration and type in the Guest properties, and within the Guest should always be a wired connection, the only configuration needed is whether to be set up as a DHCP client or manual configuration with static address.
This is the standard way to do networking across practically all virtualization technologies and docker.
Once you learn how this works, it’s simple to set up new Guests or other virtualization technologies (like Virtualbox, VMware, Hyper-V, docker) and they all will set up the same way.

Also BTW…
If you run multiple VMs connecting to the same network, you can configure any number of VMs to use the same bridge device. AFAIK you can’t do that with MacVtap since that isn’t a virtual device, it’s direct hardware access.

TSU