[libvirt] [PATCH v5.1 00/11] Introduce driver specific XML parsing callbacks

In this respin the renaming patch is moved to be first in the series. The argument rearrangement patch was too complicated to move. Unfortunately this rebase operation caused my "git notes" to be lost for the individual patches, so please see v5 for more specific comments. Patches 5 to 11 except for 10 were ACKed in previous versions. Peter Krempa (11): maint: Rename xmlconf to xmlopt and virDomainXMLConfing to virDomainXMLOption conf: Add post XML parse callbacks and prepare for cleaning of virCaps conf callback: Rearrange function parameters qemu: Record the default NIC model in the domain XML virCaps: get rid of "defaultInitPath" value in the virCaps struct virCaps: get rid of defaultDiskDriverName virCaps: get rid of emulatorRequired virCaps: get rid of defaultDiskDriverType virCaps: get rid of hasWideScsiBus virCaps: get rid of macPrefix field virCaps: get rid of defaultConsoleTargetType callback src/conf/capabilities.c | 24 - src/conf/capabilities.h | 23 - src/conf/domain_conf.c | 660 ++++++++++++--------- src/conf/domain_conf.h | 102 ++-- src/conf/snapshot_conf.c | 4 +- src/conf/snapshot_conf.h | 2 +- src/esx/esx_driver.c | 32 +- src/esx/esx_private.h | 2 +- src/libvirt_private.syms | 10 +- src/libvirt_vmx.syms | 1 + src/libxl/libxl_conf.c | 13 - src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_driver.c | 103 ++-- src/lxc/lxc_conf.c | 21 +- src/lxc/lxc_conf.h | 4 +- src/lxc/lxc_controller.c | 10 +- src/lxc/lxc_domain.c | 34 ++ src/lxc/lxc_domain.h | 1 + src/lxc/lxc_driver.c | 71 ++- src/lxc/lxc_process.c | 8 +- src/openvz/openvz_conf.c | 16 +- src/openvz/openvz_conf.h | 2 +- src/openvz/openvz_driver.c | 64 +- src/parallels/parallels_driver.c | 37 +- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 24 +- src/phyp/phyp_driver.h | 2 +- src/qemu/qemu_capabilities.c | 19 - src/qemu/qemu_command.c | 27 +- src/qemu/qemu_command.h | 6 +- src/qemu/qemu_conf.c | 18 +- src/qemu/qemu_conf.h | 5 +- src/qemu/qemu_domain.c | 98 ++- src/qemu/qemu_domain.h | 1 + src/qemu/qemu_driver.c | 147 +++-- src/qemu/qemu_migration.c | 21 +- src/qemu/qemu_process.c | 34 +- src/security/virt-aa-helper.c | 19 +- src/test/test_driver.c | 67 +-- src/uml/uml_conf.c | 9 - src/uml/uml_conf.h | 2 +- src/uml/uml_driver.c | 69 ++- src/vbox/vbox_tmpl.c | 33 +- src/vmware/vmware_conf.c | 21 +- src/vmware/vmware_conf.h | 2 +- src/vmware/vmware_driver.c | 24 +- src/vmx/vmx.c | 39 +- src/vmx/vmx.h | 12 +- src/xen/xen_driver.c | 37 +- src/xen/xen_driver.h | 4 +- src/xen/xen_hypervisor.c | 13 - src/xen/xend_internal.c | 20 +- src/xen/xm_internal.c | 16 +- src/xenapi/xenapi_driver.c | 40 +- src/xenapi/xenapi_driver_private.h | 2 +- tests/domainsnapshotxml2xmltest.c | 6 +- tests/lxcxml2xmldata/lxc-hostdev.xml | 1 + tests/lxcxml2xmldata/lxc-systemd.xml | 1 + tests/lxcxml2xmltest.c | 8 +- tests/qemuargv2xmltest.c | 6 +- tests/qemumonitorjsontest.c | 28 +- tests/qemumonitortestutils.c | 4 +- tests/qemumonitortestutils.h | 2 +- ...qemuxml2argv-disk-drive-network-nbd-export.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-export.xml | 1 + ...ml2argv-disk-drive-network-nbd-ipv6-export.args | 3 +- ...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-unix.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-unix.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd.args | 5 +- .../qemuxml2argv-disk-drive-network-nbd.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd-auth.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd.xml | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.args | 3 +- .../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 +- .../qemuxml2argv-net-eth-ifname.args | 4 +- .../qemuxml2argv-net-eth-ifname.xml | 1 + .../qemuxml2argv-net-eth-names.args | 8 +- tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 +- tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 +- .../qemuxml2argv-net-openvswitch.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 +- tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 +- tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 + .../qemuxml2argv-net-virtio-network-portgroup.xml | 2 + tests/qemuxml2argvtest.c | 6 +- .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + tests/qemuxml2xmltest.c | 6 +- tests/qemuxmlnstest.c | 6 +- tests/securityselinuxlabeltest.c | 6 +- tests/testutilslxc.c | 9 - tests/testutilsqemu.c | 11 - tests/testutilsqemu.h | 2 +- tests/testutilsxen.c | 16 - tests/testutilsxen.h | 2 - tests/vmx2xmltest.c | 17 +- tests/xmconfigtest.c | 8 +- tests/xml2sexprtest.c | 9 +- tests/xml2vmxtest.c | 20 +- 108 files changed, 1275 insertions(+), 1052 deletions(-) -- 1.8.1.5

