2024-02-20 23:06:02 +01:00
|
|
|
#include "xml.h"
|
|
|
|
|
|
|
|
result_t generate_iso_xml(char** _xml, char* iso_path, int index) {
|
|
|
|
// Initialize the output parameters
|
|
|
|
*_xml = NULL;
|
|
|
|
|
|
|
|
if (index > 25)
|
|
|
|
return failure("Too many ISO images");
|
|
|
|
|
|
|
|
// Generate the XML
|
2024-02-20 23:48:09 +01:00
|
|
|
return format(_xml, "<disk type='file' device='cdrom'>"
|
2024-02-20 23:06:02 +01:00
|
|
|
" <driver name='qemu' type='raw'/>"
|
|
|
|
" <source file='%s'/>"
|
|
|
|
" <target dev='sd%c' bus='sata'/>"
|
|
|
|
" <readonly/>"
|
|
|
|
"</disk>",
|
|
|
|
iso_path, 'a' + index);
|
|
|
|
}
|
|
|
|
|
|
|
|
result_t generate_vnc_xml(char** _xml, int vnc_port, char* password) {
|
|
|
|
// Initialize the output parameters
|
|
|
|
*_xml = NULL;
|
|
|
|
|
|
|
|
// Generate the XML
|
|
|
|
if (vnc_port == -1)
|
|
|
|
return format(_xml, "<graphics type='none'/>");
|
|
|
|
else
|
|
|
|
return format(_xml, "<graphics type='vnc' port='%d' autoport='no' listen='0.0.0.0' passwd='%s'/>", vnc_port, password);
|
|
|
|
}
|