|
|
8c03ec |
From adafaa880b67f1025c64515352e5e851daa62ae9 Mon Sep 17 00:00:00 2001
|
|
|
8c03ec |
Message-Id: <adafaa880b67f1025c64515352e5e851daa62ae9@dist-git>
|
|
|
8c03ec |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Date: Fri, 21 May 2021 14:16:05 +0200
|
|
|
8c03ec |
Subject: [PATCH] conf: introduce virDomainDefParseBootInitOptions
|
|
|
8c03ec |
|
|
|
8c03ec |
Extract the code to it's own function.
|
|
|
8c03ec |
|
|
|
8c03ec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
8c03ec |
(cherry picked from commit b07116438c96fddfa00bdb57878a707240574b42)
|
|
|
8c03ec |
|
|
|
8c03ec |
Conflicts:
|
|
|
8c03ec |
src/conf/domain_conf.c
|
|
|
8c03ec |
- using VIR_ALLOC in downstream instead of g_new0
|
|
|
8c03ec |
|
|
|
8c03ec |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1929357
|
|
|
8c03ec |
|
|
|
8c03ec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
8c03ec |
Message-Id: <cb7f11437bdbc14b0791645c39c963118d0f9806.1621599207.git.phrdina@redhat.com>
|
|
|
8c03ec |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
8c03ec |
---
|
|
|
8c03ec |
src/conf/domain_conf.c | 115 +++++++++++++++++++++++------------------
|
|
|
8c03ec |
1 file changed, 64 insertions(+), 51 deletions(-)
|
|
|
8c03ec |
|
|
|
8c03ec |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
8c03ec |
index 444657c9a1..9eb418c7c0 100644
|
|
|
8c03ec |
--- a/src/conf/domain_conf.c
|
|
|
8c03ec |
+++ b/src/conf/domain_conf.c
|
|
|
8c03ec |
@@ -19302,76 +19302,89 @@ virDomainVcpuParse(virDomainDefPtr def,
|
|
|
8c03ec |
|
|
|
8c03ec |
|
|
|
8c03ec |
static int
|
|
|
8c03ec |
-virDomainDefParseBootOptions(virDomainDefPtr def,
|
|
|
8c03ec |
- xmlXPathContextPtr ctxt)
|
|
|
8c03ec |
+virDomainDefParseBootInitOptions(virDomainDefPtr def,
|
|
|
8c03ec |
+ xmlXPathContextPtr ctxt)
|
|
|
8c03ec |
{
|
|
|
8c03ec |
char *name = NULL;
|
|
|
8c03ec |
size_t i;
|
|
|
8c03ec |
int n;
|
|
|
8c03ec |
g_autofree xmlNodePtr *nodes = NULL;
|
|
|
8c03ec |
- g_autofree char *tmp = NULL;
|
|
|
8c03ec |
|
|
|
8c03ec |
- /*
|
|
|
8c03ec |
- * Booting options for different OS types....
|
|
|
8c03ec |
- *
|
|
|
8c03ec |
- * - A bootloader (and optional kernel+initrd) (xen)
|
|
|
8c03ec |
- * - A kernel + initrd (xen)
|
|
|
8c03ec |
- * - A boot device (and optional kernel+initrd) (hvm)
|
|
|
8c03ec |
- * - An init script (exe)
|
|
|
8c03ec |
- */
|
|
|
8c03ec |
+ def->os.init = virXPathString("string(./os/init[1])", ctxt);
|
|
|
8c03ec |
+ def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
|
|
|
8c03ec |
+ def->os.initdir = virXPathString("string(./os/initdir[1])", ctxt);
|
|
|
8c03ec |
+ def->os.inituser = virXPathString("string(./os/inituser[1])", ctxt);
|
|
|
8c03ec |
+ def->os.initgroup = virXPathString("string(./os/initgroup[1])", ctxt);
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
|
|
|
8c03ec |
- def->os.init = virXPathString("string(./os/init[1])", ctxt);
|
|
|
8c03ec |
- def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
|
|
|
8c03ec |
- def->os.initdir = virXPathString("string(./os/initdir[1])", ctxt);
|
|
|
8c03ec |
- def->os.inituser = virXPathString("string(./os/inituser[1])", ctxt);
|
|
|
8c03ec |
- def->os.initgroup = virXPathString("string(./os/initgroup[1])", ctxt);
|
|
|
8c03ec |
+ if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
|
|
|
8c03ec |
+ return -1;
|
|
|
8c03ec |
|
|
|
8c03ec |
- if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0)
|
|
|
8c03ec |
+ if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
|
|
|
8c03ec |
+ return -1;
|
|
|
8c03ec |
+ for (i = 0; i < n; i++) {
|
|
|
8c03ec |
+ if (!nodes[i]->children ||
|
|
|
8c03ec |
+ !nodes[i]->children->content) {
|
|
|
8c03ec |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
8c03ec |
+ _("No data supplied for <initarg> element"));
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
+ }
|
|
|
8c03ec |
+ def->os.initargv[i] = g_strdup((const char *)nodes[i]->children->content);
|
|
|
8c03ec |
+ }
|
|
|
8c03ec |
+ def->os.initargv[n] = NULL;
|
|
|
8c03ec |
+ VIR_FREE(nodes);
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (VIR_ALLOC_N(def->os.initargv, n+1) < 0)
|
|
|
8c03ec |
+ if ((n = virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0)
|
|
|
8c03ec |
+ return -1;
|
|
|
8c03ec |
+
|
|
|
8c03ec |
+ if (VIR_ALLOC_N(def->os.initenv, n+1) < 0)
|
|
|
8c03ec |
+ return -1;
|
|
|
8c03ec |
+ for (i = 0; i < n; i++) {
|
|
|
8c03ec |
+ if (!(name = virXMLPropString(nodes[i], "name"))) {
|
|
|
8c03ec |
+ virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
8c03ec |
+ _("No name supplied for <initenv> element"));
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
- for (i = 0; i < n; i++) {
|
|
|
8c03ec |
- if (!nodes[i]->children ||
|
|
|
8c03ec |
- !nodes[i]->children->content) {
|
|
|
8c03ec |
- virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
8c03ec |
- _("No data supplied for <initarg> element"));
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
- }
|
|
|
8c03ec |
- def->os.initargv[i] = g_strdup((const char *)nodes[i]->children->content);
|
|
|
8c03ec |
}
|
|
|
8c03ec |
- def->os.initargv[n] = NULL;
|
|
|
8c03ec |
- VIR_FREE(nodes);
|
|
|
8c03ec |
|
|
|
8c03ec |
- if ((n = virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0)
|
|
|
8c03ec |
+ if (!nodes[i]->children ||
|
|
|
8c03ec |
+ !nodes[i]->children->content) {
|
|
|
8c03ec |
+ virReportError(VIR_ERR_XML_ERROR,
|
|
|
8c03ec |
+ _("No value supplied for <initenv name='%s'> element"),
|
|
|
8c03ec |
+ name);
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
+ }
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (VIR_ALLOC_N(def->os.initenv, n+1) < 0)
|
|
|
8c03ec |
+ if (VIR_ALLOC(def->os.initenv[i]) < 0)
|
|
|
8c03ec |
return -1;
|
|
|
8c03ec |
- for (i = 0; i < n; i++) {
|
|
|
8c03ec |
- if (!(name = virXMLPropString(nodes[i], "name"))) {
|
|
|
8c03ec |
- virReportError(VIR_ERR_XML_ERROR, "%s",
|
|
|
8c03ec |
- _("No name supplied for <initenv> element"));
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
- }
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (!nodes[i]->children ||
|
|
|
8c03ec |
- !nodes[i]->children->content) {
|
|
|
8c03ec |
- virReportError(VIR_ERR_XML_ERROR,
|
|
|
8c03ec |
- _("No value supplied for <initenv name='%s'> element"),
|
|
|
8c03ec |
- name);
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
- }
|
|
|
8c03ec |
+ def->os.initenv[i]->name = name;
|
|
|
8c03ec |
+ def->os.initenv[i]->value = g_strdup((const char *)nodes[i]->children->content);
|
|
|
8c03ec |
+ }
|
|
|
8c03ec |
+ def->os.initenv[n] = NULL;
|
|
|
8c03ec |
|
|
|
8c03ec |
- if (VIR_ALLOC(def->os.initenv[i]) < 0)
|
|
|
8c03ec |
- return -1;
|
|
|
8c03ec |
+ return 0;
|
|
|
8c03ec |
+}
|
|
|
8c03ec |
|
|
|
8c03ec |
- def->os.initenv[i]->name = name;
|
|
|
8c03ec |
- def->os.initenv[i]->value = g_strdup((const char *)nodes[i]->children->content);
|
|
|
8c03ec |
- }
|
|
|
8c03ec |
- def->os.initenv[n] = NULL;
|
|
|
8c03ec |
- VIR_FREE(nodes);
|
|
|
8c03ec |
+
|
|
|
8c03ec |
+static int
|
|
|
8c03ec |
+virDomainDefParseBootOptions(virDomainDefPtr def,
|
|
|
8c03ec |
+ xmlXPathContextPtr ctxt)
|
|
|
8c03ec |
+{
|
|
|
8c03ec |
+ int n;
|
|
|
8c03ec |
+ g_autofree xmlNodePtr *nodes = NULL;
|
|
|
8c03ec |
+ g_autofree char *tmp = NULL;
|
|
|
8c03ec |
+
|
|
|
8c03ec |
+ /*
|
|
|
8c03ec |
+ * Booting options for different OS types....
|
|
|
8c03ec |
+ *
|
|
|
8c03ec |
+ * - A bootloader (and optional kernel+initrd) (xen)
|
|
|
8c03ec |
+ * - A kernel + initrd (xen)
|
|
|
8c03ec |
+ * - A boot device (and optional kernel+initrd) (hvm)
|
|
|
8c03ec |
+ * - An init script (exe)
|
|
|
8c03ec |
+ */
|
|
|
8c03ec |
+
|
|
|
8c03ec |
+ if (def->os.type == VIR_DOMAIN_OSTYPE_EXE) {
|
|
|
8c03ec |
+ if (virDomainDefParseBootInitOptions(def, ctxt) < 0)
|
|
|
8c03ec |
+ return -1;
|
|
|
8c03ec |
}
|
|
|
8c03ec |
|
|
|
8c03ec |
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
|
|
|
8c03ec |
--
|
|
|
8c03ec |
2.31.1
|
|
|
8c03ec |
|