提交 46971d5e 编写于 作者: G Guido Günther

pass flags argument to all virDomain*DefParse* functions

上级 88053456
Thu Jan 8 14:41:55 CET 2009 Guido Günther <agx@sigxcpu.org>
pass flags argument to all virDomain*DefParse* functions
* src/domain_conf.c (virDomainDiskDefParseXML,
virDomainFSDefParseXML, virDomainNetDefParseXML,
virDomainChrDefParseXML, virDomainSoundDefParseXML,
virDomainHostdevSubsysUsbDefParseXML, virDomainHostdevDefParseXML,
virDomainDefParseString): Add and pass on flags argument
* src/domain_conf.h (virDomainDeviceDefParse,
virDomainDefParseString): Add flags argument
* src/lxc_driver.c (lxcDomainDefine): Pass VIR_DOMAIN_XML_INACTIVE
* src/openvz_driver.c (openvzDomainDefineXML): Likewise
* src/qemu_driver.c (qemudDomainCreate, qemudDomainRestore,
qemudDomainDefine, qemudDomainAttachDevice): Likewise
* src/test.c (testOpenDefault, testDomainCreateXML, testDomainRestore,
testDomainDefineXML): Likewise
* src/uml_driver.c (umlDomainCreate, umlDomainDefine): Likewise
* src/xend_internal.c (xenDaemonCreateXML, xenDaemonDomainCreateXML):
Likewise
* tests/qemuxml2xmltest.c (testCompareXMLToXMLFiles): Likewise
Thu Jan 8 09:48:04 CET 2009 Daniel P. Berrange <berrange@redhat.com>
poll: don't return uninitialized
......
......@@ -534,7 +534,8 @@ int virDomainDiskCompare(virDomainDiskDefPtr a,
*/
static virDomainDiskDefPtr
virDomainDiskDefParseXML(virConnectPtr conn,
xmlNodePtr node) {
xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
virDomainDiskDefPtr def;
xmlNodePtr cur;
char *type = NULL;
......@@ -721,7 +722,8 @@ cleanup:
*/
static virDomainFSDefPtr
virDomainFSDefParseXML(virConnectPtr conn,
xmlNodePtr node) {
xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
virDomainFSDefPtr def;
xmlNodePtr cur;
char *type = NULL;
......@@ -807,7 +809,8 @@ cleanup:
static virDomainNetDefPtr
virDomainNetDefParseXML(virConnectPtr conn,
virCapsPtr caps,
xmlNodePtr node) {
xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
virDomainNetDefPtr def;
xmlNodePtr cur;
char *macaddr = NULL;
......@@ -1038,7 +1041,8 @@ error:
*/
static virDomainChrDefPtr
virDomainChrDefParseXML(virConnectPtr conn,
xmlNodePtr node) {
xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
xmlNodePtr cur;
char *type = NULL;
char *bindHost = NULL;
......@@ -1257,7 +1261,8 @@ error:
static virDomainInputDefPtr
virDomainInputDefParseXML(virConnectPtr conn,
const char *ostype,
xmlNodePtr node) {
xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
virDomainInputDefPtr def;
char *type = NULL;
char *bus = NULL;
......@@ -1436,7 +1441,8 @@ error:
static virDomainSoundDefPtr
virDomainSoundDefParseXML(virConnectPtr conn,
const xmlNodePtr node) {
const xmlNodePtr node,
int flags ATTRIBUTE_UNUSED) {
char *model;
virDomainSoundDefPtr def;
......@@ -1467,7 +1473,8 @@ error:
static int
virDomainHostdevSubsysUsbDefParseXML(virConnectPtr conn,
const xmlNodePtr node,
virDomainHostdevDefPtr def) {
virDomainHostdevDefPtr def,
int flags ATTRIBUTE_UNUSED) {
int ret = -1;
xmlNodePtr cur;
......@@ -1667,7 +1674,8 @@ out:
static virDomainHostdevDefPtr
virDomainHostdevDefParseXML(virConnectPtr conn,
const xmlNodePtr node) {
const xmlNodePtr node,
int flags) {
xmlNodePtr cur;
virDomainHostdevDefPtr def;
......@@ -1709,7 +1717,8 @@ virDomainHostdevDefParseXML(virConnectPtr conn,
if (xmlStrEqual(cur->name, BAD_CAST "source")) {
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
if (virDomainHostdevSubsysUsbDefParseXML(conn, cur, def) < 0)
if (virDomainHostdevSubsysUsbDefParseXML(conn, cur,
def, flags) < 0)
goto error;
}
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
......@@ -1763,7 +1772,8 @@ static int virDomainLifecycleParseXML(virConnectPtr conn,
virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
virCapsPtr caps,
const virDomainDefPtr def,
const char *xmlStr)
const char *xmlStr,
int flags)
{
xmlDocPtr xml;
xmlNodePtr node;
......@@ -1790,27 +1800,28 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
dev->type = VIR_DOMAIN_DEVICE_DISK;
if (!(dev->data.disk = virDomainDiskDefParseXML(conn, node)))
if (!(dev->data.disk = virDomainDiskDefParseXML(conn, node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "filesystem")) {
dev->type = VIR_DOMAIN_DEVICE_FS;
if (!(dev->data.fs = virDomainFSDefParseXML(conn, node)))
if (!(dev->data.fs = virDomainFSDefParseXML(conn, node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "interface")) {
dev->type = VIR_DOMAIN_DEVICE_NET;
if (!(dev->data.net = virDomainNetDefParseXML(conn, caps, node)))
if (!(dev->data.net = virDomainNetDefParseXML(conn, caps, node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "input")) {
dev->type = VIR_DOMAIN_DEVICE_INPUT;
if (!(dev->data.input = virDomainInputDefParseXML(conn, def->os.type, node)))
if (!(dev->data.input = virDomainInputDefParseXML(conn, def->os.type,
node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "sound")) {
dev->type = VIR_DOMAIN_DEVICE_SOUND;
if (!(dev->data.sound = virDomainSoundDefParseXML(conn, node)))
if (!(dev->data.sound = virDomainSoundDefParseXML(conn, node, flags)))
goto error;
} else if (xmlStrEqual(node->name, BAD_CAST "hostdev")) {
dev->type = VIR_DOMAIN_DEVICE_HOSTDEV;
if (!(dev->data.hostdev = virDomainHostdevDefParseXML(conn, node)))
if (!(dev->data.hostdev = virDomainHostdevDefParseXML(conn, node, flags)))
goto error;
} else {
virDomainReportError(conn, VIR_ERR_XML_ERROR,
......@@ -2090,7 +2101,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(conn,
nodes[i]);
nodes[i],
flags);
if (!disk)
goto error;
......@@ -2110,7 +2122,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainFSDefPtr fs = virDomainFSDefParseXML(conn,
nodes[i]);
nodes[i],
flags);
if (!fs)
goto error;
......@@ -2129,7 +2142,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
for (i = 0 ; i < n ; i++) {
virDomainNetDefPtr net = virDomainNetDefParseXML(conn,
caps,
nodes[i]);
nodes[i],
flags);
if (!net)
goto error;
......@@ -2149,7 +2163,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(conn,
nodes[i]);
nodes[i],
flags);
if (!chr)
goto error;
......@@ -2168,7 +2183,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
for (i = 0 ; i < n ; i++) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(conn,
nodes[i]);
nodes[i],
flags);
if (!chr)
goto error;
......@@ -2179,7 +2195,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if ((node = virXPathNode(conn, "./devices/console[1]", ctxt)) != NULL) {
virDomainChrDefPtr chr = virDomainChrDefParseXML(conn,
node);
node,
flags);
if (!chr)
goto error;
......@@ -2217,7 +2234,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
for (i = 0 ; i < n ; i++) {
virDomainInputDefPtr input = virDomainInputDefParseXML(conn,
def->os.type,
nodes[i]);
nodes[i],
flags);
if (!input)
goto error;
......@@ -2292,7 +2310,8 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
for (i = 0 ; i < n ; i++) {
int collision = 0, j;
virDomainSoundDefPtr sound = virDomainSoundDefParseXML(conn,
nodes[i]);
nodes[i],
flags);
if (!sound)
goto error;
......@@ -2319,7 +2338,9 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
if (n && VIR_ALLOC_N(def->hostdevs, n) < 0)
goto no_memory;
for (i = 0 ; i < n ; i++) {
virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(conn, nodes[i]);
virDomainHostdevDefPtr hostdev = virDomainHostdevDefParseXML(conn,
nodes[i],
flags);
if (!hostdev)
goto error;
......@@ -2363,7 +2384,8 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
virDomainDefPtr virDomainDefParseString(virConnectPtr conn,
virCapsPtr caps,
const char *xmlStr)
const char *xmlStr,
int flags)
{
xmlParserCtxtPtr pctxt;
xmlDocPtr xml = NULL;
......@@ -2394,8 +2416,7 @@ virDomainDefPtr virDomainDefParseString(virConnectPtr conn,
goto cleanup;
}
def = virDomainDefParseNode(conn, caps, xml, root,
VIR_DOMAIN_XML_INACTIVE);
def = virDomainDefParseNode(conn, caps, xml, root, flags);
cleanup:
xmlFreeParserCtxt (pctxt);
......
......@@ -525,10 +525,12 @@ void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
virCapsPtr caps,
const virDomainDefPtr def,
const char *xmlStr);
const char *xmlStr,
int flags);
virDomainDefPtr virDomainDefParseString(virConnectPtr conn,
virCapsPtr caps,
const char *xmlStr);
const char *xmlStr,
int flags);
virDomainDefPtr virDomainDefParseFile(virConnectPtr conn,
virCapsPtr caps,
const char *filename,
......
......@@ -275,7 +275,8 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml)
virDomainPtr dom = NULL;
lxcDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
if ((def->nets != NULL) && !(driver->have_netns)) {
......@@ -1002,7 +1003,8 @@ lxcDomainCreateAndStart(virConnectPtr conn,
virDomainPtr dom = NULL;
lxcDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
if ((def->nets != NULL) && !(driver->have_netns)) {
......
......@@ -657,7 +657,8 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
prog[0] = NULL;
openvzDriverLock(driver);
if ((vmdef = virDomainDefParseString(conn, driver->caps, xml)) == NULL)
if ((vmdef = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
if (vmdef->os.init == NULL &&
......@@ -733,7 +734,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
progcreate[0] = NULL;
openvzDriverLock(driver);
if ((vmdef = virDomainDefParseString(conn, driver->caps, xml)) == NULL)
if ((vmdef = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
if (vmdef->os.init == NULL &&
......
......@@ -1689,7 +1689,8 @@ static virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
virDomainEventPtr event = NULL;
qemuDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
vm = virDomainFindByName(&driver->domains, def->name);
......@@ -2574,7 +2575,8 @@ static int qemudDomainRestore(virConnectPtr conn,
}
/* Create a domain from this XML */
if (!(def = virDomainDefParseString(conn, driver->caps, xml))) {
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("failed to parse XML"));
goto cleanup;
......@@ -2761,7 +2763,8 @@ static virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
int newVM = 1;
qemuDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
vm = virDomainFindByName(&driver->domains, def->name);
......@@ -3223,9 +3226,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
goto cleanup;
}
dev = virDomainDeviceDefParse(dom->conn,
driver->caps,
vm->def, xml);
dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml,
VIR_DOMAIN_XML_INACTIVE);
qemuDriverUnlock(driver);
if (dev == NULL)
goto cleanup;
......@@ -3361,7 +3363,8 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
goto cleanup;
}
dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml);
dev = virDomainDeviceDefParse(dom->conn, driver->caps, vm->def, xml,
VIR_DOMAIN_XML_INACTIVE);
qemuDriverUnlock(driver);
if (dev == NULL)
goto cleanup;
......@@ -3997,7 +4000,8 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
}
/* Parse the domain XML. */
if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml))) {
if (!(def = virDomainDefParseString(dconn, driver->caps, dom_xml,
VIR_DOMAIN_XML_INACTIVE))) {
qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("failed to parse XML"));
goto cleanup;
......
......@@ -242,7 +242,9 @@ static int testOpenDefault(virConnectPtr conn) {
privconn->nextDomID = 1;
if (!(domdef = virDomainDefParseString(conn, privconn->caps, defaultDomainXML)))
if (!(domdef = virDomainDefParseString(conn, privconn->caps,
defaultDomainXML,
VIR_DOMAIN_XML_INACTIVE)))
goto error;
if (!(domobj = virDomainAssignDef(conn, &privconn->domains, domdef))) {
virDomainDefFree(domdef);
......@@ -719,7 +721,8 @@ testDomainCreateXML(virConnectPtr conn, const char *xml,
virDomainObjPtr dom = NULL;
testDriverLock(privconn);
if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL)
if ((def = virDomainDefParseString(conn, privconn->caps, xml,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
if ((dom = virDomainAssignDef(conn, &privconn->domains,
......@@ -1211,7 +1214,8 @@ static int testDomainRestore(virConnectPtr conn,
xml[len] = '\0';
testDriverLock(privconn);
def = virDomainDefParseString(conn, privconn->caps, xml);
def = virDomainDefParseString(conn, privconn->caps, xml,
VIR_DOMAIN_XML_INACTIVE);
if (!def)
goto cleanup;
......@@ -1491,7 +1495,8 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn,
virDomainObjPtr dom = NULL;
testDriverLock(privconn);
if ((def = virDomainDefParseString(conn, privconn->caps, xml)) == NULL)
if ((def = virDomainDefParseString(conn, privconn->caps, xml,
VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto cleanup;
if ((dom = virDomainAssignDef(conn, &privconn->domains,
......
......@@ -1199,7 +1199,8 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml,
virDomainPtr dom = NULL;
umlDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
vm = virDomainFindByName(&driver->domains, def->name);
......@@ -1574,7 +1575,8 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) {
virDomainPtr dom = NULL;
umlDriverLock(driver);
if (!(def = virDomainDefParseString(conn, driver->caps, xml)))
if (!(def = virDomainDefParseString(conn, driver->caps, xml,
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
if (!(vm = virDomainAssignDef(conn,
......
......@@ -3772,7 +3772,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
if (!(def = virDomainDefParseString(conn,
priv->caps,
xmlDesc)))
xmlDesc,
VIR_DOMAIN_XML_INACTIVE)))
return (NULL);
if (!(sexpr = xenDaemonFormatSxpr(conn, def, priv->xendConfigVersion))) {
......@@ -4248,7 +4249,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
if (priv->xendConfigVersion < 3)
return(NULL);
if (!(def = virDomainDefParseString(conn, priv->caps, xmlDesc))) {
if (!(def = virDomainDefParseString(conn, priv->caps, xmlDesc,
VIR_DOMAIN_XML_INACTIVE))) {
virXendError(conn, VIR_ERR_XML_ERROR,
"%s", _("failed to parse domain description"));
return (NULL);
......
......@@ -32,7 +32,8 @@ static int testCompareXMLToXMLFiles(const char *xml) {
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
goto fail;
if (!(vmdef = virDomainDefParseString(NULL, driver.caps, xmlData)))
if (!(vmdef = virDomainDefParseString(NULL, driver.caps, xmlData,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
if (!(actual = virDomainDefFormat(NULL, vmdef, 0)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册