This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
kvm [2021/06/28 01:25] – vissie | kvm [2023/06/01 00:52] (current) – [Debian] vissie | ||
---|---|---|---|
Line 6: | Line 6: | ||
Some network advanced stuff: [[https:// | Some network advanced stuff: [[https:// | ||
< | < | ||
- | sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils | + | |
+ | sudo apt install | ||
+ | # Some apps does not get installed with --no-install-recommends and seemds to be added: qemu-utils dnsmasq | ||
+ | # ovmf is for uf | ||
sudo systemctl status libvirtd.service | sudo systemctl status libvirtd.service | ||
sudo virsh net-list --all | sudo virsh net-list --all | ||
sudo modprobe vhost_net | sudo modprobe vhost_net | ||
+ | |||
</ | </ | ||
Line 17: | Line 21: | ||
sudo virsh net-start default | sudo virsh net-start default | ||
sudo virsh net-autostart default | sudo virsh net-autostart default | ||
+ | |||
</ | </ | ||
+ | |||
+ | =====Stop all iptables rules===== | ||
+ | I had issues where these rules were interfering with my iptables manual rules. This worked | ||
+ | So edit your network (virsh net-edit) to <forward mode=' | ||
+ | |||
+ | |||
If you want to offload the mechanism of “virtio-net” and want to improve the performance of KVM VMs then add “vhost_net” kernel module on your system using the beneath command, | If you want to offload the mechanism of “virtio-net” and want to improve the performance of KVM VMs then add “vhost_net” kernel module on your system using the beneath command, | ||
Line 24: | Line 35: | ||
echo " | echo " | ||
lsmod | grep vhost | lsmod | grep vhost | ||
+ | |||
</ | </ | ||
< | < | ||
+ | |||
host_net | host_net | ||
vhost 49152 1 vhost_net | vhost 49152 1 vhost_net | ||
tap 28672 1 vhost_net | tap 28672 1 vhost_net | ||
tun 49152 2 vhost_net | tun 49152 2 vhost_net | ||
+ | |||
</ | </ | ||
+ | |||
Note: If you want a normal user to use virsh commands then add that user to libvirt and libvirt-qemu group using the following commands | Note: If you want a normal user to use virsh commands then add that user to libvirt and libvirt-qemu group using the following commands | ||
+ | |||
< | < | ||
sudo adduser pkumar libvirt | sudo adduser pkumar libvirt | ||
sudo adduser pkumar libvirt-qemu | sudo adduser pkumar libvirt-qemu | ||
+ | |||
</ | </ | ||
+ | |||
To refresh or reload group membership run the followings, | To refresh or reload group membership run the followings, | ||
+ | |||
< | < | ||
newgrp libvirt | newgrp libvirt | ||
newgrp libvirt-qemu | newgrp libvirt-qemu | ||
+ | |||
</ | </ | ||
+ | |||
+ | ======Setup Bridges Network====== | ||
+ | sudo vim / | ||
+ | <sxh bash; gutter: false> | ||
+ | # This file describes the network interfaces available on your system | ||
+ | |||
+ | source / | ||
+ | |||
+ | # The loopback network interface | ||
+ | auto lo | ||
+ | iface lo inet loopback | ||
+ | |||
+ | # The primary network interface | ||
+ | # allow-hotplug enp0s31f6 | ||
+ | #iface enp0s31f6 inet dhcp | ||
+ | #auto enp0s31f6 | ||
+ | |||
+ | auto br0 | ||
+ | iface br0 inet dhcp | ||
+ | bridge_ports enp0s31f6 | ||
+ | bridge_stp off | ||
+ | bridge_fd 0 | ||
+ | bridge_maxwait 0 | ||
+ | </ | ||
====== Allow ping in host====== | ====== Allow ping in host====== | ||
Line 130: | Line 174: | ||
virsh setmem < | virsh setmem < | ||
+ | I'll test this at some point too: | ||
+ | sudo virsh setvcpus --domain test --maximum 2 --config | ||
+ | sudo virsh setvcpus --domain test --count 2 --config | ||
+ | sudo virsh reboot test | ||
+ | |||
+ | Please remember to SWITCH OFF the VM, and back on for the changes to take affect. | ||
====error: Requested operation is not valid: cannot undefine domain with nvram==== | ====error: Requested operation is not valid: cannot undefine domain with nvram==== | ||
< | < | ||
Line 152: | Line 202: | ||
</ | </ | ||
+ | |||
+ | < | ||
+ | qemu-system-x86_64 \ | ||
+ | -boot d \ | ||
+ | -cdrom " | ||
+ | -bios / | ||
+ | -nodefaults \ | ||
+ | -enable-kvm \ | ||
+ | -smp 8 \ | ||
+ | -device intel-hda \ | ||
+ | -device hda-duplex \ | ||
+ | -device virtio-vga-gl \ | ||
+ | -net nic \ | ||
+ | -net user, | ||
+ | -cpu host \ | ||
+ | -m 4096 \ | ||
+ | -display sdl,gl=on \ | ||
+ | -hda Android.img | ||
+ | </ | ||
===== Stop a running domain ===== | ===== Stop a running domain ===== | ||
< | < | ||
Line 220: | Line 289: | ||
+ | =====Convert===== | ||
+ | qemu-img convert -f vdi -O qcow2 ./ | ||