This patch is the result of running: for i in $(git ls-files | grep -v html | grep -v \.po$ ); do sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i done and a few manual tweaks. --- src/conf/capabilities.h | 2 +- src/conf/domain_conf.c | 142 ++++++++++++++++++------------------- src/conf/domain_conf.h | 34 ++++----- src/conf/snapshot_conf.c | 4 +- src/conf/snapshot_conf.h | 2 +- src/esx/esx_driver.c | 10 +-- src/esx/esx_private.h | 2 +- src/libvirt_private.syms | 4 +- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_driver.c | 40 +++++------ src/lxc/lxc_conf.c | 4 +- src/lxc/lxc_conf.h | 4 +- src/lxc/lxc_controller.c | 8 +-- src/lxc/lxc_driver.c | 38 +++++----- src/lxc/lxc_process.c | 8 +-- src/openvz/openvz_conf.c | 4 +- src/openvz/openvz_conf.h | 2 +- src/openvz/openvz_driver.c | 12 ++-- src/parallels/parallels_driver.c | 10 +-- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 6 +- src/phyp/phyp_driver.h | 2 +- src/qemu/qemu_command.c | 12 ++-- src/qemu/qemu_command.h | 6 +- src/qemu/qemu_conf.c | 4 +- src/qemu/qemu_conf.h | 4 +- src/qemu/qemu_domain.c | 4 +- src/qemu/qemu_driver.c | 104 +++++++++++++-------------- src/qemu/qemu_migration.c | 16 ++--- src/qemu/qemu_process.c | 34 ++++----- src/security/virt-aa-helper.c | 8 +-- src/test/test_driver.c | 40 +++++------ src/uml/uml_conf.h | 2 +- src/uml/uml_driver.c | 20 +++--- src/vbox/vbox_tmpl.c | 14 ++-- src/vmware/vmware_conf.c | 4 +- src/vmware/vmware_conf.h | 2 +- src/vmware/vmware_driver.c | 14 ++-- src/xen/xen_driver.c | 6 +- src/xen/xen_driver.h | 2 +- src/xen/xend_internal.c | 4 +- src/xen/xm_internal.c | 2 +- src/xenapi/xenapi_driver.c | 10 +-- src/xenapi/xenapi_driver_private.h | 2 +- tests/domainsnapshotxml2xmltest.c | 6 +- tests/lxcxml2xmltest.c | 8 +-- tests/qemuargv2xmltest.c | 6 +- tests/qemumonitorjsontest.c | 28 ++++---- tests/qemumonitortestutils.c | 4 +- tests/qemumonitortestutils.h | 2 +- tests/qemuxml2argvtest.c | 6 +- tests/qemuxml2xmltest.c | 6 +- tests/qemuxmlnstest.c | 6 +- tests/securityselinuxlabeltest.c | 6 +- tests/testutilsqemu.h | 2 +- tests/testutilsxen.c | 4 +- tests/testutilsxen.h | 2 +- tests/xmconfigtest.c | 8 +-- tests/xml2sexprtest.c | 8 +-- tests/xml2vmxtest.c | 8 +-- 60 files changed, 383 insertions(+), 383 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index a70896a..8abe88a 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -161,7 +161,7 @@ struct _virCaps { size_t nguests_max; virCapsGuestPtr *guests; - /* Move to virDomainXMLConf later */ + /* Move to virDomainXMLOption later */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; unsigned int emulatorRequired : 1; const char *defaultDiskDriverName; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cc26f21..6714a8c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -70,7 +70,7 @@ struct _virDomainObjList { /* This structure holds various callbacks and data needed * while parsing and creating domain XMLs */ -struct _virDomainXMLConf { +struct _virDomainXMLOption { virObject parent; /* domain private data management callbacks */ @@ -720,7 +720,7 @@ VIR_ENUM_IMPL(virDomainRNGBackend, static virClassPtr virDomainObjClass; static virClassPtr virDomainObjListClass; -static virClassPtr virDomainXMLConfClass; +static virClassPtr virDomainXMLOptionClass; static void virDomainObjDispose(void *obj); static void virDomainObjListDispose(void *obj); @@ -738,10 +738,10 @@ static int virDomainObjOnceInit(void) virDomainObjListDispose))) return -1; - if (!(virDomainXMLConfClass = virClassNew(virClassForObject(), - "virDomainXMLConf", - sizeof(virDomainXMLConf), - NULL))) + if (!(virDomainXMLOptionClass = virClassNew(virClassForObject(), + "virDomainXMLOption", + sizeof(virDomainXMLOption), + NULL))) return -1; return 0; @@ -751,43 +751,43 @@ VIR_ONCE_GLOBAL_INIT(virDomainObj) /** - * virDomainXMLConfNew: + * virDomainXMLOptionNew: * * Allocate a new domain XML configuration */ -virDomainXMLConfPtr -virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, - virDomainXMLNamespacePtr xmlns) +virDomainXMLOptionPtr +virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv, + virDomainXMLNamespacePtr xmlns) { - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; if (virDomainObjInitialize() < 0) return NULL; - if (!(xmlconf = virObjectNew(virDomainXMLConfClass))) + if (!(xmlopt = virObjectNew(virDomainXMLOptionClass))) return NULL; if (priv) - xmlconf->privateData = *priv; + xmlopt->privateData = *priv; if (xmlns) - xmlconf->ns = *xmlns; + xmlopt->ns = *xmlns; - return xmlconf; + return xmlopt; } /** - * virDomainXMLConfGetNamespace: + * virDomainXMLOptionGetNamespace: * - * @xmlconf: XML parser configuration object + * @xmlopt: XML parser configuration object * * Returns a pointer to the stored namespace structure. - * The lifetime of the pointer is equal to @xmlconf; + * The lifetime of the pointer is equal to @xmlopt; */ virDomainXMLNamespacePtr -virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) +virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) { - return &xmlconf->ns; + return &xmlopt->ns; } @@ -1901,7 +1901,7 @@ static void virDomainObjDispose(void *obj) } virDomainObjPtr -virDomainObjNew(virDomainXMLConfPtr xmlconf) +virDomainObjNew(virDomainXMLOptionPtr xmlopt) { virDomainObjPtr domain; @@ -1911,12 +1911,12 @@ virDomainObjNew(virDomainXMLConfPtr xmlconf) if (!(domain = virObjectLockableNew(virDomainObjClass))) return NULL; - if (xmlconf->privateData.alloc) { - if (!(domain->privateData = (xmlconf->privateData.alloc)())) { + if (xmlopt->privateData.alloc) { + if (!(domain->privateData = (xmlopt->privateData.alloc)())) { virReportOOMError(); goto error; } - domain->privateDataFreeFunc = xmlconf->privateData.free; + domain->privateDataFreeFunc = xmlopt->privateData.free; } if (!(domain->snapshots = virDomainSnapshotObjListNew())) @@ -1982,7 +1982,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, */ static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2032,7 +2032,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } - if (!(vm = virDomainObjNew(xmlconf))) + if (!(vm = virDomainObjNew(xmlopt))) goto cleanup; vm->def = def; @@ -2053,7 +2053,7 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef) @@ -2061,7 +2061,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainObjPtr ret; virObjectLock(doms); - ret = virDomainObjListAddLocked(doms, xmlconf, def, flags, oldDef); + ret = virDomainObjListAddLocked(doms, xmlopt, def, flags, oldDef); virObjectUnlock(doms); return ret; } @@ -2080,7 +2080,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, */ int virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, bool live) { @@ -2095,7 +2095,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; - if (!(domain->newDef = virDomainDefCopy(caps, xmlconf, domain->def, false))) + if (!(domain->newDef = virDomainDefCopy(caps, xmlopt, domain->def, false))) goto out; ret = 0; @@ -2113,10 +2113,10 @@ out: */ virDomainDefPtr virDomainObjGetPersistentDef(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain) { - if (virDomainObjSetDefTransient(caps, xmlconf, domain, false) < 0) + if (virDomainObjSetDefTransient(caps, xmlopt, domain, false) < 0) return NULL; if (domain->newDef) @@ -2134,7 +2134,7 @@ virDomainObjGetPersistentDef(virCapsPtr caps, */ int virDomainLiveConfigHelperMethod(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef) @@ -2165,7 +2165,7 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, "transient domain")); goto cleanup; } - if (!(*persistentDef = virDomainObjGetPersistentDef(caps, xmlconf, dom))) { + if (!(*persistentDef = virDomainObjGetPersistentDef(caps, xmlopt, dom))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Get persistent config failed")); goto cleanup; @@ -9380,7 +9380,7 @@ cleanup: static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, @@ -11019,7 +11019,7 @@ virDomainDefParseXML(virCapsPtr caps, /* we have to make a copy of all of the callback pointers here since * we won't have the virCaps structure available during free */ - def->ns = xmlconf->ns; + def->ns = xmlopt->ns; if (def->ns.parse && (def->ns.parse)(xml, root, ctxt, &def->namespaceData) < 0) @@ -11046,7 +11046,7 @@ error: static virDomainObjPtr virDomainObjParseXML(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, xmlDocPtr xml, xmlXPathContextPtr ctxt, unsigned int expectedVirtTypes, @@ -11062,7 +11062,7 @@ virDomainObjParseXML(virCapsPtr caps, int state; int reason = 0; - if (!(obj = virDomainObjNew(xmlconf))) + if (!(obj = virDomainObjNew(xmlopt))) return NULL; if (!(config = virXPathNode("./domain", ctxt))) { @@ -11073,7 +11073,7 @@ virDomainObjParseXML(virCapsPtr caps, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(caps, xmlconf, xml, config, ctxt, expectedVirtTypes, + obj->def = virDomainDefParseXML(caps, xmlopt, xml, config, ctxt, expectedVirtTypes, flags); ctxt->node = oldnode; if (!obj->def) @@ -11130,8 +11130,8 @@ virDomainObjParseXML(virCapsPtr caps, } VIR_FREE(nodes); - if (xmlconf->privateData.parse && - ((xmlconf->privateData.parse)(ctxt, obj->privateData)) < 0) + if (xmlopt->privateData.parse && + ((xmlopt->privateData.parse)(ctxt, obj->privateData)) < 0) goto error; return obj; @@ -11147,7 +11147,7 @@ static virDomainDefPtr virDomainDefParse(const char *xmlStr, const char *filename, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11156,7 +11156,7 @@ virDomainDefParse(const char *xmlStr, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { - def = virDomainDefParseNode(caps, xmlconf, xml, xmlDocGetRootElement(xml), + def = virDomainDefParseNode(caps, xmlopt, xml, xmlDocGetRootElement(xml), expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -11167,30 +11167,30 @@ virDomainDefParse(const char *xmlStr, virDomainDefPtr virDomainDefParseString(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, xmlconf, + return virDomainDefParse(xmlStr, NULL, caps, xmlopt, expectedVirtTypes, flags); } virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(NULL, filename, caps, xmlconf, + return virDomainDefParse(NULL, filename, caps, xmlopt, expectedVirtTypes, flags); } virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, xmlDocPtr xml, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -11214,7 +11214,7 @@ virDomainDefParseNode(virCapsPtr caps, } ctxt->node = root; - def = virDomainDefParseXML(caps, xmlconf, xml, root, ctxt, + def = virDomainDefParseXML(caps, xmlopt, xml, root, ctxt, expectedVirtTypes, flags); cleanup: @@ -11225,7 +11225,7 @@ cleanup: static virDomainObjPtr virDomainObjParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, xmlDocPtr xml, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -11248,7 +11248,7 @@ virDomainObjParseNode(virCapsPtr caps, } ctxt->node = root; - obj = virDomainObjParseXML(caps, xmlconf, xml, ctxt, expectedVirtTypes, flags); + obj = virDomainObjParseXML(caps, xmlopt, xml, ctxt, expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11258,7 +11258,7 @@ cleanup: static virDomainObjPtr virDomainObjParseFile(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *filename, unsigned int expectedVirtTypes, unsigned int flags) @@ -11268,7 +11268,7 @@ virDomainObjParseFile(virCapsPtr caps, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParseFile(filename))) { - obj = virDomainObjParseNode(caps, xmlconf, xml, + obj = virDomainObjParseNode(caps, xmlopt, xml, xmlDocGetRootElement(xml), expectedVirtTypes, flags); xmlFreeDoc(xml); @@ -15243,7 +15243,7 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags) static char * -virDomainObjFormat(virDomainXMLConfPtr xmlconf, +virDomainObjFormat(virDomainXMLOptionPtr xmlopt, virDomainObjPtr obj, unsigned int flags) { @@ -15264,8 +15264,8 @@ virDomainObjFormat(virDomainXMLConfPtr xmlconf, virDomainTaintTypeToString(i)); } - if (xmlconf->privateData.format && - ((xmlconf->privateData.format)(&buf, obj->privateData)) < 0) + if (xmlopt->privateData.format && + ((xmlopt->privateData.format)(&buf, obj->privateData)) < 0) goto error; virBufferAdjustIndent(&buf, 2); @@ -15388,7 +15388,7 @@ cleanup: } int -virDomainSaveStatus(virDomainXMLConfPtr xmlconf, +virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, const char *statusDir, virDomainObjPtr obj) { @@ -15400,7 +15400,7 @@ virDomainSaveStatus(virDomainXMLConfPtr xmlconf, int ret = -1; char *xml; - if (!(xml = virDomainObjFormat(xmlconf, obj, flags))) + if (!(xml = virDomainObjFormat(xmlopt, obj, flags))) goto cleanup; if (virDomainSaveXML(statusDir, obj->def, xml)) @@ -15416,7 +15416,7 @@ cleanup: static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, const char *name, @@ -15432,7 +15432,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if (!(def = virDomainDefParseFile(caps, xmlconf, configFile, + if (!(def = virDomainDefParseFile(caps, xmlopt, configFile, expectedVirtTypes, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -15443,7 +15443,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(dom = virDomainObjListAddLocked(doms, xmlconf, def, 0, &oldDef))) + if (!(dom = virDomainObjListAddLocked(doms, xmlopt, def, 0, &oldDef))) goto error; dom->autostart = autostart; @@ -15466,7 +15466,7 @@ error: static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *statusDir, const char *name, unsigned int expectedVirtTypes, @@ -15480,7 +15480,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(caps, xmlconf, statusFile, expectedVirtTypes, + if (!(obj = virDomainObjParseFile(caps, xmlopt, statusFile, expectedVirtTypes, VIR_DOMAIN_XML_INTERNAL_STATUS | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES))) @@ -15513,7 +15513,7 @@ error: int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, int liveStatus, @@ -15552,7 +15552,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, if (liveStatus) dom = virDomainObjListLoadStatus(doms, caps, - xmlconf, + xmlopt, configDir, entry->d_name, expectedVirtTypes, @@ -15561,7 +15561,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, else dom = virDomainObjListLoadConfig(doms, caps, - xmlconf, + xmlopt, configDir, autostartDir, entry->d_name, @@ -15955,7 +15955,7 @@ cleanup: * snapshots). */ virDomainDefPtr virDomainDefCopy(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainDefPtr src, bool migratable) { @@ -15971,7 +15971,7 @@ virDomainDefCopy(virCapsPtr caps, if (!(xml = virDomainDefFormat(src, write_flags))) return NULL; - ret = virDomainDefParseString(caps, xmlconf, xml, -1, read_flags); + ret = virDomainDefParseString(caps, xmlopt, xml, -1, read_flags); VIR_FREE(xml); return ret; @@ -15979,13 +15979,13 @@ virDomainDefCopy(virCapsPtr caps, virDomainDefPtr virDomainObjCopyPersistentDef(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom) { virDomainDefPtr cur; - cur = virDomainObjGetPersistentDef(caps, xmlconf, dom); - return virDomainDefCopy(caps, xmlconf, cur, false); + cur = virDomainObjGetPersistentDef(caps, xmlopt, dom); + return virDomainDefCopy(caps, xmlopt, cur, false); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index edddf25..5fb2023 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1930,8 +1930,8 @@ typedef virDomainObjList *virDomainObjListPtr; /* This structure holds various callbacks and data needed * while parsing and creating domain XMLs */ -typedef struct _virDomainXMLConf virDomainXMLConf; -typedef virDomainXMLConf *virDomainXMLConfPtr; +typedef struct _virDomainXMLOption virDomainXMLOption; +typedef virDomainXMLOption *virDomainXMLOptionPtr; typedef void *(*virDomainXMLPrivateDataAllocFunc)(void); typedef void (*virDomainXMLPrivateDataFreeFunc)(void *); @@ -1947,12 +1947,12 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataParseFunc parse; }; -virDomainXMLConfPtr -virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, +virDomainXMLOptionPtr +virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns); virDomainXMLNamespacePtr -virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) +virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) ATTRIBUTE_NONNULL(1); static inline bool @@ -1961,7 +1961,7 @@ virDomainObjIsActive(virDomainObjPtr dom) return dom->def->id != -1; } -virDomainObjPtr virDomainObjNew(virDomainXMLConfPtr caps) +virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps) ATTRIBUTE_NONNULL(1); virDomainObjListPtr virDomainObjListNew(void); @@ -2038,7 +2038,7 @@ enum { VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1), }; virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, unsigned int flags, virDomainDefPtr *oldDef); @@ -2047,25 +2047,25 @@ void virDomainObjAssignDef(virDomainObjPtr domain, bool live, virDomainDefPtr *oldDef); int virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, bool live); virDomainDefPtr virDomainObjGetPersistentDef(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain); int virDomainLiveConfigHelperMethod(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef); -virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainXMLConfPtr xmlconf, +virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, virDomainDefPtr src, bool migratable); virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLConfPtr xmlconf, +virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom); void virDomainObjListRemove(virDomainObjListPtr doms, @@ -2076,17 +2076,17 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, const char *xmlStr, unsigned int flags); virDomainDefPtr virDomainDefParseString(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *filename, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, xmlDocPtr doc, xmlNodePtr root, unsigned int expectedVirtTypes, @@ -2203,7 +2203,7 @@ int virDomainSaveXML(const char *configDir, int virDomainSaveConfig(const char *configDir, virDomainDefPtr def); -int virDomainSaveStatus(virDomainXMLConfPtr xmlconf, +int virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, const char *statusDir, virDomainObjPtr obj) ATTRIBUTE_RETURN_CHECK; @@ -2213,7 +2213,7 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, int liveStatus, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 1154202..3a3173f 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -169,7 +169,7 @@ cleanup: virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -264,7 +264,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, _("missing domain in snapshot")); goto cleanup; } - def->dom = virDomainDefParseNode(caps, xmlconf, xml, domainNode, + def->dom = virDomainDefParseNode(caps, xmlopt, xml, domainNode, expectedVirtTypes, (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE)); diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h index e8bd24a..6d625a7 100644 --- a/src/conf/snapshot_conf.h +++ b/src/conf/snapshot_conf.h @@ -101,7 +101,7 @@ typedef enum { virDomainSnapshotDefPtr virDomainSnapshotDefParseString(const char *xmlStr, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags); void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index fc8a3ae..3e49ec0 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -71,7 +71,7 @@ esxFreePrivate(esxPrivate **priv) esxVI_Context_Free(&(*priv)->vCenter); esxUtil_FreeParsedUri(&(*priv)->parsedUri); virObjectUnref((*priv)->caps); - virObjectUnref((*priv)->xmlconf); + virObjectUnref((*priv)->xmlopt); VIR_FREE(*priv); } @@ -1100,7 +1100,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, goto cleanup; } - if (!(priv->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL))) goto cleanup; conn->privateData = priv; @@ -2887,7 +2887,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; } - def = virDomainDefParseString(priv->caps, priv->xmlconf, + def = virDomainDefParseString(priv->caps, priv->xmlopt, domainXml, 1 << VIR_DOMAIN_VIRT_VMWARE, 0); if (def == NULL) { @@ -3103,7 +3103,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) } /* Parse domain XML */ - def = virDomainDefParseString(priv->caps, priv->xmlconf, + def = virDomainDefParseString(priv->caps, priv->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); @@ -4276,7 +4276,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, } def = virDomainSnapshotDefParseString(xmlDesc, priv->caps, - priv->xmlconf, 0, 0); + priv->xmlopt, 0, 0); if (def == NULL) { return NULL; diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h index 2973130..83e945f 100644 --- a/src/esx/esx_private.h +++ b/src/esx/esx_private.h @@ -35,7 +35,7 @@ typedef struct _esxPrivate { esxVI_Context *vCenter; esxUtil_ParsedUri *parsedUri; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; int32_t maxVcpus; esxVI_Boolean supportsVMotion; esxVI_Boolean supportsLongMode; /* aka x86_64 */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 96eea0a..2930104 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -341,8 +341,8 @@ virDomainWatchdogActionTypeFromString; virDomainWatchdogActionTypeToString; virDomainWatchdogModelTypeFromString; virDomainWatchdogModelTypeToString; -virDomainXMLConfGetNamespace; -virDomainXMLConfNew; +virDomainXMLOptionGetNamespace; +virDomainXMLOptionNew; virSecurityDeviceLabelDefFree; virSecurityLabelDefFree; diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index f8602b4..fed878d 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -54,7 +54,7 @@ typedef libxlDriverPrivate *libxlDriverPrivatePtr; struct _libxlDriverPrivate { virMutex lock; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; unsigned int version; FILE *logger_file; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 40a7a6b..7c033fa 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -563,7 +563,7 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from, goto error; } - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -976,7 +976,7 @@ libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm, } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto error; if (!driver->nactive && driver->inhibitCallback) @@ -1080,7 +1080,7 @@ libxlShutdown(void) libxlDriverLock(libxl_driver); virObjectUnref(libxl_driver->caps); - virObjectUnref(libxl_driver->xmlconf); + virObjectUnref(libxl_driver->xmlopt); virObjectUnref(libxl_driver->domains); libxl_ctx_free(libxl_driver->ctx); xtl_logger_destroy(libxl_driver->logger); @@ -1239,14 +1239,14 @@ libxlStartup(bool privileged, goto error; } - if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainXMLPrivateDataCallbacks, + if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(&libxlDomainXMLPrivateDataCallbacks, NULL))) goto error; /* Load running domains first. */ if (virDomainObjListLoadAllConfigs(libxl_driver->domains, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, libxl_driver->stateDir, libxl_driver->autostartDir, 1, 1 << VIR_DOMAIN_VIRT_XEN, @@ -1258,7 +1258,7 @@ libxlStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(libxl_driver->domains, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, libxl_driver->configDir, libxl_driver->autostartDir, 0, 1 << VIR_DOMAIN_VIRT_XEN, @@ -1296,7 +1296,7 @@ libxlReload(void) libxlDriverLock(libxl_driver); virDomainObjListLoadAllConfigs(libxl_driver->domains, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, libxl_driver->configDir, libxl_driver->autostartDir, 1, 1 << VIR_DOMAIN_VIRT_XEN, @@ -1454,13 +1454,13 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL); libxlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1605,7 +1605,7 @@ libxlDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -1665,7 +1665,7 @@ libxlDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -1936,7 +1936,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, goto cleanup; } if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, - driver->xmlconf, + driver->xmlopt, vm))) goto cleanup; } @@ -2242,7 +2242,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, @@ -2580,7 +2580,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, priv = vm->privateData; - if (!(def = virDomainObjGetPersistentDef(driver->caps, driver->xmlconf, vm))) + if (!(def = virDomainObjGetPersistentDef(driver->caps, driver->xmlopt, vm))) goto cleanup; maplen = VIR_CPU_MAPLEN(nvcpus); @@ -2758,7 +2758,7 @@ libxlDomainPinVcpu(virDomainPtr dom, unsigned int vcpu, unsigned char *cpumap, goto cleanup; } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -2931,7 +2931,7 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, goto cleanup; } - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, domainXml, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, domainXml, 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; @@ -3033,13 +3033,13 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml) virDomainDefPtr oldDef = NULL; libxlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, 0, &oldDef))) @@ -3562,7 +3562,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, /* Make a copy for updated domain. */ if (!(vmdef = virDomainObjCopyPersistentDef(driver->caps, - driver->xmlconf, vm))) + driver->xmlopt, vm))) goto cleanup; switch (action) { @@ -3609,7 +3609,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * update domain status forcibly because the domain status may be * changed even if we attach the device failed. */ - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) ret = -1; } diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index c723e77..ab6c749 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -156,10 +156,10 @@ error: } -virDomainXMLConfPtr +virDomainXMLOptionPtr lxcDomainXMLConfInit(void) { - return virDomainXMLConfNew(&virLXCDriverPrivateDataCallbacks, NULL); + return virDomainXMLOptionNew(&virLXCDriverPrivateDataCallbacks, NULL); } int lxcLoadDriverConfig(virLXCDriverPtr driver) diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h index b46dc32..c12e427 100644 --- a/src/lxc/lxc_conf.h +++ b/src/lxc/lxc_conf.h @@ -51,7 +51,7 @@ struct _virLXCDriver { virMutex lock; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virCgroupPtr cgroup; @@ -84,7 +84,7 @@ struct _virLXCDriver { int lxcLoadDriverConfig(virLXCDriverPtr driver); virCapsPtr lxcCapsInit(virLXCDriverPtr driver); -virDomainXMLConfPtr lxcDomainXMLConfInit(void); +virDomainXMLOptionPtr lxcDomainXMLConfInit(void); static inline void lxcDriverLock(virLXCDriverPtr driver) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 1d1443c..440a183 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -147,7 +147,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) { virLXCControllerPtr ctrl = NULL; virCapsPtr caps = NULL; - virDomainXMLConfPtr xmlconf = NULL; + virDomainXMLOptionPtr xmlopt = NULL; char *configFile = NULL; if (VIR_ALLOC(ctrl) < 0) @@ -162,14 +162,14 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) if ((caps = lxcCapsInit(NULL)) == NULL) goto error; - if (!(xmlconf = lxcDomainXMLConfInit())) + if (!(xmlopt = lxcDomainXMLConfInit())) goto error; if ((configFile = virDomainConfigFile(LXC_STATE_DIR, ctrl->name)) == NULL) goto error; - if ((ctrl->def = virDomainDefParseFile(caps, xmlconf, + if ((ctrl->def = virDomainDefParseFile(caps, xmlopt, configFile, 1 << VIR_DOMAIN_VIRT_LXC, 0)) == NULL) @@ -183,7 +183,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) cleanup: VIR_FREE(configFile); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return ctrl; no_memory: diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ba14db7..130544c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -413,7 +413,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) virDomainDefPtr oldDef = NULL; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_LXC, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -428,7 +428,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, 0, &oldDef))) @@ -1069,7 +1069,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); lxcDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_LXC, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1085,7 +1085,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1483,7 +1483,7 @@ static int lxcStartup(bool privileged, if ((lxc_driver->caps = lxcCapsInit(lxc_driver)) == NULL) goto cleanup; - if (!(lxc_driver->xmlconf = lxcDomainXMLConfInit())) + if (!(lxc_driver->xmlopt = lxcDomainXMLConfInit())) goto cleanup; if (virLXCProcessAutoDestroyInit(lxc_driver) < 0) @@ -1492,7 +1492,7 @@ static int lxcStartup(bool privileged, /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(lxc_driver->domains, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, lxc_driver->stateDir, NULL, 1, 1 << VIR_DOMAIN_VIRT_LXC, @@ -1504,7 +1504,7 @@ static int lxcStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(lxc_driver->domains, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, lxc_driver->configDir, lxc_driver->autostartDir, 0, 1 << VIR_DOMAIN_VIRT_LXC, @@ -1552,7 +1552,7 @@ lxcReload(void) { lxcDriverLock(lxc_driver); virDomainObjListLoadAllConfigs(lxc_driver->domains, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, lxc_driver->configDir, lxc_driver->autostartDir, 0, 1 << VIR_DOMAIN_VIRT_LXC, @@ -1577,7 +1577,7 @@ static int lxcShutdown(void) virObjectUnref(lxc_driver->activeUsbHostdevs); virObjectUnref(lxc_driver->caps); virObjectUnref(lxc_driver->securityManager); - virObjectUnref(lxc_driver->xmlconf); + virObjectUnref(lxc_driver->xmlopt); VIR_FREE(lxc_driver->configDir); VIR_FREE(lxc_driver->autostartDir); VIR_FREE(lxc_driver->stateDir); @@ -1799,13 +1799,13 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &vmdef) < 0) goto cleanup; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlopt, vm); if (!vmdef) goto cleanup; } @@ -1871,7 +1871,7 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom, } } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; @@ -1941,7 +1941,7 @@ lxcGetSchedulerParametersFlags(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2054,7 +2054,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2159,7 +2159,7 @@ lxcDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2525,7 +2525,7 @@ static int lxcDomainSuspend(virDomainPtr dom) VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -2591,7 +2591,7 @@ static int lxcDomainResume(virDomainPtr dom) VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; ret = 0; @@ -4381,7 +4381,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlopt, vm); if (!vmdef) goto cleanup; switch (action) { @@ -4429,7 +4429,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) { ret = -1; goto cleanup; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 39a6ea2..99ecdd5 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -695,7 +695,7 @@ static void virLXCProcessMonitorInitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED } virDomainAuditInit(vm, initpid, inode); - if (virDomainSaveStatus(lxc_driver->xmlconf, lxc_driver->stateDir, vm) < 0) + if (virDomainSaveStatus(lxc_driver->xmlopt, lxc_driver->stateDir, vm) < 0) VIR_WARN("Cannot update XML with PID for LXC %s", vm->def->name); virObjectUnlock(vm); @@ -1058,7 +1058,7 @@ int virLXCProcessStart(virConnectPtr conn, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf, vm, true) < 0) + if (virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm, true) < 0) goto cleanup; /* Run an early hook to set-up missing devices */ @@ -1255,7 +1255,7 @@ int virLXCProcessStart(virConnectPtr conn, virLXCProcessAutoDestroyAdd(driver, vm, conn) < 0) goto error; - if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf, + if (virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm, false) < 0) goto error; @@ -1265,7 +1265,7 @@ int virLXCProcessStart(virConnectPtr conn, * location for the benefit of libvirt_lxc. We're now overwriting * it with the live status XML instead. This is a (currently * harmless) inconsistency we should fix one day */ - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto error; /* finally we can call the 'started' hook script if any */ diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index f175655..8858c2d 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -558,7 +558,7 @@ openvzFreeDriver(struct openvz_driver *driver) if (!driver) return; - virObjectUnref(driver->xmlconf); + virObjectUnref(driver->xmlopt); virObjectUnref(driver->domains); virObjectUnref(driver->caps); VIR_FREE(driver); @@ -649,7 +649,7 @@ int openvzLoadDomains(struct openvz_driver *driver) { flags |= VIR_DOMAIN_OBJ_LIST_ADD_LIVE; if (!(dom = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, flags, NULL))) diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h index a030b42..47b5123 100644 --- a/src/openvz/openvz_conf.h +++ b/src/openvz/openvz_conf.h @@ -45,7 +45,7 @@ struct openvz_driver { virMutex lock; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virDomainObjListPtr domains; int version; }; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 67d66ae..2fd6a41 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -955,7 +955,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr dom = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -968,7 +968,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) goto cleanup; } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, vmdef, 0, NULL))) goto cleanup; vmdef = NULL; @@ -1042,7 +1042,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1055,7 +1055,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, goto cleanup; } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, vmdef, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1453,7 +1453,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn, if (!(driver->caps = openvzCapsInit())) goto cleanup; - if (!(driver->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL))) goto cleanup; if (openvzLoadDomains(driver) < 0) @@ -2079,7 +2079,7 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, } if (virDomainLiveConfigHelperMethod(driver->caps, - driver->xmlconf, + driver->xmlopt, vm, &flags, &vmdef) < 0) diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 88f41f7..1d74340 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -831,7 +831,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, 0, NULL))) goto cleanup; /* dom is locked here */ @@ -929,7 +929,7 @@ parallelsOpenDefault(virConnectPtr conn) if (!(privconn->caps = parallelsBuildCapabilities())) goto error; - if (!(privconn->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL))) goto error; if (!(privconn->domains = virDomainObjListNew())) @@ -990,7 +990,7 @@ parallelsClose(virConnectPtr conn) parallelsDriverLock(privconn); virObjectUnref(privconn->caps); - virObjectUnref(privconn->xmlconf); + virObjectUnref(privconn->xmlopt); virObjectUnref(privconn->domains); conn->privateData = NULL; @@ -2330,7 +2330,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) virDomainObjPtr dom = NULL, olddom = NULL; parallelsDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_PARALLELS, VIR_DOMAIN_XML_INACTIVE)) == NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -2370,7 +2370,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) virObjectUnlock(olddom); if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, 0, NULL))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Can't allocate domobj")); diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h index 59ef18e..603f2de 100644 --- a/src/parallels/parallels_utils.h +++ b/src/parallels/parallels_utils.h @@ -43,7 +43,7 @@ struct _parallelsConn { virStoragePoolObjList pools; virNetworkObjList networks; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virDomainEventStatePtr domainEventState; }; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 59cc1ca..090581c 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1204,7 +1204,7 @@ phypOpen(virConnectPtr conn, goto failure; } - if (!(phyp_driver->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL))) goto failure; conn->privateData = phyp_driver; @@ -1255,7 +1255,7 @@ phypClose(virConnectPtr conn) libssh2_session_free(session); virObjectUnref(phyp_driver->caps); - virObjectUnref(phyp_driver->xmlconf); + virObjectUnref(phyp_driver->xmlopt); phypUUIDTable_Free(phyp_driver->uuid_table); VIR_FREE(phyp_driver->managed_system); VIR_FREE(phyp_driver); @@ -3637,7 +3637,7 @@ phypDomainCreateAndStart(virConnectPtr conn, virCheckFlags(0, NULL); - if (!(def = virDomainDefParseString(phyp_driver->caps, phyp_driver->xmlconf, + if (!(def = virDomainDefParseString(phyp_driver->caps, phyp_driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_PHYP, VIR_DOMAIN_XML_SECURE))) goto err; diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h index 8d4cc16..59a4370 100644 --- a/src/phyp/phyp_driver.h +++ b/src/phyp/phyp_driver.h @@ -68,7 +68,7 @@ typedef phyp_driver_t *phyp_driverPtr; struct _phyp_driver { uuid_tablePtr uuid_table; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; int vios_id; /* system_type: diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 29424d6..5866070 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9035,7 +9035,7 @@ qemuParseCommandLineBootDevs(virDomainDefPtr def, const char *str) { * as is practical. This is not an exact science.... */ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char **progenv, const char **progargv, char **pidfile, @@ -9891,7 +9891,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, goto error; if (cmd->num_args || cmd->num_env) { - def->ns = *virDomainXMLConfGetNamespace(xmlconf); + def->ns = *virDomainXMLOptionGetNamespace(xmlopt); def->namespaceData = cmd; } else @@ -9917,7 +9917,7 @@ error: virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *args, char **pidfile, virDomainChrSourceDefPtr *monConfig, @@ -9931,7 +9931,7 @@ virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps, if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0) goto cleanup; - def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv, + def = qemuParseCommandLine(qemuCaps, xmlopt, progenv, progargv, pidfile, monConfig, monJSON); cleanup: @@ -10007,7 +10007,7 @@ cleanup: } virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, pid_t pid, char **pidfile, virDomainChrSourceDefPtr *monConfig, @@ -10027,7 +10027,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps, qemuParseProcFileStrings(pid, "environ", &progenv) < 0) goto cleanup; - if (!(def = qemuParseCommandLine(qemuCaps, xmlconf, progenv, progargv, + if (!(def = qemuParseCommandLine(qemuCaps, xmlopt, progenv, progargv, pidfile, monConfig, monJSON))) goto cleanup; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 17687f4..2db1551 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -167,20 +167,20 @@ int qemuOpenVhostNet(virDomainDefPtr def, * *must* decide how to fill in a name in this case */ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char **progenv, const char **progargv, char **pidfile, virDomainChrSourceDefPtr *monConfig, bool *monJSON); virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *args, char **pidfile, virDomainChrSourceDefPtr *monConfig, bool *monJSON); virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, pid_t pid, char **pidfile, virDomainChrSourceDefPtr *monConfig, diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c2e2e10..15c6d89 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -551,10 +551,10 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) return conf; } -virDomainXMLConfPtr +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void) { - return virDomainXMLConfNew(&virQEMUDriverPrivateDataCallbacks, + return virDomainXMLOptionNew(&virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index c5ddaad..12f74be 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -189,7 +189,7 @@ struct _virQEMUDriver { virCapsPtr caps; /* Immutable pointer, Immutable object */ - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; /* Immutable pointer, self-locking APIs */ virQEMUCapsCachePtr qemuCapsCache; @@ -301,6 +301,6 @@ void qemuSharedDiskEntryFree(void *payload, const void *name) ATTRIBUTE_NONNULL(1); int qemuDriverAllocateID(virQEMUDriverPtr driver); -virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void); +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void); #endif /* __QEMUD_CONF_H */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c79b05d..a0a66dd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -668,7 +668,7 @@ qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj) virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); if (virDomainObjIsActive(obj)) { - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj) < 0) VIR_WARN("Failed to save status on vm %s", obj->def->name); } @@ -1784,7 +1784,7 @@ qemuDomainSetFakeReboot(virQEMUDriverPtr driver, priv->fakeReboot = value; - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) VIR_WARN("Failed to save status on vm %s", vm->def->name); cleanup: diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 552a81b..6ba899f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -441,7 +441,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, } def = virDomainSnapshotDefParseString(xmlStr, caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, flags); if (def == NULL) { @@ -723,7 +723,7 @@ qemuStartup(bool privileged, if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL) goto error; - if (!(qemu_driver->xmlconf = virQEMUDriverCreateXMLConf())) + if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf())) goto error; /* If hugetlbfs is present, then we need to create a sub-directory within @@ -767,7 +767,7 @@ qemuStartup(bool privileged, /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(qemu_driver->domains, qemu_driver->caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, cfg->stateDir, NULL, 1, QEMU_EXPECTED_VIRT_TYPES, @@ -792,7 +792,7 @@ qemuStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(qemu_driver->domains, qemu_driver->caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, cfg->configDir, cfg->autostartDir, 0, QEMU_EXPECTED_VIRT_TYPES, @@ -866,7 +866,7 @@ qemuReload(void) { cfg = virQEMUDriverGetConfig(qemu_driver); virDomainObjListLoadAllConfigs(qemu_driver->domains, caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, cfg->configDir, cfg->autostartDir, 0, QEMU_EXPECTED_VIRT_TYPES, @@ -961,7 +961,7 @@ qemuShutdown(void) { virObjectUnref(qemu_driver->domains); virObjectUnref(qemu_driver->remotePorts); - virObjectUnref(qemu_driver->xmlconf); + virObjectUnref(qemu_driver->xmlopt); virSysinfoDefFree(qemu_driver->hostsysinfo); @@ -1486,7 +1486,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1504,7 +1504,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1627,7 +1627,7 @@ static int qemuDomainSuspend(virDomainPtr dom) { eventDetail); } } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto endjob; ret = 0; @@ -1696,7 +1696,7 @@ static int qemuDomainResume(virDomainPtr dom) { } if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto endjob; - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto endjob; ret = 0; @@ -2094,7 +2094,7 @@ static int qemuDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto endjob; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto endjob; @@ -2855,7 +2855,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (xmlin) { virDomainDefPtr def = NULL; - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, xmlin, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) { goto endjob; @@ -3769,7 +3769,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, maximum = (flags & VIR_DOMAIN_VCPU_MAXIMUM) != 0; flags &= ~VIR_DOMAIN_VCPU_MAXIMUM; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto endjob; @@ -3875,7 +3875,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -3966,7 +3966,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, if (newVcpuPin) virDomainVcpuPinDefArrayFree(newVcpuPin, newVcpuPinNum); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; } @@ -4055,7 +4055,7 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &targetDef) < 0) goto cleanup; @@ -4151,7 +4151,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -4232,7 +4232,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto cleanup; } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; } @@ -4297,7 +4297,7 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &targetDef) < 0) goto cleanup; @@ -4454,7 +4454,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &def) < 0) goto cleanup; @@ -4767,14 +4767,14 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, header.was_running = state; /* Create a domain from this XML */ - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto error; if (xmlin) { virDomainDefPtr def2 = NULL; - if (!(def2 = virDomainDefParseString(caps, driver->xmlconf, xmlin, + if (!(def2 = virDomainDefParseString(caps, driver->xmlopt, xmlin, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -4890,7 +4890,7 @@ qemuDomainSaveImageStartVM(virConnectPtr conn, "%s", _("failed to resume domain")); goto cleanup; } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); goto cleanup; } @@ -4948,7 +4948,7 @@ qemuDomainRestoreFlags(virConnectPtr conn, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, @@ -5229,7 +5229,7 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - def = qemuParseCommandLineString(caps, driver->xmlconf, config, + def = qemuParseCommandLineString(caps, driver->xmlopt, config, NULL, NULL, NULL); if (!def) goto cleanup; @@ -5277,7 +5277,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - def = virDomainDefParseString(caps, driver->xmlconf, xmlData, + def = virDomainDefParseString(caps, driver->xmlopt, xmlData, QEMU_EXPECTED_VIRT_TYPES, 0); if (!def) goto cleanup; @@ -5548,7 +5548,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xml, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -5566,7 +5566,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, 0, &oldDef))) @@ -6494,7 +6494,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlopt, vm); if (!vmdef) goto endjob; switch (action) { @@ -6545,7 +6545,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * changed even if we failed to attach the device. For example, * a new controller may be created. */ - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { ret = -1; goto endjob; } @@ -6922,7 +6922,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7087,7 +7087,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7276,7 +7276,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7406,7 +7406,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7572,7 +7572,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7725,7 +7725,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7935,13 +7935,13 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &vmdef) < 0) goto cleanup; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlopt, vm); if (!vmdef) goto cleanup; } @@ -8036,7 +8036,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom, } } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; @@ -8221,7 +8221,7 @@ qemuGetSchedulerParametersFlags(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -8751,7 +8751,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -8917,7 +8917,7 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -11316,7 +11316,7 @@ cleanup: virCgroupFree(&cgroup); if (ret == 0 || !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_TRANSACTION)) { - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0 || + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0 || (persist && virDomainSaveConfig(cfg->configDir, vm->newDef) < 0)) ret = -1; } @@ -11584,7 +11584,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, !virDomainObjIsActive(vm)) parse_flags |= VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE; - if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlconf, + if (!(def = virDomainSnapshotDefParseString(xmlDesc, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, parse_flags))) goto cleanup; @@ -11760,7 +11760,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, /* Easiest way to clone inactive portion of vm->def is via * conversion in and back out of xml. */ if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) || - !(def->dom = virDomainDefParseString(caps, driver->xmlconf, xml, + !(def->dom = virDomainDefParseString(caps, driver->xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -12331,7 +12331,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, * than inactive xml? */ snap->def->current = true; if (snap->def->dom) { - config = virDomainDefCopy(caps, driver->xmlconf, snap->def->dom, true); + config = virDomainDefCopy(caps, driver->xmlopt, snap->def->dom, true); if (!config) goto cleanup; } @@ -12791,7 +12791,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = qemuParseCommandLinePid(caps, driver->xmlconf, pid, + if (!(def = qemuParseCommandLinePid(caps, driver->xmlopt, pid, &pidfile, &monConfig, &monJSON))) goto cleanup; @@ -12825,7 +12825,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, @@ -13905,7 +13905,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto endjob; @@ -14065,7 +14065,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto endjob; @@ -14254,7 +14254,7 @@ qemuDomainSetMetadata(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -14351,7 +14351,7 @@ qemuDomainGetMetadata(virDomainPtr dom, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, &def) < 0) + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &def) < 0) goto cleanup; /* use correct domain definition according to flags */ diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3f74add..2033318 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -921,7 +921,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, n); goto error; } - mig->persistent = virDomainDefParseNode(caps, driver->xmlconf, + mig->persistent = virDomainDefParseNode(caps, driver->xmlopt, doc, nodes[0], -1, VIR_DOMAIN_XML_INACTIVE); if (!mig->persistent) { @@ -1926,7 +1926,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver, } if (xmlin) { - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, xmlin, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2030,7 +2030,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlconf, dom_xml, + if (!(def = virDomainDefParseString(caps, driver->xmlopt, dom_xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2071,7 +2071,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, virDomainDefPtr newdef; VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef = virDomainDefParseString(caps, driver->xmlconf, xmlout, + newdef = virDomainDefParseString(caps, driver->xmlopt, xmlout, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE); if (!newdef) @@ -2128,7 +2128,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, @@ -3947,7 +3947,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, if (mig->persistent) vm->newDef = vmdef = mig->persistent; else - vmdef = virDomainObjGetPersistentDef(caps, driver->xmlconf, vm); + vmdef = virDomainObjGetPersistentDef(caps, driver->xmlopt, vm); if (!vmdef || virDomainSaveConfig(cfg->configDir, vmdef) < 0) { /* Hmpf. Migration was successful, but making it persistent * was not. If we report successful, then when this domain @@ -4042,7 +4042,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver, } if (virDomainObjIsActive(vm) && - virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); goto endjob; } @@ -4150,7 +4150,7 @@ int qemuMigrationConfirm(virQEMUDriverPtr driver, event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_RESUMED, VIR_DOMAIN_EVENT_RESUMED_MIGRATED); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Failed to save status on vm %s", vm->def->name); goto cleanup; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8c4bfb7..9f7c087 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -663,7 +663,7 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_DOMAIN_EVENT_SHUTDOWN, VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -713,7 +713,7 @@ qemuProcessHandleStop(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -766,7 +766,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED, } VIR_FREE(priv->lockState); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after state change", vm->def->name); } @@ -796,7 +796,7 @@ qemuProcessHandleRTCChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, if (vm->def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_VARIABLE) vm->def->clock.data.variable.adjustment = offset; - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) VIR_WARN("unable to save domain status with RTC change"); virObjectUnlock(vm); @@ -836,7 +836,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after watchdog event", vm->def->name); } @@ -918,7 +918,7 @@ qemuProcessHandleIOError(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_WARN("Unable to release lease on %s", vm->def->name); VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState)); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) VIR_WARN("Unable to save status on vm %s after IO error", vm->def->name); } virObjectUnlock(vm); @@ -1096,7 +1096,7 @@ qemuProcessHandleTrayChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, else if (reason == VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE) disk->tray_status = VIR_DOMAIN_DISK_TRAY_CLOSED; - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after tray moved event", vm->def->name); } @@ -1134,7 +1134,7 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_DOMAIN_EVENT_STARTED, VIR_DOMAIN_EVENT_STARTED_WAKEUP); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after wakeup event", vm->def->name); } @@ -1173,7 +1173,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -1208,7 +1208,7 @@ qemuProcessHandleBalloonChange(qemuMonitorPtr mon ATTRIBUTE_UNUSED, vm->def->mem.cur_balloon, actual); vm->def->mem.cur_balloon = actual; - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) VIR_WARN("unable to save domain status with balloon change"); virObjectUnlock(vm); @@ -1243,7 +1243,7 @@ qemuProcessHandlePMSuspendDisk(qemuMonitorPtr mon ATTRIBUTE_UNUSED, VIR_DOMAIN_EVENT_PMSUSPENDED, VIR_DOMAIN_EVENT_PMSUSPENDED_DISK); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", vm->def->name); } @@ -3064,7 +3064,7 @@ qemuProcessReconnect(void *opaque) goto error; /* update domain state XML with possibly updated state in virDomainObj */ - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, obj) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, obj) < 0) goto error; /* Run an hook to allow admins to do some magic */ @@ -3319,7 +3319,7 @@ int qemuProcessStart(virConnectPtr conn, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0) + if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, true) < 0) goto cleanup; vm->def->id = qemuDriverAllocateID(driver); @@ -3670,7 +3670,7 @@ int qemuProcessStart(virConnectPtr conn, } VIR_DEBUG("Writing early domain status to disk"); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { goto cleanup; } @@ -3821,7 +3821,7 @@ int qemuProcessStart(virConnectPtr conn, goto cleanup; VIR_DEBUG("Writing domain status to disk"); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; /* finally we can call the 'started' hook script if any */ @@ -4179,7 +4179,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(caps, driver->xmlconf, vm, true) < 0) + if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm, true) < 0) goto cleanup; vm->def->id = qemuDriverAllocateID(driver); @@ -4323,7 +4323,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, reason); VIR_DEBUG("Writing domain status to disk"); - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; /* Run an hook to allow admins to do some magic */ diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index f764f77..6534bea 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -71,7 +71,7 @@ typedef struct { char *files; /* list of files */ virDomainDefPtr def; /* VM definition */ virCapsPtr caps; /* VM capabilities */ - virDomainXMLConfPtr xmlconf;/* XML parser data */ + virDomainXMLOptionPtr xmlopt;/* XML parser data */ char *hvm; /* type of hypervisor (eg hvm, xen) */ virArch arch; /* machine architecture */ char *newfile; /* newly added file */ @@ -86,7 +86,7 @@ vahDeinit(vahControl * ctl) VIR_FREE(ctl->def); virObjectUnref(ctl->caps); - virObjectUnref(ctl->xmlconf); + virObjectUnref(ctl->xmlopt); VIR_FREE(ctl->files); VIR_FREE(ctl->hvm); VIR_FREE(ctl->newfile); @@ -711,7 +711,7 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - if (!(ctl->xmlconf = virDomainXMLConfNew(NULL, NULL))) { + if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL))) { vah_error(ctl, 0, _("Failed to create XML config object")); goto exit; } @@ -729,7 +729,7 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - ctl->def = virDomainDefParseString(ctl->caps, ctl->xmlconf, + ctl->def = virDomainDefParseString(ctl->caps, ctl->xmlopt, xmlStr, -1, VIR_DOMAIN_XML_INACTIVE); if (ctl->def == NULL) { diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4dbd775..4c8b21b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -84,7 +84,7 @@ struct _testConn { char *path; int nextDomID; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virNodeInfo nodeInfo; virDomainObjListPtr domains; virNetworkObjList networks; @@ -159,12 +159,12 @@ static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, } -static virDomainXMLConfPtr +static virDomainXMLOptionPtr testBuildXMLConfig(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc, .free = testDomainObjPrivateFree }; - return virDomainXMLConfNew(&priv, NULL); + return virDomainXMLOptionNew(&priv, NULL); } @@ -518,7 +518,7 @@ testDomainStartState(virConnectPtr conn, dom->def->id = privconn->nextDomID++; if (virDomainObjSetDefTransient(privconn->caps, - privconn->xmlconf, + privconn->xmlopt, dom, false) < 0) { goto cleanup; } @@ -585,13 +585,13 @@ static int testOpenDefault(virConnectPtr conn) { if (!(privconn->caps = testBuildCapabilities(conn))) goto error; - if (!(privconn->xmlconf = testBuildXMLConfig())) + if (!(privconn->xmlopt = testBuildXMLConfig())) goto error; privconn->nextDomID = 1; if (!(domdef = virDomainDefParseString(privconn->caps, - privconn->xmlconf, + privconn->xmlopt, defaultDomainXML, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE))) @@ -600,7 +600,7 @@ static int testOpenDefault(virConnectPtr conn) { if (testDomainGenerateIfnames(domdef) < 0) goto error; if (!(domobj = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, domdef, 0, NULL))) goto error; domdef = NULL; @@ -819,7 +819,7 @@ static int testOpenFromFile(virConnectPtr conn, if (!(privconn->caps = testBuildCapabilities(conn))) goto error; - if (!(privconn->xmlconf = testBuildXMLConfig())) + if (!(privconn->xmlopt = testBuildXMLConfig())) goto error; if (!(xml = virXMLParseFileCtxt(file, &ctxt))) { @@ -934,14 +934,14 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } def = virDomainDefParseFile(privconn->caps, - privconn->xmlconf, absFile, + privconn->xmlopt, absFile, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); VIR_FREE(absFile); if (!def) goto error; } else { - if ((def = virDomainDefParseNode(privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseNode(privconn->caps, privconn->xmlopt, xml, domains[i], 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) @@ -950,7 +950,7 @@ static int testOpenFromFile(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0 || !(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, 0, NULL))) { virDomainDefFree(def); goto error; @@ -1206,7 +1206,7 @@ static int testClose(virConnectPtr conn) testConnPtr privconn = conn->privateData; testDriverLock(privconn); virObjectUnref(privconn->caps); - virObjectUnref(privconn->xmlconf); + virObjectUnref(privconn->xmlopt); virObjectUnref(privconn->domains); virNodeDeviceObjListFree(&privconn->devs); virNetworkObjListFree(&privconn->networks); @@ -1344,7 +1344,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1352,7 +1352,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1959,7 +1959,7 @@ testDomainRestoreFlags(virConnectPtr conn, } xml[len] = '\0'; - def = virDomainDefParseString(privconn->caps, privconn->xmlconf, + def = virDomainDefParseString(privconn->caps, privconn->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); if (!def) @@ -1968,7 +1968,7 @@ testDomainRestoreFlags(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, @@ -2178,7 +2178,7 @@ testDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) goto cleanup; } - if (virDomainLiveConfigHelperMethod(privconn->caps, privconn->xmlconf, + if (virDomainLiveConfigHelperMethod(privconn->caps, privconn->xmlopt, vm, &flags, &def) < 0) goto cleanup; @@ -2257,7 +2257,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, } if (!(persistentDef = virDomainObjGetPersistentDef(privconn->caps, - privconn->xmlconf, + privconn->xmlopt, privdom))) goto cleanup; @@ -2510,7 +2510,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, virDomainDefPtr oldDef = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -2518,7 +2518,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, + privconn->xmlopt, def, 0, &oldDef))) diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h index 488c1b7..7f7ea05 100644 --- a/src/uml/uml_conf.h +++ b/src/uml/uml_conf.h @@ -63,7 +63,7 @@ struct uml_driver { int inotifyWatch; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; /* Event handling */ virDomainEventStatePtr domainEventState; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 09a777c..1d21d71 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -505,7 +505,7 @@ umlStartup(bool privileged, if ((uml_driver->caps = umlCapsInit()) == NULL) goto out_of_memory; - if (!(uml_driver->xmlconf = virDomainXMLConfNew(&privcb, + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&privcb, NULL))) goto error; @@ -543,7 +543,7 @@ umlStartup(bool privileged, if (virDomainObjListLoadAllConfigs(uml_driver->domains, uml_driver->caps, - uml_driver->xmlconf, + uml_driver->xmlopt, uml_driver->configDir, uml_driver->autostartDir, 0, 1 << VIR_DOMAIN_VIRT_UML, @@ -599,7 +599,7 @@ umlReload(void) { umlDriverLock(uml_driver); virDomainObjListLoadAllConfigs(uml_driver->domains, uml_driver->caps, - uml_driver->xmlconf, + uml_driver->xmlopt, uml_driver->configDir, uml_driver->autostartDir, 0, 1 << VIR_DOMAIN_VIRT_UML, @@ -640,7 +640,7 @@ umlShutdown(void) { virEventRemoveHandle(uml_driver->inotifyWatch); VIR_FORCE_CLOSE(uml_driver->inotifyFD); virObjectUnref(uml_driver->caps); - virObjectUnref(uml_driver->xmlconf); + virObjectUnref(uml_driver->xmlopt); /* shutdown active VMs * XXX allow them to stay around & reconnect */ @@ -1064,7 +1064,7 @@ static int umlStartVMDaemon(virConnectPtr conn, * report implicit runtime defaults in the XML, like vnc listen/socket */ VIR_DEBUG("Setting current domain def as transient"); - if (virDomainObjSetDefTransient(driver->caps, driver->xmlconf, + if (virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm, true) < 0) { VIR_FORCE_CLOSE(logfd); return -1; @@ -1098,7 +1098,7 @@ static int umlStartVMDaemon(virConnectPtr conn, (ret = umlProcessAutoDestroyAdd(driver, vm, conn)) < 0) goto cleanup; - ret = virDomainObjSetDefTransient(driver->caps, driver->xmlconf, vm, false); + ret = virDomainObjSetDefTransient(driver->caps, driver->xmlopt, vm, false); cleanup: VIR_FORCE_CLOSE(logfd); virCommandFree(cmd); @@ -1505,13 +1505,13 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); umlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -1926,13 +1926,13 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, def, 0, NULL))) goto cleanup; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index aa7466b..f5d687a 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -193,7 +193,7 @@ typedef struct { unsigned long version; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; IVirtualBox *vboxObj; ISession *vboxSession; @@ -851,10 +851,10 @@ static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, } -static virDomainXMLConfPtr +static virDomainXMLOptionPtr vboxXMLConfInit(void) { - return virDomainXMLConfNew(NULL, NULL); + return virDomainXMLOptionNew(NULL, NULL); } @@ -986,7 +986,7 @@ static void vboxUninitialize(vboxGlobalData *data) { data->pFuncs->pfnComUninitialize(); virObjectUnref(data->caps); - virObjectUnref(data->xmlconf); + virObjectUnref(data->xmlopt); #if VBOX_API_VERSION == 2002 /* No domainEventCallbacks in 2.2.* version */ #else /* !(VBOX_API_VERSION == 2002) */ @@ -1046,7 +1046,7 @@ static virDrvOpenStatus vboxOpen(virConnectPtr conn, if (!(data->caps = vboxCapsInit()) || vboxInitialize(data) < 0 || vboxExtractVersion(data) < 0 || - !(data->xmlconf = vboxXMLConfInit())) { + !(data->xmlopt = vboxXMLConfInit())) { vboxUninitialize(data); return VIR_DRV_OPEN_ERROR; } @@ -5052,7 +5052,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { #endif nsresult rc; - if (!(def = virDomainDefParseString(data->caps, data->xmlconf, + if (!(def = virDomainDefParseString(data->caps, data->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_VBOX, VIR_DOMAIN_XML_INACTIVE))) { goto cleanup; @@ -5932,7 +5932,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL); if (!(def = virDomainSnapshotDefParseString(xmlDesc, data->caps, - data->xmlconf, 0, 0))) + data->xmlopt, 0, 0))) goto cleanup; if (def->ndisks) { diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 19be62a..00a5590 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -45,7 +45,7 @@ vmwareFreeDriver(struct vmware_driver *driver) virMutexDestroy(&driver->lock); virObjectUnref(driver->domains); virObjectUnref(driver->caps); - virObjectUnref(driver->xmlconf); + virObjectUnref(driver->xmlopt); VIR_FREE(driver); } @@ -179,7 +179,7 @@ vmwareLoadDomains(struct vmware_driver *driver) } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, vmdef, 0, NULL))) goto cleanup; diff --git a/src/vmware/vmware_conf.h b/src/vmware/vmware_conf.h index b3ec966..cb11aca 100644 --- a/src/vmware/vmware_conf.h +++ b/src/vmware/vmware_conf.h @@ -36,7 +36,7 @@ struct vmware_driver { virMutex lock; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virDomainObjListPtr domains; int version; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 6d82532..28b4e17 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -72,13 +72,13 @@ vmwareDataFreeFunc(void *data) VIR_FREE(dom); } -static virDomainXMLConfPtr +static virDomainXMLOptionPtr vmwareDomainXMLConfigInit(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc, .free = vmwareDataFreeFunc }; - return virDomainXMLConfNew(&priv, NULL); + return virDomainXMLOptionNew(&priv, NULL); } static virDrvOpenStatus @@ -143,7 +143,7 @@ vmwareOpen(virConnectPtr conn, if (!(driver->caps = vmwareCapsInit())) goto cleanup; - if (!(driver->xmlconf = vmwareDomainXMLConfigInit())) + if (!(driver->xmlopt = vmwareDomainXMLConfigInit())) goto cleanup; if (vmwareLoadDomains(driver) < 0) @@ -324,7 +324,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) ctx.formatFileName = vmwareCopyVMXFileName; vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -346,7 +346,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, vmdef, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -595,7 +595,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -617,7 +617,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlconf, + driver->xmlopt, vmdef, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index fd20b73..edb8e98 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -401,7 +401,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL))) goto fail; #if WITH_XEN_INOTIFY @@ -451,7 +451,7 @@ xenUnifiedClose(virConnectPtr conn) int i; virObjectUnref(priv->caps); - virObjectUnref(priv->xmlconf); + virObjectUnref(priv->xmlopt); virDomainEventStateFree(priv->domainEvents); for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) @@ -1434,7 +1434,7 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, xmlData, 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index 8e43db3..f1f5d74 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -160,7 +160,7 @@ struct _xenUnifiedPrivate { * holding the lock */ virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; int handle; /* Xen hypervisor handle */ int xendConfigVersion; /* XenD config version */ diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 7abc030..ea9814b 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2409,7 +2409,7 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc, unsigned int flags) virCheckFlags(0, NULL); - if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) return NULL; @@ -3127,7 +3127,7 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) return NULL; - if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) { virReportError(VIR_ERR_XML_ERROR, diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index f6a3593..c406ee3 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1013,7 +1013,7 @@ xenXMDomainDefineXML(virConnectPtr conn, const char *xml) return NULL; } - if (!(def = virDomainDefParseString(priv->caps, priv->xmlconf, xml, + if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) { xenUnifiedUnlock(priv); diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index b368f48..0e15e26 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -169,7 +169,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, goto error; } - if (!(privP->xmlconf = virDomainXMLConfNew(NULL, NULL))) { + if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); goto error; @@ -214,7 +214,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, if (privP != NULL) { virObjectUnref(privP->caps); - virObjectUnref(privP->xmlconf); + virObjectUnref(privP->xmlopt); if (privP->session != NULL) xenSessionFree(privP->session); @@ -238,7 +238,7 @@ xenapiClose(virConnectPtr conn) struct _xenapiPrivate *priv = conn->privateData; virObjectUnref(priv->caps); - virObjectUnref(priv->xmlconf); + virObjectUnref(priv->xmlopt); if (priv->session != NULL) { xen_session_logout(priv->session); @@ -533,7 +533,7 @@ xenapiDomainCreateXML(virConnectPtr conn, virCheckFlags(0, NULL); - virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlconf, + virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlopt, xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, flags); @@ -1687,7 +1687,7 @@ xenapiDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr domP=NULL; if (!priv->caps) return NULL; - virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlconf, + virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlopt, xml, 1 << VIR_DOMAIN_VIRT_XEN, 0); diff --git a/src/xenapi/xenapi_driver_private.h b/src/xenapi/xenapi_driver_private.h index 92c18fe..b1d00e6 100644 --- a/src/xenapi/xenapi_driver_private.h +++ b/src/xenapi/xenapi_driver_private.h @@ -58,7 +58,7 @@ struct _xenapiPrivate { char *url; int noVerify; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; }; #endif /* __VIR_XENAPI_H__ */ diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index 7d95310..ac5137e 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -34,7 +34,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *uuid, int internal) if (internal) flags |= VIR_DOMAIN_SNAPSHOT_PARSE_INTERNAL; if (!(def = virDomainSnapshotDefParseString(inXmlData, driver.caps, - driver.xmlconf, + driver.xmlopt, QEMU_EXPECTED_VIRT_TYPES, flags))) goto fail; @@ -91,7 +91,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; # define DO_TEST(name, uuid, internal) \ @@ -117,7 +117,7 @@ mymain(void) DO_TEST("external_vm", "c7a5fdbd-edaf-9455-926a-d65c16db1809", 0); virObjectUnref(driver.caps); - virObjectUnref(driver.xmlconf); + virObjectUnref(driver.xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 964d433..16118bb 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -16,7 +16,7 @@ # include "testutilslxc.h" static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static int testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) @@ -32,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) if (virtTestLoadFile(outxml, &outXmlData) < 0) goto fail; - if (!(def = virDomainDefParseString(caps, xmlconf, inXmlData, + if (!(def = virDomainDefParseString(caps, xmlopt, inXmlData, 1 << VIR_DOMAIN_VIRT_LXC, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -102,7 +102,7 @@ mymain(void) if ((caps = testLXCCapsInit()) == NULL) return EXIT_FAILURE; - if (!(xmlconf = lxcDomainXMLConfInit())) + if (!(xmlopt = lxcDomainXMLConfInit())) return EXIT_FAILURE; # define DO_TEST_FULL(name, is_different, inactive) \ @@ -128,7 +128,7 @@ mymain(void) DO_TEST("hostdev"); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 6fd1de6..ec250ad 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -46,7 +46,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (virtTestLoadFile(xml, &expectxml) < 0) goto fail; - if (!(vmdef = qemuParseCommandLineString(driver.caps, driver.xmlconf, + if (!(vmdef = qemuParseCommandLineString(driver.caps, driver.xmlopt, cmd, NULL, NULL, NULL))) goto fail; @@ -120,7 +120,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; # define DO_TEST_FULL(name, extraFlags, migrateFrom) \ @@ -252,7 +252,7 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); - virObjectUnref(driver.xmlconf); + virObjectUnref(driver.xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 639eeb1..fdf67a1 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -32,8 +32,8 @@ static int testQemuMonitorJSONGetStatus(const void *data) { - virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data; - qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf); + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt); int ret = -1; bool running = false; virDomainPausedReason reason = 0; @@ -126,8 +126,8 @@ cleanup: static int testQemuMonitorJSONGetVersion(const void *data) { - virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data; - qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf); + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt); int ret = -1; int major; int minor; @@ -229,8 +229,8 @@ cleanup: static int testQemuMonitorJSONGetMachines(const void *data) { - virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data; - qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf); + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt); int ret = -1; qemuMonitorMachineInfoPtr *info; int ninfo = 0; @@ -311,8 +311,8 @@ cleanup: static int testQemuMonitorJSONGetCPUDefinitions(const void *data) { - virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data; - qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf); + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt); int ret = -1; char **cpus = NULL; int ncpus = 0; @@ -377,8 +377,8 @@ cleanup: static int testQemuMonitorJSONGetCommands(const void *data) { - virDomainXMLConfPtr xmlconf = (virDomainXMLConfPtr)data; - qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlconf); + virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; + qemuMonitorTestPtr test = qemuMonitorTestNew(true, xmlopt); int ret = -1; char **commands = NULL; int ncommands = 0; @@ -443,7 +443,7 @@ static int mymain(void) { int ret = 0; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; #if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); @@ -451,13 +451,13 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(xmlconf = virQEMUDriverCreateXMLConf())) + !(xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; virEventRegisterDefaultImpl(); #define DO_TEST(name) \ - if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlconf) < 0) \ + if (virtTestRun(# name, 1, testQemuMonitorJSON ## name, xmlopt) < 0) \ ret = -1 DO_TEST(GetStatus); @@ -466,7 +466,7 @@ mymain(void) DO_TEST(GetCPUDefinitions); DO_TEST(GetCommands); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index d5bce84..fe98813 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -450,7 +450,7 @@ static qemuMonitorCallbacks qemuCallbacks = { #define QEMU_TEXT_GREETING "QEMU 1.0,1 monitor - type 'help' for more information" -qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLConfPtr xmlconf) +qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLOptionPtr xmlopt) { qemuMonitorTestPtr test = NULL; virDomainChrSourceDef src; @@ -482,7 +482,7 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virDomainXMLConfPtr xmlconf) goto no_memory; test->json = json; - if (!(test->vm = virDomainObjNew(xmlconf))) + if (!(test->vm = virDomainObjNew(xmlopt))) goto error; if (virNetSocketNewListenUNIX(path, diff --git a/tests/qemumonitortestutils.h b/tests/qemumonitortestutils.h index 09914ae..9df118f 100644 --- a/tests/qemumonitortestutils.h +++ b/tests/qemumonitortestutils.h @@ -32,7 +32,7 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, const char *response); qemuMonitorTestPtr qemuMonitorTestNew(bool json, - virDomainXMLConfPtr xmlconf); + virDomainXMLOptionPtr xmlopt); void qemuMonitorTestFree(qemuMonitorTestPtr test); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d5d2b3d..71921e7 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -100,7 +100,7 @@ static int testCompareXMLToArgvFiles(const char *xml, goto out; conn->secretDriver = &fakeSecretDriver; - if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlconf, xml, + if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) { if (flags & FLAG_EXPECT_PARSE_ERROR) @@ -294,7 +294,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; VIR_FREE(driver.config->stateDir); if ((driver.config->stateDir = strdup("/nowhere")) == NULL) @@ -934,7 +934,7 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); - virObjectUnref(driver.xmlconf); + virObjectUnref(driver.xmlopt); VIR_FREE(map); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index ba9aa96..7305e2d 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -32,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) if (virtTestLoadFile(outxml, &outXmlData) < 0) goto fail; - if (!(def = virDomainDefParseString(driver.caps, driver.xmlconf, inXmlData, + if (!(def = virDomainDefParseString(driver.caps, driver.xmlopt, inXmlData, QEMU_EXPECTED_VIRT_TYPES, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -106,7 +106,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; # define DO_TEST_FULL(name, is_different, when) \ @@ -273,7 +273,7 @@ mymain(void) DO_TEST_DIFFERENT("metadata"); virObjectUnref(driver.caps); - virObjectUnref(driver.xmlconf); + virObjectUnref(driver.xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 76a715d..6492bac 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -51,7 +51,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (len && expectargv[len - 1] == '\n') expectargv[len - 1] = '\0'; - if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlconf, xml, + if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlopt, xml, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -204,7 +204,7 @@ mymain(void) driver.config = virQEMUDriverConfigNew(false); if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || cpuMapOverride(map) < 0) { @@ -254,7 +254,7 @@ mymain(void) virObjectUnref(driver.config); virObjectUnref(driver.caps); - virObjectUnref(driver.xmlconf); + virObjectUnref(driver.xmlopt); VIR_FREE(map); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 405bc2b..ac229de 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -44,7 +44,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static virSecurityManagerPtr mgr; @@ -166,7 +166,7 @@ testSELinuxLoadDef(const char *testname) goto cleanup; } - if (!(def = virDomainDefParseString(caps, xmlconf, xmlstr, + if (!(def = virDomainDefParseString(caps, xmlopt, xmlstr, QEMU_EXPECTED_VIRT_TYPES, 0))) goto cleanup; @@ -328,7 +328,7 @@ mymain(void) if ((caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(xmlconf = virQEMUDriverCreateXMLConf())) + if (!(xmlopt = virQEMUDriverCreateXMLConf())) return EXIT_FAILURE; #define DO_TEST_LABELING(name) \ diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 932becb..d7d5c0a 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -3,4 +3,4 @@ #include "domain_conf.h" virCapsPtr testQemuCapsInit(void); -virDomainXMLConfPtr testQemuXMLConfInit(void); +virDomainXMLOptionPtr testQemuXMLConfInit(void); diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 201ea2a..bfced0c 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -15,10 +15,10 @@ static int testXenDefaultConsoleType(const char *ostype, return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; } -virDomainXMLConfPtr +virDomainXMLOptionPtr testXenXMLConfInit(void) { - return virDomainXMLConfNew(NULL, NULL); + return virDomainXMLOptionNew(NULL, NULL); } virCapsPtr testXenCapsInit(void) { diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h index d4576cb..a38b03a 100644 --- a/tests/testutilsxen.h +++ b/tests/testutilsxen.h @@ -3,4 +3,4 @@ #include "domain_conf.h" virCapsPtr testXenCapsInit(void); -virDomainXMLConfPtr testXenXMLConfInit(void); +virDomainXMLOptionPtr testXenXMLConfInit(void); diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index a32c11a..80833eb 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -37,7 +37,7 @@ #include "viralloc.h" static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static int testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) @@ -69,7 +69,7 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) priv.caps = caps; conn->privateData = &priv; - if (!(def = virDomainDefParseString(caps, xmlconf, xmlData, + if (!(def = virDomainDefParseString(caps, xmlopt, xmlData, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -196,7 +196,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlconf = testXenXMLConfInit())) + if (!(xmlopt = testXenXMLConfInit())) return EXIT_FAILURE; #define DO_TEST(name, version) \ @@ -251,7 +251,7 @@ mymain(void) DO_TEST("pci-devs", 2); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index 364601a..daf4ac6 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -15,7 +15,7 @@ #include "testutilsxen.h" static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) @@ -32,7 +32,7 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) if (virtTestLoadFile(sexpr, &sexprData) < 0) goto fail; - if (!(def = virDomainDefParseString(caps, xmlconf, xmlData, + if (!(def = virDomainDefParseString(caps, xmlopt, xmlData, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -104,7 +104,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlconf = testXenXMLConfInit())) + if (!(xmlopt = testXenXMLConfInit())) return EXIT_FAILURE; DO_TEST("pv", "pv", "pvtest", 1); @@ -174,7 +174,7 @@ mymain(void) DO_TEST("escape", "escape", "fvtest", 1); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 800fd2c..344b097 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -13,7 +13,7 @@ static virCapsPtr caps; static virVMXContext ctx; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, virArch arch ATTRIBUTE_UNUSED) @@ -73,7 +73,7 @@ testCapsInit(void) failure: virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); caps = NULL; } @@ -94,7 +94,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - def = virDomainDefParseString(caps, xmlconf, xmlData, + def = virDomainDefParseString(caps, xmlopt, xmlData, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); @@ -240,7 +240,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL))) return EXIT_FAILURE; ctx.opaque = NULL; -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:11PM +0200, Peter Krempa wrote:
This patch is the result of running:
for i in $(git ls-files | grep -v html | grep -v \.po$ ); do sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i done
and a few manual tweaks. --- src/conf/capabilities.h | 2 +- src/conf/domain_conf.c | 142 ++++++++++++++++++------------------- src/conf/domain_conf.h | 34 ++++----- src/conf/snapshot_conf.c | 4 +- src/conf/snapshot_conf.h | 2 +- src/esx/esx_driver.c | 10 +-- src/esx/esx_private.h | 2 +- src/libvirt_private.syms | 4 +- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_driver.c | 40 +++++------ src/lxc/lxc_conf.c | 4 +- src/lxc/lxc_conf.h | 4 +- src/lxc/lxc_controller.c | 8 +-- src/lxc/lxc_driver.c | 38 +++++----- src/lxc/lxc_process.c | 8 +-- src/openvz/openvz_conf.c | 4 +- src/openvz/openvz_conf.h | 2 +- src/openvz/openvz_driver.c | 12 ++-- src/parallels/parallels_driver.c | 10 +-- src/parallels/parallels_utils.h | 2 +- src/phyp/phyp_driver.c | 6 +- src/phyp/phyp_driver.h | 2 +- src/qemu/qemu_command.c | 12 ++-- src/qemu/qemu_command.h | 6 +- src/qemu/qemu_conf.c | 4 +- src/qemu/qemu_conf.h | 4 +- src/qemu/qemu_domain.c | 4 +- src/qemu/qemu_driver.c | 104 +++++++++++++-------------- src/qemu/qemu_migration.c | 16 ++--- src/qemu/qemu_process.c | 34 ++++----- src/security/virt-aa-helper.c | 8 +-- src/test/test_driver.c | 40 +++++------ src/uml/uml_conf.h | 2 +- src/uml/uml_driver.c | 20 +++--- src/vbox/vbox_tmpl.c | 14 ++-- src/vmware/vmware_conf.c | 4 +- src/vmware/vmware_conf.h | 2 +- src/vmware/vmware_driver.c | 14 ++-- src/xen/xen_driver.c | 6 +- src/xen/xen_driver.h | 2 +- src/xen/xend_internal.c | 4 +- src/xen/xm_internal.c | 2 +- src/xenapi/xenapi_driver.c | 10 +-- src/xenapi/xenapi_driver_private.h | 2 +- tests/domainsnapshotxml2xmltest.c | 6 +- tests/lxcxml2xmltest.c | 8 +-- tests/qemuargv2xmltest.c | 6 +- tests/qemumonitorjsontest.c | 28 ++++---- tests/qemumonitortestutils.c | 4 +- tests/qemumonitortestutils.h | 2 +- tests/qemuxml2argvtest.c | 6 +- tests/qemuxml2xmltest.c | 6 +- tests/qemuxmlnstest.c | 6 +- tests/securityselinuxlabeltest.c | 6 +- tests/testutilsqemu.h | 2 +- tests/testutilsxen.c | 4 +- tests/testutilsxen.h | 2 +- tests/xmconfigtest.c | 8 +-- tests/xml2sexprtest.c | 8 +-- tests/xml2vmxtest.c | 8 +-- 60 files changed, 383 insertions(+), 383 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/04/2013 08:10 AM, Peter Krempa wrote:
This patch is the result of running:
for i in $(git ls-files | grep -v html | grep -v \.po$ ); do sed -i -e "s/virDomainXMLConf/virDomainXMLOption/g" -e "s/xmlconf/xmlopt/g" $i done
and a few manual tweaks.
ACK. (I agree with the renaming, and tested it by running make check and make syntax-check) Thanks for moving this to the beginning of the series.

Oops. I just noticed that you misspelled "Config" as "Confing" in the first line of the message.

This patch adds instrumentation that will allow hypervisor drivers to fill and validate domain and device definitions after parsed by the XML parser. With this patch, after the XML is parsed, a callback to the driver is issued requesing to fill and validate driver specific details of the configuration. This allows to use sensible defaults and checks on a per driver basis at the time the XML is parsed. Two callback pointers are stored in the new virDomainXMLConf object: * virDomainDeviceDefPostParseCallback (devicesPostParseCallback) - called for a single device parsed and for every single device in a domain config. A virDomainDeviceDefPtr is passed along with the domain definition and virCaps. * virDomainDefPostParseCallback, (domainPostParseCallback) - A callback that is meant to process the domain config after it's parsed. A virDomainDefPtr is passed along with virCaps. Both types of callbacks support arbitrary opaque data passed for the callback functions. Errors may be reported in those callbacks resulting in a XML parsing failure. --- src/conf/domain_conf.c | 101 +++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 26 ++++++++-- src/esx/esx_driver.c | 2 +- src/libxl/libxl_driver.c | 11 +++-- src/lxc/lxc_conf.c | 4 +- src/lxc/lxc_driver.c | 6 ++- src/openvz/openvz_conf.c | 1 + src/openvz/openvz_driver.c | 6 +-- src/parallels/parallels_driver.c | 2 +- src/phyp/phyp_driver.c | 6 +-- src/qemu/qemu_conf.c | 5 +- src/qemu/qemu_driver.c | 11 +++-- src/security/virt-aa-helper.c | 2 +- src/test/test_driver.c | 2 +- src/uml/uml_driver.c | 7 ++- src/vbox/vbox_tmpl.c | 10 ++-- src/vmware/vmware_driver.c | 2 +- src/xen/xen_driver.c | 2 +- src/xen/xend_internal.c | 6 +-- src/xen/xm_internal.c | 2 + src/xenapi/xenapi_driver.c | 2 +- tests/testutilsxen.c | 2 +- tests/xml2vmxtest.c | 2 +- 23 files changed, 174 insertions(+), 46 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6714a8c..a13a871 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -73,6 +73,9 @@ struct _virDomainObjList { struct _virDomainXMLOption { virObject parent; + /* XML parser callbacks and defaults */ + virDomainDefParserConfig config; + /* domain private data management callbacks */ virDomainXMLPrivateDataCallbacks privateData; @@ -723,6 +726,7 @@ static virClassPtr virDomainObjListClass; static virClassPtr virDomainXMLOptionClass; static void virDomainObjDispose(void *obj); static void virDomainObjListDispose(void *obj); +static void virDomainXMLOptionClassDispose(void *obj); static int virDomainObjOnceInit(void) { @@ -741,7 +745,7 @@ static int virDomainObjOnceInit(void) if (!(virDomainXMLOptionClass = virClassNew(virClassForObject(), "virDomainXMLOption", sizeof(virDomainXMLOption), - NULL))) + virDomainXMLOptionClassDispose))) return -1; return 0; @@ -750,13 +754,24 @@ static int virDomainObjOnceInit(void) VIR_ONCE_GLOBAL_INIT(virDomainObj) +static void +virDomainXMLOptionClassDispose(void *obj) +{ + virDomainXMLOptionPtr xmlopt = obj; + + if (xmlopt->config.privFree) + (xmlopt->config.privFree)(xmlopt->config.priv); +} + + /** * virDomainXMLOptionNew: * * Allocate a new domain XML configuration */ virDomainXMLOptionPtr -virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv, +virDomainXMLOptionNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns) { virDomainXMLOptionPtr xmlopt; @@ -770,6 +785,9 @@ virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv, if (priv) xmlopt->privateData = *priv; + if (config) + xmlopt->config = *config; + if (xmlns) xmlopt->ns = *xmlns; @@ -2461,6 +2479,73 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, } +static int +virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt) +{ + int ret; + + if (xmlopt && xmlopt->config.devicesPostParseCallback) { + ret = xmlopt->config.devicesPostParseCallback(dev, def, caps, + xmlopt->config.priv); + if (ret < 0) + return ret; + } + + return 0; +} + + +struct virDomainDefPostParseDeviceIteratorData { + virDomainDefPtr def; + virCapsPtr caps; + virDomainXMLOptionPtr xmlopt; +}; + + +static int +virDomainDefPostParseDeviceIterator(virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainDeviceDefPtr dev, + virDomainDeviceInfoPtr info ATTRIBUTE_UNUSED, + void *opaque) +{ + struct virDomainDefPostParseDeviceIteratorData *data = opaque; + return virDomainDeviceDefPostParse(dev, data->def, data->caps, data->xmlopt); +} + + +static int +virDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt) +{ + int ret; + struct virDomainDefPostParseDeviceIteratorData data = { + .def = def, + .caps = caps, + .xmlopt = xmlopt, + }; + + /* call the domain config callback */ + if (xmlopt && xmlopt->config.domainPostParseCallback) { + ret = xmlopt->config.domainPostParseCallback(def, caps, + xmlopt->config.priv); + if (ret < 0) + return ret; + } + + /* iterate the devices */ + if ((ret = virDomainDeviceInfoIterate(def, + virDomainDefPostParseDeviceIterator, + &data)) < 0) + return ret; + + return 0; +} + + void virDomainDefClearPCIAddresses(virDomainDefPtr def) { virDomainDeviceInfoIterate(def, virDomainDeviceInfoClearPCIAddress, NULL); @@ -8386,6 +8471,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, const char *xmlStr, unsigned int flags) @@ -8472,6 +8558,10 @@ virDomainDeviceDefParse(virCapsPtr caps, goto error; } + /* callback to fill driver specific device aspects */ + if (virDomainDeviceDefPostParse(dev, def, caps, xmlopt) < 0) + goto error; + cleanup: xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); @@ -11029,6 +11119,10 @@ virDomainDefParseXML(virCapsPtr caps, if (virDomainDefAddImplicitControllers(def) < 0) goto error; + /* callback to fill driver specific domain aspects */ + if (virDomainDefPostParse(def, caps, xmlopt) < 0) + goto error; + virBitmapFree(bootMap); return def; @@ -16426,6 +16520,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device) */ virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, virDomainDeviceDefPtr src) { @@ -16494,7 +16589,7 @@ virDomainDeviceDefCopy(virCapsPtr caps, goto cleanup; xmlStr = virBufferContentAndReset(&buf); - ret = virDomainDeviceDefParse(caps, def, xmlStr, flags); + ret = virDomainDeviceDefParse(caps, xmlopt, def, xmlStr, flags); cleanup: VIR_FREE(xmlStr); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 5fb2023..69a468a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1938,6 +1938,24 @@ typedef void (*virDomainXMLPrivateDataFreeFunc)(void *); typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *); typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *); +typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def, + virCapsPtr caps, + void *opaque); +typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps, + void *opaque); + +typedef struct _virDomainDefParserConfig virDomainDefParserConfig; +typedef virDomainDefParserConfig *virDomainDefParserConfigPtr; +struct _virDomainDefParserConfig { + virDomainDefPostParseCallback domainPostParseCallback; + virDomainDeviceDefPostParseCallback devicesPostParseCallback; + + void *priv; + virFreeCallback privFree; +}; + typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks; typedef virDomainXMLPrivateDataCallbacks *virDomainXMLPrivateDataCallbacksPtr; struct _virDomainXMLPrivateDataCallbacks { @@ -1947,9 +1965,9 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataParseFunc parse; }; -virDomainXMLOptionPtr -virDomainXMLOptionNew(virDomainXMLPrivateDataCallbacksPtr priv, - virDomainXMLNamespacePtr xmlns); +virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, + virDomainXMLNamespacePtr xmlns); virDomainXMLNamespacePtr virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) @@ -2009,6 +2027,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, virDomainDeviceDefPtr src); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, @@ -2072,6 +2091,7 @@ void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, const char *xmlStr, unsigned int flags); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 3e49ec0..1335ee6 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -1100,7 +1100,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, goto cleanup; } - if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto cleanup; conn->privateData = priv; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7c033fa..4015389 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1239,8 +1239,9 @@ libxlStartup(bool privileged, goto error; } - if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(&libxlDomainXMLPrivateDataCallbacks, - NULL))) + if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(NULL, + &libxlDomainXMLPrivateDataCallbacks, + NULL))) goto error; /* Load running domains first. */ @@ -3556,7 +3557,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, priv = vm->privateData; if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - if (!(dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, + if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -3586,7 +3588,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) { /* If dev exists it was created to modify the domain config. Free it. */ virDomainDeviceDefFree(dev); - if (!(dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, + if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index ab6c749..377d8af 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -159,7 +159,9 @@ error: virDomainXMLOptionPtr lxcDomainXMLConfInit(void) { - return virDomainXMLOptionNew(&virLXCDriverPrivateDataCallbacks, NULL); + return virDomainXMLOptionNew(NULL, + &virLXCDriverPrivateDataCallbacks, + NULL); } int lxcLoadDriverConfig(virLXCDriverPtr driver) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 130544c..572329d 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4360,7 +4360,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; } - dev = dev_copy = virDomainDeviceDefParse(driver->caps, vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(driver->caps, driver->xmlopt, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -4371,7 +4372,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy = virDomainDeviceDefCopy(driver->caps, vm->def, dev); + dev_copy = virDomainDeviceDefCopy(driver->caps, driver->xmlopt, + vm->def, dev); if (!dev_copy) goto cleanup; } diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 8858c2d..3cd27a4 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -174,6 +174,7 @@ static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; } + virCapsPtr openvzCapsInit(void) { virCapsPtr caps; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 2fd6a41..d334486 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1453,7 +1453,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn, if (!(driver->caps = openvzCapsInit())) goto cleanup; - if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto cleanup; if (openvzLoadDomains(driver) < 0) @@ -2085,8 +2085,8 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, &vmdef) < 0) goto cleanup; - dev = virDomainDeviceDefParse(driver->caps, vmdef, xml, - VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, + vmdef, xml, VIR_DOMAIN_XML_INACTIVE); if (!dev) goto cleanup; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 1d74340..5d5353a 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -929,7 +929,7 @@ parallelsOpenDefault(virConnectPtr conn) if (!(privconn->caps = parallelsBuildCapabilities())) goto error; - if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto error; if (!(privconn->domains = virDomainObjListNew())) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 090581c..cd9a989 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1204,7 +1204,7 @@ phypOpen(virConnectPtr conn, goto failure; } - if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto failure; conn->privateData = phyp_driver; @@ -1754,8 +1754,8 @@ phypAttachDevice(virDomainPtr domain, const char *xml) goto cleanup; } - dev = virDomainDeviceDefParse(phyp_driver->caps, def, xml, - VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(phyp_driver->caps, NULL, + def, xml, VIR_DOMAIN_XML_INACTIVE); if (!dev) { goto cleanup; } diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 15c6d89..c709188 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -554,8 +554,9 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void) { - return virDomainXMLOptionNew(&virQEMUDriverPrivateDataCallbacks, - &virQEMUDriverDomainXMLNamespace); + return virDomainXMLOptionNew(NULL, + &virQEMUDriverPrivateDataCallbacks, + &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6ba899f..d3276de 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5786,7 +5786,8 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, tmp = dev->data.disk; dev->data.disk = orig_disk; - if (!(dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, + vm->def, dev))) { dev->data.disk = tmp; goto end; } @@ -6062,7 +6063,8 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm, tmp = dev->data.disk; dev->data.disk = orig_disk; - if (!(dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, + vm->def, dev))) { dev->data.disk = tmp; goto end; } @@ -6468,7 +6470,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; } - dev = dev_copy = virDomainDeviceDefParse(caps, vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(caps, driver->xmlopt, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6479,7 +6482,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy = virDomainDeviceDefCopy(caps, vm->def, dev); + dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, vm->def, dev); if (!dev_copy) goto endjob; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 6534bea..06c19fa 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -711,7 +711,7 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL))) { + if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) { vah_error(ctl, 0, _("Failed to create XML config object")); goto exit; } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 4c8b21b..d35dfc4 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -164,7 +164,7 @@ testBuildXMLConfig(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc, .free = testDomainObjPrivateFree }; - return virDomainXMLOptionNew(&priv, NULL); + return virDomainXMLOptionNew(NULL, &priv, NULL); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 1d21d71..f9a7920 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -505,8 +505,7 @@ umlStartup(bool privileged, if ((uml_driver->caps = umlCapsInit()) == NULL) goto out_of_memory; - if (!(uml_driver->xmlopt = virDomainXMLOptionNew(&privcb, - NULL))) + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL))) goto error; if ((uml_driver->inotifyFD = inotify_init()) < 0) { @@ -2081,7 +2080,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, const char *xml) goto cleanup; } - dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, + dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) @@ -2199,7 +2198,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(driver->caps, vm->def, xml, + dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index f5d687a..eb6460c 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -854,7 +854,7 @@ static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, static virDomainXMLOptionPtr vboxXMLConfInit(void) { - return virDomainXMLOptionNew(NULL, NULL); + return virDomainXMLOptionNew(NULL, NULL, NULL); } @@ -5396,8 +5396,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, goto cleanup; } - dev = virDomainDeviceDefParse(data->caps, def, xml, - VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(data->caps, data->xmlopt, + def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -5631,8 +5631,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(data->caps, def, xml, - VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(data->caps, data->xmlopt, + def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 28b4e17..2dd6f81 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -78,7 +78,7 @@ vmwareDomainXMLConfigInit(void) virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc, .free = vmwareDataFreeFunc }; - return virDomainXMLOptionNew(&priv, NULL); + return virDomainXMLOptionNew(NULL, &priv, NULL); } static virDrvOpenStatus diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index edb8e98..38dce0a 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -401,7 +401,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto fail; #if WITH_XEN_INOTIFY diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index ea9814b..f6ce8eb 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2519,7 +2519,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2679,7 +2679,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2786,7 +2786,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, + if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index c406ee3..69c8f4a 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1311,6 +1311,7 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain, def = entry->def; if (!(dev = virDomainDeviceDefParse(priv->caps, + priv->xmlopt, entry->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1404,6 +1405,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, def = entry->def; if (!(dev = virDomainDeviceDefParse(priv->caps, + priv->xmlopt, entry->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 0e15e26..712c20b 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -169,7 +169,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, goto error; } - if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL))) { + if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); goto error; diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index bfced0c..2eb4730 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -18,7 +18,7 @@ static int testXenDefaultConsoleType(const char *ostype, virDomainXMLOptionPtr testXenXMLConfInit(void) { - return virDomainXMLOptionNew(NULL, NULL); + return virDomainXMLOptionNew(NULL, NULL, NULL); } virCapsPtr testXenCapsInit(void) { diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 344b097..5195ffa 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -240,7 +240,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL))) + if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) return EXIT_FAILURE; ctx.opaque = NULL; -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:12PM +0200, Peter Krempa wrote:
This patch adds instrumentation that will allow hypervisor drivers to fill and validate domain and device definitions after parsed by the XML parser.
With this patch, after the XML is parsed, a callback to the driver is issued requesing to fill and validate driver specific details of the configuration. This allows to use sensible defaults and checks on a per driver basis at the time the XML is parsed.
Two callback pointers are stored in the new virDomainXMLConf object: * virDomainDeviceDefPostParseCallback (devicesPostParseCallback) - called for a single device parsed and for every single device in a domain config. A virDomainDeviceDefPtr is passed along with the domain definition and virCaps.
* virDomainDefPostParseCallback, (domainPostParseCallback) - A callback that is meant to process the domain config after it's parsed. A virDomainDefPtr is passed along with virCaps.
Both types of callbacks support arbitrary opaque data passed for the callback functions.
Errors may be reported in those callbacks resulting in a XML parsing failure. --- src/conf/domain_conf.c | 101 +++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 26 ++++++++-- src/esx/esx_driver.c | 2 +- src/libxl/libxl_driver.c | 11 +++-- src/lxc/lxc_conf.c | 4 +- src/lxc/lxc_driver.c | 6 ++- src/openvz/openvz_conf.c | 1 + src/openvz/openvz_driver.c | 6 +-- src/parallels/parallels_driver.c | 2 +- src/phyp/phyp_driver.c | 6 +-- src/qemu/qemu_conf.c | 5 +- src/qemu/qemu_driver.c | 11 +++-- src/security/virt-aa-helper.c | 2 +- src/test/test_driver.c | 2 +- src/uml/uml_driver.c | 7 ++- src/vbox/vbox_tmpl.c | 10 ++-- src/vmware/vmware_driver.c | 2 +- src/xen/xen_driver.c | 2 +- src/xen/xend_internal.c | 6 +-- src/xen/xm_internal.c | 2 + src/xenapi/xenapi_driver.c | 2 +- tests/testutilsxen.c | 2 +- tests/xml2vmxtest.c | 2 +- 23 files changed, 174 insertions(+), 46 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/04/2013 06:10 AM, Peter Krempa wrote:
This patch adds instrumentation that will allow hypervisor drivers to fill and validate domain and device definitions after parsed by the XML parser.
With this patch, after the XML is parsed, a callback to the driver is issued requesing to fill and validate driver specific details of the
s/requesing/requesting/
configuration. This allows to use sensible defaults and checks on a per driver basis at the time the XML is parsed.
Two callback pointers are stored in the new virDomainXMLConf object: * virDomainDeviceDefPostParseCallback (devicesPostParseCallback) - called for a single device parsed and for every single device in a domain config. A virDomainDeviceDefPtr is passed along with the domain definition and virCaps.
* virDomainDefPostParseCallback, (domainPostParseCallback) - A callback that is meant to process the domain config after it's parsed. A virDomainDefPtr is passed along with virCaps.
Both types of callbacks support arbitrary opaque data passed for the callback functions.
Errors may be reported in those callbacks resulting in a XML parsing failure. ---
+ if (xmlopt && xmlopt->config.devicesPostParseCallback) { + ret = xmlopt->config.devicesPostParseCallback(dev, def, caps, + xmlopt->config.priv);
Indentation is off.
+ /* call the domain config callback */ + if (xmlopt && xmlopt->config.domainPostParseCallback) { + ret = xmlopt->config.domainPostParseCallback(def, caps, + xmlopt->config.priv);
and again -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Move the xmlopt and caps arguments to the end of the argument list. --- src/conf/domain_conf.c | 106 +++++++++++++++++++-------------------- src/conf/domain_conf.h | 44 ++++++++-------- src/conf/snapshot_conf.c | 2 +- src/esx/esx_driver.c | 8 +-- src/libxl/libxl_driver.c | 55 ++++++++++---------- src/lxc/lxc_controller.c | 4 +- src/lxc/lxc_driver.c | 43 ++++++++-------- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 18 +++---- src/parallels/parallels_driver.c | 12 ++--- src/phyp/phyp_driver.c | 9 ++-- src/qemu/qemu_driver.c | 68 ++++++++++++------------- src/qemu/qemu_migration.c | 13 +++-- src/security/virt-aa-helper.c | 6 +-- src/test/test_driver.c | 36 ++++++------- src/uml/uml_driver.c | 30 ++++++----- src/vbox/vbox_tmpl.c | 12 ++--- src/vmware/vmware_conf.c | 4 +- src/vmware/vmware_driver.c | 12 ++--- src/xen/xen_driver.c | 4 +- src/xen/xend_internal.c | 20 ++++---- src/xen/xm_internal.c | 14 +++--- src/xenapi/xenapi_driver.c | 8 +-- tests/lxcxml2xmltest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 2 +- tests/qemuxmlnstest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 31 files changed, 270 insertions(+), 276 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a13a871..ca2b805 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2000,8 +2000,8 @@ void virDomainObjAssignDef(virDomainObjPtr domain, */ static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, - virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef) { @@ -2071,15 +2071,15 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef) { virDomainObjPtr ret; virObjectLock(doms); - ret = virDomainObjListAddLocked(doms, xmlopt, def, flags, oldDef); + ret = virDomainObjListAddLocked(doms, def, xmlopt, flags, oldDef); virObjectUnlock(doms); return ret; } @@ -2113,7 +2113,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; - if (!(domain->newDef = virDomainDefCopy(caps, xmlopt, domain->def, false))) + if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt, false))) goto out; ret = 0; @@ -8470,10 +8470,10 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, } virDomainDeviceDefPtr -virDomainDeviceDefParse(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, - const char *xmlStr, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { xmlDocPtr xml; @@ -9469,11 +9469,11 @@ cleanup: static virDomainDefPtr -virDomainDefParseXML(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - xmlDocPtr xml, +virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11139,10 +11139,10 @@ error: static virDomainObjPtr -virDomainObjParseXML(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - xmlDocPtr xml, +virDomainObjParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11167,8 +11167,8 @@ virDomainObjParseXML(virCapsPtr caps, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(caps, xmlopt, xml, config, ctxt, expectedVirtTypes, - flags); + obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, + expectedVirtTypes, flags); ctxt->node = oldnode; if (!obj->def) goto error; @@ -11250,8 +11250,8 @@ virDomainDefParse(const char *xmlStr, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { - def = virDomainDefParseNode(caps, xmlopt, xml, xmlDocGetRootElement(xml), - expectedVirtTypes, flags); + def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, + xmlopt, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -11260,9 +11260,9 @@ virDomainDefParse(const char *xmlStr, } virDomainDefPtr -virDomainDefParseString(virCapsPtr caps, +virDomainDefParseString(const char *xmlStr, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11271,9 +11271,9 @@ virDomainDefParseString(virCapsPtr caps, } virDomainDefPtr -virDomainDefParseFile(virCapsPtr caps, +virDomainDefParseFile(const char *filename, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11283,10 +11283,10 @@ virDomainDefParseFile(virCapsPtr caps, virDomainDefPtr -virDomainDefParseNode(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - xmlDocPtr xml, +virDomainDefParseNode(xmlDocPtr xml, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11308,7 +11308,7 @@ virDomainDefParseNode(virCapsPtr caps, } ctxt->node = root; - def = virDomainDefParseXML(caps, xmlopt, xml, root, ctxt, + def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, expectedVirtTypes, flags); cleanup: @@ -11318,10 +11318,10 @@ cleanup: static virDomainObjPtr -virDomainObjParseNode(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - xmlDocPtr xml, +virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11342,7 +11342,7 @@ virDomainObjParseNode(virCapsPtr caps, } ctxt->node = root; - obj = virDomainObjParseXML(caps, xmlopt, xml, ctxt, expectedVirtTypes, flags); + obj = virDomainObjParseXML(xml, ctxt, caps, xmlopt, expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11351,9 +11351,9 @@ cleanup: static virDomainObjPtr -virDomainObjParseFile(virCapsPtr caps, +virDomainObjParseFile(const char *filename, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11362,8 +11362,8 @@ virDomainObjParseFile(virCapsPtr caps, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParseFile(filename))) { - obj = virDomainObjParseNode(caps, xmlopt, xml, - xmlDocGetRootElement(xml), + obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml), + caps, xmlopt, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -15526,7 +15526,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if (!(def = virDomainDefParseFile(caps, xmlopt, configFile, + if (!(def = virDomainDefParseFile(configFile, caps, xmlopt, expectedVirtTypes, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -15537,7 +15537,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(dom = virDomainObjListAddLocked(doms, xmlopt, def, 0, &oldDef))) + if (!(dom = virDomainObjListAddLocked(doms, def, xmlopt, 0, &oldDef))) goto error; dom->autostart = autostart; @@ -15559,10 +15559,10 @@ error: static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, const char *statusDir, const char *name, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15574,7 +15574,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(caps, xmlopt, statusFile, expectedVirtTypes, + if (!(obj = virDomainObjParseFile(statusFile, caps, xmlopt, expectedVirtTypes, VIR_DOMAIN_XML_INTERNAL_STATUS | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES))) @@ -15606,11 +15606,11 @@ error: int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, int liveStatus, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15645,10 +15645,10 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, VIR_INFO("Loading config file '%s.xml'", entry->d_name); if (liveStatus) dom = virDomainObjListLoadStatus(doms, - caps, - xmlopt, configDir, entry->d_name, + caps, + xmlopt, expectedVirtTypes, notify, opaque); @@ -16048,9 +16048,9 @@ cleanup: * persistent and active, true for transitions across save files or * snapshots). */ virDomainDefPtr -virDomainDefCopy(virCapsPtr caps, +virDomainDefCopy(virDomainDefPtr src, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - virDomainDefPtr src, bool migratable) { char *xml; @@ -16065,21 +16065,21 @@ virDomainDefCopy(virCapsPtr caps, if (!(xml = virDomainDefFormat(src, write_flags))) return NULL; - ret = virDomainDefParseString(caps, xmlopt, xml, -1, read_flags); + ret = virDomainDefParseString(xml, caps, xmlopt, -1, read_flags); VIR_FREE(xml); return ret; } virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - virDomainObjPtr dom) +virDomainObjCopyPersistentDef(virDomainObjPtr dom, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt) { virDomainDefPtr cur; cur = virDomainObjGetPersistentDef(caps, xmlopt, dom); - return virDomainDefCopy(caps, xmlopt, cur, false); + return virDomainDefCopy(cur, caps, xmlopt, false); } @@ -16519,10 +16519,10 @@ virDomainNetFind(virDomainDefPtr def, const char *device) * Returns a pointer to copied @src or NULL in case of error. */ virDomainDeviceDefPtr -virDomainDeviceDefCopy(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, - virDomainDeviceDefPtr src) + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt) { virDomainDeviceDefPtr ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -16589,7 +16589,7 @@ virDomainDeviceDefCopy(virCapsPtr caps, goto cleanup; xmlStr = virBufferContentAndReset(&buf); - ret = virDomainDeviceDefParse(caps, xmlopt, def, xmlStr, flags); + ret = virDomainDeviceDefParse(xmlStr, def, caps, xmlopt, flags); cleanup: VIR_FREE(xmlStr); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 69a468a..e54dadc 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2026,10 +2026,10 @@ void virDomainHubDefFree(virDomainHubDefPtr def); void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); -virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, - virDomainDeviceDefPtr src); + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, @@ -2057,8 +2057,8 @@ enum { VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1), }; virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLOptionPtr xmlopt, const virDomainDefPtr def, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef); void virDomainObjAssignDef(virDomainObjPtr domain, @@ -2081,34 +2081,36 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, unsigned int *flags, virDomainDefPtr *persistentDef); -virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - virDomainDefPtr src, bool migratable); -virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - virDomainObjPtr dom); +virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + bool migratable); +virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt); void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); -virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, +virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, - const char *xmlStr, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int flags); -virDomainDefPtr virDomainDefParseString(virCapsPtr caps, +virDomainDefPtr virDomainDefParseString(const char *xmlStr, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags); -virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, +virDomainDefPtr virDomainDefParseFile(const char *filename, + virCapsPtr caps, virDomainXMLOptionPtr xmlopt, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags); -virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - xmlDocPtr doc, +virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags); @@ -2232,11 +2234,11 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, void *opaque); int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, int liveStatus, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 3a3173f..bd5684d 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -264,7 +264,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, _("missing domain in snapshot")); goto cleanup; } - def->dom = virDomainDefParseNode(caps, xmlopt, xml, domainNode, + def->dom = virDomainDefParseNode(xml, domainNode, caps, xmlopt, expectedVirtTypes, (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE)); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 1335ee6..08381fc 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -2887,8 +2887,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; } - def = virDomainDefParseString(priv->caps, priv->xmlopt, - domainXml, 1 << VIR_DOMAIN_VIRT_VMWARE, 0); + def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, + 1 << VIR_DOMAIN_VIRT_VMWARE, 0); if (def == NULL) { return NULL; @@ -3103,8 +3103,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) } /* Parse domain XML */ - def = virDomainDefParseString(priv->caps, priv->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, + 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); if (def == NULL) { diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 4015389..bf682c5 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -563,8 +563,8 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from, goto error; } - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -1246,11 +1246,12 @@ libxlStartup(bool privileged, /* Load running domains first. */ if (virDomainObjListLoadAllConfigs(libxl_driver->domains, - libxl_driver->caps, - libxl_driver->xmlopt, libxl_driver->stateDir, libxl_driver->autostartDir, - 1, 1 << VIR_DOMAIN_VIRT_XEN, + 1, + libxl_driver->caps, + libxl_driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -1258,11 +1259,12 @@ libxlStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(libxl_driver->domains, - libxl_driver->caps, - libxl_driver->xmlopt, libxl_driver->configDir, libxl_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_XEN, + 0, + libxl_driver->caps, + libxl_driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -1296,11 +1298,12 @@ libxlReload(void) libxlDriverLock(libxl_driver); virDomainObjListLoadAllConfigs(libxl_driver->domains, - libxl_driver->caps, - libxl_driver->xmlopt, libxl_driver->configDir, libxl_driver->autostartDir, - 1, 1 << VIR_DOMAIN_VIRT_XEN, + 1, + libxl_driver->caps, + libxl_driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, NULL, libxl_driver); virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain, @@ -1455,14 +1458,13 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL); libxlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -2242,9 +2244,8 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, if (fd < 0) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -2932,7 +2933,8 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, goto cleanup; } - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, domainXml, + if (!(def = virDomainDefParseString(domainXml, + driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; @@ -3034,14 +3036,13 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml) virDomainDefPtr oldDef = NULL; libxlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, 0, &oldDef))) goto cleanup; @@ -3557,14 +3558,14 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, priv = vm->privateData; if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { - if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, - vm->def, xml, + if (!(dev = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; /* Make a copy for updated domain. */ - if (!(vmdef = virDomainObjCopyPersistentDef(driver->caps, - driver->xmlopt, vm))) + if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, + driver->xmlopt))) goto cleanup; switch (action) { @@ -3588,8 +3589,8 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, if (flags & VIR_DOMAIN_DEVICE_MODIFY_LIVE) { /* If dev exists it was created to modify the domain config. Free it. */ virDomainDeviceDefFree(dev); - if (!(dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, - vm->def, xml, + if (!(dev = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 440a183..ed73fa1 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -169,8 +169,8 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) ctrl->name)) == NULL) goto error; - if ((ctrl->def = virDomainDefParseFile(caps, xmlopt, - configFile, + if ((ctrl->def = virDomainDefParseFile(configFile, + caps, xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, 0)) == NULL) goto error; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 572329d..8afa664 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -413,7 +413,7 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) virDomainDefPtr oldDef = NULL; lxcDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -427,11 +427,9 @@ static virDomainPtr lxcDomainDefine(virConnectPtr conn, const char *xml) goto cleanup; } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, - 0, - &oldDef))) + 0, &oldDef))) goto cleanup; def = NULL; vm->persistent = 1; @@ -1069,7 +1067,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); lxcDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1084,9 +1082,8 @@ lxcDomainCreateAndStart(virConnectPtr conn, } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1491,11 +1488,11 @@ static int lxcStartup(bool privileged, /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(lxc_driver->domains, + lxc_driver->stateDir, + NULL, 1, lxc_driver->caps, lxc_driver->xmlopt, - lxc_driver->stateDir, - NULL, - 1, 1 << VIR_DOMAIN_VIRT_LXC, + 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1503,11 +1500,11 @@ static int lxcStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(lxc_driver->domains, + lxc_driver->configDir, + lxc_driver->autostartDir, 0, lxc_driver->caps, lxc_driver->xmlopt, - lxc_driver->configDir, - lxc_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_LXC, + 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1551,11 +1548,11 @@ lxcReload(void) { lxcDriverLock(lxc_driver); virDomainObjListLoadAllConfigs(lxc_driver->domains, + lxc_driver->configDir, + lxc_driver->autostartDir, 0, lxc_driver->caps, lxc_driver->xmlopt, - lxc_driver->configDir, - lxc_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_LXC, + 1 << VIR_DOMAIN_VIRT_LXC, lxcNotifyLoadDomain, lxc_driver); lxcDriverUnlock(lxc_driver); @@ -1805,7 +1802,7 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlopt, vm); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt); if (!vmdef) goto cleanup; } @@ -4360,8 +4357,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; } - dev = dev_copy = virDomainDeviceDefParse(driver->caps, driver->xmlopt, - vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -4372,8 +4369,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy = virDomainDeviceDefCopy(driver->caps, driver->xmlopt, - vm->def, dev); + dev_copy = virDomainDeviceDefCopy(dev, vm->def, + driver->caps, driver->xmlopt); if (!dev_copy) goto cleanup; } @@ -4383,7 +4380,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(driver->caps, driver->xmlopt, vm); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt); if (!vmdef) goto cleanup; switch (action) { diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 3cd27a4..3b0731b 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -650,8 +650,8 @@ int openvzLoadDomains(struct openvz_driver *driver) { flags |= VIR_DOMAIN_OBJ_LIST_ADD_LIVE; if (!(dom = virDomainObjListAdd(driver->domains, - driver->xmlopt, def, + driver->xmlopt, flags, NULL))) goto cleanup; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index d334486..9b1919a 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -955,8 +955,8 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr dom = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -967,9 +967,9 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) vmdef->name); goto cleanup; } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, - vmdef, 0, NULL))) + 0, NULL))) goto cleanup; vmdef = NULL; vm->persistent = 1; @@ -1042,8 +1042,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1055,8 +1055,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, goto cleanup; } if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlopt, vmdef, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -2085,8 +2085,8 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, &vmdef) < 0) goto cleanup; - dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, - vmdef, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, vmdef, driver->caps, driver->xmlopt, + VIR_DOMAIN_XML_INACTIVE); if (!dev) goto cleanup; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 5d5353a..7de9cc0 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -830,9 +830,9 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj) if (parallelsAddVNCInfo(def, jobj) < 0) goto cleanup; - if (!(dom = virDomainObjListAdd(privconn->domains, + if (!(dom = virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - def, 0, NULL))) + 0, NULL))) goto cleanup; /* dom is locked here */ @@ -2330,8 +2330,8 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) virDomainObjPtr dom = NULL, olddom = NULL; parallelsDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_PARALLELS, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, + 1 << VIR_DOMAIN_VIRT_PARALLELS, VIR_DOMAIN_XML_INACTIVE)) == NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("Can't parse XML desc")); @@ -2369,9 +2369,9 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) } virObjectUnlock(olddom); - if (!(dom = virDomainObjListAdd(privconn->domains, + if (!(dom = virDomainObjListAdd(privconn->domains, def, privconn->xmlopt, - def, 0, NULL))) { + 0, NULL))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Can't allocate domobj")); goto cleanup; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index cd9a989..8716d4d 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1754,8 +1754,8 @@ phypAttachDevice(virDomainPtr domain, const char *xml) goto cleanup; } - dev = virDomainDeviceDefParse(phyp_driver->caps, NULL, - def, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL, + VIR_DOMAIN_XML_INACTIVE); if (!dev) { goto cleanup; } @@ -3637,8 +3637,9 @@ phypDomainCreateAndStart(virConnectPtr conn, virCheckFlags(0, NULL); - if (!(def = virDomainDefParseString(phyp_driver->caps, phyp_driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_PHYP, + if (!(def = virDomainDefParseString(xml, phyp_driver->caps, + phyp_driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_PHYP, VIR_DOMAIN_XML_SECURE))) goto err; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d3276de..1215fec 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -766,11 +766,11 @@ qemuStartup(bool privileged, /* Get all the running persistent or transient configs first */ if (virDomainObjListLoadAllConfigs(qemu_driver->domains, + cfg->stateDir, + NULL, 1, qemu_driver->caps, qemu_driver->xmlopt, - cfg->stateDir, - NULL, - 1, QEMU_EXPECTED_VIRT_TYPES, + QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -791,11 +791,11 @@ qemuStartup(bool privileged, /* Then inactive persistent configs */ if (virDomainObjListLoadAllConfigs(qemu_driver->domains, + cfg->configDir, + cfg->autostartDir, 0, qemu_driver->caps, qemu_driver->xmlopt, - cfg->configDir, - cfg->autostartDir, - 0, QEMU_EXPECTED_VIRT_TYPES, + QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -865,11 +865,10 @@ qemuReload(void) { cfg = virQEMUDriverGetConfig(qemu_driver); virDomainObjListLoadAllConfigs(qemu_driver->domains, - caps, - qemu_driver->xmlopt, cfg->configDir, - cfg->autostartDir, - 0, QEMU_EXPECTED_VIRT_TYPES, + cfg->autostartDir, 0, + caps, qemu_driver->xmlopt, + QEMU_EXPECTED_VIRT_TYPES, qemuNotifyLoadDomain, qemu_driver); cleanup: virObjectUnref(cfg); @@ -1486,7 +1485,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1503,9 +1502,8 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -2855,7 +2853,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (xmlin) { virDomainDefPtr def = NULL; - if (!(def = virDomainDefParseString(caps, driver->xmlopt, xmlin, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) { goto endjob; @@ -4767,14 +4765,14 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, header.was_running = state; /* Create a domain from this XML */ - if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto error; if (xmlin) { virDomainDefPtr def2 = NULL; - if (!(def2 = virDomainDefParseString(caps, driver->xmlopt, xmlin, + if (!(def2 = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -4947,9 +4945,8 @@ qemuDomainRestoreFlags(virConnectPtr conn, if (fd < 0) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -5277,7 +5274,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - def = virDomainDefParseString(caps, driver->xmlopt, xmlData, + def = virDomainDefParseString(xmlData, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, 0); if (!def) goto cleanup; @@ -5548,7 +5545,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -5565,11 +5562,9 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, - 0, - &oldDef))) + 0, &oldDef))) goto cleanup; def = NULL; @@ -5786,8 +5781,8 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, tmp = dev->data.disk; dev->data.disk = orig_disk; - if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, - vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, + caps, driver->xmlopt))) { dev->data.disk = tmp; goto end; } @@ -6063,8 +6058,8 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm, tmp = dev->data.disk; dev->data.disk = orig_disk; - if (!(dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, - vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, + caps, driver->xmlopt))) { dev->data.disk = tmp; goto end; } @@ -6470,8 +6465,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; } - dev = dev_copy = virDomainDeviceDefParse(caps, driver->xmlopt, - vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6482,7 +6477,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy = virDomainDeviceDefCopy(caps, driver->xmlopt, vm->def, dev); + dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps, driver->xmlopt); if (!dev_copy) goto endjob; } @@ -6497,7 +6492,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlopt, vm); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto endjob; switch (action) { @@ -7944,7 +7939,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlopt, vm); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto cleanup; } @@ -11763,7 +11758,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, /* Easiest way to clone inactive portion of vm->def is via * conversion in and back out of xml. */ if (!(xml = qemuDomainDefFormatLive(driver, vm->def, true, true)) || - !(def->dom = virDomainDefParseString(caps, driver->xmlopt, xml, + !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -12334,7 +12329,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, * than inactive xml? */ snap->def->current = true; if (snap->def->dom) { - config = virDomainDefCopy(caps, driver->xmlopt, snap->def->dom, true); + config = virDomainDefCopy(snap->def->dom, caps, driver->xmlopt, true); if (!config) goto cleanup; } @@ -12827,9 +12822,8 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn, if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2033318..41ad768 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -921,8 +921,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, n); goto error; } - mig->persistent = virDomainDefParseNode(caps, driver->xmlopt, - doc, nodes[0], + mig->persistent = virDomainDefParseNode(doc, nodes[0], + caps, driver->xmlopt, -1, VIR_DOMAIN_XML_INACTIVE); if (!mig->persistent) { /* virDomainDefParseNode already reported @@ -1926,7 +1926,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver, } if (xmlin) { - if (!(def = virDomainDefParseString(caps, driver->xmlopt, xmlin, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2030,7 +2030,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlopt, dom_xml, + if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2071,7 +2071,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, virDomainDefPtr newdef; VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef = virDomainDefParseString(caps, driver->xmlopt, xmlout, + newdef = virDomainDefParseString(xmlout, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE); if (!newdef) @@ -2127,9 +2127,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, } } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 06c19fa..fee63ec 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -729,9 +729,9 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - ctl->def = virDomainDefParseString(ctl->caps, ctl->xmlopt, - xmlStr, -1, - VIR_DOMAIN_XML_INACTIVE); + ctl->def = virDomainDefParseString(xmlStr, + ctl->caps, ctl->xmlopt, + -1, VIR_DOMAIN_XML_INACTIVE); if (ctl->def == NULL) { vah_error(ctl, 0, _("could not parse XML")); goto exit; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d35dfc4..ecfbe33 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -590,9 +590,9 @@ static int testOpenDefault(virConnectPtr conn) { privconn->nextDomID = 1; - if (!(domdef = virDomainDefParseString(privconn->caps, + if (!(domdef = virDomainDefParseString(defaultDomainXML, + privconn->caps, privconn->xmlopt, - defaultDomainXML, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -600,8 +600,9 @@ static int testOpenDefault(virConnectPtr conn) { if (testDomainGenerateIfnames(domdef) < 0) goto error; if (!(domobj = virDomainObjListAdd(privconn->domains, + domdef, privconn->xmlopt, - domdef, 0, NULL))) + 0, NULL))) goto error; domdef = NULL; @@ -933,16 +934,16 @@ static int testOpenFromFile(virConnectPtr conn, _("resolving domain filename")); goto error; } - def = virDomainDefParseFile(privconn->caps, - privconn->xmlopt, absFile, + def = virDomainDefParseFile(absFile, privconn->caps, + privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); VIR_FREE(absFile); if (!def) goto error; } else { - if ((def = virDomainDefParseNode(privconn->caps, privconn->xmlopt, - xml, domains[i], + if ((def = virDomainDefParseNode(xml, domains[i], + privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto error; @@ -950,8 +951,9 @@ static int testOpenFromFile(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0 || !(dom = virDomainObjListAdd(privconn->domains, + def, privconn->xmlopt, - def, 0, NULL))) { + 0, NULL))) { virDomainDefFree(def); goto error; } @@ -1344,16 +1346,16 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + if ((def = virDomainDefParseString(xml,privconn->caps, privconn->xmlopt, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlopt, def, + privconn->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1959,8 +1961,8 @@ testDomainRestoreFlags(virConnectPtr conn, } xml[len] = '\0'; - def = virDomainDefParseString(privconn->caps, privconn->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); if (!def) goto cleanup; @@ -1968,8 +1970,8 @@ testDomainRestoreFlags(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlopt, def, + privconn->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -2510,16 +2512,16 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, virDomainDefPtr oldDef = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlopt, def, + privconn->xmlopt, 0, &oldDef))) goto cleanup; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index f9a7920..2476d1c 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -541,11 +541,11 @@ umlStartup(bool privileged, goto error; if (virDomainObjListLoadAllConfigs(uml_driver->domains, + uml_driver->configDir, + uml_driver->autostartDir, 0, uml_driver->caps, uml_driver->xmlopt, - uml_driver->configDir, - uml_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_UML, + 1 << VIR_DOMAIN_VIRT_UML, NULL, NULL) < 0) goto error; @@ -597,11 +597,11 @@ umlReload(void) { umlDriverLock(uml_driver); virDomainObjListLoadAllConfigs(uml_driver->domains, + uml_driver->configDir, + uml_driver->autostartDir, 0, uml_driver->caps, uml_driver->xmlopt, - uml_driver->configDir, - uml_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_UML, + 1 << VIR_DOMAIN_VIRT_UML, umlNotifyLoadDomain, uml_driver); umlDriverUnlock(uml_driver); @@ -1504,14 +1504,13 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); umlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_UML, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1925,14 +1924,13 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_UML, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlopt, - def, 0, NULL))) goto cleanup; def = NULL; @@ -2080,7 +2078,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, const char *xml) goto cleanup; } - dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml, + dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) @@ -2198,7 +2196,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(driver->caps, driver->xmlopt, vm->def, xml, + dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index eb6460c..d021105 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -5052,8 +5052,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { #endif nsresult rc; - if (!(def = virDomainDefParseString(data->caps, data->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_VBOX, + if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt, + 1 << VIR_DOMAIN_VIRT_VBOX, VIR_DOMAIN_XML_INACTIVE))) { goto cleanup; } @@ -5396,8 +5396,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, goto cleanup; } - dev = virDomainDeviceDefParse(data->caps, data->xmlopt, - def, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, + VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -5631,8 +5631,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(data->caps, data->xmlopt, - def, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, + VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 00a5590..3528f07 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -178,9 +178,9 @@ vmwareLoadDomains(struct vmware_driver *driver) goto cleanup; } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, - vmdef, 0, NULL))) + 0, NULL))) goto cleanup; pDomain = vm->privateData; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 2dd6f81..0e0f59d 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -324,8 +324,8 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) ctx.formatFileName = vmwareCopyVMXFileName; vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -346,8 +346,8 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlopt, vmdef, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -595,8 +595,8 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(driver->caps, driver->xmlopt, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, + 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -617,8 +617,8 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, - driver->xmlopt, vmdef, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 38dce0a..fe6252c 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -1434,8 +1434,8 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, - xmlData, 1 << VIR_DOMAIN_VIRT_XEN, 0))) + if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; if (STREQ(format, XEN_CONFIG_FORMAT_XM)) { diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index f6ce8eb..83d6d39 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -2409,8 +2409,8 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc, unsigned int flags) virCheckFlags(0, NULL); - if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, - xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) return NULL; @@ -2519,8 +2519,8 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2679,8 +2679,8 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2786,8 +2786,8 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlopt, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (virDomainXMLDevID(domain, dev, class, ref, sizeof(ref))) @@ -3127,8 +3127,8 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) return NULL; - if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, - xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt, + 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("failed to parse domain description")); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 69c8f4a..b3a537a 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -1013,7 +1013,7 @@ xenXMDomainDefineXML(virConnectPtr conn, const char *xml) return NULL; } - if (!(def = virDomainDefParseString(priv->caps, priv->xmlopt, xml, + if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) { xenUnifiedUnlock(priv); @@ -1310,10 +1310,10 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain, goto cleanup; def = entry->def; - if (!(dev = virDomainDeviceDefParse(priv->caps, + if (!(dev = virDomainDeviceDefParse(xml, entry->def, + priv->caps, priv->xmlopt, - entry->def, - xml, VIR_DOMAIN_XML_INACTIVE))) + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; switch (dev->type) { @@ -1404,10 +1404,10 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, goto cleanup; def = entry->def; - if (!(dev = virDomainDeviceDefParse(priv->caps, + if (!(dev = virDomainDeviceDefParse(xml, entry->def, + priv->caps, priv->xmlopt, - entry->def, - xml, VIR_DOMAIN_XML_INACTIVE))) + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; switch (dev->type) { diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 712c20b..d619609 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -533,8 +533,8 @@ xenapiDomainCreateXML(virConnectPtr conn, virCheckFlags(0, NULL); - virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlopt, - xmlDesc, + virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc, + priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, flags); createVMRecordFromXml(conn, defPtr, &record, &vm); @@ -1687,8 +1687,8 @@ xenapiDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr domP=NULL; if (!priv->caps) return NULL; - virDomainDefPtr defPtr = virDomainDefParseString(priv->caps, priv->xmlopt, - xml, + virDomainDefPtr defPtr = virDomainDefParseString(xml, + priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, 0); if (!defPtr) diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 16118bb..e0f99f4 100644 --- a/tests/lxcxml2xmltest.c +++ b/tests/lxcxml2xmltest.c @@ -32,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) if (virtTestLoadFile(outxml, &outXmlData) < 0) goto fail; - if (!(def = virDomainDefParseString(caps, xmlopt, inXmlData, + if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 71921e7..7a63e90 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -100,7 +100,7 @@ static int testCompareXMLToArgvFiles(const char *xml, goto out; conn->secretDriver = &fakeSecretDriver; - if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlopt, xml, + if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) { if (flags & FLAG_EXPECT_PARSE_ERROR) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 7305e2d..8f892d1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -32,7 +32,7 @@ testCompareXMLToXMLFiles(const char *inxml, const char *outxml, bool live) if (virtTestLoadFile(outxml, &outXmlData) < 0) goto fail; - if (!(def = virDomainDefParseString(driver.caps, driver.xmlopt, inXmlData, + if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, QEMU_EXPECTED_VIRT_TYPES, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 6492bac..dadf40c 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -51,7 +51,7 @@ static int testCompareXMLToArgvFiles(const char *xml, if (len && expectargv[len - 1] == '\n') expectargv[len - 1] = '\0'; - if (!(vmdef = virDomainDefParseFile(driver.caps, driver.xmlopt, xml, + if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index ac229de..c595f9b 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -166,7 +166,7 @@ testSELinuxLoadDef(const char *testname) goto cleanup; } - if (!(def = virDomainDefParseString(caps, xmlopt, xmlstr, + if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, QEMU_EXPECTED_VIRT_TYPES, 0))) goto cleanup; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 80833eb..af80061 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -69,7 +69,7 @@ testCompareParseXML(const char *xmcfg, const char *xml, int xendConfigVersion) priv.caps = caps; conn->privateData = &priv; - if (!(def = virDomainDefParseString(caps, xmlopt, xmlData, + if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index daf4ac6..a091d45 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -32,7 +32,7 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) if (virtTestLoadFile(sexpr, &sexprData) < 0) goto fail; - if (!(def = virDomainDefParseString(caps, xmlopt, xmlData, + if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 5195ffa..cee7f9e 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -94,7 +94,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - def = virDomainDefParseString(caps, xmlopt, xmlData, + def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:13PM +0200, Peter Krempa wrote:
Move the xmlopt and caps arguments to the end of the argument list. --- src/conf/domain_conf.c | 106 +++++++++++++++++++-------------------- src/conf/domain_conf.h | 44 ++++++++-------- src/conf/snapshot_conf.c | 2 +- src/esx/esx_driver.c | 8 +-- src/libxl/libxl_driver.c | 55 ++++++++++---------- src/lxc/lxc_controller.c | 4 +- src/lxc/lxc_driver.c | 43 ++++++++-------- src/openvz/openvz_conf.c | 2 +- src/openvz/openvz_driver.c | 18 +++---- src/parallels/parallels_driver.c | 12 ++--- src/phyp/phyp_driver.c | 9 ++-- src/qemu/qemu_driver.c | 68 ++++++++++++------------- src/qemu/qemu_migration.c | 13 +++-- src/security/virt-aa-helper.c | 6 +-- src/test/test_driver.c | 36 ++++++------- src/uml/uml_driver.c | 30 ++++++----- src/vbox/vbox_tmpl.c | 12 ++--- src/vmware/vmware_conf.c | 4 +- src/vmware/vmware_driver.c | 12 ++--- src/xen/xen_driver.c | 4 +- src/xen/xend_internal.c | 20 ++++---- src/xen/xm_internal.c | 14 +++--- src/xenapi/xenapi_driver.c | 8 +-- tests/lxcxml2xmltest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 2 +- tests/qemuxmlnstest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 2 +- tests/xml2vmxtest.c | 2 +- 31 files changed, 270 insertions(+), 276 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

This patch implements the devices post parse cllback and uses it to fill the default qemu network card model into the XML if none is specified. Libvirt assumes that the network card model for qemu is the "rtl8139". Record this in the XML using the new callback to avoid user confusion. --- src/qemu/qemu_conf.c | 2 +- src/qemu/qemu_domain.c | 25 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 ++-- .../qemuxml2argv-net-eth-ifname.args | 4 ++-- .../qemuxml2argv-net-eth-ifname.xml | 1 + .../qemuxml2argv-net-eth-names.args | 8 +++---- tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 ++-- .../qemuxml2argv-net-openvswitch.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 ++- tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 + .../qemuxml2argv-net-virtio-network-portgroup.xml | 2 ++ .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + 18 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c709188..7ee60d6 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -554,7 +554,7 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void) { - return virDomainXMLOptionNew(NULL, + return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a0a66dd..80e70cd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -662,6 +662,31 @@ virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = { }; +static int +qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_NET && + dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (!dev->data.net->model && + !(dev->data.net->model = strdup("rtl8139"))) + goto no_memory; + } + return 0; + +no_memory: + virReportOOMError(); + return -1; +} + + +virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = { + .devicesPostParseCallback = qemuDomainDeviceDefPostParse, +}; + + static void qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj) { diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 26d5859..089ced0 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -342,5 +342,6 @@ void qemuDomainCleanupRun(virQEMUDriverPtr driver, extern virDomainXMLPrivateDataCallbacks virQEMUDriverPrivateDataCallbacks; extern virDomainXMLNamespace virQEMUDriverDomainXMLNamespace; +extern virDomainDefParserConfig virQEMUDriverDomainDefParserConfig; #endif /* __QEMU_DOMAIN_H__ */ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml index bf7dde5..885e854 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-bandwidth.xml @@ -44,6 +44,7 @@ <interface type='network'> <mac address='52:54:00:24:a5:9f'/> <source network='default'/> + <model type='rtl8139'/> <bandwidth> <inbound average='1000' peak='4000' burst='1024'/> <outbound average='128' peak='256' burst='32768'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-client.args b/tests/qemuxml2argvdata/qemuxml2argv-net-client.args index 7974f2e..34fab0a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-client.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-client.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,connect=192.168.0.1:5558,vlan=0 \ --serial none -parallel none +macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\ +connect=192.168.0.1:5558,vlan=0 -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args index cced5d5..6aef307 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=00:11:22:33:44:55,vlan=0 -net tap,ifname=nic02,script=/etc/qemu-ifup,\ -vlan=0 -serial none -parallel none +macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,ifname=nic02,\ +script=/etc/qemu-ifup,vlan=0 -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml index 04a4ca4..b150371 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-ifname.xml @@ -25,6 +25,7 @@ <mac address='00:11:22:33:44:55'/> <script path='/etc/qemu-ifup'/> <target dev='nic02'/> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args index dc15f63..57761c5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth-names.args @@ -1,7 +1,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=00:11:22:33:44:55,vlan=0,name=net0 -net tap,script=/etc/qemu-ifup,\ -vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,vlan=1,model=e1000,\ -name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 -serial none \ --parallel none +macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139,name=net0 -net tap,\ +script=/etc/qemu-ifup,vlan=0,name=hostnet0 -net nic,macaddr=00:11:22:33:44:56,\ +vlan=1,model=e1000,name=net1 -net tap,script=/etc/qemu-ifup,vlan=1,name=hostnet1 \ +-serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args index a482193..877dac2 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=00:11:22:33:44:55,vlan=0 -net tap,script=/etc/qemu-ifup,vlan=0 -serial \ -none -parallel none +macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net tap,script=/etc/qemu-ifup,\ +vlan=0 -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml index 87dd65f..eca5da5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml @@ -24,6 +24,7 @@ <interface type='ethernet'> <mac address='00:11:22:33:44:55'/> <script path='/etc/qemu-ifup'/> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml index 81f70d0..9be0d2d 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-hostdev.xml @@ -32,6 +32,7 @@ <virtualport type='802.1Qbg'> <parameters managerid='11' typeid='1193047' typeidversion='2' instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> </virtualport> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args b/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args index fc2091b..ed4f01e 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,mcast=192.0.0.1:5558,vlan=0 \ --serial none -parallel none +macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,mcast=192.0.0.1:5558,\ +vlan=0 -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml index ff09844..9c2c5dc 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-openvswitch.xml @@ -32,6 +32,7 @@ <virtualport type='openvswitch'> <parameters interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' profileid='bob'/> </virtualport> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-server.args b/tests/qemuxml2argvdata/qemuxml2argv-net-server.args index 7c9d735..c92a3ff 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-server.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-server.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=52:54:00:8c:b9:05,vlan=0 -net socket,listen=192.168.0.1:5558,vlan=0 \ --serial none -parallel none +macaddr=52:54:00:8c:b9:05,vlan=0,model=rtl8139 -net socket,\ +listen=192.168.0.1:5558,vlan=0 -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args index 7364281..814167b 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args @@ -1,4 +1,5 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ -no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 -net nic,\ -macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -serial none -parallel none +macaddr=00:11:22:33:44:55,vlan=0,model=rtl8139 -net user,vlan=0 -serial none \ +-parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml index 37e5edf..fe3a271 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml @@ -23,6 +23,7 @@ <controller type='ide' index='0'/> <interface type='user'> <mac address='00:11:22:33:44:55'/> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml index c84ed3f..0fb9b2c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-network-portgroup.xml @@ -38,6 +38,7 @@ <virtualport> <parameters instanceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f' interfaceid='09b11c53-8b5c-4eeb-8f00-d84eaa0aaa4f'/> </virtualport> + <model type='rtl8139'/> </interface> <interface type='network'> <mac address='22:11:22:33:44:55'/> @@ -45,6 +46,7 @@ <virtualport type='802.1Qbh'> <parameters profileid='testhis99'/> </virtualport> + <model type='rtl8139'/> </interface> <memballoon model='virtio'/> </devices> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index cd19b64..54b68fa 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -62,6 +62,7 @@ <interface type='ethernet'> <mac address='52:54:00:71:70:89'/> <script path='/etc/qemu-ifup'/> + <model type='rtl8139'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </interface> <serial type='pty'> -- 1.8.1.5

On 04/04/2013 02:10 PM, Peter Krempa wrote:
This patch implements the devices post parse cllback and uses it to fill the default qemu network card model into the XML if none is specified.
Libvirt assumes that the network card model for qemu is the "rtl8139". Record this in the XML using the new callback to avoid user confusion. + if (dev->type == VIR_DOMAIN_DEVICE_NET && + dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (!dev->data.net->model && + !(dev->data.net->model = strdup("rtl8139"))) + goto no_memory; + }
Not sure about other architectures, but this will break s390. You should squash in something similar to (hope t-bird isn't breaking format again): diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e5e9223..c3a7aff 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -678,7 +678,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, - virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainDefPtr def, virCapsPtr caps ATTRIBUTE_UNUSED, void *opaque) { @@ -688,9 +688,15 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_NET && dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { + const char *model = NULL; + if (def->os.arch == VIR_ARCH_S390 || + def->os.arch == VIR_ARCH_S390X) + model = "virtio"; + else + model = "rtl8139"; if (!dev->data.net->model && - !(dev->data.net->model = strdup("rtl8139"))) - goto no_memory; + !(dev->data.net->model = strdup(model))) + goto no_memory; } /* set default disk types and drivers */ -- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 04/04/13 17:35, Viktor Mihajlovski wrote:
On 04/04/2013 02:10 PM, Peter Krempa wrote:
This patch implements the devices post parse cllback and uses it to fill the default qemu network card model into the XML if none is specified.
Libvirt assumes that the network card model for qemu is the "rtl8139". Record this in the XML using the new callback to avoid user confusion. + if (dev->type == VIR_DOMAIN_DEVICE_NET && + dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (!dev->data.net->model && + !(dev->data.net->model = strdup("rtl8139"))) + goto no_memory; + }
Not sure about other architectures, but this will break s390. You should squash in something similar to (hope t-bird isn't breaking format again):
Hmmm, I actually lost a cleanup patch on the piece of code in the qemu command line generator that assigns the default value for this parameter. That piece of code would show, that this actually is a 1:1 port of what qemu does all the time: char * qemuBuildNicDevStr(virDomainNetDefPtr net, int vlan, int bootindex, virQEMUCapsPtr qemuCaps) { virBuffer buf = VIR_BUFFER_INITIALIZER; const char *nic; bool usingVirtio = false; char macaddr[VIR_MAC_STRING_BUFLEN]; if (!net->model) { nic = "rtl8139"; } else if (STREQ(net->model, "virtio")) { if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { nic = "virtio-net-ccw"; } else if (net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) { nic = "virtio-net-s390"; } else { nic = "virtio-net-pci"; } usingVirtio = true; } else { nic = net->model; } thus on s390, the default model is the realtek one too (unless it gets changed somewhere else). I don't know if the realtek card works on the s390 qemu too, but if it doesn't I don't mind changing it to virtio. In case it does work, we need to consider if we aren't regressing here. I will follow up with some patches but I'd rather not touch this series any more as rebasing it is tedious. Peter

On 04/04/2013 09:50 PM, Peter Krempa wrote:
I don't know if the realtek card works on the s390 qemu too, but if it doesn't I don't mind changing it to virtio. In case it does work, we need to consider if we aren't regressing here.
commit 539d73d intercepts this global defaulting but relies on the model being NULL. So your patch is indeed causing a regression. We can fix this before the next release though. No need for a V5.1.1 ;-) -- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 04/05/13 09:37, Viktor Mihajlovski wrote:
On 04/04/2013 09:50 PM, Peter Krempa wrote:
I don't know if the realtek card works on the s390 qemu too, but if it doesn't I don't mind changing it to virtio. In case it does work, we need to consider if we aren't regressing here.
commit 539d73d intercepts this global defaulting but relies on the model being NULL. So your patch is indeed causing a regression. We can fix this before the next release though. No need for a V5.1.1 ;-)
That's the place I overlooked! :D okay, I will go with your fix in the connection callback and then we can get rid of the workarounds and have the management centralised. Peter

On Thu, Apr 04, 2013 at 02:10:14PM +0200, Peter Krempa wrote:
This patch implements the devices post parse cllback and uses it to fill the default qemu network card model into the XML if none is specified.
Libvirt assumes that the network card model for qemu is the "rtl8139". Record this in the XML using the new callback to avoid user confusion. --- src/qemu/qemu_conf.c | 2 +- src/qemu/qemu_domain.c | 25 ++++++++++++++++++++++ src/qemu/qemu_domain.h | 1 + .../qemuxml2argv-net-bandwidth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-client.args | 4 ++-- .../qemuxml2argv-net-eth-ifname.args | 4 ++-- .../qemuxml2argv-net-eth-ifname.xml | 1 + .../qemuxml2argv-net-eth-names.args | 8 +++---- tests/qemuxml2argvdata/qemuxml2argv-net-eth.args | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-net-eth.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-hostdev.xml | 1 + tests/qemuxml2argvdata/qemuxml2argv-net-mcast.args | 4 ++-- .../qemuxml2argv-net-openvswitch.xml | 1 + .../qemuxml2argvdata/qemuxml2argv-net-server.args | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 3 ++- tests/qemuxml2argvdata/qemuxml2argv-net-user.xml | 1 + .../qemuxml2argv-net-virtio-network-portgroup.xml | 2 ++ .../qemuxml2xmlout-graphics-spice-timeout.xml | 1 + 18 files changed, 52 insertions(+), 16 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/04/2013 06:10 AM, Peter Krempa wrote:
This patch implements the devices post parse cllback and uses it to fill
s/cllback/callback/
the default qemu network card model into the XML if none is specified.
Libvirt assumes that the network card model for qemu is the "rtl8139". Record this in the XML using the new callback to avoid user confusion. ---
+static int +qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_NET && + dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { + if (!dev->data.net->model && + !(dev->data.net->model = strdup("rtl8139")))
Possible merge conflict with VIR_STRDUP patches, but we'll cross that bridge when we get there. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

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. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 31 +++++++++++++++++++------------ src/openvz/openvz_conf.c | 1 - src/openvz/openvz_driver.c | 26 +++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 8abe88a..064da80 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -168,7 +168,6 @@ struct _virCaps { int defaultDiskDriverType; /* enum virStorageFileFormat */ int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); bool hasWideScsiBus; - const char *defaultInitPath; }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ca2b805..8467424 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2480,6 +2480,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, virCapsPtr caps, @@ -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) { diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 3b0731b..439e457 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -206,7 +206,6 @@ virCapsPtr openvzCapsInit(void) NULL) == NULL) goto no_memory; - caps->defaultInitPath = "/sbin/init"; caps->defaultConsoleTargetType = openvzDefaultConsoleType; return caps; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 9b1919a..583a415 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -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) -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:15PM +0200, Peter Krempa wrote:
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. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 31 +++++++++++++++++++------------ src/openvz/openvz_conf.c | 1 - src/openvz/openvz_driver.c | 26 +++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 15 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

