aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2022-04-20 13:08:28 -0400
committerCara Salter <cara@devcara.com>2022-04-20 13:08:28 -0400
commit6b995785c780dd47cb0e02821001f446cf4ec211 (patch)
tree2bbe9147151056527468c1dcf70b6b98140ccb40 /templates
parent5978befd317189f1f18dddbab3db7ddd0061c236 (diff)
downloadsolarlib-6b995785c780dd47cb0e02821001f446cf4ec211.tar.gz
solarlib-6b995785c780dd47cb0e02821001f446cf4ec211.zip
house: Allow for the introduction of new VMs
Templates the XML and creates the disk images
Diffstat (limited to 'templates')
-rw-r--r--templates/vm.rs.xml83
1 files changed, 83 insertions, 0 deletions
diff --git a/templates/vm.rs.xml b/templates/vm.rs.xml
new file mode 100644
index 0000000..2004b35
--- /dev/null
+++ b/templates/vm.rs.xml
@@ -0,0 +1,83 @@
+@(name: String, uuid: String, mac_address: String, sata: bool, memory: u64, cpus: u64, seed: String)
+<domain type="kvm" xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
+ <name>@name</name>
+ <uuid>@uuid</uuid>
+ <metadata>
+ <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
+ <libosinfo:os id="http://nixos.org/nixos/unstable"/>
+ </libosinfo:libosinfo>
+ </metadata>
+ <memory>@memory</memory>
+ <currentMemory>@memory</currentMemory>
+ <vcpu>@cpus</vcpu>
+ <os>
+ <type arch="x86_64" machine="q35">hvm</type>
+ <boot dev="hd"/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <vmport state="off"/>
+ </features>
+ <cpu mode="host-model"/>
+ <clock offset="utc">
+ <timer name="rtc" tickpolicy="catchup"/>
+ <timer name="pit" tickpolicy="delay"/>
+ <timer name="hpet" present="no"/>
+ </clock>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <pm>
+ <suspend-to-mem enabled="no"/>
+ <suspend-to-disk enabled="no"/>
+ </pm>
+ <devices>
+ <emulator>/run/libvirt/nix-emulators/qemu-system-x86_64</emulator>
+ <disk type="block" device="disk">
+ <driver name="qemu" type="raw" cache="none" io="native"/>
+ <source file="/var/lib/libvirt/images/@name\.qcow2"/>
+ @if sata {
+ <target dev="sda" bus="sata"/>
+ } else {
+ <target dev="vda" bus="virtio"/>
+ }
+ </disk>
+ <controller type="usb" model="qemu-xhci" ports="15"/>
+ <interface type="network">
+ <source network="default"/>
+ <mac address="@mac_address"/>
+ @if sata {
+ <model type="e1000e"/>
+ <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
+ } else {
+ <model type="virtio"/>
+ }
+ </interface>
+ <console type="pty"/>
+ <channel type="unix">
+ <source mode="bind"/>
+ <target type="virtio" name="org.qemu.guest_agent.0"/>
+ </channel>
+ <channel type="spicevmc">
+ <target type="virtio" name="com.redhat.spice.0"/>
+ </channel>
+ <input type="tablet" bus="usb"/>
+ <graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
+ <sound model="ich9"/>
+ <video>
+ <model type="qxl"/>
+ </video>
+ <redirdev bus="usb" type="spicevmc"/>
+ <redirdev bus="usb" type="spicevmc"/>
+ <memballoon model="virtio"/>
+ <rng model="virtio">
+ <backend model="random">/dev/urandom</backend>
+ </rng>
+ </devices>
+ <qemu:commandline>
+ <qemu:arg value="-smbios" />
+ <qemu:arg value="type=1,serial=ds=nocloud-net;s=@seed" />
+ </qemu:commandline>
+</domain>
+