KVM/QEMU
簡介
QEMU為Fabrice Bellard開發的開源硬體模擬器軟體,支援模擬x86、ARM、SPARC、RISC-V、MIPS各種架構的電腦。
Home: QEMU
Installation
- Ubuntu安裝QEMU/KVM和Virt Manager虛擬機管理員 · Ivon的部落格 (ivonblog.com)
- How to Install and Use Qemu on Ubuntu (itsfoss.com)
- EmuGUI + QEMU,Windows系統安裝虛擬機軟體 · Ivon的部落格 (ivonblog.com)
- Setting Up Virtual Machines with QEMU, KVM, and Virt-Manager on Debian/Ubuntu - LinuxConfig
- How to run virtual machines with virt-manager - Fedora Magazine
- How to Install KVM on Fedora 37/36 Step-by-Step
- Virtualization Deployment and Administration Guide | Red Hat Product Documentation
Fedora
QEMU
sudo dnf update
sudo dnf install qemu
From QEMU's source files
# Install prerequisite rpms to build the source code
sudo dnf install pixman-devel gcc make git python38
# Download source code
wget https://download.qemu.org/qemu-9.1.0.tar.xz
tar xvJf qemu-9.1.0.tar.xz
cd qemu-9.1.0
mkdir build
cd build
../configure --target-list='ppc64-softmmu ppc-softmmu' --prefix=/opt/qemu
make
sudo make install
/opt/qemu/bin/qemu-system-ppc64 --version
If you don not mentioned the --target-list='ppc64-softmmu ppc-softmmu', it will build more than 50 machines emulator, and will take a longer time to compile. fore more info, type #../configure -h
KVM/QEMU/Virt-Manager
sudo dnf install -y qemu-kvm libvirt virt-install bridge-utils qemu virt-manager \
libvirt-devel virt-top libguestfs-tools guestfs-tools libvirt-client libvirt-python
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
sudo usermod -a -G libvirt $(whoami)
sudo usermod -a -G kvm $(whoami)
sudo usermod -a -G input $(whoami)
RedHat
# RHEL 7
yum install qemu-kvm libvirt
yum install virt-install libvirt-python virt-manager virt-install libvirt-client
# RHEL 8
yum module install virt
yum install virt-install virt-viewer
systemctl start libvirtd
## Verification
virt-host-validate
Ubuntu 22.04
sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
sudo apt-get install libnfs-dev libiscsi-dev python3-tomli
# Download source code
wget https://download.qemu.org/qemu-9.1.0.tar.xz
tar xvJf qemu-9.1.0.tar.xz
cd qemu-9.1.0
mkdir build
cd build
../configure --target-list='ppc64-softmmu ppc-softmmu' --prefix=/opt/qemu
make
sudo make install
/opt/qemu/bin/qemu-system-ppc64 --version
Command Line
- How To Use QEMU From the Linux Command-Line | Baeldung on Linux
- A Comprehensive Guide to Using QEMU from the Linux Command-Line — nixFAQ
- Chapter 20. Managing Guest Virtual Machines with virsh | Red Hat Product Documentation
virsh
Guest CPU Models
# For x86
virsh cpu-models x86_64
# For PowerPC
virsh cpu-models ppc64
List the VMs
sudo virsh list --all
FAQ
Operation not permitted
qemu-system-ppc64: -net nic -net tap,script=no,ifname=tap0: could not configure /dev/net/tun (tap): Operation not permitted
Solution:
sudo setcap CAP_NET_ADMIN=ep /usr/bin/qemu-system-ppc64
Install Error
Running postconf script '/home/alang/文件/worktmp/qemu-9.1.0/build/pyvenv/bin/python3 /home/alang/文件/worktmp/qemu-9.1.0/scripts/symlink-install-tree.py'
Traceback (most recent call last):
File "/home/alang/文件/worktmp/qemu-9.1.0/scripts/symlink-install-tree.py", line 17, in <module>
out = subprocess.run([*introspect.split(' '), '--installed'],
File "/usr/lib/python3.10/subprocess.py", line 503, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1863, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: "'/home/alang/文件/worktmp/qemu-9.1.0/build/pyvenv/bin/meson'"
Fix bug: edit symlink-install-tree.py
import shlex
out = subprocess.run([*shlex.split(introspect), '--installed'],
No Comments