Added some checks
This commit is contained in:
parent
18eefa93c3
commit
96944f1111
@ -3,7 +3,6 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "backing.h"
|
#include "backing.h"
|
||||||
#include "container.h"
|
#include "container.h"
|
||||||
#include "domain.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
12
src/xml.c
12
src/xml.c
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
result_t generate_domain_xml(char** _xml, const char* container, uint64_t memory, int vcpus, const char** pci_addresses, const char** iso_paths, int vnc_port, const char* vnc_password) {
|
result_t generate_domain_xml(char** _xml, const char* container, uint64_t memory, int vcpus, const char** pci_addresses, const char** iso_paths, int vnc_port, const char* vnc_password) {
|
||||||
// Initialize the output parameters
|
// Initialize the output parameters
|
||||||
@ -132,7 +134,14 @@ result_t generate_pci_xml(char** _xml, const char** pci_addresses) {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
// Generate the XML configuration for the PCI devices
|
// Generate the XML configuration for the PCI devices
|
||||||
|
errno = 0;
|
||||||
char* xml = strdup("");
|
char* xml = strdup("");
|
||||||
|
if (xml == NULL) {
|
||||||
|
for (int i = 0; pci_devices[i] != NULL; i++)
|
||||||
|
free(pci_devices[i]);
|
||||||
|
free(pci_devices);
|
||||||
|
return failure("Failed to allocate memory for the initial XML configuration (%s).", strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
// For each PCI device, generate the XML configuration, and append it to the result
|
// For each PCI device, generate the XML configuration, and append it to the result
|
||||||
for (int i = 0; pci_devices[i] != NULL; i++) {
|
for (int i = 0; pci_devices[i] != NULL; i++) {
|
||||||
@ -195,7 +204,10 @@ result_t generate_iso_xml(char** _xml, const char** iso_paths) {
|
|||||||
*_xml = NULL;
|
*_xml = NULL;
|
||||||
|
|
||||||
// Generate the XML configuration for the ISO images
|
// Generate the XML configuration for the ISO images
|
||||||
|
errno = 0;
|
||||||
char* xml = strdup("");
|
char* xml = strdup("");
|
||||||
|
if (xml == NULL)
|
||||||
|
return failure("Failed to allocate memory for the initial XML configuration (%s).", strerror(errno));
|
||||||
|
|
||||||
// For each ISO image, generate the XML configuration, and append it to the result
|
// For each ISO image, generate the XML configuration, and append it to the result
|
||||||
for (int i = 0; iso_paths[i] != NULL; i++) {
|
for (int i = 0; iso_paths[i] != NULL; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user