Skip to content

Instantly share code, notes, and snippets.

@peter279k
Last active July 17, 2020 13:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peter279k/c54cb6f0b8bba098e09d7c70a38efaf8 to your computer and use it in GitHub Desktop.
Save peter279k/c54cb6f0b8bba098e09d7c70a38efaf8 to your computer and use it in GitHub Desktop.
The useful and completed references for KVM installation in RHEL 8 and CentOS 8 (including troubleshooting)

References

Common Problems (Troubleshooting)

  • Most of trobuleshottings are also for KVM running in Ubuntu 18.04.

  • virsh define node_imei.xml

error: Failed to define domain from node_imei.xml
error: Cannot check QEMU binary /usr/bin/qemu-system-x86_64: No such file or directory
  • virsh create node_imei.xml
error: Failed to create domain from node_imei.xml
error: internal error: process exited while connecting to monitor: 2020-07-16T14:37:16.111004Z qemu-system-x86_64: -machine pc-i440fx-bionic,accel=kvm,usb=off,dump-guest-core=off: unsupported machine type
Use -machine help to list supported machines

Solution

  • Using virsh capabilities | grep machine to find available machine name
error: Failed to create domain from node_imei.xml
error: internal error: process exited while connecting to monitor: 2020-07-16T14:41:54.254519Z qemu-system-x86_64: -drive file=/root/virtual_smartphone/imei-test/system.img,format=raw,if=none,id=drive-virtio-disk0,readonly=on: Could not open '/root/virtual_smartphone/imei-test/system.img': Permission denied

Solution

  • Editing /etc/libvirt/qemu.conf with vim editor.
  • Change to line 442 probably.
  • Uncomment #user = "root" and #group = "root".
  • Uncomment dynamic_ownership = 0 to disable file ownership change.
  • systemctl restart libvirtd to restart libvirt daemon service.
error: internal error: process exited while connecting to monitor: 2020-07-16 14:48:12.280+0000: Domain id=1 is tainted: high-privileges
2020-07-16T14:48:12.424833Z qemu-system-x86_64: cannot set up guest memory 'pc.ram': Cannot allocate memory

Solution

  • Try to decrease memory or allocate memeories on host OS.
......
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
......
2020-07-16T15:07:48.264787Z qemu-system-x86_64: -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,share-rw=on,drive=drive-virtio-disk1,id=virtio-disk1,write-cache=on: Block node is read-only

Solution

  • Set current ownership via chown root:root imei-test/* command
guest CPU doesn't match specification: extra features: hypervisor, missing features: tsc_adjust,clflushopt,stibp,ssbd
......
unsupported machine type "pc-i440fx-3.1"
......

Solution

Here are useful commands to check out current CPU features and machine name support:

virsh -c qemu:///system capabilities | grep machine
virsh -c qemu:///system capabilities | grep "feature "
  • Fix defined XML file:
......
    <feature policy='require' name='ss'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='clflushopt'/>
    <feature policy='require' name='stibp'/>
    <feature policy='require' name='ssbd'/>
    <feature policy='require' name='pdpe1gb'/>
    <feature policy='disable' name='mpx'/>
......

Sample CPU Features (propably suggested):

......
<cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>Skylake-Client-IBRS</model>
    <vendor>Intel</vendor>
    <feature policy='require' name='vme'/>
    <feature policy='require' name='f16c'/>
    <feature policy='require' name='rdrand'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='arat'/>
    <feature policy='require' name='xsaveopt'/>
    <feature policy='require' name='abm'/>
    <feature policy='disable' name='rtm'/>
    <feature policy='disable' name='hle'/>
    <feature policy='disable' name='mpx'/>
    <feature policy='disable' name='rdseed'/>
    <feature policy='disable' name='adx'/>
    <feature policy='disable' name='smap'/>
    <feature policy='disable' name='xsavec'/>
    <feature policy='disable' name='xgetbv1'/>
    <feature policy='disable' name='3dnowprefetch'/>
    <feature policy='disable' name='pcid'/>
    <feature policy='disable' name='erms'/>
    <feature policy='disable' name='invpcid'/>
    <feature policy='disable' name='spec-ctrl'/>
  </cpu>
......

Export VM

  • Export XML setting file via virsh dumpxml "machine_name"
  • Convert qcow2 file to raw (.img) file
qemu-img convert -f qcow2 -O raw rhel7.5.qcow2 rhel7.5.img
  • Convert qcow2 file to raw (.img) file
qemu-img convert -f raw -O qcow2 rhel7.5.img rhel7.5.qcow2
<domain type='kvm'>
<name>rhel8.1</name>
<uuid>78b7f58c-1742-4f27-bf31-fc13b0ee3807</uuid>
<memory unit='KiB'>12288000</memory>
<currentMemory unit='KiB'>12288000</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-bionic'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
<model fallback='allow'>EPYC-IBPB</model>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/bin/kvm-spice</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data2/rhel7.5.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hda' bus='ide'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</controller>
<interface type='network'>
<mac address='52:54:00:3a:a0:d6'/>
<source network='default'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
<address type='virtio-serial' controller='0' bus='0' port='2'/>
</channel>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<graphics type='spice' autoport='yes'>
<listen type='address'/>
<image compression='off'/>
</graphics>
<sound model='ich6'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</sound>
<video>
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='2'/>
</redirdev>
<redirdev bus='usb' type='spicevmc'>
<address type='usb' bus='0' port='3'/>
</redirdev>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</memballoon>
</devices>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment