Compare commits
10 Commits
1c6ab98227
...
main
Author | SHA1 | Date | |
---|---|---|---|
c75c79a7ce | |||
5ee048e1dc | |||
828338cd41 | |||
3a350f2f12 | |||
518b87325f | |||
d4092f4280 | |||
1f364a1289 | |||
a80d97d3ab | |||
6110cfc9e6 | |||
49c18900ac |
@ -21,7 +21,7 @@ The best parameters are defined as parameters that are:
|
||||
|
||||
There are two kinds of definition for QEMU: **session-driven** virtual machines, and **system-driven** virtual machines.
|
||||
|
||||
- **System-driven virtual machines** are running with higher privileges. If one intend to share a physical device with a virtual machine using VFIO passthrough, this is the definition to use. More information [here](https://blog.wikichoon.com/2016/01/qemusystem-vs-qemusession.html).
|
||||
- **System-driven virtual machines** are running with higher privileges. If one intend to share a physical device with a virtual machine using VFIO passthrough, this is the definition to use. More information [here](https://blog.wikichoon.com/2016/01/qemusystem-vs-qemusession.html) or [here](https://wiki.libvirt.org/FAQ.html#what-is-the-difference-between-qemu-system-and-qemu-session-which-one-should-i-use)
|
||||
|
||||
- **Session-driven virtual machines** are running with user-derived privileges.
|
||||
|
||||
|
57
define-vms.sh
Executable file
57
define-vms.sh
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Directory containing XML definitions of virtual machines requiring root permissions
|
||||
SYSTEM="./system/"
|
||||
|
||||
# Ensure the directory exists
|
||||
if [ ! -d "$SYSTEM" ]; then
|
||||
echo "The specified directory does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Loop over each XML file in the directory
|
||||
for root_vm in "$SYSTEM"/*.xml; do
|
||||
if [ -f "$root_vm" ]; then
|
||||
# Use virsh define to create a virtual machine from each XML file
|
||||
sudo virsh define "$root_vm"
|
||||
|
||||
# Check if the command was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully defined virtual machine from $root_vm"
|
||||
else
|
||||
echo "Failed to define virtual machine from $root_vm"
|
||||
fi
|
||||
else
|
||||
echo "No XML files found in directory: $SYSTEM"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished defining all root virtual machines."
|
||||
|
||||
# Directory containing XML definitions of virtual machines requiring user permissions
|
||||
SESSION="./session/"
|
||||
|
||||
# Ensure the directory exists
|
||||
if [ ! -d "$SESSION" ]; then
|
||||
echo "The specified directory does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Loop over each XML file in the directory
|
||||
for rootless_vm in "$SESSION"/*.xml; do
|
||||
if [ -f "$rootless_vm" ]; then
|
||||
# Use virsh define to create a virtual machine from each XML file
|
||||
virsh define "$rootless_vm"
|
||||
|
||||
# Check if the command was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully defined virtual machine from $rootless_vm"
|
||||
else
|
||||
echo "Failed to define virtual machine from $rootless_vm"
|
||||
fi
|
||||
else
|
||||
echo "No XML files found in directory: $SESSION"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished defining all rootless virtual machines."
|
@ -1,27 +1,27 @@
|
||||
<domain type='kvm'>
|
||||
<name>Linux5.15</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<name>linux515</name>
|
||||
<description>Rootless QEMU virtual machine model optimized for Linux guests running at least kernel 5.15. Secure boot is disabled</description>
|
||||
<memory unit="KiB">4194304</memory>
|
||||
<currentMemory unit="KiB">1048576</currentMemory>
|
||||
<memory unit="GiB">4</memory>
|
||||
<currentMemory unit="GiB">1</currentMemory>
|
||||
<memoryBacking>
|
||||
<source type="memfd"/>
|
||||
<access mode="shared"/>
|
||||
</memoryBacking>
|
||||
<vcpu placement='static'>4</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='q35'>hvm</type>
|
||||
<loader readonly='yes' secure='no' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
|
||||
<boot dev='cdrom'/>
|
||||
<os firmware="efi">
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<loader secure='no'/>
|
||||
<boot dev="cdrom"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<vmport state='off'/>
|
||||
</features>
|
||||
<cpu mode="host-passthrough" check="none" migratable="on">
|
||||
<cpu mode="host-model">
|
||||
<topology sockets="1" dies="1" cores="2" threads="2"/>
|
||||
</cpu>
|
||||
<clock offset='utc'>
|
||||
<timer name='rtc' tickpolicy='catchup'/>
|
||||
<timer name='pit' tickpolicy='delay'/>
|
||||
<timer name='hpet' present='no'/>
|
||||
<timer name='kvmclock' tickpolicy='catchup'/>
|
||||
</clock>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
@ -39,42 +39,50 @@
|
||||
<readonly/>
|
||||
</disk>
|
||||
<controller type='virtio-serial' index='0'>
|
||||
<model type='virtio-non-transitional'/>
|
||||
</controller>
|
||||
<smartcard mode='host'/>
|
||||
<interface type='user'>
|
||||
<backend type='passt'/>
|
||||
<model type='virtio'/>
|
||||
</interface>
|
||||
<console type='pty'>
|
||||
<target type='virtio' port='0'/>
|
||||
</console>
|
||||
<channel type="spicevmc">
|
||||
<target type="virtio" name="com.redhat.spice.0"/>
|
||||
<address type="virtio-serial" controller="0" bus="0" port="1"/>
|
||||
</channel>
|
||||
<channel type='unix'>
|
||||
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='2'/>
|
||||
</channel>
|
||||
<input type='keyboard' bus='virtio'>
|
||||
</input>
|
||||
<input type='tablet' bus='virtio'>
|
||||
<input type='mouse' bus='virtio'>
|
||||
</input>
|
||||
<tpm model="tpm-crb">
|
||||
<backend type="emulator" version="2.0"/>
|
||||
</tpm>
|
||||
<graphics type="spice">
|
||||
<listen type="none"/>
|
||||
<image compression="off"/>
|
||||
<graphics type="dbus">
|
||||
<gl enable="yes"/>
|
||||
<audio id="1"/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type="virtio" heads="1" primary="yes">
|
||||
<acceleration accel3d="yes"/>
|
||||
</model>
|
||||
</video>
|
||||
<memballoon model="virtio"/>
|
||||
<rng model='virtio'>
|
||||
<sound model="virtio"/>
|
||||
<memballoon model="virtio-non-transitional"/>
|
||||
<rng model="virtio-non-transitional">
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
</rng>
|
||||
<filesystem type="mount" accessmode="passthrough">
|
||||
<driver type="virtiofs"/>
|
||||
<source dir="/mnt"/>
|
||||
<target dir="mnt"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
<vsock model="virtio-non-transitional">
|
||||
<cid auto="yes"/>
|
||||
</vsock>
|
||||
<iommu model="virtio"/>
|
||||
</devices>
|
||||
</domain>
|
@ -1,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>Linux5.4</name>
|
||||
<name>linux54</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<description>Rootless QEMU virtual machine model optimized for Linux guests running at least kernel 5.4. Secure boot is disabled</description>
|
||||
<memory unit="KiB">4194304</memory>
|
||||
@ -71,6 +71,7 @@
|
||||
<acceleration accel3d="yes"/>
|
||||
</model>
|
||||
</video>
|
||||
<sound model="virtio"/>
|
||||
<memballoon model="virtio"/>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
@ -1,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>Linux5.15</name>
|
||||
<name>linux515</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<description>QEMU Virtual machine model optimized for Linux guests running at least kernel 5.15. Secure boot is disabled</description>
|
||||
<memory unit="KiB">4194304</memory>
|
||||
@ -9,10 +9,10 @@
|
||||
<access mode="shared"/>
|
||||
</memoryBacking>
|
||||
<vcpu placement='static'>4</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='q35'>hvm</type>
|
||||
<loader readonly='yes' secure='no' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
|
||||
<boot dev='cdrom'/>
|
||||
<os firmware="efi">
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<loader secure='no'/>
|
||||
<boot dev="cdrom"/>
|
||||
</os>
|
||||
<features>
|
||||
<acpi/>
|
||||
@ -80,12 +80,13 @@
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
</rng>
|
||||
<sound model="virtio"/>
|
||||
<filesystem type="mount" accessmode="passthrough">
|
||||
<driver type="virtiofs"/>
|
||||
<source dir="/mnt/"/>
|
||||
<target dir="share"/>
|
||||
<source dir="/var/lib/libvirt/isos/"/>
|
||||
<target dir="isos"/>
|
||||
<readonly/>
|
||||
</filesystem>
|
||||
<iommu model="virtio"/>
|
||||
</devices>
|
||||
</domain>
|
||||
|
||||
</domain>
|
@ -1,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>Linux5.4</name>
|
||||
<name>linux54</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<description>QEMU Virtual machine model optimized for Linux guests running at least kernel 5.4. Secure boot is disabled</description>
|
||||
<memory unit="KiB">4194304</memory>
|
||||
@ -76,6 +76,7 @@
|
||||
<acceleration accel3d="yes"/>
|
||||
</model>
|
||||
</video>
|
||||
<sound model="virtio"/>
|
||||
<memballoon model="virtio"/>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
@ -1,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>WindowsNT10</name>
|
||||
<name>windows10</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<description>QEMU virtual machine model optimized for Windows NT 10 guests such as Windows 10. Secure boot is disabled</description>
|
||||
<currentMemory unit='KiB'>4194304</currentMemory>
|
||||
@ -17,17 +17,22 @@
|
||||
<acpi/>
|
||||
<apic/>
|
||||
<hyperv mode="custom">
|
||||
<relaxed state="on"/>
|
||||
<vapic state="on"/>
|
||||
<spinlocks state="on" retries="8191"/>
|
||||
<vpindex state="on"/>
|
||||
<runtime state="on"/>
|
||||
<synic state="on"/>
|
||||
<stimer state="on"/>
|
||||
<vendor_id state='on' value='Phyllome OS'/>
|
||||
<frequencies state="on"/>
|
||||
<tlbflush state="on"/>
|
||||
<ipi state="on"/>
|
||||
<relaxed state='on'/>
|
||||
<vapic state='on'/>
|
||||
<spinlocks state='on' retries='4096'/>
|
||||
<vpindex state='on'/>
|
||||
<runtime state='on'/>
|
||||
<synic state='on'/>
|
||||
<stimer state='on'>
|
||||
<direct state='on'/>
|
||||
</stimer>
|
||||
<reset state='on'/>
|
||||
<frequencies state='on'/>
|
||||
<reenlightenment state='on'/>
|
||||
<tlbflush state='on'>
|
||||
<direct state='on'/>
|
||||
<extended state='on'/>
|
||||
</tlbflush>
|
||||
</hyperv>
|
||||
<kvm>
|
||||
<hidden state='on'/>
|
@ -1,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>WindowsNT11</name>
|
||||
<name>windows11</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<description>QEMU virtual machine model optimized for Windows NT 11 guests such as Windows 11. Secure boot is enabled</description>
|
||||
<currentMemory unit='KiB'>4194304</currentMemory>
|
||||
@ -19,18 +19,23 @@
|
||||
<hyperv mode="custom">
|
||||
<relaxed state="on"/>
|
||||
<vapic state="on"/>
|
||||
<spinlocks state="on" retries="8191"/>
|
||||
<spinlocks state="on" retries="4096"/>
|
||||
<vpindex state="on"/>
|
||||
<runtime state="on"/>
|
||||
<synic state="on"/>
|
||||
<stimer state="on"/>
|
||||
<vendor_id state='on' value='Phyllome OS'/>
|
||||
<stimer state="on">
|
||||
<direct state="on"/>
|
||||
</stimer>
|
||||
<reset state="on"/>
|
||||
<frequencies state="on"/>
|
||||
<tlbflush state="on"/>
|
||||
<ipi state="on"/>
|
||||
<reenlightenment state="on"/>
|
||||
<tlbflush state="on">
|
||||
<direct state="on"/>
|
||||
<extended state="on"/>
|
||||
</tlbflush>
|
||||
</hyperv>
|
||||
<kvm>
|
||||
<hidden state='on'/>
|
||||
<hidden state="on"/>
|
||||
</kvm>
|
||||
<vmport state="off"/>
|
||||
</features>
|
62
undefine-vms.sh
Executable file
62
undefine-vms.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Function to undefine a virtual machine. Takes just the VM name.
|
||||
# This makes it more robust and aligned with how virsh expects the name.
|
||||
undefine_vm() {
|
||||
local vm_name="$1"
|
||||
|
||||
# Use virsh undefine to undefine a virtual machine
|
||||
sudo virsh undefine "$vm_name"
|
||||
|
||||
# Check if the command was successful
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Successfully undefined virtual machine $vm_name"
|
||||
else
|
||||
echo "Failed to undefine virtual machine $vm_name"
|
||||
fi
|
||||
}
|
||||
|
||||
# Directory containing XML definitions of virtual machines requiring root permissions
|
||||
SYSTEM="./system/"
|
||||
|
||||
# Ensure the directory exists
|
||||
if [ ! -d "$SYSTEM" ]; then
|
||||
echo "The specified directory does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Loop over each XML file in the directory
|
||||
for root_vm in "$SYSTEM"/*.xml; do
|
||||
if [ -f "$root_vm" ]; then
|
||||
# Extract the VM name from the full path
|
||||
vm_name=$(basename "$root_vm" .xml) # Removes the .xml extension
|
||||
|
||||
# Call the undefine function
|
||||
undefine_vm "$vm_name"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished undefining all root virtual machines."
|
||||
|
||||
|
||||
# Directory containing XML definitions of virtual machines requiring user permissions
|
||||
SESSION="./session/"
|
||||
|
||||
# Ensure the directory exists
|
||||
if [ ! -d "$SESSION" ]; then
|
||||
echo "The specified directory does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Loop over each XML file in the directory
|
||||
for rootless_vm in "$SESSION"/*.xml; do # Corrected the pattern
|
||||
if [ -f "$rootless_vm" ]; then
|
||||
# Extract the VM name from the full path
|
||||
vm_name=$(basename "$rootless_vm" .xml) #remove .xml extension
|
||||
|
||||
# Call the undefine function
|
||||
virsh undefine "$vm_name"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Finished undefining all rootless virtual machines."
|
Reference in New Issue
Block a user