User Tools

Site Tools


kvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
kvm [2021/06/28 01:25] vissiekvm [2023/06/01 00:52] (current) – [Debian] vissie
Line 6: Line 6:
 Some network advanced stuff: [[https://www.linuxtechi.com/install-configure-kvm-debian-10-buster/|https://www.linuxtechi.com/install-configure-kvm-debian-10-buster/]] Some network advanced stuff: [[https://www.linuxtechi.com/install-configure-kvm-debian-10-buster/|https://www.linuxtechi.com/install-configure-kvm-debian-10-buster/]]
 <code> <code>
-sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils+ 
 +sudo apt install --no-install-recommends qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst dnsmasq qemu-utils ovmf 
 +#  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
 +
 </code> </code>
  
Line 17: Line 21:
 sudo virsh net-start default sudo virsh net-start default
 sudo virsh net-autostart default sudo virsh net-autostart default
 +
 </code> </code>
 +
 +=====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='open'/>.
 +
 +
  
 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 "vhost_net" | sudo  tee -a /etc/modules echo "vhost_net" | sudo  tee -a /etc/modules
 lsmod | grep vhost lsmod | grep vhost
 +
 </code> </code>
 <code> <code>
 +
 host_net               24576  0 host_net               24576  0
 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
 +
 </code> </code>
 +
 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
 +
 <code> <code>
 sudo adduser pkumar libvirt sudo adduser pkumar libvirt
 sudo adduser pkumar libvirt-qemu sudo adduser pkumar libvirt-qemu
 +
 </code> </code>
 +
 To refresh or reload group membership run the followings, To refresh or reload group membership run the followings,
 +
 <code> <code>
 newgrp libvirt newgrp libvirt
 newgrp libvirt-qemu newgrp libvirt-qemu
 +
 </code> </code>
 +
 +======Setup Bridges Network======
 +  sudo vim /etc/network/interfaces
 +<sxh bash; gutter: false>  
 +# This file describes the network interfaces available on your system
 +
 +source /etc/network/interfaces.d/*
 +
 +# 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   
 +</sxh>
  
 ====== Allow ping in host====== ====== Allow ping in host======
Line 130: Line 174:
   virsh setmem <vm_name> <memsize> --config   virsh setmem <vm_name> <memsize> --config
  
 +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====
 <code>sudo virsh undefine --nvram nameofvm</code> <code>sudo virsh undefine --nvram nameofvm</code>
Line 152: Line 202:
 </code> </code>
  
 +
 +<code>
 +qemu-system-x86_64 \
 +  -boot d \
 +  -cdrom "Bliss-v14.10-x86_64-OFFICIAL-opengapps-20221027.iso" \
 +  -bios /usr/share/ovmf/x64/OVMF.fd \
 +  -nodefaults \
 +  -enable-kvm \
 +  -smp 8 \
 +  -device intel-hda \
 +  -device hda-duplex \
 +  -device virtio-vga-gl \
 +  -net nic \
 +  -net user,hostfwd=tcp::5555-:5555 \
 +  -cpu host \
 +  -m 4096 \
 +  -display sdl,gl=on \
 +  -hda Android.img
 +</code>
 ===== Stop a running domain ===== ===== Stop a running domain =====
 <code> <code>
Line 220: Line 289:
  
  
 +=====Convert===== 
 +  qemu-img convert -f vdi -O qcow2 ./Lineage.vdi ./Lineage.qcow2
  
  
kvm.1624868744.txt.gz · Last modified: 2021/06/28 01:25 by vissie