Skip to content

Latest commit

 

History

History
246 lines (196 loc) · 9.75 KB

qemu.md

File metadata and controls

246 lines (196 loc) · 9.75 KB

**

General Info

Books

Blog

running guest OS in qemu

Shortcut keys

ctrl-alt-F toggle screen
ctrl-alt-G toggle between vm and the host

image related

qemu-img https://dustymabe.com/2015/01/11/qemu-img-backing-files-a-poor-mans-snapshotrollback/ [overlay image] (https://wiki.archlinux.org/title/QEMU#Overlay_storage_images)

image overlay

 qemu-img create -o backing_file=img1.raw,backing_fmt=raw -f qcow2 img1.cow
 qemu-img rebase -u -b /new/img1.raw /new/img1.cow

convert image format

qemu-img convert -f raw -O qcow2 vm_hdd.img vm_hdd.qcow2

image conversion

qemu-img convert -O vdi gnome.qcow2 gnome.vdi
#if its a raw image then:
VBoxManage convertdd opnstk.raw VBox.vdi --format VDI

Reference: https://gist.github.com/mamonu/671038b09f5ae9e034e8

vnc connect

-vnc :0
-vnc 192.168.1.5:0
-vnc 0.0.0.0:5
-vnc 0.0.0.0:1 -k en-us
####  Require that password based authentication is used for client connections ####
-vnc 0.0.0.0:1,password -k en-us

qemu-kvm -S -M rhel5.4.0 -m 1024 -smp 1 -vnc 0.0.0.0:1 -k en-us -name centos1 -monitor pty -boot c -drive file=/var/lib/libvirt/images/centos1.img

Reference https://www.cyberciti.biz/faq/linux-kvm-vnc-for-guest-machine/

Questions and Answers.

Windows related

using virtio drivers for Windows VM

sudo mount.cifs \
	//10.0.2.2/share \
	/mnt \
	-o user=username,pass=password
/usr/libexec/qemu-kvm \
-M pc \
-cpu SandyBridge,hv_relaxed,hv_vapic,hv_spinlocks=0x1fff \
-m 2G \
-smp 4,sockets=2,cores=2,threads=1,maxcpus=16 \
-enable-kvm \
-name win8 \
-uuid 990ea161-6b67-47b2-b803-19fb01d30d12 \
-smbios type=1,manufacturer='Red Hat',product='RHEV Hypervisor',version=el6,serial=koTUXQrb,uuid=feebc8fd-f8b0-4e75-abc3-e63fcdb67170 \
-k en-us \
-rtc base=localtime,clock=host,driftfix=slew \
-nodefaults \
-monitor stdio \
-qmp tcp:localhost:6666,server,nowait \
-boot menu=on \
-bios /usr/share/seabios/bios.bin \
-vga cirrus \
-vnc :0 \
-global PIIX4_PM.disable_s3=0 \
-global PIIX4_PM.disable_s4=0 \
-drive file=/home/win8-32.raw,if=none,id=drive-virtio-disk0,format=raw,cache=none,werror=stop,rerror=stop,aio=threads \
-device virtio-blk-pci,scsi=off,bus=pci.0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=0 \
-device virtio-net-pci,netdev=dev1,mac=9a:e8:e9:ea:eb:ec,id=net1 \
-netdev tap,id=dev1,vhost=on \
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
-device usb-tablet,id=input0 \

hyper V related

LXC related

https://unix.stackexchange.com/questions/50201/how-to-configure-external-ip-addresses-for-lxc-guests

Comparision to docker

Networking on QEMU

# using bridge network
sudo qemu-system-aarch64 -nographic -no-reboot \
-boot n \
-machine virt,gic-version=max -m 2048 -cpu cortex-a53 -smp 4 \
-device virtio-net-pci,netdev=vnet,mac=52:54:00:12:xx:xx \
-netdev user,id=vnet,type=tap \
-device virtio-blk-pci,drive=hd \
-drive if=none,file=swap.qcow2,format=qcow2,id=hd \
-kernel vmlinuz-4.19.0-13-arm64 \
-initrd initrd.img-4.19.0-13-arm64 \
-append "root=/dev/nfs rw \
nfsroot=192.168.xx.xx:/opt/remote/nfsroot/rpi4b-arm64 ip=dhcp"
#RDP redirection.  QEMU needs to set IP address first. 
redir --lport 3389 --caddr=GuestIP --cport 3389
qemu-system-i386 -net nic,model=rtl8139 \
  -net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::443-:443,hostfwd=tcp::992-:992 \
  -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet \
  -k en-us -hda win.img -nographic

  # legacy redir option
  qemu-system-i386 -net nic,model=rtl8139 \
  -net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::443-:443,hostfwd=tcp::992-:992 \
  -m 512M -localtime -cpu core2duo,+nx -smp 2 -usbdevice tablet \
  -k en-us -hda win.img -nographic

parprouted

other virtualization methods

private network for virtualbox

qemu monitor

https://kashyapc.wordpress.com/tag/qemu/ https://en.wikibooks.org/wiki/QEMU/Monitor#:~:text=The%20monitor%20is%20accessed%20from,back%20to%20the%20guest%20OS. https://qemu.readthedocs.io/en/latest/system/monitor.html

wireguard

https://stty.io/2019/05/13/qemu-vm-wireguard-vpn-tun-tap-networking/

libvirt

https://serverfault.com/questions/289979/libvirt-how-can-i-make-a-domain-start-when-the-host-starts

virsh

provide blockpull and blockcommit.

  • blockcommit commits the change to the backing file
  • blockpull commits the backing file.
  • blockcommit is faster than blockpull

compile qmeu and virsh

https://developer.ibm.com/tutorials/compiling-libvirt-and-qemu/

AutoInstall openbsd.

OS in general

publication

xv6