Compare commits
3 Commits
1c6ab98227
...
a80d97d3ab
Author | SHA1 | Date | |
---|---|---|---|
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,5 +1,5 @@
|
||||
<domain type='kvm'>
|
||||
<name>Linux5.15</name>
|
||||
<name>linux515</name>
|
||||
<memory unit='KiB'>4194304</memory>
|
||||
<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>
|
@ -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>
|
@ -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>
|
@ -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>
|
@ -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>
|
@ -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>
|
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