提交 4750c848 编写于 作者: P Peter Krempa

virCaps: get rid of "defaultInitPath" value in the virCaps struct

This gets rid of the parameter in favor of using the new callback
infrastructure to do the same stuff.

This patch implements the domain adjustment callback in the openVZ
driver and moves the check from the parser to a new validation method in
the callback infrastructure.
上级 a68d6726
......@@ -168,7 +168,6 @@ struct _virCaps {
int defaultDiskDriverType; /* enum virStorageFileFormat */
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
bool hasWideScsiBus;
const char *defaultInitPath;
};
......
......@@ -2479,6 +2479,21 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def,
}
static int
virDomainDefPostParseInternal(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED)
{
/* verify init path for container based domains */
if (STREQ(def->os.type, "exe") && !def->os.init) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("init binary must be specified"));
return -1;
}
return 0;
}
static int
virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def,
......@@ -2542,6 +2557,10 @@ virDomainDefPostParse(virDomainDefPtr def,
&data)) < 0)
return ret;
if ((ret = virDomainDefPostParseInternal(def, caps)) < 0)
return ret;
return 0;
}
......@@ -10333,18 +10352,6 @@ virDomainDefParseXML(xmlDocPtr xml,
if (STREQ(def->os.type, "exe")) {
def->os.init = virXPathString("string(./os/init[1])", ctxt);
if (!def->os.init) {
if (caps->defaultInitPath) {
def->os.init = strdup(caps->defaultInitPath);
if (!def->os.init) {
goto no_memory;
}
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("init binary must be specified"));
goto error;
}
}
def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt);
if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) {
......
......@@ -206,7 +206,6 @@ virCapsPtr openvzCapsInit(void)
NULL) == NULL)
goto no_memory;
caps->defaultInitPath = "/sbin/init";
caps->defaultConsoleTargetType = openvzDefaultConsoleType;
return caps;
......
......@@ -97,6 +97,29 @@ static void cmdExecFree(const char *cmdExec[])
}
}
static int
openvzDomainDefPostParse(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
/* fill the init path */
if (STREQ(def->os.type, "exe") && !def->os.init) {
if (!(def->os.init = strdup("/sbin/init"))) {
virReportOOMError();
return -1;
}
}
return 0;
}
virDomainDefParserConfig openvzDomainDefParserConfig = {
.domainPostParseCallback = openvzDomainDefPostParse,
};
/* generate arguments to create OpenVZ container
return -1 - error
0 - OK
......@@ -1453,7 +1476,8 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn,
if (!(driver->caps = openvzCapsInit()))
goto cleanup;
if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig,
NULL, NULL)))
goto cleanup;
if (openvzLoadDomains(driver) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册