This patch removes the defaultDiskDriverName from the virCaps structure. This particular default value is used only in the qemu driver so this patch uses the recently added callback to fill the driver name if it's needed instead of propagating it through virCaps. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 8 -------- src/qemu/qemu_conf.c | 5 ++--- src/qemu/qemu_conf.h | 3 ++- src/qemu/qemu_domain.c | 25 ++++++++++++++++++++++--- src/qemu/qemu_driver.c | 2 +- tests/domainsnapshotxml2xmltest.c | 2 +- tests/qemuargv2xmltest.c | 2 +- tests/qemumonitorjsontest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 2 +- tests/qemuxmlnstest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- 13 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 064da80..a3838e6 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -164,7 +164,6 @@ struct _virCaps { /* Move to virDomainXMLOption later */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; unsigned int emulatorRequired : 1; - const char *defaultDiskDriverName; int defaultDiskDriverType; /* enum virStorageFileFormat */ int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); bool hasWideScsiBus; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8467424..1771c4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4829,11 +4829,6 @@ virDomainDiskDefParseXML(virCapsPtr caps, def->format = caps->defaultDiskDriverType; } - if (!def->driverName && - caps->defaultDiskDriverName && - !(def->driverName = strdup(caps->defaultDiskDriverName))) - goto no_memory; - if (mirrorFormat) { def->mirrorFormat = virStorageFileFormatTypeFromString(mirrorFormat); if (def->mirrorFormat <= 0) { @@ -4896,9 +4891,6 @@ cleanup: ctxt->node = save_ctxt; return def; -no_memory: - virReportOOMError(); - error: virDomainDiskDefFree(def); def = NULL; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 7ee60d6..268223f 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -552,8 +552,9 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) } virDomainXMLOptionPtr -virQEMUDriverCreateXMLConf(void) +virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) { + virQEMUDriverDomainDefParserConfig.priv = driver; return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); @@ -574,10 +575,8 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver) goto no_memory; if (cfg->allowDiskFormatProbing) { - caps->defaultDiskDriverName = NULL; caps->defaultDiskDriverType = VIR_STORAGE_FILE_AUTO; } else { - caps->defaultDiskDriverName = "qemu"; caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW; } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 12f74be..5299920 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -301,6 +301,7 @@ void qemuSharedDiskEntryFree(void *payload, const void *name) ATTRIBUTE_NONNULL(1); int qemuDriverAllocateID(virQEMUDriverPtr driver); -virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(void); +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver); + #endif /* __QEMUD_CONF_H */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 80e70cd..2e7a986 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -666,19 +666,38 @@ static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virDomainDefPtr def ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED, - void *opaque ATTRIBUTE_UNUSED) + void *opaque) { + int ret = -1; + virQEMUDriverPtr driver = opaque; + virQEMUDriverConfigPtr cfg = NULL; + if (dev->type == VIR_DOMAIN_DEVICE_NET && dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV) { if (!dev->data.net->model && !(dev->data.net->model = strdup("rtl8139"))) goto no_memory; } - return 0; + + if (dev->type == VIR_DOMAIN_DEVICE_DISK && + !dev->data.disk->driverName && + driver && + (cfg = virQEMUDriverGetConfig(driver))) { + if (!cfg->allowDiskFormatProbing && + !(dev->data.disk->driverName = strdup("qemu"))) { + goto no_memory; + } + } + + ret = 0; + +cleanup: + virObjectUnref(cfg); + return ret; no_memory: virReportOOMError(); - return -1; + goto cleanup; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 1215fec..3f62414 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -723,7 +723,7 @@ qemuStartup(bool privileged, if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL) goto error; - if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf())) + if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf(qemu_driver))) goto error; /* If hugetlbfs is present, then we need to create a sub-directory within diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index ac5137e..6f1c600 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -91,7 +91,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST(name, uuid, internal) \ diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index ec250ad..9167d88 100644 --- a/tests/qemuargv2xmltest.c +++ b/tests/qemuargv2xmltest.c @@ -120,7 +120,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST_FULL(name, extraFlags, migrateFrom) \ diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index fdf67a1..24685c7 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -451,7 +451,7 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(xmlopt = virQEMUDriverCreateXMLConf())) + !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7a63e90..099fb36 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -294,7 +294,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; VIR_FREE(driver.config->stateDir); if ((driver.config->stateDir = strdup("/nowhere")) == NULL) diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 8f892d1..aa058bd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -106,7 +106,7 @@ mymain(void) if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST_FULL(name, is_different, when) \ diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index dadf40c..e6b42dc 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -204,7 +204,7 @@ mymain(void) driver.config = virQEMUDriverConfigNew(false); if ((driver.caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(driver.xmlopt = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; if (virAsprintf(&map, "%s/src/cpu/cpu_map.xml", abs_top_srcdir) < 0 || cpuMapOverride(map) < 0) { diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index c595f9b..f585f6f 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -328,7 +328,7 @@ mymain(void) if ((caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(xmlopt = virQEMUDriverCreateXMLConf())) + if (!(xmlopt = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; #define DO_TEST_LABELING(name) \ -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:16PM +0200, Peter Krempa wrote:
This patch removes the defaultDiskDriverName from the virCaps structure. This particular default value is used only in the qemu driver so this patch uses the recently added callback to fill the driver name if it's needed instead of propagating it through virCaps. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 8 -------- src/qemu/qemu_conf.c | 5 ++--- src/qemu/qemu_conf.h | 3 ++- src/qemu/qemu_domain.c | 25 ++++++++++++++++++++++--- src/qemu/qemu_driver.c | 2 +- tests/domainsnapshotxml2xmltest.c | 2 +- tests/qemuargv2xmltest.c | 2 +- tests/qemumonitorjsontest.c | 2 +- tests/qemuxml2argvtest.c | 2 +- tests/qemuxml2xmltest.c | 2 +- tests/qemuxmlnstest.c | 2 +- tests/securityselinuxlabeltest.c | 2 +- 13 files changed, 34 insertions(+), 24 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

