linuxinstall/src/xml.c

30 lines
809 B
C
Raw Normal View History

#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
return format(_xml, "<disk type='file' device='cdrom'>"
" <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);
}