Ubuntu中使用cockpit管理kvm虚拟机

cockpit

使用cockpit管理kvm需要安装cockpit本身,还有cockpit-machines组件来管理虚拟机

$ sudo apt update
$ sudo apt install -y kpit cockpit-machines
$ sudo systemctl start cockpit

kvm、qemu、libvirt

安装kvm、qemu、libvirt相关工具

$ sudo apt install qemu qemu-kvm libvirt-bin  bridge-utils  virt-manager
$ sudo systemctl start libvirtd
$ sudo systemctl enable libvirtd

创建虚拟机无法启动network相关问题

在安装完成kvm后从cockpit中创建虚拟机时报错:libvirtError: Requested operation is not valid: network ‘default’ is not active,在用virsh 尝试激活default network失败。

$ sudo virsh net-start default

error: Failed to start network default
error: internal error: Failed to initialize a valid firewall backend

从错误信息中可以看到,无法初始化防火墙后端,需要安装firewalld,然后重启libvirtd

$ sudo apt update && sudo apt install firewalld -y
$ sudo systemctl enable --now firewalld
$ sudo systemctl restart libvirtd****