This patch removes the emulatorRequired field and associated infrastructure from the virCaps object. Instead the driver specific callbacks are used as this field isn't enforced by all drivers. This patch implements the appropriate callbacks in the qemu and lxc driver and moves to check to that location. --- src/conf/capabilities.c | 10 ---------- src/conf/capabilities.h | 7 ------- src/conf/domain_conf.c | 17 +++++++---------- src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 3 +-- src/lxc/lxc_conf.c | 6 ++---- src/lxc/lxc_domain.c | 17 +++++++++++++++++ src/lxc/lxc_domain.h | 1 + src/qemu/qemu_capabilities.c | 3 --- src/qemu/qemu_domain.c | 15 +++++++++++++++ tests/lxcxml2xmldata/lxc-hostdev.xml | 1 + tests/lxcxml2xmldata/lxc-systemd.xml | 1 + 12 files changed, 47 insertions(+), 36 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index d53d5a3..1d29ce6 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -935,13 +935,3 @@ virCapabilitiesGenerateMac(virCapsPtr caps, { virMacAddrGenerate(caps->macPrefix, mac); } - -extern void -virCapabilitiesSetEmulatorRequired(virCapsPtr caps) { - caps->emulatorRequired = 1; -} - -extern unsigned int -virCapabilitiesIsEmulatorRequired(virCapsPtr caps) { - return caps->emulatorRequired; -} diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index a3838e6..5e7a5f6 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -163,7 +163,6 @@ struct _virCaps { /* Move to virDomainXMLOption later */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; - unsigned int emulatorRequired : 1; int defaultDiskDriverType; /* enum virStorageFileFormat */ int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); bool hasWideScsiBus; @@ -186,12 +185,6 @@ extern void virCapabilitiesGenerateMac(virCapsPtr caps, virMacAddrPtr mac); -extern void -virCapabilitiesSetEmulatorRequired(virCapsPtr caps); - -extern unsigned int -virCapabilitiesIsEmulatorRequired(virCapsPtr caps); - extern int virCapabilitiesAddHostFeature(virCapsPtr caps, const char *name); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1771c4d..6a480d0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9165,8 +9165,10 @@ virDomainLeaseRemove(virDomainDefPtr def, } -static char *virDomainDefDefaultEmulator(virDomainDefPtr def, - virCapsPtr caps) { +char * +virDomainDefGetDefaultEmulator(virDomainDefPtr def, + virCapsPtr caps) +{ const char *type; const char *emulator; char *retemu; @@ -9185,13 +9187,13 @@ static char *virDomainDefDefaultEmulator(virDomainDefPtr def, if (!emulator) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("no emulator for domain %s os type %s on architecture %s"), + _("no emulator for domain %s os type %s " + "on architecture %s"), type, def->os.type, virArchToString(def->os.arch)); return NULL; } - retemu = strdup(emulator); - if (!retemu) + if (!(retemu = strdup(emulator))) virReportOOMError(); return retemu; @@ -10385,11 +10387,6 @@ virDomainDefParseXML(xmlDocPtr xml, } def->emulator = virXPathString("string(./devices/emulator[1])", ctxt); - if (!def->emulator && virCapabilitiesIsEmulatorRequired(caps)) { - def->emulator = virDomainDefDefaultEmulator(def, caps); - if (!def->emulator) - goto error; - } /* analysis of the disk devices */ if ((n = virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e54dadc..19a66ed 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2476,4 +2476,6 @@ int virDomainObjListExport(virDomainObjListPtr doms, virDomainVcpuPinDefPtr virDomainLookupVcpuPin(virDomainDefPtr def, int vcpuid); +char *virDomainDefGetDefaultEmulator(virDomainDefPtr def, virCapsPtr caps); + #endif /* __DOMAIN_CONF_H */ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2930104..36e4ee0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -21,9 +21,7 @@ virCapabilitiesFormatXML; virCapabilitiesFreeMachines; virCapabilitiesFreeNUMAInfo; virCapabilitiesGenerateMac; -virCapabilitiesIsEmulatorRequired; virCapabilitiesNew; -virCapabilitiesSetEmulatorRequired; virCapabilitiesSetHostCPU; virCapabilitiesSetMacPrefix; @@ -118,6 +116,7 @@ virDomainDefFormat; virDomainDefFormatInternal; virDomainDefFree; virDomainDefGenSecurityLabelDef; +virDomainDefGetDefaultEmulator; virDomainDefGetSecurityLabelDef; virDomainDefParseFile; virDomainDefParseNode; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 377d8af..ce8c2b5 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -119,9 +119,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) goto error; } - /* LXC Requires an emulator in the XML */ - virCapabilitiesSetEmulatorRequired(caps); - if (driver) { /* Security driver data */ const char *doi, *model; @@ -159,11 +156,12 @@ error: virDomainXMLOptionPtr lxcDomainXMLConfInit(void) { - return virDomainXMLOptionNew(NULL, + return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, &virLXCDriverPrivateDataCallbacks, NULL); } + int lxcLoadDriverConfig(virLXCDriverPtr driver) { char *filename; diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 08cf8f6..8090789 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -79,3 +79,20 @@ virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks = { .format = virLXCDomainObjPrivateXMLFormat, .parse = virLXCDomainObjPrivateXMLParse, }; + +static int +virLXCDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, + void *opaque ATTRIBUTE_UNUSED) +{ + /* check for emulator and create a default one if needed */ + if (!def->emulator && + !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) + return -1; + + return 0; +} + +virDomainDefParserConfig virLXCDriverDomainDefParserConfig = { + .domainPostParseCallback = virLXCDomainDefPostParse, +}; diff --git a/src/lxc/lxc_domain.h b/src/lxc/lxc_domain.h index 007ea84..12753aa 100644 --- a/src/lxc/lxc_domain.h +++ b/src/lxc/lxc_domain.h @@ -39,5 +39,6 @@ struct _virLXCDomainObjPrivate { }; extern virDomainXMLPrivateDataCallbacks virLXCDriverPrivateDataCallbacks; +extern virDomainDefParserConfig virLXCDriverDomainDefParserConfig; #endif /* __LXC_DOMAIN_H__ */ diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index aa381b4..748fd40 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -909,9 +909,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) i) < 0) goto error; - /* QEMU Requires an emulator in the XML */ - virCapabilitiesSetEmulatorRequired(caps); - caps->defaultConsoleTargetType = virQEMUCapsDefaultConsoleType; return caps; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 2e7a986..3073257 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -663,6 +663,20 @@ virDomainXMLNamespace virQEMUDriverDomainXMLNamespace = { static int +qemuDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, + void *opaque ATTRIBUTE_UNUSED) +{ + /* check for emulator and create a default one if needed */ + if (!def->emulator && + !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) + return -1; + + return 0; +} + + +static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virDomainDefPtr def ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED, @@ -703,6 +717,7 @@ no_memory: virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = { .devicesPostParseCallback = qemuDomainDeviceDefPostParse, + .domainPostParseCallback = qemuDomainDefPostParse, }; diff --git a/tests/lxcxml2xmldata/lxc-hostdev.xml b/tests/lxcxml2xmldata/lxc-hostdev.xml index 02a87a7..b022cc7 100644 --- a/tests/lxcxml2xmldata/lxc-hostdev.xml +++ b/tests/lxcxml2xmldata/lxc-hostdev.xml @@ -13,6 +13,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/root/container'/> <target dir='/'/> diff --git a/tests/lxcxml2xmldata/lxc-systemd.xml b/tests/lxcxml2xmldata/lxc-systemd.xml index 2f36eee..fd3a606 100644 --- a/tests/lxcxml2xmldata/lxc-systemd.xml +++ b/tests/lxcxml2xmldata/lxc-systemd.xml @@ -15,6 +15,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> + <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/root/container'/> <target dir='/'/> -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:17PM +0200, Peter Krempa wrote:
This patch removes the emulatorRequired field and associated infrastructure from the virCaps object. Instead the driver specific callbacks are used as this field isn't enforced by all drivers.
This patch implements the appropriate callbacks in the qemu and lxc driver and moves to check to that location. --- src/conf/capabilities.c | 10 ---------- src/conf/capabilities.h | 7 ------- src/conf/domain_conf.c | 17 +++++++---------- src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 3 +-- src/lxc/lxc_conf.c | 6 ++---- src/lxc/lxc_domain.c | 17 +++++++++++++++++ src/lxc/lxc_domain.h | 1 + src/qemu/qemu_capabilities.c | 3 --- src/qemu/qemu_domain.c | 15 +++++++++++++++ tests/lxcxml2xmldata/lxc-hostdev.xml | 1 + tests/lxcxml2xmldata/lxc-systemd.xml | 1 + 12 files changed, 47 insertions(+), 36 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Use the qemu specific callback to fill this data in the qemu driver as it's the only place where it was used and fix tests as the qemu test capability object didn't configure the defaults for the tests. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 5 --- src/qemu/qemu_conf.c | 6 ---- src/qemu/qemu_domain.c | 42 ++++++++++++++++++---- ...qemuxml2argv-disk-drive-network-nbd-export.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-export.xml | 1 + ...ml2argv-disk-drive-network-nbd-ipv6-export.args | 3 +- ...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-unix.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-unix.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd.args | 5 +-- .../qemuxml2argv-disk-drive-network-nbd.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd-auth.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd.xml | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.args | 3 +- .../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 + 21 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 5e7a5f6..743b1f0 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -163,7 +163,6 @@ struct _virCaps { /* Move to virDomainXMLOption later */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; - int defaultDiskDriverType; /* enum virStorageFileFormat */ int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); bool hasWideScsiBus; }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6a480d0..ab4227e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4824,9 +4824,6 @@ virDomainDiskDefParseXML(virCapsPtr caps, driverType); goto error; } - } else if (def->type == VIR_DOMAIN_DISK_TYPE_FILE || - def->type == VIR_DOMAIN_DISK_TYPE_BLOCK) { - def->format = caps->defaultDiskDriverType; } if (mirrorFormat) { @@ -4837,8 +4834,6 @@ virDomainDiskDefParseXML(virCapsPtr caps, driverType); goto error; } - } else if (def->mirror) { - def->mirrorFormat = caps->defaultDiskDriverType; } if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 268223f..084b694 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -574,12 +574,6 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver) if (!(caps = virQEMUCapsInit(driver->qemuCapsCache))) goto no_memory; - if (cfg->allowDiskFormatProbing) { - caps->defaultDiskDriverType = VIR_STORAGE_FILE_AUTO; - } else { - caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW; - } - if (virGetHostUUID(caps->host.host_uuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("cannot get the host uuid")); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3073257..e5e9223 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -693,13 +693,41 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, goto no_memory; } - if (dev->type == VIR_DOMAIN_DEVICE_DISK && - !dev->data.disk->driverName && - driver && - (cfg = virQEMUDriverGetConfig(driver))) { - if (!cfg->allowDiskFormatProbing && - !(dev->data.disk->driverName = strdup("qemu"))) { - goto no_memory; + /* set default disk types and drivers */ + if (dev->type == VIR_DOMAIN_DEVICE_DISK) { + virDomainDiskDefPtr disk = dev->data.disk; + + /* both of these require data from the driver config */ + if (driver && (cfg = virQEMUDriverGetConfig(driver))) { + /* assign default storage format and driver according to config */ + if (cfg->allowDiskFormatProbing) { + /* default disk format for drives */ + if (disk->format == VIR_STORAGE_FILE_NONE && + (disk->type == VIR_DOMAIN_DISK_TYPE_FILE || + disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK)) + disk->format = VIR_STORAGE_FILE_AUTO; + + /* default disk format for mirrored drive */ + if (disk->mirror && + disk->mirrorFormat == VIR_STORAGE_FILE_NONE) + disk->mirrorFormat = VIR_STORAGE_FILE_AUTO; + } else { + /* default driver if probing is forbidden */ + if (!disk->driverName && + !(disk->driverName = strdup("qemu"))) + goto no_memory; + + /* default disk format for drives */ + if (disk->format == VIR_STORAGE_FILE_NONE && + (disk->type == VIR_DOMAIN_DISK_TYPE_FILE || + disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK)) + disk->format = VIR_STORAGE_FILE_RAW; + + /* default disk format for mirrored drive */ + if (disk->mirror && + disk->mirrorFormat == VIR_STORAGE_FILE_NONE) + disk->mirrorFormat = VIR_STORAGE_FILE_RAW; + } } } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args index bc9d93d..ca70ce4 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \ -drive file=nbd:example.org:6000:exportname=bar,if=virtio,format=raw \ -net none -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml index f2b5ca4..7a84604 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args index 1541073..745efe7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \ -drive 'file=nbd://[::1]:6000/bar,if=virtio,format=raw' -net none \ -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml index 595d7ea..c063db8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args index a28d015..0331ff5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \ -drive 'file=nbd://[::1]:6000,if=virtio,format=raw' -net none \ -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml index 3c5c99d..540aa02 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args index 977b68f..84cae4a 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \ -drive file=nbd:unix:/var/run/nbdsock:exportname=bar,if=virtio,format=raw \ -net none -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml index 46114d5..a4126f5 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args index 856217b..8d0f69f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \ -file=nbd:example.org:6000,if=virtio,format=raw -net none -serial none \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \ +-drive file=nbd:example.org:6000,if=virtio,format=raw -net none -serial none \ -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml index e31da87..36301a9 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args index 4f3ccd5..6714553 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args @@ -1,7 +1,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \ -file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \ +file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \ 'file=rbd:pool/image:\ id=myname:\ key=QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=:\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args index 0c67229..6623161 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args @@ -1,7 +1,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \ -file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \ +file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \ 'file=rbd:pool/image:auth_supported=none:\ mon_host=[\:\:1]\:6321\;example.org\:6789\;\ [ffff\:1234\:567\:abc\:\:0f]\:6322\;\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml index a2ca2d2..be4edbf 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args index ad3ed3e..cf433a3 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args @@ -1,7 +1,7 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \ /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \ -file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \ +file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \ 'file=rbd:pool/image:auth_supported=none:\ mon_host=mon1.example.org\:6321\;mon2.example.org\:6322\;\ mon3.example.org\:6322,\ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml index 8309cae..081f9a6 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args index 3e9d913..e0a5cfa 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args @@ -1,5 +1,6 @@ LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ pc -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait \ --no-acpi -boot c -usb -drive file=/dev/HostVG/QEMU,,Guest,,,,1,if=ide,bus=0,unit=0 \ +-no-acpi -boot c -usb \ +-drive file=/dev/HostVG/QEMU,,Guest,,,,1,if=ide,bus=0,unit=0,format=raw \ -drive file=sheepdog:example.org:6000:image,,with,,commas,if=virtio,format=raw \ -net none -serial none -parallel none diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml index 7917357..ac89dd7 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml @@ -15,6 +15,7 @@ <devices> <emulator>/usr/bin/qemu</emulator> <disk type='block' device='disk'> + <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMU,Guest,,1'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:18PM +0200, Peter Krempa wrote:
Use the qemu specific callback to fill this data in the qemu driver as it's the only place where it was used and fix tests as the qemu test capability object didn't configure the defaults for the tests. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 5 --- src/qemu/qemu_conf.c | 6 ---- src/qemu/qemu_domain.c | 42 ++++++++++++++++++---- ...qemuxml2argv-disk-drive-network-nbd-export.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-export.xml | 1 + ...ml2argv-disk-drive-network-nbd-ipv6-export.args | 3 +- ...xml2argv-disk-drive-network-nbd-ipv6-export.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-ipv6.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd-unix.args | 3 +- .../qemuxml2argv-disk-drive-network-nbd-unix.xml | 1 + .../qemuxml2argv-disk-drive-network-nbd.args | 5 +-- .../qemuxml2argv-disk-drive-network-nbd.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd-auth.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd-ipv6.xml | 1 + .../qemuxml2argv-disk-drive-network-rbd.args | 2 +- .../qemuxml2argv-disk-drive-network-rbd.xml | 1 + .../qemuxml2argv-disk-drive-network-sheepdog.args | 3 +- .../qemuxml2argv-disk-drive-network-sheepdog.xml | 1 + 21 files changed, 59 insertions(+), 29 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Use the virDomainXMLConf structure to hold this data. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 13 +++++++------ src/conf/domain_conf.h | 8 +++++++- src/esx/esx_driver.c | 11 +++++------ src/libvirt_vmx.syms | 1 + src/qemu/qemu_command.c | 9 +++++---- src/vmware/vmware_conf.c | 2 +- src/vmware/vmware_driver.c | 6 +++--- src/vmx/vmx.c | 38 ++++++++++++++++++++++++++------------ src/vmx/vmx.h | 12 +++++++----- tests/vmx2xmltest.c | 9 ++++++--- tests/xml2vmxtest.c | 6 +++--- 12 files changed, 71 insertions(+), 45 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 743b1f0..bbc0197 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -164,7 +164,6 @@ struct _virCaps { /* Move to virDomainXMLOption later */ unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); - bool hasWideScsiBus; }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab4227e..3513590 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3593,7 +3593,8 @@ virDomainDiskFindByBusAndDst(virDomainDefPtr def, } int -virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def) +virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, + virDomainDiskDefPtr def) { int idx = virDiskNameToIndex(def->dst); if (idx < 0) { @@ -3607,7 +3608,7 @@ virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def) case VIR_DOMAIN_DISK_BUS_SCSI: def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; - if (caps->hasWideScsiBus) { + if (xmlopt->config.hasWideScsiBus) { /* For a wide SCSI bus we define the default mapping to be * 16 units per bus, 1 bus per controller, many controllers. * Unit 7 is the SCSI controller itself. Therefore unit 7 @@ -4046,7 +4047,7 @@ cleanup: * @param node XML nodeset to parse for disk definition */ static virDomainDiskDefPtr -virDomainDiskDefParseXML(virCapsPtr caps, +virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, virBitmapPtr bootMap, @@ -4837,7 +4838,7 @@ virDomainDiskDefParseXML(virCapsPtr caps, } if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE - && virDomainDiskDefAssignAddress(caps, def) < 0) + && virDomainDiskDefAssignAddress(xmlopt, def) < 0) goto error; cleanup: @@ -8499,7 +8500,7 @@ virDomainDeviceDefParse(const char *xmlStr, if (xmlStrEqual(node->name, BAD_CAST "disk")) { dev->type = VIR_DOMAIN_DEVICE_DISK; - if (!(dev->data.disk = virDomainDiskDefParseXML(caps, node, ctxt, + if (!(dev->data.disk = virDomainDiskDefParseXML(xmlopt, node, ctxt, NULL, def->seclabels, def->nseclabels, flags))) @@ -10391,7 +10392,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, + virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt, nodes[i], ctxt, bootMap, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 19a66ed..f3647a3 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1949,11 +1949,16 @@ typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev, typedef struct _virDomainDefParserConfig virDomainDefParserConfig; typedef virDomainDefParserConfig *virDomainDefParserConfigPtr; struct _virDomainDefParserConfig { + /* driver domain definition callbacks */ virDomainDefPostParseCallback domainPostParseCallback; virDomainDeviceDefPostParseCallback devicesPostParseCallback; + /* private data for the callbacks */ void *priv; virFreeCallback privFree; + + /* data */ + bool hasWideScsiBus; }; typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks; @@ -2151,7 +2156,8 @@ int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk); void virDomainDiskInsertPreAlloced(virDomainDefPtr def, virDomainDiskDefPtr disk); -int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def); +int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, + virDomainDiskDefPtr def); virDomainDiskDefPtr virDomainDiskRemove(virDomainDefPtr def, size_t i); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 08381fc..c639199 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -601,7 +601,6 @@ esxCapsInit(esxPrivate *priv) virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr"); - caps->hasWideScsiBus = true; caps->defaultConsoleTargetType = esxDefaultConsoleType; if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) { @@ -1100,7 +1099,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, goto cleanup; } - if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) + if (!(priv->xmlopt = virVMXDomainXMLConfInit())) goto cleanup; conn->privateData = priv; @@ -2786,7 +2785,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) ctx.formatFileName = NULL; ctx.autodetectSCSIControllerModel = NULL; - def = virVMXParseConfig(&ctx, priv->caps, vmx); + def = virVMXParseConfig(&ctx, priv->xmlopt, vmx); if (def != NULL) { if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { @@ -2845,7 +2844,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, ctx.formatFileName = NULL; ctx.autodetectSCSIControllerModel = NULL; - def = virVMXParseConfig(&ctx, priv->caps, nativeConfig); + def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig); if (def != NULL) { xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); @@ -2902,7 +2901,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, ctx.formatFileName = esxFormatVMXFileName; ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel; - vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version); + vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version); virDomainDefFree(def); @@ -3149,7 +3148,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) ctx.formatFileName = esxFormatVMXFileName; ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel; - vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version); + vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version); if (vmx == NULL) { goto cleanup; diff --git a/src/libvirt_vmx.syms b/src/libvirt_vmx.syms index 0b15f49..206ad44 100644 --- a/src/libvirt_vmx.syms +++ b/src/libvirt_vmx.syms @@ -4,6 +4,7 @@ # vmx/vmx.h virVMXConvertToUTF8; +virVMXDomainXMLConfInit; virVMXEscapeHex; virVMXFormatCDROM; virVMXFormatConfig; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 5866070..ae7c96b 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7971,7 +7971,7 @@ error: * Will fail if not using the 'index' keyword */ static virDomainDiskDefPtr -qemuParseCommandLineDisk(virCapsPtr qemuCaps, +qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, const char *val, int nvirtiodisk, bool old_style_ceph_args) @@ -8271,7 +8271,7 @@ qemuParseCommandLineDisk(virCapsPtr qemuCaps, else def->dst[2] = 'a' + idx; - if (virDomainDiskDefAssignAddress(qemuCaps, def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid device name '%s'"), def->dst); virDomainDiskDefFree(def); @@ -9345,7 +9345,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, !disk->dst) goto no_memory; - if (virDomainDiskDefAssignAddress(qemuCaps, disk) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, disk) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot assign address for device name '%s'"), disk->dst); @@ -9571,7 +9571,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, } } else if (STREQ(arg, "-drive")) { WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(qemuCaps, val, nvirtiodisk, + if (!(disk = qemuParseCommandLineDisk(xmlopt, val, + nvirtiodisk, ceph_args != NULL))) goto error; if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0) diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 3528f07..ed63f50 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -174,7 +174,7 @@ vmwareLoadDomains(struct vmware_driver *driver) goto cleanup; if ((vmdef = - virVMXParseConfig(&ctx, driver->caps, vmx)) == NULL) { + virVMXParseConfig(&ctx, driver->xmlopt, vmx)) == NULL) { goto cleanup; } diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 0e0f59d..c7e493f 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -330,7 +330,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) goto cleanup; /* generate vmx file */ - vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7); + vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7); if (vmx == NULL) goto cleanup; @@ -601,7 +601,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, goto cleanup; /* generate vmx file */ - vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7); + vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7); if (vmx == NULL) goto cleanup; @@ -943,7 +943,7 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, ctx.parseFileName = vmwareCopyVMXFileName; - def = virVMXParseConfig(&ctx, driver->caps, nativeConfig); + def = virVMXParseConfig(&ctx, driver->xmlopt, nativeConfig); if (def != NULL) xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index d7eee09..67fbe6c 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -520,6 +520,18 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, * Helpers */ +virDomainDefParserConfig virVMXDomainDefParserConfig = { + .hasWideScsiBus = true, +}; + + +virDomainXMLOptionPtr +virVMXDomainXMLConfInit(void) +{ + return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, + NULL, NULL); +} + char * virVMXEscapeHex(const char *string, char escape, const char *special) { @@ -935,7 +947,7 @@ virVMXFloppyDiskNameToUnit(const char *name, int *unit) static int -virVMXVerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk) +virVMXVerifyDiskAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr disk) { virDomainDiskDef def; virDomainDeviceDriveAddressPtr drive; @@ -954,7 +966,7 @@ virVMXVerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk) def.dst = disk->dst; def.bus = disk->bus; - if (virDomainDiskDefAssignAddress(caps, &def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, &def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not verify disk address")); return -1; @@ -1211,7 +1223,9 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, */ virDomainDefPtr -virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) +virVMXParseConfig(virVMXContext *ctx, + virDomainXMLOptionPtr xmlopt, + const char *vmx) { bool success = false; virConfPtr conf = NULL; @@ -1588,7 +1602,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) continue; } - if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK, + if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, &def->disks[def->ndisks]) < 0) { goto cleanup; @@ -1599,7 +1613,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) continue; } - if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, + if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, &def->disks[def->ndisks]) < 0) { goto cleanup; @@ -1614,7 +1628,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) /* def:disks (ide) */ for (bus = 0; bus < 2; ++bus) { for (unit = 0; unit < 2; ++unit) { - if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK, + if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_BUS_IDE, bus, unit, &def->disks[def->ndisks]) < 0) { goto cleanup; @@ -1625,7 +1639,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) continue; } - if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, + if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, VIR_DOMAIN_DISK_BUS_IDE, bus, unit, &def->disks[def->ndisks]) < 0) { goto cleanup; @@ -1639,7 +1653,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx) /* def:disks (floppy) */ for (unit = 0; unit < 2; ++unit) { - if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY, + if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY, VIR_DOMAIN_DISK_BUS_FDC, 0, unit, &def->disks[def->ndisks]) < 0) { goto cleanup; @@ -1950,7 +1964,7 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, int -virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf, +virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr conf, int device, int busType, int controllerOrBus, int unit, virDomainDiskDefPtr *def) { @@ -2284,7 +2298,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf, goto cleanup; } - if (virDomainDiskDefAssignAddress(caps, *def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, *def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not assign address to disk '%s'"), (*def)->src); goto cleanup; @@ -3022,7 +3036,7 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def) */ char * -virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def, +virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, int virtualHW_version) { char *vmx = NULL; @@ -3231,7 +3245,7 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def, /* def:disks */ for (i = 0; i < def->ndisks; ++i) { - if (virVMXVerifyDiskAddress(caps, def->disks[i]) < 0 || + if (virVMXVerifyDiskAddress(xmlopt, def->disks[i]) < 0 || virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) { goto cleanup; } diff --git a/src/vmx/vmx.h b/src/vmx/vmx.h index f4877b1..ec63317 100644 --- a/src/vmx/vmx.h +++ b/src/vmx/vmx.h @@ -29,6 +29,7 @@ typedef struct _virVMXContext virVMXContext; +virDomainXMLOptionPtr virVMXDomainXMLConfInit(void); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -78,7 +79,8 @@ char *virVMXConvertToUTF8(const char *encoding, const char *string); * VMX -> Domain XML */ -virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, +virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, + virDomainXMLOptionPtr xmlopt, const char *vmx); int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def); @@ -86,9 +88,9 @@ int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def); int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, int *virtualDev); -int virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf, - int device, int busType, int controllerOrBus, int unit, - virDomainDiskDefPtr *def); +int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, + virConfPtr conf, int device, int busType, + int controllerOrBus, int unit, virDomainDiskDefPtr *def); int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def); @@ -108,7 +110,7 @@ int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def); * Domain XML -> VMX */ -char *virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, +char *virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, int virtualHW_version); int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index cee4c39..429dc81 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -12,6 +12,7 @@ # include "vmx/vmx.h" static virCapsPtr caps; +static virDomainXMLOptionPtr xmlopt; static virVMXContext ctx; static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, @@ -36,8 +37,6 @@ testCapsInit(void) virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "esx"); - caps->hasWideScsiBus = true; - /* i686 guest */ guest = virCapabilitiesAddGuest(caps, "hvm", @@ -93,7 +92,7 @@ testCompareFiles(const char *vmx, const char *xml) goto failure; } - def = virVMXParseConfig(&ctx, caps, vmxData); + def = virVMXParseConfig(&ctx, xmlopt, vmxData); if (def == NULL) { err = virGetLastError(); @@ -221,6 +220,9 @@ mymain(void) return EXIT_FAILURE; } + if (!(xmlopt = virVMXDomainXMLConfInit())) + return EXIT_FAILURE; + ctx.opaque = NULL; ctx.parseFileName = testParseVMXFileName; ctx.formatFileName = NULL; @@ -296,6 +298,7 @@ mymain(void) DO_TEST("svga", "svga"); virObjectUnref(caps); + virObjectUnref(xmlopt); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index cee7f9e..7e2d4ca 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -37,7 +37,6 @@ testCapsInit(void) virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "esx"); - caps->hasWideScsiBus = true; /* i686 guest */ guest = @@ -102,7 +101,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - formatted = virVMXFormatConfig(&ctx, caps, def, virtualHW_version); + formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); if (formatted == NULL) { goto failure; @@ -240,7 +239,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) + if (!(xmlopt = virVMXDomainXMLConfInit())) return EXIT_FAILURE; ctx.opaque = NULL; @@ -312,6 +311,7 @@ mymain(void) DO_TEST("svga", "svga", 4); virObjectUnref(caps); + virObjectUnref(xmlopt); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:19PM +0200, Peter Krempa wrote:
Use the virDomainXMLConf structure to hold this data. --- src/conf/capabilities.h | 1 - src/conf/domain_conf.c | 13 +++++++------ src/conf/domain_conf.h | 8 +++++++- src/esx/esx_driver.c | 11 +++++------ src/libvirt_vmx.syms | 1 + src/qemu/qemu_command.c | 9 +++++---- src/vmware/vmware_conf.c | 2 +- src/vmware/vmware_driver.c | 6 +++--- src/vmx/vmx.c | 38 ++++++++++++++++++++++++++------------ src/vmx/vmx.h | 12 +++++++----- tests/vmx2xmltest.c | 9 ++++++--- tests/xml2vmxtest.c | 6 +++--- 12 files changed, 71 insertions(+), 45 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Use the virDomainXMLConf structure to hold this data and tweak the code to avoid semantic change. Without configuration the KVM mac prefix is used by default. I chose it as it's in the privately administered segment so it should be usable for any purposes. --- src/conf/capabilities.c | 14 -------------- src/conf/capabilities.h | 9 --------- src/conf/domain_conf.c | 28 ++++++++++++++++++++++++---- src/conf/domain_conf.h | 3 +++ src/esx/esx_driver.c | 1 - src/libvirt_private.syms | 3 +-- src/libxl/libxl_conf.c | 2 -- src/libxl/libxl_driver.c | 6 +++++- src/lxc/lxc_conf.c | 3 --- src/openvz/openvz_conf.c | 2 -- src/openvz/openvz_driver.c | 2 +- src/parallels/parallels_driver.c | 12 ++++++++---- src/phyp/phyp_driver.c | 4 ---- src/qemu/qemu_capabilities.c | 3 --- src/qemu/qemu_command.c | 6 +++--- src/vbox/vbox_tmpl.c | 10 +++++++--- src/vmware/vmware_conf.c | 2 -- src/vmx/vmx.c | 1 + src/xen/xen_driver.c | 7 ++++++- src/xen/xen_hypervisor.c | 2 -- tests/vmx2xmltest.c | 1 - tests/xml2vmxtest.c | 1 - 22 files changed, 59 insertions(+), 63 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 1d29ce6..c7ec92f 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -921,17 +921,3 @@ virCapabilitiesFormatXML(virCapsPtr caps) return virBufferContentAndReset(&xml); } - -extern void -virCapabilitiesSetMacPrefix(virCapsPtr caps, - const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN]) -{ - memcpy(caps->macPrefix, prefix, sizeof(caps->macPrefix)); -} - -extern void -virCapabilitiesGenerateMac(virCapsPtr caps, - virMacAddrPtr mac) -{ - virMacAddrGenerate(caps->macPrefix, mac); -} diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index bbc0197..9bb22a7 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -162,7 +162,6 @@ struct _virCaps { virCapsGuestPtr *guests; /* Move to virDomainXMLOption later */ - unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); }; @@ -175,14 +174,6 @@ virCapabilitiesNew(virArch hostarch, extern void virCapabilitiesFreeNUMAInfo(virCapsPtr caps); -extern void -virCapabilitiesSetMacPrefix(virCapsPtr caps, - const unsigned char prefix[VIR_MAC_PREFIX_BUFLEN]); - -extern void -virCapabilitiesGenerateMac(virCapsPtr caps, - virMacAddrPtr mac); - extern int virCapabilitiesAddHostFeature(virCapsPtr caps, const char *name); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3513590..f2269c0 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -791,6 +791,18 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config, if (xmlns) xmlopt->ns = *xmlns; + /* Technically this forbids to use one of Xerox's MAC address prefixes in + * our hypervisor drivers. This shouldn't ever be a problem. + * + * Use the KVM prefix as default as it's in the privately administered + * range */ + if (xmlopt->config.macPrefix[0] == 0 && + xmlopt->config.macPrefix[1] == 0 && + xmlopt->config.macPrefix[2] == 0) { + xmlopt->config.macPrefix[0] = 0x52; + xmlopt->config.macPrefix[1] = 0x54; + } + return xmlopt; } @@ -5039,6 +5051,14 @@ cleanup: } +void +virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, + virMacAddrPtr mac) +{ + virMacAddrGenerate(xmlopt->config.macPrefix, mac); +} + + /* Parse a value located at XPATH within CTXT, and store the * result into val. If REQUIRED, then the value must exist; * otherwise, the value is optional. The value is in bytes. @@ -5407,7 +5427,7 @@ error: * @return 0 on success, -1 on failure */ static virDomainNetDefPtr -virDomainNetDefParseXML(virCapsPtr caps, +virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, virBitmapPtr bootMap, @@ -5592,7 +5612,7 @@ virDomainNetDefParseXML(virCapsPtr caps, goto error; } } else { - virCapabilitiesGenerateMac(caps, &def->mac); + virDomainNetGenerateMAC(xmlopt, &def->mac); } if (devaddr) { @@ -8515,7 +8535,7 @@ virDomainDeviceDefParse(const char *xmlStr, goto error; } else if (xmlStrEqual(node->name, BAD_CAST "interface")) { dev->type = VIR_DOMAIN_DEVICE_NET; - if (!(dev->data.net = virDomainNetDefParseXML(caps, node, ctxt, + if (!(dev->data.net = virDomainNetDefParseXML(xmlopt, node, ctxt, NULL, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "input")) { @@ -10492,7 +10512,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->nets, n) < 0) goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainNetDefPtr net = virDomainNetDefParseXML(caps, + virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt, nodes[i], ctxt, bootMap, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f3647a3..45a79a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1959,6 +1959,7 @@ struct _virDomainDefParserConfig { /* data */ bool hasWideScsiBus; + unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN]; }; typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks; @@ -1974,6 +1975,8 @@ virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns); +void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac); + virDomainXMLNamespacePtr virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) ATTRIBUTE_NONNULL(1); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index c639199..3a21395 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -598,7 +598,6 @@ esxCapsInit(esxPrivate *priv) return NULL; } - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr"); caps->defaultConsoleTargetType = esxDefaultConsoleType; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 36e4ee0..7fc15d3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -20,10 +20,8 @@ virCapabilitiesDefaultGuestMachine; virCapabilitiesFormatXML; virCapabilitiesFreeMachines; virCapabilitiesFreeNUMAInfo; -virCapabilitiesGenerateMac; virCapabilitiesNew; virCapabilitiesSetHostCPU; -virCapabilitiesSetMacPrefix; # conf/cpu_conf.h @@ -240,6 +238,7 @@ virDomainMemDumpTypeToString; virDomainNetDefFree; virDomainNetFind; virDomainNetFindIdx; +virDomainNetGenerateMAC; virDomainNetGetActualBandwidth; virDomainNetGetActualBridgeName; virDomainNetGetActualDirectDev; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index b208dd8..ed3e832 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -85,8 +85,6 @@ libxlBuildCapabilities(virArch hostarch, if ((caps = virCapabilitiesNew(hostarch, 1, 1)) == NULL) goto no_memory; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x16, 0x3e }); - if (host_pae && virCapabilitiesAddHostFeature(caps, "pae") < 0) goto no_memory; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index bf682c5..32818ff 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -431,6 +431,10 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = { .free = libxlDomainObjPrivateFree, }; +virDomainDefParserConfig libxlDomainDefParserConfig = { + .macPrefix = { 0x00, 0x16, 0x3e }, +}; + /* driver must be locked before calling */ static void libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event) @@ -1239,7 +1243,7 @@ libxlStartup(bool privileged, goto error; } - if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(NULL, + if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, NULL))) goto error; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index ce8c2b5..05e0d45 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -79,9 +79,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) goto error; } - /* XXX shouldn't 'borrow' KVM's prefix */ - virCapabilitiesSetMacPrefix(caps, (unsigned char []){ 0x52, 0x54, 0x00 }); - if ((guest = virCapabilitiesAddGuest(caps, "exe", caps->host.arch, diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 439e457..22dea79 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -187,8 +187,6 @@ virCapsPtr openvzCapsInit(void) if (nodeCapsInitNUMA(caps) < 0) goto no_memory; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x52, 0x54, 0x00 }); - if ((guest = virCapabilitiesAddGuest(caps, "exe", caps->host.arch, diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 583a415..180d047 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -832,7 +832,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid, } virMacAddrFormat(&net->mac, macaddr); - virCapabilitiesGenerateMac(driver->caps, &host_mac); + virDomainNetGenerateMAC(driver->xmlopt, &host_mac); virMacAddrFormat(&host_mac, host_macaddr); if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE || diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 7de9cc0..c6833f7 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -129,9 +129,6 @@ parallelsBuildCapabilities(void) if (nodeCapsInitNUMA(caps) < 0) goto no_memory; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]) { - 0x42, 0x1C, 0x00}); - if ((guest = virCapabilitiesAddGuest(caps, "hvm", VIR_ARCH_X86_64, "parallels", @@ -911,6 +908,12 @@ parallelsLoadDomains(parallelsConnPtr privconn, const char *domain_name) return ret; } + +virDomainDefParserConfig parallelsDomainDefParserConfig = { + .macPrefix = {0x42, 0x1C, 0x00}, +}; + + static int parallelsOpenDefault(virConnectPtr conn) { @@ -929,7 +932,8 @@ parallelsOpenDefault(virConnectPtr conn) if (!(privconn->caps = parallelsBuildCapabilities())) goto error; - if (!(privconn->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) + if (!(privconn->xmlopt = virDomainXMLOptionNew(¶llelsDomainDefParserConfig, + NULL, NULL))) goto error; if (!(privconn->domains = virDomainObjListNew())) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 8716d4d..07f230f 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -327,10 +327,6 @@ phypCapsInit(void) ("Failed to query host NUMA topology, disabling NUMA capabilities"); } - /* XXX shouldn't 'borrow' KVM's prefix */ - virCapabilitiesSetMacPrefix(caps, (unsigned char[]) { - 0x52, 0x54, 0x00}); - if ((guest = virCapabilitiesAddGuest(caps, "linux", caps->host.arch, diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 748fd40..7760542 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -876,9 +876,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) 1, 1)) == NULL) goto error; - /* Using KVM's mac prefix for QEMU too */ - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x52, 0x54, 0x00 }); - /* Some machines have problematic NUMA toplogy causing * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ae7c96b..493e5f8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8337,7 +8337,7 @@ qemuFindNICForVLAN(int nnics, * match up against. Horribly complicated stuff */ static virDomainNetDefPtr -qemuParseCommandLineNet(virCapsPtr qemuCaps, +qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, const char *val, int nnics, const char **nics) @@ -8471,7 +8471,7 @@ qemuParseCommandLineNet(virCapsPtr qemuCaps, } if (genmac) - virCapabilitiesGenerateMac(qemuCaps, &def->mac); + virDomainNetGenerateMAC(xmlopt, &def->mac); cleanup: for (i = 0 ; i < nkeywords ; i++) { @@ -9561,7 +9561,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, WANT_VALUE(); if (!STRPREFIX(val, "nic") && STRNEQ(val, "none")) { virDomainNetDefPtr net; - if (!(net = qemuParseCommandLineNet(qemuCaps, val, nnics, nics))) + if (!(net = qemuParseCommandLineNet(xmlopt, val, nnics, nics))) goto error; if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) { virDomainNetDefFree(net); diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index d021105..4490d0c 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -851,10 +851,16 @@ static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, } +static virDomainDefParserConfig vboxDomainDefParserConfig = { + .macPrefix = { 0x08, 0x00, 0x27 }, +}; + + static virDomainXMLOptionPtr vboxXMLConfInit(void) { - return virDomainXMLOptionNew(NULL, NULL, NULL); + return virDomainXMLOptionNew(&vboxDomainDefParserConfig, + NULL, NULL); } @@ -870,8 +876,6 @@ static virCapsPtr vboxCapsInit(void) if (nodeCapsInitNUMA(caps) < 0) goto no_memory; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x08, 0x00, 0x27 }); - if ((guest = virCapabilitiesAddGuest(caps, "hvm", caps->host.arch, diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index ed63f50..d8d2611 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -72,8 +72,6 @@ vmwareCapsInit(void) if (nodeCapsInitNUMA(caps) < 0) goto error; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]) {0x52, 0x54, 0x00}); - /* i686 guests are always supported */ if ((guest = virCapabilitiesAddGuest(caps, "hvm", diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 67fbe6c..5dc5046 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -522,6 +522,7 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, virDomainDefParserConfig virVMXDomainDefParserConfig = { .hasWideScsiBus = true, + .macPrefix = {0x00, 0x0c, 0x29}, }; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index fe6252c..6761090 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -265,6 +265,10 @@ xenUnifiedXendProbe(void) #endif +virDomainDefParserConfig xenDomainDefParserConfig = { + .macPrefix = { 0x00, 0x16, 0x3e }, +}; + static virDrvOpenStatus xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) @@ -401,7 +405,8 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) + if (!(priv->xmlopt = virDomainXMLOptionNew(&xenDomainDefParserConfig, + NULL, NULL))) goto fail; #if WITH_XEN_INOTIFY diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index d803972..69bc6cd 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2303,8 +2303,6 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, if ((caps = virCapabilitiesNew(hostarch, 1, 1)) == NULL) goto no_memory; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x16, 0x3e }); - if (hvm_type && STRNEQ(hvm_type, "") && virCapabilitiesAddHostFeature(caps, hvm_type) < 0) goto no_memory; diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 429dc81..d63ac52 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -34,7 +34,6 @@ testCapsInit(void) caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "esx"); /* i686 guest */ diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 7e2d4ca..659b0c8 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -34,7 +34,6 @@ testCapsInit(void) caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 }); virCapabilitiesAddHostMigrateTransport(caps, "esx"); -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:10:20PM +0200, Peter Krempa wrote:
Use the virDomainXMLConf structure to hold this data and tweak the code to avoid semantic change.
Without configuration the KVM mac prefix is used by default. I chose it as it's in the privately administered segment so it should be usable for any purposes. --- src/conf/capabilities.c | 14 -------------- src/conf/capabilities.h | 9 --------- src/conf/domain_conf.c | 28 ++++++++++++++++++++++++---- src/conf/domain_conf.h | 3 +++ src/esx/esx_driver.c | 1 - src/libvirt_private.syms | 3 +-- src/libxl/libxl_conf.c | 2 -- src/libxl/libxl_driver.c | 6 +++++- src/lxc/lxc_conf.c | 3 --- src/openvz/openvz_conf.c | 2 -- src/openvz/openvz_driver.c | 2 +- src/parallels/parallels_driver.c | 12 ++++++++---- src/phyp/phyp_driver.c | 4 ---- src/qemu/qemu_capabilities.c | 3 --- src/qemu/qemu_command.c | 6 +++--- src/vbox/vbox_tmpl.c | 10 +++++++--- src/vmware/vmware_conf.c | 2 -- src/vmx/vmx.c | 1 + src/xen/xen_driver.c | 7 ++++++- src/xen/xen_hypervisor.c | 2 -- tests/vmx2xmltest.c | 1 - tests/xml2vmxtest.c | 1 - 22 files changed, 59 insertions(+), 63 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

This patch refactors various places to allow removing of the defaultConsoleTargetType callback from the virCaps structure. A new console character device target type is introduced - VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was specified in the XML. This type is at the end converted to the standard VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are different from this default have to be processed separately in the device post parse callback. --- src/conf/capabilities.h | 3 - src/conf/domain_conf.c | 269 +++++++++++++++++++++------------------ src/conf/domain_conf.h | 3 +- src/esx/esx_driver.c | 8 -- src/libxl/libxl_conf.c | 11 -- src/libxl/libxl_driver.c | 19 +++ src/lxc/lxc_conf.c | 8 -- src/lxc/lxc_domain.c | 17 +++ src/openvz/openvz_conf.c | 10 +- src/openvz/openvz_driver.c | 16 +++ src/parallels/parallels_driver.c | 7 - src/phyp/phyp_driver.c | 9 -- src/qemu/qemu_capabilities.c | 13 -- src/qemu/qemu_domain.c | 7 + src/security/virt-aa-helper.c | 7 - src/test/test_driver.c | 11 +- src/uml/uml_conf.c | 9 -- src/uml/uml_driver.c | 24 +++- src/vbox/vbox_tmpl.c | 9 -- src/vmware/vmware_conf.c | 9 -- src/xen/xen_driver.c | 28 +++- src/xen/xen_driver.h | 2 + src/xen/xen_hypervisor.c | 11 -- src/xenapi/xenapi_driver.c | 28 ++-- tests/testutilslxc.c | 9 -- tests/testutilsqemu.c | 11 -- tests/testutilsxen.c | 16 --- tests/testutilsxen.h | 2 - tests/vmx2xmltest.c | 7 - tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 3 +- tests/xml2vmxtest.c | 7 - 32 files changed, 279 insertions(+), 316 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 9bb22a7..abcf6de 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -160,9 +160,6 @@ struct _virCaps { size_t nguests; size_t nguests_max; virCapsGuestPtr *guests; - - /* Move to virDomainXMLOption later */ - int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f2269c0..f98af61 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -385,6 +385,7 @@ VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_ENUM_IMPL(virDomainChrConsoleTarget, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, + "none", "serial", "xen", "uml", @@ -2347,9 +2348,11 @@ virDomainDeviceInfoClearCCWAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, return 0; } -int virDomainDeviceInfoIterate(virDomainDefPtr def, - virDomainDeviceInfoCallback cb, - void *opaque) +static int +virDomainDeviceInfoIterateInternal(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + bool all, + void *opaque) { int i; virDomainDeviceDef device; @@ -2413,9 +2416,11 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, return -1; } for (i = 0; i < def->nconsoles ; i++) { - if (i == 0 && - def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL && - STREQ_NULLABLE(def->os.type, "hvm")) + if (!all && + i == 0 && + (def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && + STREQ_NULLABLE(def->os.type, "hvm")) continue; device.data.chr = def->consoles[i]; if (cb(def, &device, &def->consoles[i]->info, opaque) < 0) @@ -2491,10 +2496,21 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, } +int +virDomainDeviceInfoIterate(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + void *opaque) +{ + return virDomainDeviceInfoIterateInternal(def, cb, false, opaque); +} + + static int virDomainDefPostParseInternal(virDomainDefPtr def, virCapsPtr caps ATTRIBUTE_UNUSED) { + int i; + /* verify init path for container based domains */ if (STREQ(def->os.type, "exe") && !def->os.init) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2502,6 +2518,91 @@ virDomainDefPostParseInternal(virDomainDefPtr def, return -1; } + /* + * Some really crazy backcompat stuff for consoles + * + * Historically the first (and only) '<console>' element in an HVM guest + * was treated as being an alias for a <serial> device. + * + * So if we see that this console device should be a serial device, then we + * move the config over to def->serials[0] (or discard it if that already + * exists). However, given console can already be filled with aliased data + * of def->serials[0]. Keep it then. + * + * We then fill def->consoles[0] with a stub just so we get sequencing + * correct for consoles > 0 + */ + if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") && + (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) { + /* First verify that only the first console is of type serial */ + for (i = 1; i < def->nconsoles; i++) { + virDomainChrDefPtr cons = def->consoles[i]; + + if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only the first console can be a serial port")); + return -1; + } + } + + /* If there isn't a corresponding serial port: + * - create one and set, the console to be an alias for it + * + * If there is a corresponding serial port: + * - Check if the source definition is equal: + * - if yes: leave it as-is + * - if no: change the console to be alias of the serial port + */ + + /* create the serial port definition from the console definition */ + if (def->nserials == 0) { + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, + def->consoles[0]) < 0) + goto no_memory; + + /* modify it to be a serial port */ + def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; + def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + def->serials[0]->target.port = 0; + } else { + /* if the console source doesn't match */ + if (!virDomainChrSourceDefIsEqual(&def->serials[0]->source, + &def->consoles[0]->source)) { + virDomainChrDefFree(def->consoles[0]); + def->consoles[0] = NULL; + } + } + + if (!def->consoles[0]) { + /* allocate a new console type for the stolen one */ + if (VIR_ALLOC(def->consoles[0]) < 0) + goto no_memory; + + /* Create an console alias for the serial port */ + def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; + } + } + + return 0; + +no_memory: + virReportOOMError(); + return -1; +} + + +static int +virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; + return 0; } @@ -2521,6 +2622,9 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, return ret; } + if ((ret = virDomainDeviceDefPostParseInternal(dev, def, caps)) < 0) + return ret; + return 0; } @@ -2564,9 +2668,10 @@ virDomainDefPostParse(virDomainDefPtr def, } /* iterate the devices */ - if ((ret = virDomainDeviceInfoIterate(def, - virDomainDefPostParseDeviceIterator, - &data)) < 0) + if ((ret = virDomainDeviceInfoIterateInternal(def, + virDomainDefPostParseDeviceIterator, + true, + &data)) < 0) return ret; @@ -5923,87 +6028,66 @@ error: } static int -virDomainChrDefaultTargetType(virCapsPtr caps, - virDomainDefPtr def, - int devtype) { - - int target = -1; - - switch (devtype) { +virDomainChrDefaultTargetType(int devtype) { + switch ((enum virDomainChrDeviceType) devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: virReportError(VIR_ERR_XML_ERROR, _("target type must be specified for %s device"), virDomainChrDeviceTypeToString(devtype)); - break; + return -1; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - if (!caps->defaultConsoleTargetType) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Driver does not have a default console type set")); - return -1; - } - target = caps->defaultConsoleTargetType(def->os.type, def->os.arch); - break; + return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; - break; + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - default: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ - target = 0; break; } - return target; + return 0; } static int -virDomainChrTargetTypeFromString(virCapsPtr caps, - virDomainDefPtr vmdef, - virDomainChrDefPtr def, +virDomainChrTargetTypeFromString(virDomainChrDefPtr def, int devtype, const char *targetType) { int ret = -1; - int target = 0; - if (!targetType) { - target = virDomainChrDefaultTargetType(caps, vmdef, devtype); - goto out; - } + if (!targetType) + return virDomainChrDefaultTargetType(devtype); - switch (devtype) { + switch ((enum virDomainChrDeviceType) devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: - target = virDomainChrChannelTargetTypeFromString(targetType); + ret = virDomainChrChannelTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - target = virDomainChrConsoleTargetTypeFromString(targetType); + ret = virDomainChrConsoleTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - target = virDomainChrSerialTargetTypeFromString(targetType); + ret = virDomainChrSerialTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - default: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ + ret = 0; break; } def->targetTypeAttr = true; -out: - ret = target; return ret; } static int -virDomainChrDefParseTargetXML(virCapsPtr caps, - virDomainDefPtr vmdef, - virDomainChrDefPtr def, +virDomainChrDefParseTargetXML(virDomainChrDefPtr def, xmlNodePtr cur) { int ret = -1; @@ -6013,8 +6097,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, const char *portStr = NULL; if ((def->targetType = - virDomainChrTargetTypeFromString(caps, vmdef, def, - def->deviceType, targetType)) < 0) { + virDomainChrTargetTypeFromString(def, def->deviceType, + targetType)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown target type '%s' specified for character device"), targetType); @@ -6373,9 +6457,7 @@ virDomainChrDefNew(void) { * */ static virDomainChrDefPtr -virDomainChrDefParseXML(virCapsPtr caps, - virDomainDefPtr vmdef, - xmlXPathContextPtr ctxt, +virDomainChrDefParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virSecurityLabelDefPtr* vmSeclabels, int nvmSeclabels, @@ -6419,7 +6501,7 @@ virDomainChrDefParseXML(virCapsPtr caps, if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "target")) { seenTarget = true; - if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) { + if (virDomainChrDefParseTargetXML(def, cur) < 0) { goto error; } } @@ -6429,7 +6511,7 @@ virDomainChrDefParseXML(virCapsPtr caps, } if (!seenTarget && - ((def->targetType = virDomainChrDefaultTargetType(caps, vmdef, def->deviceType)) < 0)) + ((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0)) goto cleanup; if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { @@ -10557,9 +10639,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10587,9 +10667,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10619,10 +10697,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - bool create_stub = true; - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10630,64 +10705,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (!chr) goto error; - /* - * Some really crazy backcompat stuff for consoles - * - * Historically the first (and only) '<console>' - * element in an HVM guest was treated as being - * an alias for a <serial> device. - * - * So if we see that this console device should - * be a serial device, then we move the config - * over to def->serials[0] (or discard it if - * that already exists). However, given console - * can already be filled with aliased data of - * def->serials[0]. Keep it then. - * - * We then fill def->consoles[0] with a stub - * just so we get sequencing correct for consoles - * > 0 - */ - if (STREQ(def->os.type, "hvm") && - (chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)) { - if (i != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only the first console can be a serial port")); - virDomainChrDefFree(chr); - goto error; - } - - /* Either discard or move this chr to the serial config */ - if (def->nserials != 0) { - if (virDomainChrSourceDefIsEqual(&def->serials[0]->source, - &chr->source)) { - /* Alias to def->serial[0]. Skip it */ - create_stub = false; - } else { - virDomainChrDefFree(chr); - } - } else { - if (VIR_ALLOC_N(def->serials, 1) < 0) { - virDomainChrDefFree(chr); - goto no_memory; - } - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - def->nserials = 1; - def->serials[0] = chr; - chr->target.port = 0; - } - - if (create_stub) { - /* And create a stub placeholder */ - if (VIR_ALLOC(chr) < 0) - goto no_memory; - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; - chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - } - } - chr->target.port = i; - def->consoles[def->nconsoles++] = chr; } VIR_FREE(nodes); @@ -10699,9 +10717,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -15200,7 +15216,6 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) goto error; - for (n = 0 ; n < def->nnets ; n++) if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0) goto error; @@ -15223,7 +15238,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, * if it is type == serial */ if (STREQ(def->os.type, "hvm") && - (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) && + (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && (n < def->nserials)) { memcpy(&console, def->serials[n], sizeof(console)); console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; @@ -15240,6 +15256,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, virDomainChrDef console; memcpy(&console, def->serials[n], sizeof(console)); console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; if (virDomainChrDefFormat(buf, &console, flags) < 0) goto error; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 45a79a4..700f03f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -956,7 +956,8 @@ enum virDomainChrChannelTargetType { }; enum virDomainChrConsoleTargetType { - VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE = 0, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 3a21395..4828209 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -569,13 +569,6 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid) } -static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virCapsPtr esxCapsInit(esxPrivate *priv) { @@ -600,7 +593,6 @@ esxCapsInit(esxPrivate *priv) virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr"); - caps->defaultConsoleTargetType = esxDefaultConsoleType; if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) { goto failure; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index ed3e832..7e0753a 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -64,15 +64,6 @@ static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x static regex_t xen_cap_rec; -static int libxlDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - static virCapsPtr libxlBuildCapabilities(virArch hostarch, int host_pae, @@ -162,8 +153,6 @@ libxlBuildCapabilities(virArch hostarch, } } - caps->defaultConsoleTargetType = libxlDefaultConsoleType; - return caps; no_memory: diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 32818ff..9980b38 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -431,10 +431,29 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = { .free = libxlDomainObjPrivateFree, }; + +static int +libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; +} + + virDomainDefParserConfig libxlDomainDefParserConfig = { .macPrefix = { 0x00, 0x16, 0x3e }, + .devicesPostParseCallback = libxlDomainDeviceDefPostParse, }; + /* driver must be locked before calling */ static void libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 05e0d45..13c0d97 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -41,12 +41,6 @@ #define VIR_FROM_THIS VIR_FROM_LXC -static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; -} - /* Functions */ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) @@ -59,8 +53,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) 0, 0)) == NULL) goto error; - caps->defaultConsoleTargetType = lxcDefaultConsoleType; - /* Some machines have problematic NUMA toplogy causing * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 8090789..e7a85ca 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -93,6 +93,23 @@ virLXCDomainDefPostParse(virDomainDefPtr def, return 0; } + +static int +virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; + + return 0; +} + + virDomainDefParserConfig virLXCDriverDomainDefParserConfig = { .domainPostParseCallback = virLXCDomainDefPostParse, + .devicesPostParseCallback = virLXCDomainDeviceDefPostParse, }; diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 22dea79..4b21c4e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -168,13 +168,6 @@ error: } -static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; -} - - virCapsPtr openvzCapsInit(void) { virCapsPtr caps; @@ -204,9 +197,8 @@ virCapsPtr openvzCapsInit(void) NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = openvzDefaultConsoleType; - return caps; + no_memory: virObjectUnref(caps); return NULL; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 180d047..9b10624 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -115,8 +115,24 @@ openvzDomainDefPostParse(virDomainDefPtr def, } +static int +openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; + + return 0; +} + + virDomainDefParserConfig openvzDomainDefParserConfig = { .domainPostParseCallback = openvzDomainDefPostParse, + .devicesPostParseCallback = openvzDomainDeviceDefPostParse, }; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index c6833f7..c524bf1 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -96,12 +96,6 @@ parallelsDriverUnlock(parallelsConnPtr driver) virMutexUnlock(&driver->lock); } -static int -parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void parallelsDomObjFreePrivate(void *p) @@ -149,7 +143,6 @@ parallelsBuildCapabilities(void) "parallels", NULL, NULL, 0, NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = parallelsDefaultConsoleType; return caps; no_memory: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 07f230f..071caf2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -300,13 +300,6 @@ phypGetVIOSPartitionID(virConnectPtr conn) } -static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virCapsPtr phypCapsInit(void) { @@ -337,8 +330,6 @@ phypCapsInit(void) "phyp", NULL, NULL, 0, NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = phypDefaultConsoleType; - return caps; no_memory: diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7760542..50712b0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -856,17 +856,6 @@ error: } -static int virQEMUCapsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch) -{ - if (arch == VIR_ARCH_S390 || - arch == VIR_ARCH_S390X) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) { virCapsPtr caps; @@ -906,8 +895,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) i) < 0) goto error; - caps->defaultConsoleTargetType = virQEMUCapsDefaultConsoleType; - return caps; error: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e5e9223..f431aec 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -731,6 +731,13 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, } } + /* set the default console type for S390 arches */ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + (def->os.arch == VIR_ARCH_S390 || def->os.arch == VIR_ARCH_S390X)) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; + ret = 0; cleanup: diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index fee63ec..3d3b772 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -687,11 +687,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr) return rc; } -static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static int get_definition(vahControl * ctl, const char *xmlStr) @@ -716,8 +711,6 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - ctl->caps->defaultConsoleTargetType = aaDefaultConsoleType; - if ((guest = virCapabilitiesAddGuest(ctl->caps, ctl->hvm, ctl->arch, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ecfbe33..4c14bb0 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -152,14 +152,7 @@ static void testDomainObjPrivateFree(void *data) } -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - -static virDomainXMLOptionPtr +static virDomainXMLConfPtr testBuildXMLConfig(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc, @@ -179,8 +172,6 @@ testBuildCapabilities(virConnectPtr conn) { if ((caps = virCapabilitiesNew(VIR_ARCH_I686, 0, 0)) == NULL) goto no_memory; - caps->defaultConsoleTargetType = testDefaultConsoleType; - if (virCapabilitiesAddHostFeature(caps, "pae") < 0) goto no_memory; if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 0fe59fb..4fa7927 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -52,13 +52,6 @@ #define VIR_FROM_THIS VIR_FROM_UML -static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; -} - - virCapsPtr umlCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; @@ -102,8 +95,6 @@ virCapsPtr umlCapsInit(void) { NULL) == NULL) goto error; - caps->defaultConsoleTargetType = umlDefaultConsoleType; - return caps; error: diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2476d1c..6cff6fd 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -420,6 +420,27 @@ cleanup: umlDriverUnlock(driver); } + +static int +umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; + + return 0; +} + + +virDomainDefParserConfig umlDriverDomainDefParserConfig = { + .devicesPostParseCallback = umlDomainDeviceDefPostParse, +}; + + /** * umlStartup: * @@ -505,7 +526,8 @@ umlStartup(bool privileged, if ((uml_driver->caps = umlCapsInit()) == NULL) goto out_of_memory; - if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL))) + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig, + &privcb, NULL))) goto error; if ((uml_driver->inotifyFD = inotify_init()) < 0) { diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 4490d0c..0248ee0 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -844,13 +844,6 @@ cleanup: } -static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virDomainDefParserConfig vboxDomainDefParserConfig = { .macPrefix = { 0x08, 0x00, 0x27 }, }; @@ -893,8 +886,6 @@ static virCapsPtr vboxCapsInit(void) NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = vboxDefaultConsoleType; - return caps; no_memory: diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index d8d2611..573fb33 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -50,13 +50,6 @@ vmwareFreeDriver(struct vmware_driver *driver) } -static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - virCapsPtr vmwareCapsInit(void) { @@ -122,8 +115,6 @@ vmwareCapsInit(void) goto error; } - caps->defaultConsoleTargetType = vmwareDefaultConsoleType; - cleanup: virCPUDefFree(cpu); if (caps) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 6761090..e253a27 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -265,11 +265,36 @@ xenUnifiedXendProbe(void) #endif +static int +xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; +} + + virDomainDefParserConfig xenDomainDefParserConfig = { .macPrefix = { 0x00, 0x16, 0x3e }, + .devicesPostParseCallback = xenDomainDeviceDefPostParse, }; +virDomainXMLConfPtr +xenDomainXMLConfInit(void) +{ + return virDomainXMLConfNew(&xenDomainDefParserConfig, + NULL, NULL); +} + + static virDrvOpenStatus xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) { @@ -405,8 +430,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlopt = virDomainXMLOptionNew(&xenDomainDefParserConfig, - NULL, NULL))) + if (!(priv->xmlconf = xenDomainXMLConfInit())) goto fail; #if WITH_XEN_INOTIFY diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index f1f5d74..4d7fb53 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -226,6 +226,8 @@ typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr; char *xenDomainUsedCpus(virDomainPtr dom); +virDomainXMLConfPtr xenDomainXMLConfInit(void); + void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info); int xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info, int id, char *name, diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 69bc6cd..e16fffe 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2279,15 +2279,6 @@ struct guest_arch { }; -static int xenDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - static virCapsPtr xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, int host_pae, @@ -2414,8 +2405,6 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, } - caps->defaultConsoleTargetType = xenDefaultConsoleType; - return caps; no_memory: diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index d619609..123c4f2 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -43,16 +43,27 @@ #define VIR_FROM_THIS VIR_FROM_XENAPI -static int xenapiDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) +static int +xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) { - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; } +virDomainDefParserConfig xenapiDomainDefParserConfig = { + .devicesPostParseCallback = xenapiDomainDeviceDefPostParse, +}; + + /* * getCapsObject * @@ -83,8 +94,6 @@ getCapsObject(void) if (!domain2) goto error_cleanup; - caps->defaultConsoleTargetType = xenapiDefaultConsoleType; - return caps; error_cleanup: @@ -169,7 +178,8 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, goto error; } - if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) { + if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig, + NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); goto error; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index 0c2170c..1bc6feb 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -8,13 +8,6 @@ # include "domain_conf.h" -static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; -} - - virCapsPtr testLXCCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; @@ -23,8 +16,6 @@ virCapsPtr testLXCCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testLXCDefaultConsoleType; - if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686, "/usr/libexec/libvirt_lxc", NULL, 0, NULL)) == NULL) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index db15ee6..fba17a3 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -55,15 +55,6 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines) return machines; } -static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch) -{ - if (arch == VIR_ARCH_S390 || - arch == VIR_ARCH_S390X) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static int testQemuAddPPC64Guest(virCapsPtr caps) { @@ -200,8 +191,6 @@ virCapsPtr testQemuCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testQemuDefaultConsoleType; - if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL || (machines = testQemuAllocMachines(&nmachines)) == NULL) goto cleanup; diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 2eb4730..1b5ee79 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -6,20 +6,6 @@ #include "testutilsxen.h" #include "domain_conf.h" -static int testXenDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - -virDomainXMLOptionPtr -testXenXMLConfInit(void) -{ - return virDomainXMLOptionNew(NULL, NULL, NULL); -} virCapsPtr testXenCapsInit(void) { struct utsname utsname; @@ -39,8 +25,6 @@ virCapsPtr testXenCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testXenDefaultConsoleType; - nmachines = ARRAY_CARDINALITY(x86_machines); if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL) goto cleanup; diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h index a38b03a..7f27e22 100644 --- a/tests/testutilsxen.h +++ b/tests/testutilsxen.h @@ -1,6 +1,4 @@ #include "capabilities.h" -#include "domain_conf.h" virCapsPtr testXenCapsInit(void); -virDomainXMLOptionPtr testXenXMLConfInit(void); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index d63ac52..2d04da7 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virDomainXMLOptionPtr xmlopt; static virVMXContext ctx; -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void testCapsInit(void) @@ -32,8 +27,6 @@ testCapsInit(void) return; } - caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesAddHostMigrateTransport(caps, "esx"); /* i686 guest */ diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index af80061..812e309 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -196,7 +196,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlopt = testXenXMLConfInit())) + if (!(xmlconf = xenDomainXMLConfInit())) return EXIT_FAILURE; #define DO_TEST(name, version) \ diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index a091d45..294a53f 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -10,6 +10,7 @@ #include "internal.h" #include "xen/xend_internal.h" +#include "xen/xen_driver.h" #include "xenxs/xen_sxpr.h" #include "testutils.h" #include "testutilsxen.h" @@ -104,7 +105,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlopt = testXenXMLConfInit())) + if (!(xmlconf = xenDomainXMLConfInit())) return EXIT_FAILURE; DO_TEST("pv", "pv", "pvtest", 1); diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 659b0c8..1957659 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virVMXContext ctx; static virDomainXMLOptionPtr xmlopt; -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void testCapsInit(void) @@ -32,8 +27,6 @@ testCapsInit(void) return; } - caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesAddHostMigrateTransport(caps, "esx"); -- 1.8.1.5

This patch refactors various places to allow removing of the defaultConsoleTargetType callback from the virCaps structure. A new console character device target type is introduced - VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was specified in the XML. This type is at the end converted to the standard VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are different from this default have to be processed separately in the device post parse callback. --- I had some uncommited changes resulting from the rename of the structures when I was formatting v5.1. This version has the changes in. src/conf/capabilities.h | 3 - src/conf/domain_conf.c | 269 +++++++++++++++++++++------------------ src/conf/domain_conf.h | 3 +- src/esx/esx_driver.c | 8 -- src/libxl/libxl_conf.c | 11 -- src/libxl/libxl_driver.c | 19 +++ src/lxc/lxc_conf.c | 8 -- src/lxc/lxc_domain.c | 17 +++ src/openvz/openvz_conf.c | 10 +- src/openvz/openvz_driver.c | 16 +++ src/parallels/parallels_driver.c | 7 - src/phyp/phyp_driver.c | 9 -- src/qemu/qemu_capabilities.c | 13 -- src/qemu/qemu_domain.c | 7 + src/security/virt-aa-helper.c | 7 - src/test/test_driver.c | 9 -- src/uml/uml_conf.c | 9 -- src/uml/uml_driver.c | 24 +++- src/vbox/vbox_tmpl.c | 9 -- src/vmware/vmware_conf.c | 9 -- src/xen/xen_driver.c | 28 +++- src/xen/xen_driver.h | 2 + src/xen/xen_hypervisor.c | 11 -- src/xenapi/xenapi_driver.c | 28 ++-- tests/testutilslxc.c | 9 -- tests/testutilsqemu.c | 11 -- tests/testutilsxen.c | 16 --- tests/testutilsxen.h | 2 - tests/vmx2xmltest.c | 7 - tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 3 +- tests/xml2vmxtest.c | 7 - 32 files changed, 278 insertions(+), 315 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 9bb22a7..abcf6de 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -160,9 +160,6 @@ struct _virCaps { size_t nguests; size_t nguests_max; virCapsGuestPtr *guests; - - /* Move to virDomainXMLOption later */ - int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f2269c0..f98af61 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -385,6 +385,7 @@ VIR_ENUM_IMPL(virDomainChrChannelTarget, VIR_ENUM_IMPL(virDomainChrConsoleTarget, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LAST, + "none", "serial", "xen", "uml", @@ -2347,9 +2348,11 @@ virDomainDeviceInfoClearCCWAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, return 0; } -int virDomainDeviceInfoIterate(virDomainDefPtr def, - virDomainDeviceInfoCallback cb, - void *opaque) +static int +virDomainDeviceInfoIterateInternal(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + bool all, + void *opaque) { int i; virDomainDeviceDef device; @@ -2413,9 +2416,11 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, return -1; } for (i = 0; i < def->nconsoles ; i++) { - if (i == 0 && - def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL && - STREQ_NULLABLE(def->os.type, "hvm")) + if (!all && + i == 0 && + (def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[i]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && + STREQ_NULLABLE(def->os.type, "hvm")) continue; device.data.chr = def->consoles[i]; if (cb(def, &device, &def->consoles[i]->info, opaque) < 0) @@ -2491,10 +2496,21 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, } +int +virDomainDeviceInfoIterate(virDomainDefPtr def, + virDomainDeviceInfoCallback cb, + void *opaque) +{ + return virDomainDeviceInfoIterateInternal(def, cb, false, opaque); +} + + static int virDomainDefPostParseInternal(virDomainDefPtr def, virCapsPtr caps ATTRIBUTE_UNUSED) { + int i; + /* verify init path for container based domains */ if (STREQ(def->os.type, "exe") && !def->os.init) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2502,6 +2518,91 @@ virDomainDefPostParseInternal(virDomainDefPtr def, return -1; } + /* + * Some really crazy backcompat stuff for consoles + * + * Historically the first (and only) '<console>' element in an HVM guest + * was treated as being an alias for a <serial> device. + * + * So if we see that this console device should be a serial device, then we + * move the config over to def->serials[0] (or discard it if that already + * exists). However, given console can already be filled with aliased data + * of def->serials[0]. Keep it then. + * + * We then fill def->consoles[0] with a stub just so we get sequencing + * correct for consoles > 0 + */ + if (def->nconsoles > 0 && STREQ(def->os.type, "hvm") && + (def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[0]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE)) { + /* First verify that only the first console is of type serial */ + for (i = 1; i < def->nconsoles; i++) { + virDomainChrDefPtr cons = def->consoles[i]; + + if (cons->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only the first console can be a serial port")); + return -1; + } + } + + /* If there isn't a corresponding serial port: + * - create one and set, the console to be an alias for it + * + * If there is a corresponding serial port: + * - Check if the source definition is equal: + * - if yes: leave it as-is + * - if no: change the console to be alias of the serial port + */ + + /* create the serial port definition from the console definition */ + if (def->nserials == 0) { + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, + def->consoles[0]) < 0) + goto no_memory; + + /* modify it to be a serial port */ + def->serials[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; + def->serials[0]->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; + def->serials[0]->target.port = 0; + } else { + /* if the console source doesn't match */ + if (!virDomainChrSourceDefIsEqual(&def->serials[0]->source, + &def->consoles[0]->source)) { + virDomainChrDefFree(def->consoles[0]); + def->consoles[0] = NULL; + } + } + + if (!def->consoles[0]) { + /* allocate a new console type for the stolen one */ + if (VIR_ALLOC(def->consoles[0]) < 0) + goto no_memory; + + /* Create an console alias for the serial port */ + def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + def->consoles[0]->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; + } + } + + return 0; + +no_memory: + virReportOOMError(); + return -1; +} + + +static int +virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; + return 0; } @@ -2521,6 +2622,9 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, return ret; } + if ((ret = virDomainDeviceDefPostParseInternal(dev, def, caps)) < 0) + return ret; + return 0; } @@ -2564,9 +2668,10 @@ virDomainDefPostParse(virDomainDefPtr def, } /* iterate the devices */ - if ((ret = virDomainDeviceInfoIterate(def, - virDomainDefPostParseDeviceIterator, - &data)) < 0) + if ((ret = virDomainDeviceInfoIterateInternal(def, + virDomainDefPostParseDeviceIterator, + true, + &data)) < 0) return ret; @@ -5923,87 +6028,66 @@ error: } static int -virDomainChrDefaultTargetType(virCapsPtr caps, - virDomainDefPtr def, - int devtype) { - - int target = -1; - - switch (devtype) { +virDomainChrDefaultTargetType(int devtype) { + switch ((enum virDomainChrDeviceType) devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: virReportError(VIR_ERR_XML_ERROR, _("target type must be specified for %s device"), virDomainChrDeviceTypeToString(devtype)); - break; + return -1; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - if (!caps->defaultConsoleTargetType) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Driver does not have a default console type set")); - return -1; - } - target = caps->defaultConsoleTargetType(def->os.type, def->os.arch); - break; + return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - target = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; - break; + return VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - default: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ - target = 0; break; } - return target; + return 0; } static int -virDomainChrTargetTypeFromString(virCapsPtr caps, - virDomainDefPtr vmdef, - virDomainChrDefPtr def, +virDomainChrTargetTypeFromString(virDomainChrDefPtr def, int devtype, const char *targetType) { int ret = -1; - int target = 0; - if (!targetType) { - target = virDomainChrDefaultTargetType(caps, vmdef, devtype); - goto out; - } + if (!targetType) + return virDomainChrDefaultTargetType(devtype); - switch (devtype) { + switch ((enum virDomainChrDeviceType) devtype) { case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL: - target = virDomainChrChannelTargetTypeFromString(targetType); + ret = virDomainChrChannelTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE: - target = virDomainChrConsoleTargetTypeFromString(targetType); + ret = virDomainChrConsoleTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL: - target = virDomainChrSerialTargetTypeFromString(targetType); + ret = virDomainChrSerialTargetTypeFromString(targetType); break; case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: - default: + case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST: /* No target type yet*/ + ret = 0; break; } def->targetTypeAttr = true; -out: - ret = target; return ret; } static int -virDomainChrDefParseTargetXML(virCapsPtr caps, - virDomainDefPtr vmdef, - virDomainChrDefPtr def, +virDomainChrDefParseTargetXML(virDomainChrDefPtr def, xmlNodePtr cur) { int ret = -1; @@ -6013,8 +6097,8 @@ virDomainChrDefParseTargetXML(virCapsPtr caps, const char *portStr = NULL; if ((def->targetType = - virDomainChrTargetTypeFromString(caps, vmdef, def, - def->deviceType, targetType)) < 0) { + virDomainChrTargetTypeFromString(def, def->deviceType, + targetType)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown target type '%s' specified for character device"), targetType); @@ -6373,9 +6457,7 @@ virDomainChrDefNew(void) { * */ static virDomainChrDefPtr -virDomainChrDefParseXML(virCapsPtr caps, - virDomainDefPtr vmdef, - xmlXPathContextPtr ctxt, +virDomainChrDefParseXML(xmlXPathContextPtr ctxt, xmlNodePtr node, virSecurityLabelDefPtr* vmSeclabels, int nvmSeclabels, @@ -6419,7 +6501,7 @@ virDomainChrDefParseXML(virCapsPtr caps, if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "target")) { seenTarget = true; - if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) { + if (virDomainChrDefParseTargetXML(def, cur) < 0) { goto error; } } @@ -6429,7 +6511,7 @@ virDomainChrDefParseXML(virCapsPtr caps, } if (!seenTarget && - ((def->targetType = virDomainChrDefaultTargetType(caps, vmdef, def->deviceType)) < 0)) + ((def->targetType = virDomainChrDefaultTargetType(def->deviceType)) < 0)) goto cleanup; if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { @@ -10557,9 +10639,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10587,9 +10667,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10619,10 +10697,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - bool create_stub = true; - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -10630,64 +10705,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (!chr) goto error; - /* - * Some really crazy backcompat stuff for consoles - * - * Historically the first (and only) '<console>' - * element in an HVM guest was treated as being - * an alias for a <serial> device. - * - * So if we see that this console device should - * be a serial device, then we move the config - * over to def->serials[0] (or discard it if - * that already exists). However, given console - * can already be filled with aliased data of - * def->serials[0]. Keep it then. - * - * We then fill def->consoles[0] with a stub - * just so we get sequencing correct for consoles - * > 0 - */ - if (STREQ(def->os.type, "hvm") && - (chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL)) { - if (i != 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only the first console can be a serial port")); - virDomainChrDefFree(chr); - goto error; - } - - /* Either discard or move this chr to the serial config */ - if (def->nserials != 0) { - if (virDomainChrSourceDefIsEqual(&def->serials[0]->source, - &chr->source)) { - /* Alias to def->serial[0]. Skip it */ - create_stub = false; - } else { - virDomainChrDefFree(chr); - } - } else { - if (VIR_ALLOC_N(def->serials, 1) < 0) { - virDomainChrDefFree(chr); - goto no_memory; - } - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; - def->nserials = 1; - def->serials[0] = chr; - chr->target.port = 0; - } - - if (create_stub) { - /* And create a stub placeholder */ - if (VIR_ALLOC(chr) < 0) - goto no_memory; - chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; - chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - } - } - chr->target.port = i; - def->consoles[def->nconsoles++] = chr; } VIR_FREE(nodes); @@ -10699,9 +10717,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainChrDefPtr chr = virDomainChrDefParseXML(caps, - def, - ctxt, + virDomainChrDefPtr chr = virDomainChrDefParseXML(ctxt, nodes[i], def->seclabels, def->nseclabels, @@ -15200,7 +15216,6 @@ virDomainDefFormatInternal(virDomainDefPtr def, if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) goto error; - for (n = 0 ; n < def->nnets ; n++) if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0) goto error; @@ -15223,7 +15238,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, * if it is type == serial */ if (STREQ(def->os.type, "hvm") && - (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) && + (def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL || + def->consoles[n]->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) && (n < def->nserials)) { memcpy(&console, def->serials[n], sizeof(console)); console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; @@ -15240,6 +15256,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, virDomainChrDef console; memcpy(&console, def->serials[n], sizeof(console)); console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE; + console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; if (virDomainChrDefFormat(buf, &console, flags) < 0) goto error; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 45a79a4..700f03f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -956,7 +956,8 @@ enum virDomainChrChannelTargetType { }; enum virDomainChrConsoleTargetType { - VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL = 0, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE = 0, + VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML, VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO, diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 3a21395..4828209 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -569,13 +569,6 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid) } -static int esxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virCapsPtr esxCapsInit(esxPrivate *priv) { @@ -600,7 +593,6 @@ esxCapsInit(esxPrivate *priv) virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr"); - caps->defaultConsoleTargetType = esxDefaultConsoleType; if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) { goto failure; diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index ed3e832..7e0753a 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -64,15 +64,6 @@ static const char *xen_cap_re = "(xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x static regex_t xen_cap_rec; -static int libxlDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - static virCapsPtr libxlBuildCapabilities(virArch hostarch, int host_pae, @@ -162,8 +153,6 @@ libxlBuildCapabilities(virArch hostarch, } } - caps->defaultConsoleTargetType = libxlDefaultConsoleType; - return caps; no_memory: diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 32818ff..9980b38 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -431,10 +431,29 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = { .free = libxlDomainObjPrivateFree, }; + +static int +libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; +} + + virDomainDefParserConfig libxlDomainDefParserConfig = { .macPrefix = { 0x00, 0x16, 0x3e }, + .devicesPostParseCallback = libxlDomainDeviceDefPostParse, }; + /* driver must be locked before calling */ static void libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event) diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 05e0d45..13c0d97 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -41,12 +41,6 @@ #define VIR_FROM_THIS VIR_FROM_LXC -static int lxcDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; -} - /* Functions */ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) @@ -59,8 +53,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver) 0, 0)) == NULL) goto error; - caps->defaultConsoleTargetType = lxcDefaultConsoleType; - /* Some machines have problematic NUMA toplogy causing * unexpected failures. We don't want to break the QEMU * driver in this scenario, so log errors & carry on diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index 8090789..e7a85ca 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -93,6 +93,23 @@ virLXCDomainDefPostParse(virDomainDefPtr def, return 0; } + +static int +virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; + + return 0; +} + + virDomainDefParserConfig virLXCDriverDomainDefParserConfig = { .domainPostParseCallback = virLXCDomainDefPostParse, + .devicesPostParseCallback = virLXCDomainDeviceDefPostParse, }; diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 22dea79..4b21c4e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -168,13 +168,6 @@ error: } -static int openvzDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; -} - - virCapsPtr openvzCapsInit(void) { virCapsPtr caps; @@ -204,9 +197,8 @@ virCapsPtr openvzCapsInit(void) NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = openvzDefaultConsoleType; - return caps; + no_memory: virObjectUnref(caps); return NULL; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 180d047..9b10624 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -115,8 +115,24 @@ openvzDomainDefPostParse(virDomainDefPtr def, } +static int +openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_OPENVZ; + + return 0; +} + + virDomainDefParserConfig openvzDomainDefParserConfig = { .domainPostParseCallback = openvzDomainDefPostParse, + .devicesPostParseCallback = openvzDomainDeviceDefPostParse, }; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index c6833f7..c524bf1 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -96,12 +96,6 @@ parallelsDriverUnlock(parallelsConnPtr driver) virMutexUnlock(&driver->lock); } -static int -parallelsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void parallelsDomObjFreePrivate(void *p) @@ -149,7 +143,6 @@ parallelsBuildCapabilities(void) "parallels", NULL, NULL, 0, NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = parallelsDefaultConsoleType; return caps; no_memory: diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 07f230f..071caf2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -300,13 +300,6 @@ phypGetVIOSPartitionID(virConnectPtr conn) } -static int phypDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virCapsPtr phypCapsInit(void) { @@ -337,8 +330,6 @@ phypCapsInit(void) "phyp", NULL, NULL, 0, NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = phypDefaultConsoleType; - return caps; no_memory: diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7760542..50712b0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -856,17 +856,6 @@ error: } -static int virQEMUCapsDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch) -{ - if (arch == VIR_ARCH_S390 || - arch == VIR_ARCH_S390X) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) { virCapsPtr caps; @@ -906,8 +895,6 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache) i) < 0) goto error; - caps->defaultConsoleTargetType = virQEMUCapsDefaultConsoleType; - return caps; error: diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index e5e9223..f431aec 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -731,6 +731,13 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, } } + /* set the default console type for S390 arches */ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + (def->os.arch == VIR_ARCH_S390 || def->os.arch == VIR_ARCH_S390X)) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; + ret = 0; cleanup: diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index fee63ec..3d3b772 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -687,11 +687,6 @@ caps_mockup(vahControl * ctl, const char *xmlStr) return rc; } -static int aaDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static int get_definition(vahControl * ctl, const char *xmlStr) @@ -716,8 +711,6 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - ctl->caps->defaultConsoleTargetType = aaDefaultConsoleType; - if ((guest = virCapabilitiesAddGuest(ctl->caps, ctl->hvm, ctl->arch, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index ecfbe33..76fbfda 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -152,13 +152,6 @@ static void testDomainObjPrivateFree(void *data) } -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virDomainXMLOptionPtr testBuildXMLConfig(void) { @@ -179,8 +172,6 @@ testBuildCapabilities(virConnectPtr conn) { if ((caps = virCapabilitiesNew(VIR_ARCH_I686, 0, 0)) == NULL) goto no_memory; - caps->defaultConsoleTargetType = testDefaultConsoleType; - if (virCapabilitiesAddHostFeature(caps, "pae") < 0) goto no_memory; if (virCapabilitiesAddHostFeature(caps ,"nonpae") < 0) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index 0fe59fb..4fa7927 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -52,13 +52,6 @@ #define VIR_FROM_THIS VIR_FROM_UML -static int umlDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; -} - - virCapsPtr umlCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; @@ -102,8 +95,6 @@ virCapsPtr umlCapsInit(void) { NULL) == NULL) goto error; - caps->defaultConsoleTargetType = umlDefaultConsoleType; - return caps; error: diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2476d1c..6cff6fd 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -420,6 +420,27 @@ cleanup: umlDriverUnlock(driver); } + +static int +umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def ATTRIBUTE_UNUSED, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_UML; + + return 0; +} + + +virDomainDefParserConfig umlDriverDomainDefParserConfig = { + .devicesPostParseCallback = umlDomainDeviceDefPostParse, +}; + + /** * umlStartup: * @@ -505,7 +526,8 @@ umlStartup(bool privileged, if ((uml_driver->caps = umlCapsInit()) == NULL) goto out_of_memory; - if (!(uml_driver->xmlopt = virDomainXMLOptionNew(NULL, &privcb, NULL))) + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig, + &privcb, NULL))) goto error; if ((uml_driver->inotifyFD = inotify_init()) < 0) { diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 4490d0c..0248ee0 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -844,13 +844,6 @@ cleanup: } -static int vboxDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - static virDomainDefParserConfig vboxDomainDefParserConfig = { .macPrefix = { 0x08, 0x00, 0x27 }, }; @@ -893,8 +886,6 @@ static virCapsPtr vboxCapsInit(void) NULL) == NULL) goto no_memory; - caps->defaultConsoleTargetType = vboxDefaultConsoleType; - return caps; no_memory: diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index d8d2611..573fb33 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -50,13 +50,6 @@ vmwareFreeDriver(struct vmware_driver *driver) } -static int vmwareDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} - - virCapsPtr vmwareCapsInit(void) { @@ -122,8 +115,6 @@ vmwareCapsInit(void) goto error; } - caps->defaultConsoleTargetType = vmwareDefaultConsoleType; - cleanup: virCPUDefFree(cpu); if (caps) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 6761090..5a15b58 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -265,11 +265,36 @@ xenUnifiedXendProbe(void) #endif +static int +xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; +} + + virDomainDefParserConfig xenDomainDefParserConfig = { .macPrefix = { 0x00, 0x16, 0x3e }, + .devicesPostParseCallback = xenDomainDeviceDefPostParse, }; +virDomainXMLOptionPtr +xenDomainXMLConfInit(void) +{ + return virDomainXMLOptionNew(&xenDomainDefParserConfig, + NULL, NULL); +} + + static virDrvOpenStatus xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) { @@ -405,8 +430,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlopt = virDomainXMLOptionNew(&xenDomainDefParserConfig, - NULL, NULL))) + if (!(priv->xmlopt = xenDomainXMLConfInit())) goto fail; #if WITH_XEN_INOTIFY diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index f1f5d74..702b1e8 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -226,6 +226,8 @@ typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr; char *xenDomainUsedCpus(virDomainPtr dom); +virDomainXMLOptionPtr xenDomainXMLConfInit(void); + void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info); int xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info, int id, char *name, diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 69bc6cd..e16fffe 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2279,15 +2279,6 @@ struct guest_arch { }; -static int xenDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - static virCapsPtr xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, int host_pae, @@ -2414,8 +2405,6 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch, } - caps->defaultConsoleTargetType = xenDefaultConsoleType; - return caps; no_memory: diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index d619609..123c4f2 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -43,16 +43,27 @@ #define VIR_FROM_THIS VIR_FROM_XENAPI -static int xenapiDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) +static int +xenapiDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) { - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + if (dev->type == VIR_DOMAIN_DEVICE_CHR && + dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE && + STRNEQ(def->os.type, "hvm")) + dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; + + return 0; } +virDomainDefParserConfig xenapiDomainDefParserConfig = { + .devicesPostParseCallback = xenapiDomainDeviceDefPostParse, +}; + + /* * getCapsObject * @@ -83,8 +94,6 @@ getCapsObject(void) if (!domain2) goto error_cleanup; - caps->defaultConsoleTargetType = xenapiDefaultConsoleType; - return caps; error_cleanup: @@ -169,7 +178,8 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, goto error; } - if (!(privP->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) { + if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig, + NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); goto error; diff --git a/tests/testutilslxc.c b/tests/testutilslxc.c index 0c2170c..1bc6feb 100644 --- a/tests/testutilslxc.c +++ b/tests/testutilslxc.c @@ -8,13 +8,6 @@ # include "domain_conf.h" -static int testLXCDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_LXC; -} - - virCapsPtr testLXCCapsInit(void) { virCapsPtr caps; virCapsGuestPtr guest; @@ -23,8 +16,6 @@ virCapsPtr testLXCCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testLXCDefaultConsoleType; - if ((guest = virCapabilitiesAddGuest(caps, "exe", VIR_ARCH_I686, "/usr/libexec/libvirt_lxc", NULL, 0, NULL)) == NULL) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index db15ee6..fba17a3 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -55,15 +55,6 @@ static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines) return machines; } -static int testQemuDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch) -{ - if (arch == VIR_ARCH_S390 || - arch == VIR_ARCH_S390X) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static int testQemuAddPPC64Guest(virCapsPtr caps) { @@ -200,8 +191,6 @@ virCapsPtr testQemuCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testQemuDefaultConsoleType; - if ((caps->host.cpu = virCPUDefCopy(&host_cpu)) == NULL || (machines = testQemuAllocMachines(&nmachines)) == NULL) goto cleanup; diff --git a/tests/testutilsxen.c b/tests/testutilsxen.c index 2eb4730..1b5ee79 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -6,20 +6,6 @@ #include "testutilsxen.h" #include "domain_conf.h" -static int testXenDefaultConsoleType(const char *ostype, - virArch arch ATTRIBUTE_UNUSED) -{ - if (STREQ(ostype, "hvm")) - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; - else - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; -} - -virDomainXMLOptionPtr -testXenXMLConfInit(void) -{ - return virDomainXMLOptionNew(NULL, NULL, NULL); -} virCapsPtr testXenCapsInit(void) { struct utsname utsname; @@ -39,8 +25,6 @@ virCapsPtr testXenCapsInit(void) { 0, 0)) == NULL) return NULL; - caps->defaultConsoleTargetType = testXenDefaultConsoleType; - nmachines = ARRAY_CARDINALITY(x86_machines); if ((machines = virCapabilitiesAllocMachines(x86_machines, nmachines)) == NULL) goto cleanup; diff --git a/tests/testutilsxen.h b/tests/testutilsxen.h index a38b03a..7f27e22 100644 --- a/tests/testutilsxen.h +++ b/tests/testutilsxen.h @@ -1,6 +1,4 @@ #include "capabilities.h" -#include "domain_conf.h" virCapsPtr testXenCapsInit(void); -virDomainXMLOptionPtr testXenXMLConfInit(void); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index d63ac52..2d04da7 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virDomainXMLOptionPtr xmlopt; static virVMXContext ctx; -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void testCapsInit(void) @@ -32,8 +27,6 @@ testCapsInit(void) return; } - caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesAddHostMigrateTransport(caps, "esx"); /* i686 guest */ diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index af80061..b7ff48c 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -196,7 +196,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlopt = testXenXMLConfInit())) + if (!(xmlopt = xenDomainXMLConfInit())) return EXIT_FAILURE; #define DO_TEST(name, version) \ diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index a091d45..062ff07 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -10,6 +10,7 @@ #include "internal.h" #include "xen/xend_internal.h" +#include "xen/xen_driver.h" #include "xenxs/xen_sxpr.h" #include "testutils.h" #include "testutilsxen.h" @@ -104,7 +105,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlopt = testXenXMLConfInit())) + if (!(xmlopt = xenDomainXMLConfInit())) return EXIT_FAILURE; DO_TEST("pv", "pv", "pvtest", 1); diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 659b0c8..1957659 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virVMXContext ctx; static virDomainXMLOptionPtr xmlopt; -static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED, - virArch arch ATTRIBUTE_UNUSED) -{ - return VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL; -} static void testCapsInit(void) @@ -32,8 +27,6 @@ testCapsInit(void) return; } - caps->defaultConsoleTargetType = testDefaultConsoleType; - virCapabilitiesAddHostMigrateTransport(caps, "esx"); -- 1.8.1.5

On Thu, Apr 04, 2013 at 02:16:09PM +0200, Peter Krempa wrote:
This patch refactors various places to allow removing of the defaultConsoleTargetType callback from the virCaps structure.
A new console character device target type is introduced - VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE - to mark that no type was specified in the XML. This type is at the end converted to the standard VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL. Other types that are different from this default have to be processed separately in the device post parse callback. --- I had some uncommited changes resulting from the rename of the structures when I was formatting v5.1. This version has the changes in.
src/conf/capabilities.h | 3 - src/conf/domain_conf.c | 269 +++++++++++++++++++++------------------ src/conf/domain_conf.h | 3 +- src/esx/esx_driver.c | 8 -- src/libxl/libxl_conf.c | 11 -- src/libxl/libxl_driver.c | 19 +++ src/lxc/lxc_conf.c | 8 -- src/lxc/lxc_domain.c | 17 +++ src/openvz/openvz_conf.c | 10 +- src/openvz/openvz_driver.c | 16 +++ src/parallels/parallels_driver.c | 7 - src/phyp/phyp_driver.c | 9 -- src/qemu/qemu_capabilities.c | 13 -- src/qemu/qemu_domain.c | 7 + src/security/virt-aa-helper.c | 7 - src/test/test_driver.c | 9 -- src/uml/uml_conf.c | 9 -- src/uml/uml_driver.c | 24 +++- src/vbox/vbox_tmpl.c | 9 -- src/vmware/vmware_conf.c | 9 -- src/xen/xen_driver.c | 28 +++- src/xen/xen_driver.h | 2 + src/xen/xen_hypervisor.c | 11 -- src/xenapi/xenapi_driver.c | 28 ++-- tests/testutilslxc.c | 9 -- tests/testutilsqemu.c | 11 -- tests/testutilsxen.c | 16 --- tests/testutilsxen.h | 2 - tests/vmx2xmltest.c | 7 - tests/xmconfigtest.c | 2 +- tests/xml2sexprtest.c | 3 +- tests/xml2vmxtest.c | 7 - 32 files changed, 278 insertions(+), 315 deletions(-)
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/04/13 14:10, Peter Krempa wrote:
In this respin the renaming patch is moved to be first in the series. The argument rearrangement patch was too complicated to move.
Unfortunately this rebase operation caused my "git notes" to be lost for the individual patches, so please see v5 for more specific comments.
Patches 5 to 11 except for 10 were ACKed in previous versions.
Peter Krempa (11): maint: Rename xmlconf to xmlopt and virDomainXMLConfing to virDomainXMLOption conf: Add post XML parse callbacks and prepare for cleaning of virCaps conf callback: Rearrange function parameters qemu: Record the default NIC model in the domain XML virCaps: get rid of "defaultInitPath" value in the virCaps struct virCaps: get rid of defaultDiskDriverName virCaps: get rid of emulatorRequired virCaps: get rid of defaultDiskDriverType virCaps: get rid of hasWideScsiBus virCaps: get rid of macPrefix field virCaps: get rid of defaultConsoleTargetType callback
Thank you all for the reviews. I've pushed the series now and I will follow up with a cleanup and patch to solve the s390 network issue tomorrow. Peter
participants (5)
-
Daniel P. Berrange
-
Eric Blake
-
Laine Stump
-
Peter Krempa
-
Viktor Mihajlovski