Skip to content

Commit

Permalink
domain XML generation: add QEMU commandline (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyYakeley committed Apr 2, 2024
1 parent 0af44a3 commit 348ec01
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions checks/domain/template-windows-2/expected.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
</devices>
<commandline xmlns='http://libvirt.org/schemas/domain/qemu/1.0'>
<arg value='-newarg'/>
<arg value='parameter'/>
<env name='ID' value='wibble'/>
<env name='BAR'/>
</commandline>
</domain>
25 changes: 20 additions & 5 deletions checks/domain/template-windows-2/input.nix
Original file line number Diff line number Diff line change
@@ -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"; }
];
};
}
6 changes: 6 additions & 0 deletions generate-xml/domain.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions generate-xml/generate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 348ec01

Please sign in to comment.