Kvm: Difference between revisions

From Halfface
Jump to navigation Jump to search
 
(70 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==prepare environment==
=prepare environment=
Is environment prepared for viritutalization.
# Is environment prepared for viritutalization.
  egrep '(vmx|svm)' /proc/cpuinfo
  egrep '(vmx|svm)' /proc/cpuinfo
vmx - (intel) svm - (amd)


vmx - (intel) svm - (amd)
=Create disk image.=
qemu-img create -f qcow2 fedora20.halfface.se.qcow2 50G
=mount qcow2=
qemu-img info $machine.qcow2
qemu-img info $machine.qcow2 --force-share
=mount qcow2 image=
# Create /dev/nbd devices if they do not exist.
modprobe nbd max_part=8
# Connect qcow2 file to nbd device.
qemu-nbd --connect=/dev/nbd0 ./img_output/Rocky-8.6-x86_64-dvd1/rocky8.qcow2
# Sanity check disk device.
gdisk -l /dev/nbd0
Number  Start (sector)   End (sector) Size      Code  Name
  1            2048        2099199  1024.0 MiB  8300  Linux filesystem
  2        2099200        41943039  19.0 GiB    8E00  Linux LVM
# List device to mount
ls -la /dev/mapper/
total 0
drwxr-xr-x  2 root root    100 2022-08-25 12:13:50 .
drwxr-xr-x 22 root root    5220 2022-08-25 12:13:50 ..
lrwxrwxrwx  1 root root      7 2022-08-25 12:13:50 vg0-root -> ../dm-1
# Mount device
mount /dev/mapper/vg0-root /mnt/


Create disk image.
=list all domain blocks=
  qemu-img create -f qcow2 f8_1_x86_64.img 10G
  virsh domblklist $vm
=list info about block device=
virsh domblkstat $vm vda --human
=List short info about vm=
virsh dominfo $vm
=add ram on the fly=
virsh setmem --domain $VM --size 1500M --current


Install software.
=Install software=
  yum install -y qemu kvm SDL bridge-utils tunctl
  yum install -y qemu kvm SDL bridge-utils tunctl


==Prepare vitual environment and create bridge with eth0==
=install virtual machine.=
virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm
=delete virtual machine.=
virsh undefine kvm_1
=list libvirt storage pools=
virsh pool-list --all
=list content of pools=
virsh pool-list --name | grep -v '^$' | while read POOL ; do POOL_DIR=$(virsh pool-dumpxml "${POOL}" | xmllint --format - | awk -F '<path>|</path>' '/<path>/ {print $2}') ; echo '#' "${POOL} ${POOL_DIR}" ; (cd "${POOL_DIR}/"; ls -la *.iso *.ISO *.qcow2 *.QCOW2 *.ima *.IMA *.img *.IMG 2>/dev/null ); done


load modules.
=connect to virtual machine.=
  modprobe kvm-intel
  virt-viewer Fedora_16
  modprobe tun
On remote machine over ssh
  virt-viewer --connect qemu+ssh://root@anden.halfface.se/system win8


Create bridge.
=convert file format=
  tunctl -t tap0
  # img to qcow2
  ip addr flush eth0
  qemu-img convert -cp -O qcow2 kvm_1.img kvm_1.qcow2
  ifconfig eth0 0.0.0.0 promisc
  # vmdk to qcow2
  ifconfig tap0 0.0.0.0 promisc
  qemu-img convert disk0.vmdk -O qcow2 bigbluebutton.qcow2
  brctl addbr br0
  FILE=costest-ph9l4-rhcos.vmdk ; qemu-img convert ${FILE} -O qcow2 ${FILE%.*}.qcow2
ifconfig br0 hw ether 62-f0-dc-95-c4-c9
brctl addif br0 eth0
brctl addif br0 tap0
dhclient br0


==Prepare vitual environment and create bridge with wlan0==
=snapshot=
# Create snapshot
virsh snapshot-create SL_63
# List snapshots
virsh snapshot-list SL_63
# Delete snapshot
virsh snapshot-delete SL_63 1346734871
# Revert to snapshot
virsh snapshot-revert fedora20_2.halfface.se 1414336149
List info about qcow2 image.
qemu-img info sms-app02.qcow2 --force-share
image: sms-app02.qcow2
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 107G
cluster_size: 65536
Snapshot list:
ID        TAG                VM SIZE                DATE      VM CLOCK
2        snapshot1                0 2018-04-23 18:50:15  00:00:00.000
4        pre-patch                0 2018-04-24 10:34:05  00:00:00.000
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
Delete snapshot
qemu-img snapshot -d 4 sms-app02.qcow2


sudo sysctl net.ipv4.ip_forward=1
=list information=
# Simple information about domain.
virsh dominfo fedora_20_raid1


  modprobe kvm-intel
  # View information about domain.
  modprobe tun
  virsh dumpxml fedora_20_raid1 | less
=change value of virtual machine=
virsh autostart virtual_machine_name


Create bridge.
=disk handling=
  tunctl -t tap0
# Detach one of the disks.
  ip addr flush wlan0
  virsh detach-disk fedora_20_raid1 vda
ifconfig wlan0 0.0.0.0 promisc
  virsh detach-disk rhel8.5 vda --persistent
ifconfig tap0 0.0.0.0 promisc
brctl addbr br0
ifconfig br0 hw ether 62:f0:dc:95:c4:c9
brctl addif br0 wlan0
brctl addif br0 tap0
dhclient br0


Load modules.
# Attach disk
  sudo modprobe kvm-intel
  virsh attach-disk fedora_20_raid1 /ssd/libvirt/fedora20_1.qcow2 vda --sourcetype file --subdriver qcow2
  sudo modprobe tun
  virsh attach-disk host /var/lib/libvirt/images/host-#.qcow2 vdb --driver qemu --subdriver qcow2 --targetbus virtio --persistent


Paravirtulazied network interface.
# Copy kvm machine.
  qemu-system-x86_64 -hda windowsxp.img -net nic,model=virtio
virsh dumpxml <domain> > domain.xml
vi domain.xml
  virsh create domain.xml


Start install
  # Eject cdrom.
  sudo qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot d -cdrom /storage/install/system/winxp/xpsp2/winxpsp2.iso
  virsh change-media www.halfface.se hda --eject
Start virtual machine.
  qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot c -net nic -net tap,ifname=tap0,script=no


==Some startscript==
=duplicate move machine=
# You cannot "clone" a running vm, stop it.  suspend and destroy
# are also valid options for less graceful cloning
virsh shutdown this.vm
# copy the storage.
cp /var/lib/libvirt/images/{this-vm,that-vm}.img
# dump the xml for the original
virsh dumpxml this-vm > /tmp/that-vm.xml
# hardware addresses need to be removed, libvirt will assign
# new addresses automatically
sed -i /uuid/d /tmp/that-vm.xml
sed -i '/mac address/d' /tmp/that-vm.xml
# and actually rename the vm: (this also updates the storage path)
sed -i 's/this-vm/that-vm/g' /tmp/that-vm.xml
# finally, create the new vm
virsh define /tmp/that-vm.xml
virsh start this-vm
virsh start that-vm


  #!/bin/sh
=virt-convert=
  PATH=$PATH:/usr/sbin:/sbin
Convert vmware image to kvm.
sudo brctl addbr br0
  virt-convert . --disk-format qcow2 --destination .
  sudo ifconfig wlan0 0.0.0.0
=drivers=
  sudo brctl addif br0 wlan0
Drivers for other os and enhancements.
  sudo ifconfig br0 10.111.222.8 netmask 255.255.255.0 up
  https://www.spice-space.org/download.html
  sudo route add -net 10.111.222.0 netmask 255.255.255.0 br0
=access via spice=
  sudo route add default gw 10.111.222.1 br0
  remote-viewer spice://10.151.105.122:5900
  sudo tunctl -b
=virsh capabilities=
  sudo ifconfig tap0 up
  currently supported machine types.
  sudo brctl addif br0 tap0
virsh capabilities
  qemu-kvm ~/win2k.img -m 512 -net nic -net tap,ifname=tap0,script=no
=extend qcow2 image=
  qemu-kvm -hda winxp.vmd -m 512 -net nic -net tap,ifname=tap0,script=no
Inspect storage
  virsh domblklist almalinux8.4
Inspect storage
virsh domblkinfo almalinux8.4 /var/lib/libvirt/images/almalinux8.4.qcow2
Make storage to new size.
  virsh blockresize almalinux8.4 /var/lib/libvirt/images/almalinux8.4.qcow2 64G
Inspect storage
  qemu-img info almalinux8.4.qcow2 --force-share
Create partition from free space.
  fdisk /dev/vda
  pvcreate /dev/vda3
  vgextend almalinux /dev/vda3
  lvextend -l +100%FREE /dev/mapper/almalinux-root
resize2fs /dev/mapper/almalinux-root
xfs_growfs /dev/mapper/almalinux-root
=resize qcow2=
  qemu-img resize Fedora-38-Silverblue.qcow2 60G


Ip forwarding.
=rename vm=
  sudo sysctl net.ipv4.ip_forward=1
virsh stop foo
virsh domrename foo bar
cd /var/lib/libvirt/images
  mv foo.qcow2 bar.qcow2
# replace foo with bar
virsh edit bar


==error checking==
[[Category:Applications]]
[[Category:Unix]]
[[Category:Virtualization]]


Create virtual bridge.
=rename vm=
  sudo brctl addbr br0
  virsh domrename foo bar


Are interfaces connected.
=dhcp leases=
  sudo brctl show
  virsh net-list
virsh net-dhcp-leases okd01-dwb8v


Create tun interface.
List networks
  sudo tunctl
  virsh net-list


Activate interfaces.
virsh net-info default
  sudo ifconfig tap0 up
View leases
  sudo ifconfig br0 up
virsh net-dhcp-leases default
=ip address=
Which ip does vm have
  virsh domifaddr <vm>
==Get ip from vm==
  nmap -sn -n 10.111.222.* >/dev/null ; export VM=<vm> ; MAC=$(virsh domiflist $VM | grep -oE '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})') ; arp -a | grep $MAC


Add interfaces to bridge.
=stop running vm:s=
  sudo brctl addif br0 eth0
virsh list --state-running --name | grep -v ^$ | while read VM ; do virsh shutdown $VM ; done
  sudo brctl addif br0 wlan0
 
  sudo brctl addif br0 tap0
=execute command via agent=
virsh -c qemu:///system qemu-agent-command <vm> '{"execute": "guest-exec", "arguments": { "path": "/usr/bin/ls", "arg": [ "/" ], "capture-output": true }}'
virsh -c qemu:///system qemu-agent-command <vm> '{"execute": "guest-exec-status", "arguments": { "pid": <pid> }}'
base64 -d on output.
==all in one==
export KVM=pm-app02 ; KVM_PID=$(virsh -c qemu:///system qemu-agent-command ${KVM} '{"execute": "guest-exec", "arguments": { "path": "id", "arg": [ "-a","-a" ], "capture-output": true }}' --pretty | jq -r .return.pid) ; virsh -c qemu:///system qemu-agent-command "${KVM}" "{\"execute\": \"guest-exec-status\", \"arguments\": { \"pid\": ${KVM_PID} }}" | jq -r '.return."out-data"' | base64 -d
 
=virsh console <vm>=
Connect to vm serial
virsh console <vm>
=socat console=
VM=terraform_test ; sudo socat -,echo=0 $(virsh dumpxml $VM | xq | grep "console type" | awk -F\" '{print $4}')
 
=set password on user=
virsh set-user-password <vm> root password
=Which version of libvirtd=
virsh -c qemu+ssh://root@hdplex.halfface.se/system version
=send keyboard to vm=
https://libvirt.org/manpages/virkeycode-xtkbd.html
virsh send-key terraform_vm --codeset linux KEY_LEFTALT KEY_TAB KEY_TAB
 
=nested virualization and virt-install=
<pre>
# Enable nested virtualization.
cat <<'EOF' > /etc/modprobe.d/kvm.conf
options kvm_amd nested=1
options kvm ignore_msrs=1 report_ignored_msrs=0
EOF
# Install dependecies.
systemctl enable autofs --now ; ln -s /net/10.111.222.1/storage/install /install ; ln -s /net/10.111.222.1/storage/temp /temp
dnf install -y virt-install libvirt qemu-kvm git stow vim-enhanced
systemctl enable libvirtd --now
# Setup cloud-os
cp /install/system/linux/fedora/40/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2
qemu-img info /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2
qemu-img resize  /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2  +195G
virt-install  --name fedora-cloud-base-generic \
    --cpu host-passthrough,cache.mode=passthrough \
    --memory 19456 --vcpus 10 --graphics none\
    --os-variant centos-stream9\
    --import \
    --disk /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2,format=qcow2,bus=virtio \
    --network bridge=br0,model=virtio  \
    --cloud-init \
    --console pty,target_type=serial
# Setup Fedora Server.
cp /install/system/linux/fedora/40/Fedora-Server-KVM-40-1.14.x86_64.qcow2 /var/lib/libvirt/images/fedora-server-kvm.qcow2
qemu-img info /var/lib/libvirt/images/fedora-server-kvm.qcow2
qemu-img resize /var/lib/libvirt/images/fedora-server-kvm.qcow2 +195G
virt-install --name fedora-server-kvm \
    --cpu host-passthrough,cache.mode=passthrough \
    --memory 19456 --vcpus 10 --graphics none\
    --os-variant centos-stream9\
    --import \
    --disk /var/lib/libvirt/images/fedora-server-kvm.qcow2,format=qcow2,bus=virtio \
    --network bridge=br0,model=virtio  \
    --cloud-init \
    --console pty,target_type=serial
</pre>
[[Category:Applications]]
[[Category:Unix]]
[[Category:Virtualization]]

Latest revision as of 18:13, 18 November 2024

prepare environment

# Is environment prepared for viritutalization.
egrep '(vmx|svm)' /proc/cpuinfo
vmx - (intel) svm - (amd)

Create disk image.

qemu-img create -f qcow2 fedora20.halfface.se.qcow2 50G

mount qcow2

qemu-img info $machine.qcow2
qemu-img info $machine.qcow2 --force-share

mount qcow2 image

# Create /dev/nbd devices if they do not exist.
modprobe nbd max_part=8
# Connect qcow2 file to nbd device.
qemu-nbd --connect=/dev/nbd0 ./img_output/Rocky-8.6-x86_64-dvd1/rocky8.qcow2
# Sanity check disk device.
gdisk -l /dev/nbd0
Number  Start (sector)    End (sector)  Size       Code  Name
  1            2048         2099199   1024.0 MiB  8300  Linux filesystem
  2         2099200        41943039   19.0 GiB    8E00  Linux LVM
# List device to mount
ls -la /dev/mapper/
total 0
drwxr-xr-x  2 root root     100 2022-08-25 12:13:50 .
drwxr-xr-x 22 root root    5220 2022-08-25 12:13:50 ..
lrwxrwxrwx  1 root root       7 2022-08-25 12:13:50 vg0-root -> ../dm-1
# Mount device
mount /dev/mapper/vg0-root /mnt/

list all domain blocks

virsh domblklist $vm

list info about block device

virsh domblkstat $vm vda --human

List short info about vm

virsh dominfo $vm

add ram on the fly

virsh setmem --domain $VM --size 1500M --current

Install software

yum install -y qemu kvm SDL bridge-utils tunctl

install virtual machine.

virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm

delete virtual machine.

virsh undefine kvm_1

list libvirt storage pools

virsh pool-list --all

list content of pools

virsh pool-list --name | grep -v '^$' | while read POOL ; do POOL_DIR=$(virsh pool-dumpxml "${POOL}" | xmllint --format - | awk -F '<path>|</path>' '/<path>/ {print $2}') ; echo '#' "${POOL} ${POOL_DIR}" ; (cd "${POOL_DIR}/"; ls -la *.iso *.ISO *.qcow2 *.QCOW2 *.ima *.IMA *.img *.IMG 2>/dev/null ); done

connect to virtual machine.

virt-viewer Fedora_16

On remote machine over ssh

virt-viewer --connect qemu+ssh://root@anden.halfface.se/system win8

convert file format

# img to qcow2
qemu-img convert -cp -O qcow2 kvm_1.img kvm_1.qcow2
# vmdk to qcow2
qemu-img convert disk0.vmdk -O qcow2 bigbluebutton.qcow2
FILE=costest-ph9l4-rhcos.vmdk ; qemu-img convert ${FILE} -O qcow2 ${FILE%.*}.qcow2

snapshot

# Create snapshot
virsh snapshot-create SL_63
# List snapshots
virsh snapshot-list SL_63
# Delete snapshot
virsh snapshot-delete SL_63 1346734871
# Revert to snapshot
virsh snapshot-revert fedora20_2.halfface.se 1414336149

List info about qcow2 image.

qemu-img info sms-app02.qcow2 --force-share
image: sms-app02.qcow2
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 107G
cluster_size: 65536
Snapshot list:
ID        TAG                 VM SIZE                DATE       VM CLOCK
2         snapshot1                 0 2018-04-23 18:50:15   00:00:00.000
4         pre-patch                 0 2018-04-24 10:34:05   00:00:00.000
Format specific information:
   compat: 1.1
   lazy refcounts: false
   refcount bits: 16
   corrupt: false

Delete snapshot

qemu-img snapshot -d 4 sms-app02.qcow2

list information

# Simple information about domain.
virsh dominfo fedora_20_raid1
# View information about domain.
virsh dumpxml fedora_20_raid1 | less

change value of virtual machine

virsh autostart virtual_machine_name

disk handling

# Detach one of the disks.
virsh detach-disk fedora_20_raid1 vda
virsh detach-disk rhel8.5 vda --persistent
# Attach disk
virsh attach-disk fedora_20_raid1 /ssd/libvirt/fedora20_1.qcow2 vda --sourcetype file --subdriver qcow2
virsh attach-disk host /var/lib/libvirt/images/host-#.qcow2 vdb --driver qemu --subdriver qcow2 --targetbus virtio --persistent
# Copy kvm machine.
virsh dumpxml <domain> > domain.xml
vi domain.xml
virsh create domain.xml
# Eject cdrom.
virsh change-media www.halfface.se hda --eject

duplicate move machine

# You cannot "clone" a running vm, stop it.  suspend and destroy
# are also valid options for less graceful cloning
virsh shutdown this.vm

# copy the storage.
cp /var/lib/libvirt/images/{this-vm,that-vm}.img

# dump the xml for the original
virsh dumpxml this-vm > /tmp/that-vm.xml

# hardware addresses need to be removed, libvirt will assign
# new addresses automatically
sed -i /uuid/d /tmp/that-vm.xml
sed -i '/mac address/d' /tmp/that-vm.xml

# and actually rename the vm: (this also updates the storage path)
sed -i 's/this-vm/that-vm/g' /tmp/that-vm.xml

# finally, create the new vm
virsh define /tmp/that-vm.xml
virsh start this-vm
virsh start that-vm

virt-convert

Convert vmware image to kvm.

virt-convert . --disk-format qcow2 --destination .

drivers

Drivers for other os and enhancements.

https://www.spice-space.org/download.html

access via spice

remote-viewer spice://10.151.105.122:5900

virsh capabilities

currently supported machine types.

virsh capabilities

extend qcow2 image

Inspect storage

virsh domblklist almalinux8.4

Inspect storage

virsh domblkinfo almalinux8.4 /var/lib/libvirt/images/almalinux8.4.qcow2

Make storage to new size.

virsh blockresize almalinux8.4 /var/lib/libvirt/images/almalinux8.4.qcow2 64G

Inspect storage

qemu-img info almalinux8.4.qcow2 --force-share

Create partition from free space.

fdisk /dev/vda
pvcreate /dev/vda3
vgextend almalinux /dev/vda3
lvextend -l +100%FREE /dev/mapper/almalinux-root
resize2fs /dev/mapper/almalinux-root
xfs_growfs /dev/mapper/almalinux-root

resize qcow2

qemu-img resize Fedora-38-Silverblue.qcow2 60G

rename vm

virsh stop foo
virsh domrename foo bar
cd /var/lib/libvirt/images
mv foo.qcow2 bar.qcow2 
# replace foo with bar
virsh edit bar

rename vm

virsh domrename foo bar

dhcp leases

virsh net-list
virsh net-dhcp-leases okd01-dwb8v

List networks

virsh net-list
virsh net-info default

View leases

virsh net-dhcp-leases default

ip address

Which ip does vm have

virsh domifaddr <vm>

Get ip from vm

nmap -sn -n 10.111.222.* >/dev/null ; export VM=<vm> ; MAC=$(virsh domiflist $VM | grep -oE '([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})') ; arp -a | grep $MAC

stop running vm:s

virsh list --state-running --name | grep -v ^$ | while read VM ; do virsh shutdown $VM ; done

execute command via agent

virsh -c qemu:///system qemu-agent-command <vm> '{"execute": "guest-exec", "arguments": { "path": "/usr/bin/ls", "arg": [ "/" ], "capture-output": true }}'
virsh -c qemu:///system qemu-agent-command <vm> '{"execute": "guest-exec-status", "arguments": { "pid": <pid> }}'
base64 -d on output.

all in one

export KVM=pm-app02 ; KVM_PID=$(virsh -c qemu:///system qemu-agent-command ${KVM} '{"execute": "guest-exec", "arguments": { "path": "id", "arg": [ "-a","-a" ], "capture-output": true }}' --pretty | jq -r .return.pid) ; virsh -c qemu:///system qemu-agent-command "${KVM}" "{\"execute\": \"guest-exec-status\", \"arguments\": { \"pid\": ${KVM_PID} }}" | jq -r '.return."out-data"' | base64 -d

virsh console <vm>

Connect to vm serial

virsh console <vm>

socat console

VM=terraform_test ; sudo socat -,echo=0 $(virsh dumpxml $VM | xq | grep "console type" | awk -F\" '{print $4}')

set password on user

virsh set-user-password <vm> root password

Which version of libvirtd

virsh -c qemu+ssh://root@hdplex.halfface.se/system version

send keyboard to vm

https://libvirt.org/manpages/virkeycode-xtkbd.html

virsh send-key terraform_vm --codeset linux KEY_LEFTALT KEY_TAB KEY_TAB

nested virualization and virt-install

# Enable nested virtualization.
cat <<'EOF' > /etc/modprobe.d/kvm.conf
options kvm_amd nested=1
options kvm ignore_msrs=1 report_ignored_msrs=0
EOF
# Install dependecies.
systemctl enable autofs --now ; ln -s /net/10.111.222.1/storage/install /install ; ln -s /net/10.111.222.1/storage/temp /temp
dnf install -y virt-install libvirt qemu-kvm git stow vim-enhanced
systemctl enable libvirtd --now
# Setup cloud-os
cp /install/system/linux/fedora/40/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2
qemu-img info /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2
qemu-img resize  /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2  +195G
virt-install  --name fedora-cloud-base-generic \
     --cpu host-passthrough,cache.mode=passthrough \
     --memory 19456 --vcpus 10 --graphics none\
     --os-variant centos-stream9\
     --import  \
     --disk /var/lib/libvirt/images/fedora-cloud-base-generic.qcow2,format=qcow2,bus=virtio \
     --network bridge=br0,model=virtio  \
     --cloud-init \
     --console pty,target_type=serial
# Setup Fedora Server.
cp /install/system/linux/fedora/40/Fedora-Server-KVM-40-1.14.x86_64.qcow2 /var/lib/libvirt/images/fedora-server-kvm.qcow2
qemu-img info /var/lib/libvirt/images/fedora-server-kvm.qcow2
qemu-img resize /var/lib/libvirt/images/fedora-server-kvm.qcow2 +195G
virt-install  --name fedora-server-kvm \
     --cpu host-passthrough,cache.mode=passthrough \
     --memory 19456 --vcpus 10 --graphics none\
     --os-variant centos-stream9\
     --import  \
     --disk /var/lib/libvirt/images/fedora-server-kvm.qcow2,format=qcow2,bus=virtio \
     --network bridge=br0,model=virtio  \
     --cloud-init \
     --console pty,target_type=serial