Libvirt importing a virtual appliance

This directly from here: https://www.redhat.com/en/blog/importing-vms-kvm-virt-v2v

yum update

yum install virt-v2v

virsh pool-list
mkdir /var/lib/libvirt/Appliances
virsh pool-define-as Appliances –type dir –target /var/lib/libvirt/Appliances
virsh pool-start Appliances
virsh pool-autostart Appliances
virsh pool-list

Then import an OVA file:

virt-v2v -i ova /root/third_party_appliance.ova -o libvirt -of qcow2 -os Appliances -n default

Example: virt-v2v -i ova /home/brad/Nextcloud_VM_www.hanssonit.se.ova -o libvirt -of qcow2 -os Appliances -n default

If you get something like this:

[root@centos8 ~]# virt-v2v -i ova /home/brad/Nextcloud_VM_www.hanssonit.se.ova -o libvirt -of qcow2 -os Appliances -n default
[ 0.0] Opening the source -i ova /home/brad/Nextcloud_VM_www.hanssonit.se.ova
virt-v2v: warning: making OVA directory public readable to work around
libvirt bug https://bugzilla.redhat.com/1045069
[ 8.8] Creating an overlay to protect the source from being modified
[ 9.0] Initializing the target -o libvirt -os Appliances
[ 9.0] Opening the overlay
virt-v2v: error: libguestfs error: could not create appliance through
libvirt.

Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct

Original error from libvirt: Cannot access backing file
‘/home/brad/Nextcloud_VM_www.hanssonit.se.ova’ of storage file
‘/var/tmp/v2vovl2af2bf.qcow2’ (as uid:107, gid:107): Permission denied
If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:

virt-v2v -v -x […]

You work around this by running:
export LIBGUESTFS_BACKEND=direct
then do the virt-v2v again and it should work.

Now start your imported appliance:

[root@centos8 ~]# virsh list –all
Id Name State
1 kali running
Nextcloud_VM_www.hanssonit.se shut off

[root@centos8 ~]# virsh start Nextcloud_VM_www.hanssonit.se
error: Failed to start domain Nextcloud_VM_www.hanssonit.se
error: Cannot get interface MTU on ‘bridged’: No such device

You probably need to edit the network card to match your other VM’s

Centos 7 or 8 Libvirt + Cockpit virtual host

Build minimal install box of Centos 7 or 8. With 8 you can choose Virtual Host and Headless administration and it covers most of this right off the bat.

Watch your disk partitions! Changing storage after the fact isn’t terrible, but if you need to change storage, follow this: https://linuxconfig.org/configure-default-kvm-virtual-storage-on-redhat-linux#h6-1-create-new-virtual-storage-directory

SSH should be enabled and running:

sudo yum install openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd
sudo systemctl status sshd
ssh to box:
yum -y update
yum -y install cockpit cockpit-machines
yum -y install qemu-kvm libvirt libvirt-python libguestfs-tools virt-install
yum -y install mc iperf3 iptraf-ng
yum -y install virt-install virt-viewer
systemctl start cockpit.socket
systemctl enable cockpit.socket
systemctl status cockpit.socket
firewall-cmd –add-service=cockpit –permanent
firewall-cmd –reload
# Cockpit is on: https://SERVER_IP:9090/

Centos 8 needs: 
sudo systemctl enable –now cockpit.socket

modprobe fuse
virt-host-validate
systemctl start libvirtd.service
systemctl enable libvirtd.service
systemctl status libvirtd.service

If needed, set up network bridge:
Cockpit – Networking – Add Bridge
Select your ethernet card (em1)

Should now be able to build virtual machines from within cockpit. You might need to reload the page or go out and back in for it to figure out libvirt is enabled.

If you can’t build a new VM, reboot the box at least once before freaking out.
ISO’s to install from:
ISOs should live in /var/lib/libvirt/images/ probably want to mount that as a read only nfs mount:
go to cockpit – storage and add the NFS or SMB share, stupid easy.

Optional
Netdata: Install netdata on CentOS 7 (and for docker host stats)

Docker: You *can* do docker too:
yum install -y cockpit-docker
sudo systemctl restart cockpit.socket

But compared to Portainer, there’s no comparison. Doesn’t mean you can’t do both on one box though, just that the cockpit plugin is garbage. Use Portainer.

sudo dnf config-manager –add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf repolist -v
dnf list docker-ce –showduplicates | sort -r
dnf install –nobest docker-ce –allowerasing (Removes buildah and cockpit-podman and podman, that’s ok, they suck.)

sudo systemctl enable –now docker
systemctl is-active docker
systemctl is-enabled docker

Docker compose:
curl -L “https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)” -o docker-compose sudo mv docker-compose /usr/local/bin && sudo chmod +x /usr/local/bin/docker-compose

# Portainer
docker pull portainer/portainer:latest
docker volume create portainer_data
docker run -d –name portainer –restart unless-stopped -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer