From 348ec01fc4e843cc591b59f49ed30a57199be1ec Mon Sep 17 00:00:00 2001 From: Ashley Yakeley Date: Mon, 1 Apr 2024 19:25:28 -0700 Subject: [PATCH] domain XML generation: add QEMU commandline (#18) --- CHANGELOG.md | 2 ++ checks/domain/template-windows-2/expected.xml | 6 +++++ checks/domain/template-windows-2/input.nix | 25 +++++++++++++++---- generate-xml/domain.nix | 6 +++++ generate-xml/generate.nix | 1 + 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8340eca..43229b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## [0.4.2] * Lib: + * XML generation: + * Allow QEMU `commandline` in domains * Domain Templates: * Fix defect in `storage_vol` in Windows template * add `virtio_drive` option for all diff --git a/checks/domain/template-windows-2/expected.xml b/checks/domain/template-windows-2/expected.xml index 81c3f9a..1803dc2 100644 --- a/checks/domain/template-windows-2/expected.xml +++ b/checks/domain/template-windows-2/expected.xml @@ -88,4 +88,10 @@ + + + + + + diff --git a/checks/domain/template-windows-2/input.nix b/checks/domain/template-windows-2/input.nix index 79943e7..6e1916b 100644 --- a/checks/domain/template-windows-2/input.nix +++ b/checks/domain/template-windows-2/input.nix @@ -1,8 +1,23 @@ lib: lib.domain.templates.windows + { + name = "test-windows-2"; + uuid = "a67f3ed6-fdad-462a-8c3b-d970db34d8da"; + storage_vol = { pool = "default"; volume = "win10.qcow2"; }; + install_vol = /Source/Win11_23H2_EnglishInternational_x64v2.iso; + nvram_path = /Storage/MyNVRAM.fd; + } // { - name = "test-windows-2"; - uuid = "a67f3ed6-fdad-462a-8c3b-d970db34d8da"; - storage_vol = { pool = "default"; volume = "win10.qcow2"; }; - install_vol = /Source/Win11_23H2_EnglishInternational_x64v2.iso; - nvram_path = /Storage/MyNVRAM.fd; + qemu-commandline = + { + arg = + [ + { value = "-newarg"; } + { value = "parameter"; } + ]; + env = + [ + { name = "ID"; value = "wibble"; } + { name = "BAR"; } + ]; + }; } diff --git a/generate-xml/domain.nix b/generate-xml/domain.nix index f7f3c71..a745447 100644 --- a/generate-xml/domain.nix +++ b/generate-xml/domain.nix @@ -279,6 +279,12 @@ let (subelem "memballoon" [ (subattr "model" typeString) ] [ addresselem ]) ] ) + (sub "qemu-commandline" (elem "commandline" + [ (attr "xmlns" (typeConstant "http://libvirt.org/schemas/domain/qemu/1.0")) ] + [ + (subelem "arg" [ (subattr "value" typeString) ] [ ]) + (subelem "env" [ (subattr "name" typeString) (subattr "value" typeString) ] [ ]) + ])) ]; in diff --git a/generate-xml/generate.nix b/generate-xml/generate.nix index da51da3..d97055a 100644 --- a/generate-xml/generate.nix +++ b/generate-xml/generate.nix @@ -37,6 +37,7 @@ rec subelem = etype: attrs: contents: sub etype (many (elem etype attrs contents)); + typeConstant = c: x: c; typeString = typeConvert "string" builtins.isString id; typeInt = typeConvert "int" builtins.isInt builtins.toString; typeBoolYesNo = typeConvert "bool" builtins.isBool yesno;