[libvirt] [PATCHv5 00/11] Introduce driver specific XML parsing callbacks

This series now splits out everything unrelated from the virCaps object. See notes in individual patches for change summary. This series now contains 2 renaming patches that were suggested by Eric and Laine. Peter Krempa (11): 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 maint: Rename xmlconf to xmlopt and virDomainXMLConfing to virDomainXMLOption src/conf/capabilities.c | 24 - src/conf/capabilities.h | 23 - src/conf/domain_conf.c | 658 ++++++++++++--------- src/conf/domain_conf.h | 103 ++-- 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 | 101 ++-- 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 | 16 +- 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 | 69 +-- 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 | 19 +- 108 files changed, 1273 insertions(+), 1050 deletions(-) -- 1.8.1.5

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. --- Notes: Version 5: - added support for opaque data for the callback - removed post-devices domain config callback until it's needed - renamed the structure holding the data as it will also contain some defaults as values - squashed patch adding the new argument to the contstructor Version 4: - added support for opaque data for the callback - removed post-devices domain config callback until it's needed - renamed the structure holding the data as it will also contain some defaults as values - squashed patch adding the new argument to the contstructor src/conf/domain_conf.c | 101 +++++++++++++++++++++++++++++++++++++-- src/conf/domain_conf.h | 27 +++++++++-- src/esx/esx_driver.c | 2 +- src/libxl/libxl_driver.c | 9 ++-- 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 | 3 +- 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, 173 insertions(+), 44 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f3fca7f..7ebac12 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -73,6 +73,9 @@ struct _virDomainObjList { struct _virDomainXMLConf { 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 virDomainXMLConfClass; static void virDomainObjDispose(void *obj); static void virDomainObjListDispose(void *obj); +static void virDomainXMLConfClassDispose(void *obj); static int virDomainObjOnceInit(void) { @@ -741,7 +745,7 @@ static int virDomainObjOnceInit(void) if (!(virDomainXMLConfClass = virClassNew(virClassForObject(), "virDomainXMLConf", sizeof(virDomainXMLConf), - NULL))) + virDomainXMLConfClassDispose))) return -1; return 0; @@ -750,13 +754,24 @@ static int virDomainObjOnceInit(void) VIR_ONCE_GLOBAL_INIT(virDomainObj) +static void +virDomainXMLConfClassDispose(void *obj) +{ + virDomainXMLConfPtr xmlconf = obj; + + if (xmlconf->config.privFree) + (xmlconf->config.privFree)(xmlconf->config.priv); +} + + /** * virDomainXMLConfNew: * * Allocate a new domain XML configuration */ virDomainXMLConfPtr -virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, +virDomainXMLConfNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns) { virDomainXMLConfPtr xmlconf; @@ -770,6 +785,9 @@ virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, if (priv) xmlconf->privateData = *priv; + if (config) + xmlconf->config = *config; + if (xmlns) xmlconf->ns = *xmlns; @@ -2461,6 +2479,73 @@ int virDomainDeviceInfoIterate(virDomainDefPtr def, } +static int +virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + virDomainDefPtr def, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf) +{ + int ret; + + if (xmlconf && xmlconf->config.devicesPostParseCallback) { + ret = xmlconf->config.devicesPostParseCallback(dev, def, caps, + xmlconf->config.priv); + if (ret < 0) + return ret; + } + + return 0; +} + + +struct virDomainDefPostParseDeviceIteratorData { + virDomainDefPtr def; + virCapsPtr caps; + virDomainXMLConfPtr xmlconf; +}; + + +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->xmlconf); +} + + +static int +virDomainDefPostParse(virDomainDefPtr def, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf) +{ + int ret; + struct virDomainDefPostParseDeviceIteratorData data = { + .def = def, + .caps = caps, + .xmlconf = xmlconf, + }; + + /* call the domain config callback */ + if (xmlconf && xmlconf->config.domainPostParseCallback) { + ret = xmlconf->config.domainPostParseCallback(def, caps, + xmlconf->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, + virDomainXMLConfPtr xmlconf, 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, xmlconf) < 0) + goto error; + cleanup: xmlFreeDoc(xml); xmlXPathFreeContext(ctxt); @@ -10994,6 +11084,10 @@ virDomainDefParseXML(virCapsPtr caps, if (virDomainDefAddImplicitControllers(def) < 0) goto error; + /* callback to fill driver specific domain aspects */ + if (virDomainDefPostParse(def, caps, xmlconf) < 0) + goto error; + virBitmapFree(bootMap); return def; @@ -16391,6 +16485,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device) */ virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, virDomainDeviceDefPtr src) { @@ -16459,7 +16554,7 @@ virDomainDeviceDefCopy(virCapsPtr caps, goto cleanup; xmlStr = virBufferContentAndReset(&buf); - ret = virDomainDeviceDefParse(caps, def, xmlStr, flags); + ret = virDomainDeviceDefParse(caps, xmlconf, def, xmlStr, flags); cleanup: VIR_FREE(xmlStr); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index edddf25..2b7a69a 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,10 @@ struct _virDomainXMLPrivateDataCallbacks { virDomainXMLPrivateDataParseFunc parse; }; -virDomainXMLConfPtr -virDomainXMLConfNew(virDomainXMLPrivateDataCallbacksPtr priv, - virDomainXMLNamespacePtr xmlns); + +virDomainXMLConfPtr virDomainXMLConfNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, + virDomainXMLNamespacePtr xmlns); virDomainXMLNamespacePtr virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) @@ -2009,6 +2028,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, virDomainDeviceDefPtr src); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, @@ -2072,6 +2092,7 @@ void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, + virDomainXMLConfPtr xmlconf, virDomainDefPtr def, const char *xmlStr, unsigned int flags); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index fc8a3ae..2bff60e 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->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(priv->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) goto cleanup; conn->privateData = priv; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 40a7a6b..fd69637 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1239,7 +1239,8 @@ libxlStartup(bool privileged, goto error; } - if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainXMLPrivateDataCallbacks, + if (!(libxl_driver->xmlconf = virDomainXMLConfNew(NULL, + &libxlDomainXMLPrivateDataCallbacks, NULL))) goto error; @@ -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->xmlconf, + 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->xmlconf, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index c723e77..dbc0b42 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -159,7 +159,9 @@ error: virDomainXMLConfPtr lxcDomainXMLConfInit(void) { - return virDomainXMLConfNew(&virLXCDriverPrivateDataCallbacks, NULL); + return virDomainXMLConfNew(NULL, + &virLXCDriverPrivateDataCallbacks, + NULL); } int lxcLoadDriverConfig(virLXCDriverPtr driver) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ba14db7..dc71c16 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->xmlconf, + 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->xmlconf, + vm->def, dev); if (!dev_copy) goto cleanup; } diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index f175655..e3e64e5 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 67d66ae..a6f4c66 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->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(driver->xmlconf = virDomainXMLConfNew(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->xmlconf, + 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 88f41f7..ffb86dc 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->xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(privconn->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) goto error; if (!(privconn->domains = virDomainObjListNew())) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 59cc1ca..6063256 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->xmlconf = virDomainXMLConfNew(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 c2e2e10..d67debd 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -554,7 +554,8 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void) { - return virDomainXMLConfNew(&virQEMUDriverPrivateDataCallbacks, + return virDomainXMLConfNew(NULL, + &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 96bf235..f99b3c6 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->xmlconf, + 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->xmlconf, + vm->def, dev))) { dev->data.disk = tmp; goto end; } @@ -6465,7 +6467,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; } - dev = dev_copy = virDomainDeviceDefParse(caps, vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(caps, driver->xmlconf, + vm->def, xml, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6476,7 +6479,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->xmlconf, 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 f764f77..2f2bc71 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->xmlconf = virDomainXMLConfNew(NULL, NULL))) { + if (!(ctl->xmlconf = virDomainXMLConfNew(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 c5fffb9..76e04c3 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -162,7 +162,7 @@ testBuildXMLConfig(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc, .free = testDomainObjPrivateFree }; - return virDomainXMLConfNew(&priv, NULL); + return virDomainXMLConfNew(NULL, &priv, NULL); } diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 09a777c..ba88b2d 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->xmlconf = virDomainXMLConfNew(&privcb, - NULL))) + if (!(uml_driver->xmlconf = virDomainXMLConfNew(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->xmlconf, 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->xmlconf, 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 aa7466b..dd96e7b 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 virDomainXMLConfPtr vboxXMLConfInit(void) { - return virDomainXMLConfNew(NULL, NULL); + return virDomainXMLConfNew(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->xmlconf, + 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->xmlconf, + 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 6d82532..bf4c1ff 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 virDomainXMLConfNew(&priv, NULL); + return virDomainXMLConfNew(NULL, &priv, NULL); } static virDrvOpenStatus diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index fd20b73..2ef3609 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) goto fail; #if WITH_XEN_INOTIFY diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 398da0d..93ba456 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->xmlconf, 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->xmlconf, 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->xmlconf, def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index f6a3593..2a42e0a 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->xmlconf, 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->xmlconf, entry->def, xml, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index b368f48..941f3bd 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->xmlconf = virDomainXMLConfNew(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 201ea2a..479eec3 100644 --- a/tests/testutilsxen.c +++ b/tests/testutilsxen.c @@ -18,7 +18,7 @@ static int testXenDefaultConsoleType(const char *ostype, virDomainXMLConfPtr testXenXMLConfInit(void) { - return virDomainXMLConfNew(NULL, NULL); + return virDomainXMLConfNew(NULL, NULL, NULL); } virCapsPtr testXenCapsInit(void) { diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 800fd2c..c606036 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -240,7 +240,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlconf = virDomainXMLConfNew(NULL, NULL))) + if (!(xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) return EXIT_FAILURE; ctx.opaque = NULL; -- 1.8.1.5

Move the xmlconf and caps arguments to the end of the argument list. --- Notes: Version 5: - new in series, renaming suggested by Laine Version 4: - added support for opaque data for the callback - removed post-devices domain config callback until it's needed - renamed the structure holding the data as it will also contain some defaults as values - squashed patch adding the new argument to the contstructor 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 7ebac12..c34093b 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, - virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, + virDomainXMLConfPtr xmlconf, unsigned int flags, virDomainDefPtr *oldDef) { @@ -2071,15 +2071,15 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, + virDomainXMLConfPtr xmlconf, unsigned int flags, virDomainDefPtr *oldDef) { virDomainObjPtr ret; virObjectLock(doms); - ret = virDomainObjListAddLocked(doms, xmlconf, def, flags, oldDef); + ret = virDomainObjListAddLocked(doms, def, xmlconf, flags, oldDef); virObjectUnlock(doms); return ret; } @@ -2113,7 +2113,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; - if (!(domain->newDef = virDomainDefCopy(caps, xmlconf, domain->def, false))) + if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlconf, false))) goto out; ret = 0; @@ -8470,10 +8470,10 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, } virDomainDeviceDefPtr -virDomainDeviceDefParse(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, +virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, - const char *xmlStr, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int flags) { xmlDocPtr xml; @@ -9469,11 +9469,11 @@ cleanup: static virDomainDefPtr -virDomainDefParseXML(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - xmlDocPtr xml, +virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11104,10 +11104,10 @@ error: static virDomainObjPtr -virDomainObjParseXML(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - xmlDocPtr xml, +virDomainObjParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11132,8 +11132,8 @@ virDomainObjParseXML(virCapsPtr caps, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(caps, xmlconf, xml, config, ctxt, expectedVirtTypes, - flags); + obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlconf, + expectedVirtTypes, flags); ctxt->node = oldnode; if (!obj->def) goto error; @@ -11215,8 +11215,8 @@ virDomainDefParse(const char *xmlStr, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { - def = virDomainDefParseNode(caps, xmlconf, xml, xmlDocGetRootElement(xml), - expectedVirtTypes, flags); + def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, + xmlconf, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -11225,9 +11225,9 @@ virDomainDefParse(const char *xmlStr, } virDomainDefPtr -virDomainDefParseString(virCapsPtr caps, +virDomainDefParseString(const char *xmlStr, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11236,9 +11236,9 @@ virDomainDefParseString(virCapsPtr caps, } virDomainDefPtr -virDomainDefParseFile(virCapsPtr caps, +virDomainDefParseFile(const char *filename, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11248,10 +11248,10 @@ virDomainDefParseFile(virCapsPtr caps, virDomainDefPtr -virDomainDefParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - xmlDocPtr xml, +virDomainDefParseNode(xmlDocPtr xml, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11273,7 +11273,7 @@ virDomainDefParseNode(virCapsPtr caps, } ctxt->node = root; - def = virDomainDefParseXML(caps, xmlconf, xml, root, ctxt, + def = virDomainDefParseXML(xml, root, ctxt, caps, xmlconf, expectedVirtTypes, flags); cleanup: @@ -11283,10 +11283,10 @@ cleanup: static virDomainObjPtr -virDomainObjParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - xmlDocPtr xml, +virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11307,7 +11307,7 @@ virDomainObjParseNode(virCapsPtr caps, } ctxt->node = root; - obj = virDomainObjParseXML(caps, xmlconf, xml, ctxt, expectedVirtTypes, flags); + obj = virDomainObjParseXML(xml, ctxt, caps, xmlconf, expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11316,9 +11316,9 @@ cleanup: static virDomainObjPtr -virDomainObjParseFile(virCapsPtr caps, +virDomainObjParseFile(const char *filename, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11327,8 +11327,8 @@ virDomainObjParseFile(virCapsPtr caps, int keepBlanksDefault = xmlKeepBlanksDefault(0); if ((xml = virXMLParseFile(filename))) { - obj = virDomainObjParseNode(caps, xmlconf, xml, - xmlDocGetRootElement(xml), + obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml), + caps, xmlconf, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -15491,7 +15491,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if (!(def = virDomainDefParseFile(caps, xmlconf, configFile, + if (!(def = virDomainDefParseFile(configFile, caps, xmlconf, expectedVirtTypes, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -15502,7 +15502,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(dom = virDomainObjListAddLocked(doms, xmlconf, def, 0, &oldDef))) + if (!(dom = virDomainObjListAddLocked(doms, def, xmlconf, 0, &oldDef))) goto error; dom->autostart = autostart; @@ -15524,10 +15524,10 @@ error: static virDomainObjPtr virDomainObjListLoadStatus(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLConfPtr xmlconf, const char *statusDir, const char *name, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15539,7 +15539,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(caps, xmlconf, statusFile, expectedVirtTypes, + if (!(obj = virDomainObjParseFile(statusFile, caps, xmlconf, expectedVirtTypes, VIR_DOMAIN_XML_INTERNAL_STATUS | VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET | VIR_DOMAIN_XML_INTERNAL_PCI_ORIG_STATES))) @@ -15571,11 +15571,11 @@ error: int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, int liveStatus, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15610,10 +15610,10 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, VIR_INFO("Loading config file '%s.xml'", entry->d_name); if (liveStatus) dom = virDomainObjListLoadStatus(doms, - caps, - xmlconf, configDir, entry->d_name, + caps, + xmlconf, expectedVirtTypes, notify, opaque); @@ -16013,9 +16013,9 @@ cleanup: * persistent and active, true for transitions across save files or * snapshots). */ virDomainDefPtr -virDomainDefCopy(virCapsPtr caps, +virDomainDefCopy(virDomainDefPtr src, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - virDomainDefPtr src, bool migratable) { char *xml; @@ -16030,21 +16030,21 @@ virDomainDefCopy(virCapsPtr caps, if (!(xml = virDomainDefFormat(src, write_flags))) return NULL; - ret = virDomainDefParseString(caps, xmlconf, xml, -1, read_flags); + ret = virDomainDefParseString(xml, caps, xmlconf, -1, read_flags); VIR_FREE(xml); return ret; } virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - virDomainObjPtr dom) +virDomainObjCopyPersistentDef(virDomainObjPtr dom, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf) { virDomainDefPtr cur; cur = virDomainObjGetPersistentDef(caps, xmlconf, dom); - return virDomainDefCopy(caps, xmlconf, cur, false); + return virDomainDefCopy(cur, caps, xmlconf, false); } @@ -16484,10 +16484,10 @@ virDomainNetFind(virDomainDefPtr def, const char *device) * Returns a pointer to copied @src or NULL in case of error. */ virDomainDeviceDefPtr -virDomainDeviceDefCopy(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, +virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, - virDomainDeviceDefPtr src) + virCapsPtr caps, + virDomainXMLConfPtr xmlconf) { virDomainDeviceDefPtr ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -16554,7 +16554,7 @@ virDomainDeviceDefCopy(virCapsPtr caps, goto cleanup; xmlStr = virBufferContentAndReset(&buf); - ret = virDomainDeviceDefParse(caps, xmlconf, def, xmlStr, flags); + ret = virDomainDeviceDefParse(xmlStr, def, caps, xmlconf, flags); cleanup: VIR_FREE(xmlStr); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 2b7a69a..a2a17bd 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2027,10 +2027,10 @@ void virDomainHubDefFree(virDomainHubDefPtr def); void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def); -virDomainDeviceDefPtr virDomainDeviceDefCopy(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, +virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, - virDomainDeviceDefPtr src); + virCapsPtr caps, + virDomainXMLConfPtr xmlconf); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, @@ -2058,8 +2058,8 @@ enum { VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1), }; virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, - virDomainXMLConfPtr xmlconf, const virDomainDefPtr def, + virDomainXMLConfPtr xmlconf, unsigned int flags, virDomainDefPtr *oldDef); void virDomainObjAssignDef(virDomainObjPtr domain, @@ -2082,34 +2082,36 @@ virDomainLiveConfigHelperMethod(virCapsPtr caps, unsigned int *flags, virDomainDefPtr *persistentDef); -virDomainDefPtr virDomainDefCopy(virCapsPtr caps, virDomainXMLConfPtr xmlconf, - virDomainDefPtr src, bool migratable); -virDomainDefPtr -virDomainObjCopyPersistentDef(virCapsPtr caps, virDomainXMLConfPtr xmlconf, - virDomainObjPtr dom); +virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, + bool migratable); +virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf); void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); -virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, +virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, - const char *xmlStr, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int flags); -virDomainDefPtr virDomainDefParseString(virCapsPtr caps, +virDomainDefPtr virDomainDefParseString(const char *xmlStr, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - const char *xmlStr, unsigned int expectedVirtTypes, unsigned int flags); -virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, +virDomainDefPtr virDomainDefParseFile(const char *filename, + virCapsPtr caps, virDomainXMLConfPtr xmlconf, - const char *filename, unsigned int expectedVirtTypes, unsigned int flags); -virDomainDefPtr virDomainDefParseNode(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, - xmlDocPtr doc, +virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc, xmlNodePtr root, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, unsigned int flags); @@ -2233,11 +2235,11 @@ typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom, void *opaque); int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, - virCapsPtr caps, - virDomainXMLConfPtr xmlconf, const char *configDir, const char *autostartDir, int liveStatus, + virCapsPtr caps, + virDomainXMLConfPtr xmlconf, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 1154202..d8d8ae7 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, xmlconf, xml, domainNode, + def->dom = virDomainDefParseNode(xml, domainNode, caps, xmlconf, expectedVirtTypes, (VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE)); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 2bff60e..7a12ae3 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->xmlconf, - domainXml, 1 << VIR_DOMAIN_VIRT_VMWARE, 0); + def = virDomainDefParseString(domainXml, priv->caps, priv->xmlconf, + 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + def = virDomainDefParseString(xml, priv->caps, priv->xmlconf, + 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 fd69637..90e48dc 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 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->xmlconf, libxl_driver->stateDir, libxl_driver->autostartDir, - 1, 1 << VIR_DOMAIN_VIRT_XEN, + 1, + libxl_driver->caps, + libxl_driver->xmlconf, + 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->xmlconf, libxl_driver->configDir, libxl_driver->autostartDir, - 0, 1 << VIR_DOMAIN_VIRT_XEN, + 0, + libxl_driver->caps, + libxl_driver->xmlconf, + 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->xmlconf, libxl_driver->configDir, libxl_driver->autostartDir, - 1, 1 << VIR_DOMAIN_VIRT_XEN, + 1, + libxl_driver->caps, + libxl_driver->xmlconf, + 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlconf, - 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->xmlconf, - 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->xmlconf, domainXml, + if (!(def = virDomainDefParseString(domainXml, + driver->caps, driver->xmlconf, 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->xmlconf, xml, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlconf, - 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->xmlconf, - vm->def, xml, + if (!(dev = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlconf, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; /* Make a copy for updated domain. */ - if (!(vmdef = virDomainObjCopyPersistentDef(driver->caps, - driver->xmlconf, vm))) + if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, + driver->xmlconf))) 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->xmlconf, - vm->def, xml, + if (!(dev = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlconf, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 1d1443c..cde85b4 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, xmlconf, - configFile, + if ((ctrl->def = virDomainDefParseFile(configFile, + caps, xmlconf, 1 << VIR_DOMAIN_VIRT_LXC, 0)) == NULL) goto error; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index dc71c16..9f17baa 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(xml, driver->caps, driver->xmlconf, 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->xmlconf, - 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->xmlconf, xml, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, 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->xmlconf, - 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->xmlconf, - 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->xmlconf, - 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->xmlconf, - 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->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlconf); if (!vmdef) goto cleanup; } @@ -4360,8 +4357,8 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; } - dev = dev_copy = virDomainDeviceDefParse(driver->caps, driver->xmlconf, - vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, + driver->caps, driver->xmlconf, 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->xmlconf, - vm->def, dev); + dev_copy = virDomainDeviceDefCopy(dev, vm->def, + driver->caps, driver->xmlconf); 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->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlconf); if (!vmdef) goto cleanup; switch (action) { diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index e3e64e5..9ec1d24 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->xmlconf, def, + driver->xmlconf, flags, NULL))) goto cleanup; diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index a6f4c66..0cf9156 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 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->xmlconf, - 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_OPENVZ, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 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->xmlconf, vmdef, + driver->xmlconf, 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->xmlconf, - vmdef, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, vmdef, driver->caps, driver->xmlconf, + VIR_DOMAIN_XML_INACTIVE); if (!dev) goto cleanup; diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index ffb86dc..d8c1def 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->xmlconf, - 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_PARALLELS, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + 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->xmlconf, - 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 6063256..59c3bc2 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_PHYP, + if (!(def = virDomainDefParseString(xml, phyp_driver->caps, + phyp_driver->xmlconf, + 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 f99b3c6..c1275b3 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->xmlconf, - 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->xmlconf, - 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->xmlconf, cfg->configDir, - cfg->autostartDir, - 0, QEMU_EXPECTED_VIRT_TYPES, + cfg->autostartDir, 0, + caps, qemu_driver->xmlconf, + 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->xmlconf, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, 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->xmlconf, - 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->xmlconf, xmlin, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlconf, 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->xmlconf, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, 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(xmlin, caps, driver->xmlconf, 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->xmlconf, - 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->xmlconf, xmlData, + def = virDomainDefParseString(xmlData, caps, driver->xmlconf, 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->xmlconf, xml, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, 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->xmlconf, - 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->xmlconf, - vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, + caps, driver->xmlconf))) { 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->xmlconf, - vm->def, dev))) { + if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, + caps, driver->xmlconf))) { dev->data.disk = tmp; goto end; } @@ -6467,8 +6462,8 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; } - dev = dev_copy = virDomainDeviceDefParse(caps, driver->xmlconf, - vm->def, xml, + dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlconf, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6479,7 +6474,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->xmlconf, vm->def, dev); + dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps, driver->xmlconf); if (!dev_copy) goto endjob; } @@ -6494,7 +6489,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlconf); if (!vmdef) goto endjob; switch (action) { @@ -7941,7 +7936,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom, if (flags & VIR_DOMAIN_AFFECT_CONFIG) { /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(caps, driver->xmlconf, vm); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlconf); if (!vmdef) goto cleanup; } @@ -11760,7 +11755,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(xml, caps, driver->xmlconf, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -12331,7 +12326,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(snap->def->dom, caps, driver->xmlconf, true); if (!config) goto cleanup; } @@ -12824,9 +12819,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->xmlconf, - 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 15f3cef..b0df4f4 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -919,8 +919,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, n); goto error; } - mig->persistent = virDomainDefParseNode(caps, driver->xmlconf, - doc, nodes[0], + mig->persistent = virDomainDefParseNode(doc, nodes[0], + caps, driver->xmlconf, -1, VIR_DOMAIN_XML_INACTIVE); if (!mig->persistent) { /* virDomainDefParseNode already reported @@ -1924,7 +1924,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver, } if (xmlin) { - if (!(def = virDomainDefParseString(caps, driver->xmlconf, xmlin, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlconf, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2026,7 +2026,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(caps, driver->xmlconf, dom_xml, + if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlconf, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2067,7 +2067,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, virDomainDefPtr newdef; VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef = virDomainDefParseString(caps, driver->xmlconf, xmlout, + newdef = virDomainDefParseString(xmlout, caps, driver->xmlconf, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE); if (!newdef) @@ -2084,9 +2084,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, } } - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlconf, - 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 2f2bc71..bdae3cc 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->xmlconf, - xmlStr, -1, - VIR_DOMAIN_XML_INACTIVE); + ctl->def = virDomainDefParseString(xmlStr, + ctl->caps, ctl->xmlconf, + -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 76e04c3..47973e5 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -588,9 +588,9 @@ static int testOpenDefault(virConnectPtr conn) { privconn->nextDomID = 1; - if (!(domdef = virDomainDefParseString(privconn->caps, + if (!(domdef = virDomainDefParseString(defaultDomainXML, + privconn->caps, privconn->xmlconf, - defaultDomainXML, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -598,8 +598,9 @@ static int testOpenDefault(virConnectPtr conn) { if (testDomainGenerateIfnames(domdef) < 0) goto error; if (!(domobj = virDomainObjListAdd(privconn->domains, + domdef, privconn->xmlconf, - domdef, 0, NULL))) + 0, NULL))) goto error; domdef = NULL; @@ -931,16 +932,16 @@ static int testOpenFromFile(virConnectPtr conn, _("resolving domain filename")); goto error; } - def = virDomainDefParseFile(privconn->caps, - privconn->xmlconf, absFile, + def = virDomainDefParseFile(absFile, privconn->caps, + privconn->xmlconf, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); VIR_FREE(absFile); if (!def) goto error; } else { - if ((def = virDomainDefParseNode(privconn->caps, privconn->xmlconf, - xml, domains[i], + if ((def = virDomainDefParseNode(xml, domains[i], + privconn->caps, privconn->xmlconf, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto error; @@ -948,8 +949,9 @@ static int testOpenFromFile(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0 || !(dom = virDomainObjListAdd(privconn->domains, + def, privconn->xmlconf, - def, 0, NULL))) { + 0, NULL))) { virDomainDefFree(def); goto error; } @@ -1342,16 +1344,16 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + if ((def = virDomainDefParseString(xml,privconn->caps, privconn->xmlconf, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, def, + privconn->xmlconf, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1957,8 +1959,8 @@ testDomainRestoreFlags(virConnectPtr conn, } xml[len] = '\0'; - def = virDomainDefParseString(privconn->caps, privconn->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); if (!def) goto cleanup; @@ -1966,8 +1968,8 @@ testDomainRestoreFlags(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, def, + privconn->xmlconf, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -2508,16 +2510,16 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, virDomainDefPtr oldDef = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(privconn->caps, privconn->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_TEST, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; if (testDomainGenerateIfnames(def) < 0) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, - privconn->xmlconf, def, + privconn->xmlconf, 0, &oldDef))) goto cleanup; diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index ba88b2d..6790bd7 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->xmlconf, - 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->xmlconf, - 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_UML, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlconf, - 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_UML, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - if (!(vm = virDomainObjListAdd(driver->domains, + if (!(vm = virDomainObjListAdd(driver->domains, def, driver->xmlconf, - 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->xmlconf, vm->def, xml, + dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlconf, 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->xmlconf, vm->def, xml, + dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlconf, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index dd96e7b..e2dd81c 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_VBOX, + if (!(def = virDomainDefParseString(xml, data->caps, data->xmlconf, + 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->xmlconf, - def, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlconf, + 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->xmlconf, - def, xml, VIR_DOMAIN_XML_INACTIVE); + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlconf, + VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 19be62a..fe28034 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->xmlconf, - 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 bf4c1ff..9512275 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 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->xmlconf, vmdef, + driver->xmlconf, 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->xmlconf, - xml, 1 << VIR_DOMAIN_VIRT_VMWARE, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + 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->xmlconf, vmdef, + driver->xmlconf, 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 2ef3609..cc053dc 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->xmlconf, - xmlData, 1 << VIR_DOMAIN_VIRT_XEN, 0))) + if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlconf, + 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 93ba456..03d08fc 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->xmlconf, - xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlconf, + 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->xmlconf, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2679,8 +2679,8 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlconf, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2786,8 +2786,8 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(priv->caps, priv->xmlconf, - def, xml, VIR_DOMAIN_XML_INACTIVE))) + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + 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->xmlconf, - xmlDesc, 1 << VIR_DOMAIN_VIRT_XEN, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlconf, + 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 2a42e0a..618d4f1 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(xml, priv->caps, priv->xmlconf, 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->xmlconf, - 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->xmlconf, - 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 941f3bd..ca8ea41 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->xmlconf, - xmlDesc, + virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc, + priv->caps, priv->xmlconf, 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->xmlconf, - xml, + virDomainDefPtr defPtr = virDomainDefParseString(xml, + priv->caps, priv->xmlconf, 1 << VIR_DOMAIN_VIRT_XEN, 0); if (!defPtr) diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c index 964d433..b7c010f 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, xmlconf, inXmlData, + if (!(def = virDomainDefParseString(inXmlData, caps, xmlconf, 1 << VIR_DOMAIN_VIRT_LXC, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 38787ac..db1b794 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(xml, driver.caps, driver.xmlconf, 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 ba9aa96..eb62409 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(inXmlData, driver.caps, driver.xmlconf, QEMU_EXPECTED_VIRT_TYPES, live ? 0 : VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 76a715d..7a5ac2c 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(xml, driver.caps, driver.xmlconf, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 405bc2b..e296e95 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -166,7 +166,7 @@ testSELinuxLoadDef(const char *testname) goto cleanup; } - if (!(def = virDomainDefParseString(caps, xmlconf, xmlstr, + if (!(def = virDomainDefParseString(xmlstr, caps, xmlconf, QEMU_EXPECTED_VIRT_TYPES, 0))) goto cleanup; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index a32c11a..e8dc22f 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, xmlconf, xmlData, + if (!(def = virDomainDefParseString(xmlData, caps, xmlconf, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index 364601a..efa149e 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, xmlconf, xmlData, + if (!(def = virDomainDefParseString(xmlData, caps, xmlconf, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index c606036..f592823 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, xmlconf, xmlData, + def = virDomainDefParseString(xmlData, caps, xmlconf, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); -- 1.8.1.5

On 03/31/2013 04:48 PM, Peter Krempa wrote:
Move the xmlconf and caps arguments to the end of the argument list. ---
Did you try moving this and 11/11 to the front of the patches? If it doesn't create too large of a rebase headache, that would make review much simpler. (If it causes too many problems, then I guess I'll just deal with it).

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. --- Notes: Version 5: - no change, although Laine suggested that this patch should also write the new config to the disk if this changes the default value. This can be added later. Version 4: - tweaked naming after previous changes 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 d67debd..128baf8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -554,7 +554,7 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void) { - return virDomainXMLConfNew(NULL, + return virDomainXMLConfNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c79b05d..20c370a 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

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. --- Notes: Version 5: - removed spurious newline addition - ACKed in v3, v4 Version 4: - tweaked naming do comply with other changes - v3 ACKed Version 3: - new in series 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 a70896a..43ace12 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 c34093b..1c41d4c 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; } @@ -10298,18 +10317,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 9ec1d24..d04833c 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 0cf9156..52b356f 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(driver->xmlconf = virDomainXMLConfNew(&openvzDomainDefParserConfig, + NULL, NULL))) goto cleanup; if (openvzLoadDomains(driver) < 0) -- 1.8.1.5

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. --- Notes: Version 5: - already ACKed in v3, confirmed in v4 Version 4: - tweaked naming to comply - v3 was already ACKed Version 3: - new in series 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 43ace12..5fd1bb5 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -164,7 +164,6 @@ struct _virCaps { /* Move to virDomainXMLConf 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 1c41d4c..5d3b0c7 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 128baf8..aab3375 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -552,8 +552,9 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) } virDomainXMLConfPtr -virQEMUDriverCreateXMLConf(void) +virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) { + virQEMUDriverDomainDefParserConfig.priv = driver; return virDomainXMLConfNew(&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 c5ddaad..4b917a7 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); -virDomainXMLConfPtr virQEMUDriverCreateXMLConf(void); +virDomainXMLConfPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver); + #endif /* __QEMUD_CONF_H */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 20c370a..b1b50c9 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 c1275b3..f187c97 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->xmlconf = virQEMUDriverCreateXMLConf())) + if (!(qemu_driver->xmlconf = 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 7d95310..e6bd3a6 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.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlconf = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST(name, uuid, internal) \ diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c index 6fd1de6..810bddd 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.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlconf = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST_FULL(name, extraFlags, migrateFrom) \ diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 639eeb1..d6f1d64 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -451,7 +451,7 @@ mymain(void) #endif if (virThreadInitialize() < 0 || - !(xmlconf = virQEMUDriverCreateXMLConf())) + !(xmlconf = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; virEventRegisterDefaultImpl(); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index db1b794..02d0213 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.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlconf = 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 eb62409..8c7f6af 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.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlconf = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; # define DO_TEST_FULL(name, is_different, when) \ diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 7a5ac2c..15628dd 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.xmlconf = virQEMUDriverCreateXMLConf())) + if (!(driver.xmlconf = 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 e296e95..c132927 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -328,7 +328,7 @@ mymain(void) if ((caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(xmlconf = virQEMUDriverCreateXMLConf())) + if (!(xmlconf = virQEMUDriverCreateXMLConf(NULL))) return EXIT_FAILURE; #define DO_TEST_LABELING(name) \ -- 1.8.1.5

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. --- Notes: Version 5: - removed spurious newline addition - ACKed by Eric in v4 Version 4: - rename virDomainDefDefaultEmulator to virDomainDefGetDefaultEmulator - changed names of functions to comply with the rest Version 3: - new in the series 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 5fd1bb5..dcf38a8 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -163,7 +163,6 @@ struct _virCaps { /* Move to virDomainXMLConf 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 5d3b0c7..22b4f85 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; @@ -10350,11 +10352,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 a2a17bd..724770e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2477,4 +2477,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 96eea0a..38d082e 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 dbc0b42..71b8916 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: virDomainXMLConfPtr lxcDomainXMLConfInit(void) { - return virDomainXMLConfNew(NULL, + return virDomainXMLConfNew(&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 861d3c4..4db85a1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -906,9 +906,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 b1b50c9..50a4c8c 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

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. --- Notes: Version 5: - squashed in follow up fixes that were posted in the list - ACKed by Eric in v4 Version 4: - new in series 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 dcf38a8..22a7a3d 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -163,7 +163,6 @@ struct _virCaps { /* Move to virDomainXMLConf 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 22b4f85..6f3e0ab 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 aab3375..c1ab3c9 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 50a4c8c..31916ca 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

Use the virDomainXMLConf structure to hold this data. --- Notes: Version 5: - ACKed by Eric in v4 Version 4: - new in series 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 | 7 +++---- 12 files changed, 71 insertions(+), 46 deletions(-) diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 22a7a3d..f4cf8f3 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -164,7 +164,6 @@ struct _virCaps { /* Move to virDomainXMLConf 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 6f3e0ab..6b44c15 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(virDomainXMLConfPtr xmlconf, + 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 (xmlconf->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(virDomainXMLConfPtr xmlconf, 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(xmlconf, 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(xmlconf, node, ctxt, NULL, def->seclabels, def->nseclabels, flags))) @@ -10356,7 +10357,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps, + virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlconf, nodes[i], ctxt, bootMap, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 724770e..9a5203a 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; @@ -2152,7 +2157,8 @@ int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk); void virDomainDiskInsertPreAlloced(virDomainDefPtr def, virDomainDiskDefPtr disk); -int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def); +int virDomainDiskDefAssignAddress(virDomainXMLConfPtr xmlconf, + virDomainDiskDefPtr def); virDomainDiskDefPtr virDomainDiskRemove(virDomainDefPtr def, size_t i); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 7a12ae3..f29643d 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(priv->xmlconf = 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->xmlconf, 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->xmlconf, 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->xmlconf, 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->xmlconf, 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 a0c278f..e9d5680 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7959,7 +7959,7 @@ error: * Will fail if not using the 'index' keyword */ static virDomainDiskDefPtr -qemuParseCommandLineDisk(virCapsPtr qemuCaps, +qemuParseCommandLineDisk(virDomainXMLConfPtr xmlconf, const char *val, int nvirtiodisk, bool old_style_ceph_args) @@ -8259,7 +8259,7 @@ qemuParseCommandLineDisk(virCapsPtr qemuCaps, else def->dst[2] = 'a' + idx; - if (virDomainDiskDefAssignAddress(qemuCaps, def) < 0) { + if (virDomainDiskDefAssignAddress(xmlconf, def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid device name '%s'"), def->dst); virDomainDiskDefFree(def); @@ -9333,7 +9333,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, !disk->dst) goto no_memory; - if (virDomainDiskDefAssignAddress(qemuCaps, disk) < 0) { + if (virDomainDiskDefAssignAddress(xmlconf, disk) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot assign address for device name '%s'"), disk->dst); @@ -9559,7 +9559,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, } } else if (STREQ(arg, "-drive")) { WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(qemuCaps, val, nvirtiodisk, + if (!(disk = qemuParseCommandLineDisk(xmlconf, 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 fe28034..03b1697 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->xmlconf, vmx)) == NULL) { goto cleanup; } diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 9512275..d27acc3 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->xmlconf, 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->xmlconf, 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->xmlconf, 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..cb3d714 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, +}; + + +virDomainXMLConfPtr +virVMXDomainXMLConfInit(void) +{ + return virDomainXMLConfNew(&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(virDomainXMLConfPtr xmlconf, 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(xmlconf, &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, + virDomainXMLConfPtr xmlconf, + 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, xmlconf, 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, xmlconf, 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, xmlconf, 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, xmlconf, 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, xmlconf, 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, virDomainXMLConfPtr xmlconf, 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(xmlconf, *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, virDomainXMLConfPtr xmlconf, 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(xmlconf, 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..b9d623d 100644 --- a/src/vmx/vmx.h +++ b/src/vmx/vmx.h @@ -29,6 +29,7 @@ typedef struct _virVMXContext virVMXContext; +virDomainXMLConfPtr 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, + virDomainXMLConfPtr xmlconf, 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, virDomainXMLConfPtr xmlconf, + 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, virDomainXMLConfPtr xmlconf, virDomainDefPtr def, int virtualHW_version); int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index cee4c39..808f12a 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -12,6 +12,7 @@ # include "vmx/vmx.h" static virCapsPtr caps; +static virDomainXMLConfPtr xmlconf; 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, xmlconf, vmxData); if (def == NULL) { err = virGetLastError(); @@ -221,6 +220,9 @@ mymain(void) return EXIT_FAILURE; } + if (!(xmlconf = 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(xmlconf); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index f592823..6b51a6a 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 = @@ -73,7 +72,6 @@ testCapsInit(void) failure: virObjectUnref(caps); - virObjectUnref(xmlconf); caps = NULL; } @@ -102,7 +100,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - formatted = virVMXFormatConfig(&ctx, caps, def, virtualHW_version); + formatted = virVMXFormatConfig(&ctx, xmlconf, def, virtualHW_version); if (formatted == NULL) { goto failure; @@ -240,7 +238,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(xmlconf = virVMXDomainXMLConfInit())) return EXIT_FAILURE; ctx.opaque = NULL; @@ -312,6 +310,7 @@ mymain(void) DO_TEST("svga", "svga", 4); virObjectUnref(caps); + virObjectUnref(xmlconf); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.8.1.5

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. --- Notes: Version 5: - fixed the default mac address prefix (qemu address prefix) to 0x52, 0x54, 0x00 - not changed any esx/vmx stuff: see http://www.redhat.com/archives/libvir-list/2013-March/msg01691.html for explanation. - I will try to fix the testsuite to verify that the qemu prefix can't be accidentaly changed in the future as almost happened in v4 Version 4: - new in series 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 f4cf8f3..6b65e6a 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -162,7 +162,6 @@ struct _virCaps { virCapsGuestPtr *guests; /* Move to virDomainXMLConf 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 6b44c15..1c51a6e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -791,6 +791,18 @@ virDomainXMLConfNew(virDomainDefParserConfigPtr config, if (xmlns) xmlconf->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 (xmlconf->config.macPrefix[0] == 0 && + xmlconf->config.macPrefix[1] == 0 && + xmlconf->config.macPrefix[2] == 0) { + xmlconf->config.macPrefix[0] = 0x52; + xmlconf->config.macPrefix[1] = 0x54; + } + return xmlconf; } @@ -5039,6 +5051,14 @@ cleanup: } +void +virDomainNetGenerateMAC(virDomainXMLConfPtr xmlconf, + virMacAddrPtr mac) +{ + virMacAddrGenerate(xmlconf->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(virDomainXMLConfPtr xmlconf, xmlNodePtr node, xmlXPathContextPtr ctxt, virBitmapPtr bootMap, @@ -5592,7 +5612,7 @@ virDomainNetDefParseXML(virCapsPtr caps, goto error; } } else { - virCapabilitiesGenerateMac(caps, &def->mac); + virDomainNetGenerateMAC(xmlconf, &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(xmlconf, node, ctxt, NULL, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "input")) { @@ -10457,7 +10477,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(xmlconf, nodes[i], ctxt, bootMap, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9a5203a..04f2af9 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; @@ -1975,6 +1976,8 @@ virDomainXMLConfPtr virDomainXMLConfNew(virDomainDefParserConfigPtr config, virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns); +void virDomainNetGenerateMAC(virDomainXMLConfPtr xmlconf, virMacAddrPtr mac); + virDomainXMLNamespacePtr virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) ATTRIBUTE_NONNULL(1); diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f29643d..cce2c34 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 38d082e..ed5017d 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 90e48dc..384f787 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->xmlconf = virDomainXMLConfNew(NULL, + if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, NULL))) goto error; diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c index 71b8916..d835139 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 d04833c..992b702 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 52b356f..2d3b75b 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->xmlconf, &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 d8c1def..05ef911 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(privconn->xmlconf = virDomainXMLConfNew(¶llelsDomainDefParserConfig, + NULL, NULL))) goto error; if (!(privconn->domains = virDomainObjListNew())) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 59c3bc2..5a7ab56 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 4db85a1..b10cdb0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -873,9 +873,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 e9d5680..d2f7d84 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8325,7 +8325,7 @@ qemuFindNICForVLAN(int nnics, * match up against. Horribly complicated stuff */ static virDomainNetDefPtr -qemuParseCommandLineNet(virCapsPtr qemuCaps, +qemuParseCommandLineNet(virDomainXMLConfPtr xmlconf, const char *val, int nnics, const char **nics) @@ -8459,7 +8459,7 @@ qemuParseCommandLineNet(virCapsPtr qemuCaps, } if (genmac) - virCapabilitiesGenerateMac(qemuCaps, &def->mac); + virDomainNetGenerateMAC(xmlconf, &def->mac); cleanup: for (i = 0 ; i < nkeywords ; i++) { @@ -9549,7 +9549,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(xmlconf, 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 e2dd81c..1e6bfe6 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 virDomainXMLConfPtr vboxXMLConfInit(void) { - return virDomainXMLConfNew(NULL, NULL, NULL); + return virDomainXMLConfNew(&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 03b1697..9f19136 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 cb3d714..d69fc0e 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 cc053dc..d8fbe8e 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(priv->xmlconf = virDomainXMLConfNew(&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 808f12a..26613fd 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 6b51a6a..a962add 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

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. --- Notes: Version 5: - fixed typo in comment - version 4 ACKed by Eric Version 4: - new in series 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 6b65e6a..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 virDomainXMLConf later */ - int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch); }; diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1c51a6e..2d555e1 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) { @@ -10522,9 +10604,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, @@ -10552,9 +10632,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, @@ -10584,10 +10662,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, @@ -10595,64 +10670,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); @@ -10664,9 +10682,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, @@ -15165,7 +15181,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; @@ -15188,7 +15203,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; @@ -15205,6 +15221,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 04f2af9..c931e3b 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 cce2c34..46efab8 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 384f787..f5d4c73 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 d835139..63a77a7 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 992b702..f1ec170 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 2d3b75b..a825691 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 05ef911..4dc9669 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 5a7ab56..ca2400a 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 b10cdb0..3e2e703 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -853,17 +853,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; @@ -903,8 +892,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 31916ca..6d47606 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 bdae3cc..7c284be 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 47973e5..01dd871 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -150,13 +150,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 virDomainXMLConfPtr testBuildXMLConfig(void) { @@ -177,8 +170,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 b3ac326..598eb76 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 6790bd7..cda7110 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->xmlconf = virDomainXMLConfNew(NULL, &privcb, NULL))) + if (!(uml_driver->xmlconf = virDomainXMLConfNew(¨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 1e6bfe6..79ee2c0 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 9f19136..999b7c3 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 d8fbe8e..4f8b711 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->xmlconf = virDomainXMLConfNew(&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 8e43db3..568de07 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 ca8ea41..35d00a2 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->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) { + if (!(privP->xmlconf = virDomainXMLConfNew(&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 479eec3..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; -} - -virDomainXMLConfPtr -testXenXMLConfInit(void) -{ - return virDomainXMLConfNew(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 d4576cb..7f27e22 100644 --- a/tests/testutilsxen.h +++ b/tests/testutilsxen.h @@ -1,6 +1,4 @@ #include "capabilities.h" -#include "domain_conf.h" virCapsPtr testXenCapsInit(void); -virDomainXMLConfPtr testXenXMLConfInit(void); diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 26613fd..07e7544 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virDomainXMLConfPtr xmlconf; 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 e8dc22f..e19336f 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -196,7 +196,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlconf = testXenXMLConfInit())) + if (!(xmlconf = xenDomainXMLConfInit())) return EXIT_FAILURE; #define DO_TEST(name, version) \ diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index efa149e..27a0905 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 (!(xmlconf = testXenXMLConfInit())) + if (!(xmlconf = xenDomainXMLConfInit())) return EXIT_FAILURE; DO_TEST("pv", "pv", "pvtest", 1); diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index a962add..8cc9257 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -15,11 +15,6 @@ static virCapsPtr caps; static virVMXContext ctx; static virDomainXMLConfPtr xmlconf; -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 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 --- Notes: Version 5: - new in series - suggested by Eric, I decided to do it after the series to avoid touching the other patches. Justification is that it anyways changes code that is already pushed. src/conf/domain_conf.c | 218 ++++++++++++++++++------------------- src/conf/domain_conf.h | 40 +++---- src/conf/snapshot_conf.c | 4 +- src/conf/snapshot_conf.h | 2 +- src/esx/esx_driver.c | 18 +-- src/esx/esx_private.h | 2 +- src/libvirt_private.syms | 4 +- src/libxl/libxl_conf.h | 2 +- src/libxl/libxl_driver.c | 44 ++++---- src/lxc/lxc_conf.c | 4 +- src/lxc/lxc_conf.h | 4 +- src/lxc/lxc_controller.c | 8 +- src/lxc/lxc_driver.c | 42 +++---- src/lxc/lxc_process.c | 8 +- src/openvz/openvz_conf.c | 4 +- src/openvz/openvz_conf.h | 2 +- src/openvz/openvz_driver.c | 16 +-- 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 | 26 ++--- 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 | 112 +++++++++---------- 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 | 24 ++-- src/vbox/vbox_tmpl.c | 18 +-- src/vmware/vmware_conf.c | 6 +- src/vmware/vmware_conf.h | 2 +- src/vmware/vmware_driver.c | 20 ++-- src/vmx/vmx.c | 28 ++--- src/vmx/vmx.h | 8 +- src/xen/xen_driver.c | 10 +- src/xen/xen_driver.h | 4 +- src/xen/xend_internal.c | 10 +- src/xen/xm_internal.c | 6 +- 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/vmx2xmltest.c | 8 +- tests/xmconfigtest.c | 8 +- tests/xml2sexprtest.c | 8 +- tests/xml2vmxtest.c | 10 +- 60 files changed, 480 insertions(+), 480 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2d555e1..3dd43f3 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; /* XML parser callbacks and defaults */ @@ -724,10 +724,10 @@ 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); -static void virDomainXMLConfClassDispose(void *obj); +static void virDomainXMLOptionClassDispose(void *obj); static int virDomainObjOnceInit(void) { @@ -743,10 +743,10 @@ static int virDomainObjOnceInit(void) virDomainObjListDispose))) return -1; - if (!(virDomainXMLConfClass = virClassNew(virClassForObject(), - "virDomainXMLConf", - sizeof(virDomainXMLConf), - virDomainXMLConfClassDispose))) + if (!(virDomainXMLOptionClass = virClassNew(virClassForObject(), + "virDomainXMLOption", + sizeof(virDomainXMLOption), + virDomainXMLOptionClassDispose))) return -1; return 0; @@ -756,69 +756,69 @@ VIR_ONCE_GLOBAL_INIT(virDomainObj) static void -virDomainXMLConfClassDispose(void *obj) +virDomainXMLOptionClassDispose(void *obj) { - virDomainXMLConfPtr xmlconf = obj; + virDomainXMLOptionPtr xmlopt = obj; - if (xmlconf->config.privFree) - (xmlconf->config.privFree)(xmlconf->config.priv); + if (xmlopt->config.privFree) + (xmlopt->config.privFree)(xmlopt->config.priv); } /** - * virDomainXMLConfNew: + * virDomainXMLOptionNew: * * Allocate a new domain XML configuration */ -virDomainXMLConfPtr -virDomainXMLConfNew(virDomainDefParserConfigPtr config, +virDomainXMLOptionPtr +virDomainXMLOptionNew(virDomainDefParserConfigPtr config, 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 (config) - xmlconf->config = *config; + xmlopt->config = *config; if (xmlns) - xmlconf->ns = *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 (xmlconf->config.macPrefix[0] == 0 && - xmlconf->config.macPrefix[1] == 0 && - xmlconf->config.macPrefix[2] == 0) { - xmlconf->config.macPrefix[0] = 0x52; - xmlconf->config.macPrefix[1] = 0x54; + 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 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; } @@ -1932,7 +1932,7 @@ static void virDomainObjDispose(void *obj) } virDomainObjPtr -virDomainObjNew(virDomainXMLConfPtr xmlconf) +virDomainObjNew(virDomainXMLOptionPtr xmlopt) { virDomainObjPtr domain; @@ -1942,12 +1942,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())) @@ -2014,7 +2014,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, static virDomainObjPtr virDomainObjListAddLocked(virDomainObjListPtr doms, const virDomainDefPtr def, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef) { @@ -2063,7 +2063,7 @@ virDomainObjListAddLocked(virDomainObjListPtr doms, goto error; } - if (!(vm = virDomainObjNew(xmlconf))) + if (!(vm = virDomainObjNew(xmlopt))) goto cleanup; vm->def = def; @@ -2085,14 +2085,14 @@ error: virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, const virDomainDefPtr def, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef) { virDomainObjPtr ret; virObjectLock(doms); - ret = virDomainObjListAddLocked(doms, def, xmlconf, flags, oldDef); + ret = virDomainObjListAddLocked(doms, def, xmlopt, flags, oldDef); virObjectUnlock(doms); return ret; } @@ -2111,7 +2111,7 @@ virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, */ int virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr domain, bool live) { @@ -2126,7 +2126,7 @@ virDomainObjSetDefTransient(virCapsPtr caps, if (domain->newDef) return 0; - if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlconf, false))) + if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt, false))) goto out; ret = 0; @@ -2144,10 +2144,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) @@ -2165,7 +2165,7 @@ virDomainObjGetPersistentDef(virCapsPtr caps, */ int virDomainLiveConfigHelperMethod(virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, virDomainObjPtr dom, unsigned int *flags, virDomainDefPtr *persistentDef) @@ -2196,7 +2196,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; @@ -2611,13 +2611,13 @@ static int virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf) + virDomainXMLOptionPtr xmlopt) { int ret; - if (xmlconf && xmlconf->config.devicesPostParseCallback) { - ret = xmlconf->config.devicesPostParseCallback(dev, def, caps, - xmlconf->config.priv); + if (xmlopt && xmlopt->config.devicesPostParseCallback) { + ret = xmlopt->config.devicesPostParseCallback(dev, def, caps, + xmlopt->config.priv); if (ret < 0) return ret; } @@ -2632,7 +2632,7 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, struct virDomainDefPostParseDeviceIteratorData { virDomainDefPtr def; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; }; @@ -2643,26 +2643,26 @@ virDomainDefPostParseDeviceIterator(virDomainDefPtr def ATTRIBUTE_UNUSED, void *opaque) { struct virDomainDefPostParseDeviceIteratorData *data = opaque; - return virDomainDeviceDefPostParse(dev, data->def, data->caps, data->xmlconf); + return virDomainDeviceDefPostParse(dev, data->def, data->caps, data->xmlopt); } static int virDomainDefPostParse(virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf) + virDomainXMLOptionPtr xmlopt) { int ret; struct virDomainDefPostParseDeviceIteratorData data = { .def = def, .caps = caps, - .xmlconf = xmlconf, + .xmlopt = xmlopt, }; /* call the domain config callback */ - if (xmlconf && xmlconf->config.domainPostParseCallback) { - ret = xmlconf->config.domainPostParseCallback(def, caps, - xmlconf->config.priv); + if (xmlopt && xmlopt->config.domainPostParseCallback) { + ret = xmlopt->config.domainPostParseCallback(def, caps, + xmlopt->config.priv); if (ret < 0) return ret; } @@ -3710,7 +3710,7 @@ virDomainDiskFindByBusAndDst(virDomainDefPtr def, } int -virDomainDiskDefAssignAddress(virDomainXMLConfPtr xmlconf, +virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr def) { int idx = virDiskNameToIndex(def->dst); @@ -3725,7 +3725,7 @@ virDomainDiskDefAssignAddress(virDomainXMLConfPtr xmlconf, case VIR_DOMAIN_DISK_BUS_SCSI: def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; - if (xmlconf->config.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 @@ -4164,7 +4164,7 @@ cleanup: * @param node XML nodeset to parse for disk definition */ static virDomainDiskDefPtr -virDomainDiskDefParseXML(virDomainXMLConfPtr xmlconf, +virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, virBitmapPtr bootMap, @@ -4955,7 +4955,7 @@ virDomainDiskDefParseXML(virDomainXMLConfPtr xmlconf, } if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE - && virDomainDiskDefAssignAddress(xmlconf, def) < 0) + && virDomainDiskDefAssignAddress(xmlopt, def) < 0) goto error; cleanup: @@ -5157,10 +5157,10 @@ cleanup: void -virDomainNetGenerateMAC(virDomainXMLConfPtr xmlconf, +virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac) { - virMacAddrGenerate(xmlconf->config.macPrefix, mac); + virMacAddrGenerate(xmlopt->config.macPrefix, mac); } @@ -5532,7 +5532,7 @@ error: * @return 0 on success, -1 on failure */ static virDomainNetDefPtr -virDomainNetDefParseXML(virDomainXMLConfPtr xmlconf, +virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, xmlNodePtr node, xmlXPathContextPtr ctxt, virBitmapPtr bootMap, @@ -5717,7 +5717,7 @@ virDomainNetDefParseXML(virDomainXMLConfPtr xmlconf, goto error; } } else { - virDomainNetGenerateMAC(xmlconf, &def->mac); + virDomainNetGenerateMAC(xmlopt, &def->mac); } if (devaddr) { @@ -8582,7 +8582,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int flags) { xmlDocPtr xml; @@ -8602,7 +8602,7 @@ virDomainDeviceDefParse(const char *xmlStr, if (xmlStrEqual(node->name, BAD_CAST "disk")) { dev->type = VIR_DOMAIN_DEVICE_DISK; - if (!(dev->data.disk = virDomainDiskDefParseXML(xmlconf, node, ctxt, + if (!(dev->data.disk = virDomainDiskDefParseXML(xmlopt, node, ctxt, NULL, def->seclabels, def->nseclabels, flags))) @@ -8617,7 +8617,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(xmlconf, node, ctxt, + if (!(dev->data.net = virDomainNetDefParseXML(xmlopt, node, ctxt, NULL, flags))) goto error; } else if (xmlStrEqual(node->name, BAD_CAST "input")) { @@ -8668,7 +8668,7 @@ virDomainDeviceDefParse(const char *xmlStr, } /* callback to fill driver specific device aspects */ - if (virDomainDeviceDefPostParse(dev, def, caps, xmlconf) < 0) + if (virDomainDeviceDefPostParse(dev, def, caps, xmlopt) < 0) goto error; cleanup: @@ -9584,7 +9584,7 @@ virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr root, xmlXPathContextPtr ctxt, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -10459,7 +10459,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto no_memory; for (i = 0 ; i < n ; i++) { - virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlconf, + virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt, nodes[i], ctxt, bootMap, @@ -10559,7 +10559,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(xmlconf, + virDomainNetDefPtr net = virDomainNetDefParseXML(xmlopt, nodes[i], ctxt, bootMap, @@ -11102,7 +11102,7 @@ virDomainDefParseXML(xmlDocPtr xml, /* 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) @@ -11113,7 +11113,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; /* callback to fill driver specific domain aspects */ - if (virDomainDefPostParse(def, caps, xmlconf) < 0) + if (virDomainDefPostParse(def, caps, xmlopt) < 0) goto error; virBitmapFree(bootMap); @@ -11135,7 +11135,7 @@ static virDomainObjPtr virDomainObjParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11149,7 +11149,7 @@ virDomainObjParseXML(xmlDocPtr xml, int state; int reason = 0; - if (!(obj = virDomainObjNew(xmlconf))) + if (!(obj = virDomainObjNew(xmlopt))) return NULL; if (!(config = virXPathNode("./domain", ctxt))) { @@ -11160,7 +11160,7 @@ virDomainObjParseXML(xmlDocPtr xml, oldnode = ctxt->node; ctxt->node = config; - obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlconf, + obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, expectedVirtTypes, flags); ctxt->node = oldnode; if (!obj->def) @@ -11217,8 +11217,8 @@ virDomainObjParseXML(xmlDocPtr xml, } 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; @@ -11234,7 +11234,7 @@ static virDomainDefPtr virDomainDefParse(const char *xmlStr, const char *filename, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11244,7 +11244,7 @@ virDomainDefParse(const char *xmlStr, if ((xml = virXMLParse(filename, xmlStr, _("(domain_definition)")))) { def = virDomainDefParseNode(xml, xmlDocGetRootElement(xml), caps, - xmlconf, expectedVirtTypes, flags); + xmlopt, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -11255,22 +11255,22 @@ virDomainDefParse(const char *xmlStr, virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, xmlconf, + return virDomainDefParse(xmlStr, NULL, caps, xmlopt, expectedVirtTypes, flags); } virDomainDefPtr virDomainDefParseFile(const char *filename, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(NULL, filename, caps, xmlconf, + return virDomainDefParse(NULL, filename, caps, xmlopt, expectedVirtTypes, flags); } @@ -11279,7 +11279,7 @@ virDomainDefPtr virDomainDefParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11301,7 +11301,7 @@ virDomainDefParseNode(xmlDocPtr xml, } ctxt->node = root; - def = virDomainDefParseXML(xml, root, ctxt, caps, xmlconf, + def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, expectedVirtTypes, flags); cleanup: @@ -11314,7 +11314,7 @@ static virDomainObjPtr virDomainObjParseNode(xmlDocPtr xml, xmlNodePtr root, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11335,7 +11335,7 @@ virDomainObjParseNode(xmlDocPtr xml, } ctxt->node = root; - obj = virDomainObjParseXML(xml, ctxt, caps, xmlconf, expectedVirtTypes, flags); + obj = virDomainObjParseXML(xml, ctxt, caps, xmlopt, expectedVirtTypes, flags); cleanup: xmlXPathFreeContext(ctxt); @@ -11346,7 +11346,7 @@ cleanup: static virDomainObjPtr virDomainObjParseFile(const char *filename, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags) { @@ -11356,7 +11356,7 @@ virDomainObjParseFile(const char *filename, if ((xml = virXMLParseFile(filename))) { obj = virDomainObjParseNode(xml, xmlDocGetRootElement(xml), - caps, xmlconf, + caps, xmlopt, expectedVirtTypes, flags); xmlFreeDoc(xml); } @@ -15331,7 +15331,7 @@ virDomainDefFormat(virDomainDefPtr def, unsigned int flags) static char * -virDomainObjFormat(virDomainXMLConfPtr xmlconf, +virDomainObjFormat(virDomainXMLOptionPtr xmlopt, virDomainObjPtr obj, unsigned int flags) { @@ -15352,8 +15352,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); @@ -15476,7 +15476,7 @@ cleanup: } int -virDomainSaveStatus(virDomainXMLConfPtr xmlconf, +virDomainSaveStatus(virDomainXMLOptionPtr xmlopt, const char *statusDir, virDomainObjPtr obj) { @@ -15488,7 +15488,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)) @@ -15504,7 +15504,7 @@ cleanup: static virDomainObjPtr virDomainObjListLoadConfig(virDomainObjListPtr doms, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *configDir, const char *autostartDir, const char *name, @@ -15520,7 +15520,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((configFile = virDomainConfigFile(configDir, name)) == NULL) goto error; - if (!(def = virDomainDefParseFile(configFile, caps, xmlconf, + if (!(def = virDomainDefParseFile(configFile, caps, xmlopt, expectedVirtTypes, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -15531,7 +15531,7 @@ virDomainObjListLoadConfig(virDomainObjListPtr doms, if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0) goto error; - if (!(dom = virDomainObjListAddLocked(doms, def, xmlconf, 0, &oldDef))) + if (!(dom = virDomainObjListAddLocked(doms, def, xmlopt, 0, &oldDef))) goto error; dom->autostart = autostart; @@ -15556,7 +15556,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, const char *statusDir, const char *name, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15568,7 +15568,7 @@ virDomainObjListLoadStatus(virDomainObjListPtr doms, if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) goto error; - if (!(obj = virDomainObjParseFile(statusFile, caps, xmlconf, 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))) @@ -15604,7 +15604,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, const char *autostartDir, int liveStatus, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque) @@ -15642,14 +15642,14 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, configDir, entry->d_name, caps, - xmlconf, + xmlopt, expectedVirtTypes, notify, opaque); else dom = virDomainObjListLoadConfig(doms, caps, - xmlconf, + xmlopt, configDir, autostartDir, entry->d_name, @@ -16044,7 +16044,7 @@ cleanup: virDomainDefPtr virDomainDefCopy(virDomainDefPtr src, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, bool migratable) { char *xml; @@ -16059,7 +16059,7 @@ virDomainDefCopy(virDomainDefPtr src, if (!(xml = virDomainDefFormat(src, write_flags))) return NULL; - ret = virDomainDefParseString(xml, caps, xmlconf, -1, read_flags); + ret = virDomainDefParseString(xml, caps, xmlopt, -1, read_flags); VIR_FREE(xml); return ret; @@ -16068,12 +16068,12 @@ virDomainDefCopy(virDomainDefPtr src, virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, virCapsPtr caps, - virDomainXMLConfPtr xmlconf) + virDomainXMLOptionPtr xmlopt) { virDomainDefPtr cur; - cur = virDomainObjGetPersistentDef(caps, xmlconf, dom); - return virDomainDefCopy(cur, caps, xmlconf, false); + cur = virDomainObjGetPersistentDef(caps, xmlopt, dom); + return virDomainDefCopy(cur, caps, xmlopt, false); } @@ -16516,7 +16516,7 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf) + virDomainXMLOptionPtr xmlopt) { virDomainDeviceDefPtr ret = NULL; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -16583,7 +16583,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, goto cleanup; xmlStr = virBufferContentAndReset(&buf); - ret = virDomainDeviceDefParse(xmlStr, def, caps, xmlconf, 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 c931e3b..0128633 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1931,8 +1931,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 *); @@ -1973,14 +1973,14 @@ struct _virDomainXMLPrivateDataCallbacks { }; -virDomainXMLConfPtr virDomainXMLConfNew(virDomainDefParserConfigPtr config, +virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, virDomainXMLPrivateDataCallbacksPtr priv, virDomainXMLNamespacePtr xmlns); -void virDomainNetGenerateMAC(virDomainXMLConfPtr xmlconf, virMacAddrPtr mac); +void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac); virDomainXMLNamespacePtr -virDomainXMLConfGetNamespace(virDomainXMLConfPtr xmlconf) +virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) ATTRIBUTE_NONNULL(1); static inline bool @@ -1989,7 +1989,7 @@ virDomainObjIsActive(virDomainObjPtr dom) return dom->def->id != -1; } -virDomainObjPtr virDomainObjNew(virDomainXMLConfPtr caps) +virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps) ATTRIBUTE_NONNULL(1); virDomainObjListPtr virDomainObjListNew(void); @@ -2039,7 +2039,7 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def); virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, const virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf); + virDomainXMLOptionPtr xmlopt); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, @@ -2068,7 +2068,7 @@ enum { }; virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, const virDomainDefPtr def, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int flags, virDomainDefPtr *oldDef); void virDomainObjAssignDef(virDomainObjPtr domain, @@ -2076,28 +2076,28 @@ 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(virDomainDefPtr src, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, bool migratable); virDomainDefPtr virDomainObjCopyPersistentDef(virDomainObjPtr dom, virCapsPtr caps, - virDomainXMLConfPtr xmlconf); + virDomainXMLOptionPtr xmlopt); void virDomainObjListRemove(virDomainObjListPtr doms, virDomainObjPtr dom); @@ -2105,22 +2105,22 @@ void virDomainObjListRemove(virDomainObjListPtr doms, virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDefPtr def, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int flags); virDomainDefPtr virDomainDefParseString(const char *xmlStr, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseFile(const char *filename, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags); virDomainDefPtr virDomainDefParseNode(xmlDocPtr doc, xmlNodePtr root, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, unsigned int flags); @@ -2161,7 +2161,7 @@ int virDomainDiskInsert(virDomainDefPtr def, virDomainDiskDefPtr disk); void virDomainDiskInsertPreAlloced(virDomainDefPtr def, virDomainDiskDefPtr disk); -int virDomainDiskDefAssignAddress(virDomainXMLConfPtr xmlconf, +int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr def); virDomainDiskDefPtr @@ -2236,7 +2236,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; @@ -2249,7 +2249,7 @@ int virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, const char *autostartDir, int liveStatus, virCapsPtr caps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, unsigned int expectedVirtTypes, virDomainLoadConfigNotify notify, void *opaque); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index d8d8ae7..bd5684d 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(xml, domainNode, caps, xmlconf, + def->dom = virDomainDefParseNode(xml, domainNode, caps, xmlopt, 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 46efab8..4828209 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); } @@ -1090,7 +1090,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, goto cleanup; } - if (!(priv->xmlconf = virVMXDomainXMLConfInit())) + if (!(priv->xmlopt = virVMXDomainXMLConfInit())) goto cleanup; conn->privateData = priv; @@ -2776,7 +2776,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) ctx.formatFileName = NULL; ctx.autodetectSCSIControllerModel = NULL; - def = virVMXParseConfig(&ctx, priv->xmlconf, vmx); + def = virVMXParseConfig(&ctx, priv->xmlopt, vmx); if (def != NULL) { if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { @@ -2835,7 +2835,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, ctx.formatFileName = NULL; ctx.autodetectSCSIControllerModel = NULL; - def = virVMXParseConfig(&ctx, priv->xmlconf, nativeConfig); + def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig); if (def != NULL) { xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); @@ -2877,7 +2877,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, return NULL; } - def = virDomainDefParseString(domainXml, priv->caps, priv->xmlconf, + def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, 0); if (def == NULL) { @@ -2892,7 +2892,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, ctx.formatFileName = esxFormatVMXFileName; ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel; - vmx = virVMXFormatConfig(&ctx, priv->xmlconf, def, virtualHW_version); + vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version); virDomainDefFree(def); @@ -3093,7 +3093,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) } /* Parse domain XML */ - def = virDomainDefParseString(xml, priv->caps, priv->xmlconf, + def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); @@ -3139,7 +3139,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) ctx.formatFileName = esxFormatVMXFileName; ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel; - vmx = virVMXFormatConfig(&ctx, priv->xmlconf, def, virtualHW_version); + vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version); if (vmx == NULL) { goto cleanup; @@ -4266,7 +4266,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 ed5017d..7fc15d3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -339,8 +339,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 f5d4c73..a5ed45f 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -586,7 +586,7 @@ libxlSaveImageOpen(libxlDriverPrivatePtr driver, const char *from, goto error; } - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -999,7 +999,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) @@ -1103,7 +1103,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); @@ -1262,7 +1262,7 @@ libxlStartup(bool privileged, goto error; } - if (!(libxl_driver->xmlconf = virDomainXMLConfNew(&libxlDomainDefParserConfig, + if (!(libxl_driver->xmlopt = virDomainXMLOptionNew(&libxlDomainDefParserConfig, &libxlDomainXMLPrivateDataCallbacks, NULL))) goto error; @@ -1273,7 +1273,7 @@ libxlStartup(bool privileged, libxl_driver->autostartDir, 1, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -1286,7 +1286,7 @@ libxlStartup(bool privileged, libxl_driver->autostartDir, 0, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, NULL, NULL) < 0) goto error; @@ -1325,7 +1325,7 @@ libxlReload(void) libxl_driver->autostartDir, 1, libxl_driver->caps, - libxl_driver->xmlconf, + libxl_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, NULL, libxl_driver); @@ -1481,13 +1481,13 @@ libxlDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_PAUSED, NULL); libxlDriverLock(driver); - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1631,7 +1631,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; @@ -1691,7 +1691,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; @@ -1962,7 +1962,7 @@ libxlDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem, goto cleanup; } if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, - driver->xmlconf, + driver->xmlopt, vm))) goto cleanup; } @@ -2268,7 +2268,7 @@ libxlDomainRestoreFlags(virConnectPtr conn, const char *from, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -2605,7 +2605,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); @@ -2783,7 +2783,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; @@ -2957,7 +2957,7 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, } if (!(def = virDomainDefParseString(domainXml, - driver->caps, driver->xmlconf, + driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; @@ -3059,13 +3059,13 @@ libxlDomainDefineXML(virConnectPtr conn, const char *xml) virDomainDefPtr oldDef = NULL; libxlDriverLock(driver); - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, 0, &oldDef))) goto cleanup; @@ -3582,13 +3582,13 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { if (!(dev = virDomainDeviceDefParse(xml, vm->def, - driver->caps, driver->xmlconf, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; /* Make a copy for updated domain. */ if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, - driver->xmlconf))) + driver->xmlopt))) goto cleanup; switch (action) { @@ -3613,7 +3613,7 @@ libxlDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, /* If dev exists it was created to modify the domain config. Free it. */ virDomainDeviceDefFree(dev); if (!(dev = virDomainDeviceDefParse(xml, vm->def, - driver->caps, driver->xmlconf, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -3636,7 +3636,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 63a77a7..67f9451 100644 --- a/src/lxc/lxc_conf.c +++ b/src/lxc/lxc_conf.c @@ -142,10 +142,10 @@ error: } -virDomainXMLConfPtr +virDomainXMLOptionPtr lxcDomainXMLConfInit(void) { - return virDomainXMLConfNew(&virLXCDriverDomainDefParserConfig, + return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, &virLXCDriverPrivateDataCallbacks, NULL); } 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 cde85b4..ed73fa1 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,7 +162,7 @@ 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, @@ -170,7 +170,7 @@ static virLXCControllerPtr virLXCControllerNew(const char *name) goto error; if ((ctrl->def = virDomainDefParseFile(configFile, - caps, xmlconf, + caps, xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, 0)) == NULL) goto error; @@ -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 9f17baa..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(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 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, def, - driver->xmlconf, + driver->xmlopt, 0, &oldDef))) goto cleanup; def = NULL; @@ -1067,7 +1067,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); lxcDriverLock(driver); - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1083,7 +1083,7 @@ lxcDomainCreateAndStart(virConnectPtr conn, if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1480,7 +1480,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) @@ -1491,7 +1491,7 @@ static int lxcStartup(bool privileged, lxc_driver->stateDir, NULL, 1, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1503,7 +1503,7 @@ static int lxcStartup(bool privileged, lxc_driver->configDir, lxc_driver->autostartDir, 0, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, NULL, NULL) < 0) goto cleanup; @@ -1551,7 +1551,7 @@ lxcReload(void) { lxc_driver->configDir, lxc_driver->autostartDir, 0, lxc_driver->caps, - lxc_driver->xmlconf, + lxc_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_LXC, lxcNotifyLoadDomain, lxc_driver); lxcDriverUnlock(lxc_driver); @@ -1574,7 +1574,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); @@ -1796,13 +1796,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(vm, driver->caps, driver->xmlconf); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt); if (!vmdef) goto cleanup; } @@ -1868,7 +1868,7 @@ lxcSetSchedulerParametersFlags(virDomainPtr dom, } } - if (virDomainSaveStatus(driver->xmlconf, driver->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, driver->stateDir, vm) < 0) goto cleanup; @@ -1938,7 +1938,7 @@ lxcGetSchedulerParametersFlags(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2051,7 +2051,7 @@ lxcDomainSetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2156,7 +2156,7 @@ lxcDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlconf, + if (virDomainLiveConfigHelperMethod(driver->caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -2522,7 +2522,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; @@ -2588,7 +2588,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; @@ -4358,7 +4358,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, } dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, - driver->caps, driver->xmlconf, + driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -4370,7 +4370,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * to CONFIG takes one instance. */ dev_copy = virDomainDeviceDefCopy(dev, vm->def, - driver->caps, driver->xmlconf); + driver->caps, driver->xmlopt); if (!dev_copy) goto cleanup; } @@ -4380,7 +4380,7 @@ lxcDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto cleanup; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlconf); + vmdef = virDomainObjCopyPersistentDef(vm, driver->caps, driver->xmlopt); if (!vmdef) goto cleanup; switch (action) { @@ -4428,7 +4428,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 f1ec170..4b21c4e 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -548,7 +548,7 @@ openvzFreeDriver(struct openvz_driver *driver) if (!driver) return; - virObjectUnref(driver->xmlconf); + virObjectUnref(driver->xmlopt); virObjectUnref(driver->domains); virObjectUnref(driver->caps); VIR_FREE(driver); @@ -640,7 +640,7 @@ int openvzLoadDomains(struct openvz_driver *driver) { if (!(dom = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, flags, NULL))) goto cleanup; 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 a825691..206772c 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -848,7 +848,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid, } virMacAddrFormat(&net->mac, macaddr); - virDomainNetGenerateMAC(driver->xmlconf, &host_mac); + virDomainNetGenerateMAC(driver->xmlopt, &host_mac); virMacAddrFormat(&host_mac, host_macaddr); if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE || @@ -994,7 +994,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) virDomainPtr dom = NULL; openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1007,7 +1007,7 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml) goto cleanup; } if (!(vm = virDomainObjListAdd(driver->domains, vmdef, - driver->xmlconf, + driver->xmlopt, 0, NULL))) goto cleanup; vmdef = NULL; @@ -1081,7 +1081,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); openvzDriverLock(driver); - if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_OPENVZ, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1095,7 +1095,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, } if (!(vm = virDomainObjListAdd(driver->domains, vmdef, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1492,7 +1492,7 @@ static virDrvOpenStatus openvzOpen(virConnectPtr conn, if (!(driver->caps = openvzCapsInit())) goto cleanup; - if (!(driver->xmlconf = virDomainXMLConfNew(&openvzDomainDefParserConfig, + if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig, NULL, NULL))) goto cleanup; @@ -2119,13 +2119,13 @@ openvzDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml, } if (virDomainLiveConfigHelperMethod(driver->caps, - driver->xmlconf, + driver->xmlopt, vm, &flags, &vmdef) < 0) goto cleanup; - dev = virDomainDeviceDefParse(xml, vmdef, driver->caps, driver->xmlconf, + 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 4dc9669..317e024 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -821,7 +821,7 @@ parallelsLoadDomain(parallelsConnPtr privconn, virJSONValuePtr jobj) goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, 0, NULL))) goto cleanup; /* dom is locked here */ @@ -925,7 +925,7 @@ parallelsOpenDefault(virConnectPtr conn) if (!(privconn->caps = parallelsBuildCapabilities())) goto error; - if (!(privconn->xmlconf = virDomainXMLConfNew(¶llelsDomainDefParserConfig, + if (!(privconn->xmlopt = virDomainXMLOptionNew(¶llelsDomainDefParserConfig, NULL, NULL))) goto error; @@ -987,7 +987,7 @@ parallelsClose(virConnectPtr conn) parallelsDriverLock(privconn); virObjectUnref(privconn->caps); - virObjectUnref(privconn->xmlconf); + virObjectUnref(privconn->xmlopt); virObjectUnref(privconn->domains); conn->privateData = NULL; @@ -2327,7 +2327,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) virDomainObjPtr dom = NULL, olddom = NULL; parallelsDriverLock(privconn); - if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_PARALLELS, VIR_DOMAIN_XML_INACTIVE)) == NULL) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -2367,7 +2367,7 @@ parallelsDomainDefineXML(virConnectPtr conn, const char *xml) virObjectUnlock(olddom); if (!(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, 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 ca2400a..071caf2 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -1191,7 +1191,7 @@ phypOpen(virConnectPtr conn, goto failure; } - if (!(phyp_driver->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) + if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) goto failure; conn->privateData = phyp_driver; @@ -1242,7 +1242,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); @@ -3625,7 +3625,7 @@ phypDomainCreateAndStart(virConnectPtr conn, virCheckFlags(0, NULL); if (!(def = virDomainDefParseString(xml, phyp_driver->caps, - phyp_driver->xmlconf, + phyp_driver->xmlopt, 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 d2f7d84..88c9756 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7959,7 +7959,7 @@ error: * Will fail if not using the 'index' keyword */ static virDomainDiskDefPtr -qemuParseCommandLineDisk(virDomainXMLConfPtr xmlconf, +qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, const char *val, int nvirtiodisk, bool old_style_ceph_args) @@ -8259,7 +8259,7 @@ qemuParseCommandLineDisk(virDomainXMLConfPtr xmlconf, else def->dst[2] = 'a' + idx; - if (virDomainDiskDefAssignAddress(xmlconf, def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid device name '%s'"), def->dst); virDomainDiskDefFree(def); @@ -8325,7 +8325,7 @@ qemuFindNICForVLAN(int nnics, * match up against. Horribly complicated stuff */ static virDomainNetDefPtr -qemuParseCommandLineNet(virDomainXMLConfPtr xmlconf, +qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt, const char *val, int nnics, const char **nics) @@ -8459,7 +8459,7 @@ qemuParseCommandLineNet(virDomainXMLConfPtr xmlconf, } if (genmac) - virDomainNetGenerateMAC(xmlconf, &def->mac); + virDomainNetGenerateMAC(xmlopt, &def->mac); cleanup: for (i = 0 ; i < nkeywords ; i++) { @@ -9023,7 +9023,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, @@ -9333,7 +9333,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, !disk->dst) goto no_memory; - if (virDomainDiskDefAssignAddress(xmlconf, disk) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, disk) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot assign address for device name '%s'"), disk->dst); @@ -9549,7 +9549,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, WANT_VALUE(); if (!STRPREFIX(val, "nic") && STRNEQ(val, "none")) { virDomainNetDefPtr net; - if (!(net = qemuParseCommandLineNet(xmlconf, val, nnics, nics))) + if (!(net = qemuParseCommandLineNet(xmlopt, val, nnics, nics))) goto error; if (VIR_REALLOC_N(def->nets, def->nnets+1) < 0) { virDomainNetDefFree(net); @@ -9559,7 +9559,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps, } } else if (STREQ(arg, "-drive")) { WANT_VALUE(); - if (!(disk = qemuParseCommandLineDisk(xmlconf, val, + if (!(disk = qemuParseCommandLineDisk(xmlopt, val, nvirtiodisk, ceph_args != NULL))) goto error; @@ -9880,7 +9880,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 @@ -9906,7 +9906,7 @@ error: virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *args, char **pidfile, virDomainChrSourceDefPtr *monConfig, @@ -9920,7 +9920,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: @@ -9996,7 +9996,7 @@ cleanup: } virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, pid_t pid, char **pidfile, virDomainChrSourceDefPtr *monConfig, @@ -10016,7 +10016,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 c1ab3c9..717e59c 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -551,11 +551,11 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver) return conf; } -virDomainXMLConfPtr +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) { virQEMUDriverDomainDefParserConfig.priv = driver; - return virDomainXMLConfNew(&virQEMUDriverDomainDefParserConfig, + return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, &virQEMUDriverPrivateDataCallbacks, &virQEMUDriverDomainXMLNamespace); } diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 4b917a7..5299920 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,7 +301,7 @@ void qemuSharedDiskEntryFree(void *payload, const void *name) ATTRIBUTE_NONNULL(1); int qemuDriverAllocateID(virQEMUDriverPtr driver); -virDomainXMLConfPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver); +virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver); #endif /* __QEMUD_CONF_H */ diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6d47606..f431aec 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -762,7 +762,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); } @@ -1878,7 +1878,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 f187c97..37d24df 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(qemu_driver))) + if (!(qemu_driver->xmlopt = virQEMUDriverCreateXMLConf(qemu_driver))) goto error; /* If hugetlbfs is present, then we need to create a sub-directory within @@ -769,7 +769,7 @@ qemuStartup(bool privileged, cfg->stateDir, NULL, 1, qemu_driver->caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -794,7 +794,7 @@ qemuStartup(bool privileged, cfg->configDir, cfg->autostartDir, 0, qemu_driver->caps, - qemu_driver->xmlconf, + qemu_driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, NULL, NULL) < 0) goto error; @@ -867,7 +867,7 @@ qemuReload(void) { virDomainObjListLoadAllConfigs(qemu_driver->domains, cfg->configDir, cfg->autostartDir, 0, - caps, qemu_driver->xmlconf, + caps, qemu_driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, qemuNotifyLoadDomain, qemu_driver); cleanup: @@ -960,7 +960,7 @@ qemuShutdown(void) { virObjectUnref(qemu_driver->domains); virObjectUnref(qemu_driver->remotePorts); - virObjectUnref(qemu_driver->xmlconf); + virObjectUnref(qemu_driver->xmlopt); virSysinfoDefFree(qemu_driver->hostsysinfo); @@ -1485,7 +1485,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1503,7 +1503,7 @@ static virDomainPtr qemuDomainCreate(virConnectPtr conn, const char *xml, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1625,7 +1625,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; @@ -1694,7 +1694,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; @@ -2092,7 +2092,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; @@ -2853,7 +2853,7 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (xmlin) { virDomainDefPtr def = NULL; - if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) { goto endjob; @@ -3767,7 +3767,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; @@ -3873,7 +3873,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; @@ -3964,7 +3964,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; } @@ -4053,7 +4053,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; @@ -4149,7 +4149,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -4230,7 +4230,7 @@ qemuDomainPinEmulator(virDomainPtr dom, goto cleanup; } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; } @@ -4295,7 +4295,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; @@ -4452,7 +4452,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; @@ -4765,14 +4765,14 @@ qemuDomainSaveImageOpen(virQEMUDriverPtr driver, header.was_running = state; /* Create a domain from this XML */ - if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, + 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(xmlin, caps, driver->xmlconf, + if (!(def2 = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -4888,7 +4888,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; } @@ -4946,7 +4946,7 @@ qemuDomainRestoreFlags(virConnectPtr conn, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -5226,7 +5226,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; @@ -5274,7 +5274,7 @@ static char *qemuDomainXMLToNative(virConnectPtr conn, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - def = virDomainDefParseString(xmlData, caps, driver->xmlconf, + def = virDomainDefParseString(xmlData, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, 0); if (!def) goto cleanup; @@ -5545,7 +5545,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(xml, caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -5563,7 +5563,7 @@ static virDomainPtr qemuDomainDefine(virConnectPtr conn, const char *xml) { goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, 0, &oldDef))) goto cleanup; @@ -5782,7 +5782,7 @@ qemuDomainAttachDeviceDiskLive(virConnectPtr conn, dev->data.disk = orig_disk; if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, - caps, driver->xmlconf))) { + caps, driver->xmlopt))) { dev->data.disk = tmp; goto end; } @@ -6059,7 +6059,7 @@ qemuDomainChangeDiskMediaLive(virDomainObjPtr vm, dev->data.disk = orig_disk; if (!(dev_copy = virDomainDeviceDefCopy(dev, vm->def, - caps, driver->xmlconf))) { + caps, driver->xmlopt))) { dev->data.disk = tmp; goto end; } @@ -6463,7 +6463,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, } dev = dev_copy = virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlconf, + caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto endjob; @@ -6474,7 +6474,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, * create a deep copy of device as adding * to CONFIG takes one instance. */ - dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps, driver->xmlconf); + dev_copy = virDomainDeviceDefCopy(dev, vm->def, caps, driver->xmlopt); if (!dev_copy) goto endjob; } @@ -6489,7 +6489,7 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, goto endjob; /* Make a copy for updated domain. */ - vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlconf); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto endjob; switch (action) { @@ -6540,7 +6540,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; } @@ -6917,7 +6917,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; @@ -7082,7 +7082,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom, goto cleanup; } - if (virDomainLiveConfigHelperMethod(caps, driver->xmlconf, vm, &flags, + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags, &persistentDef) < 0) goto cleanup; @@ -7271,7 +7271,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; @@ -7401,7 +7401,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; @@ -7567,7 +7567,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; @@ -7720,7 +7720,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; @@ -7930,13 +7930,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(vm, caps, driver->xmlconf); + vmdef = virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); if (!vmdef) goto cleanup; } @@ -8031,7 +8031,7 @@ qemuSetSchedulerParametersFlags(virDomainPtr dom, } } - if (virDomainSaveStatus(driver->xmlconf, cfg->stateDir, vm) < 0) + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; @@ -8216,7 +8216,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; @@ -8746,7 +8746,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; @@ -8912,7 +8912,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; @@ -11311,7 +11311,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; } @@ -11579,7 +11579,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; @@ -11755,7 +11755,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(xml, caps, driver->xmlconf, + !(def->dom = virDomainDefParseString(xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -12326,7 +12326,7 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, * than inactive xml? */ snap->def->current = true; if (snap->def->dom) { - config = virDomainDefCopy(snap->def->dom, caps, driver->xmlconf, true); + config = virDomainDefCopy(snap->def->dom, caps, driver->xmlopt, true); if (!config) goto cleanup; } @@ -12786,7 +12786,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; @@ -12820,7 +12820,7 @@ static virDomainPtr qemuDomainAttach(virConnectPtr conn, goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -13899,7 +13899,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; @@ -14059,7 +14059,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; @@ -14248,7 +14248,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; @@ -14345,7 +14345,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 b0df4f4..12774ba 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -920,7 +920,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, goto error; } mig->persistent = virDomainDefParseNode(doc, nodes[0], - caps, driver->xmlconf, + caps, driver->xmlopt, -1, VIR_DOMAIN_XML_INACTIVE); if (!mig->persistent) { /* virDomainDefParseNode already reported @@ -1924,7 +1924,7 @@ char *qemuMigrationBegin(virQEMUDriverPtr driver, } if (xmlin) { - if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2026,7 +2026,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlconf, + if (!(def = virDomainDefParseString(dom_xml, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2067,7 +2067,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, virDomainDefPtr newdef; VIR_DEBUG("Using hook-filtered domain XML: %s", xmlout); - newdef = virDomainDefParseString(xmlout, caps, driver->xmlconf, + newdef = virDomainDefParseString(xmlout, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, VIR_DOMAIN_XML_INACTIVE); if (!newdef) @@ -2085,7 +2085,7 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, } if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -3890,7 +3890,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 @@ -3985,7 +3985,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; } @@ -4093,7 +4093,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 7c284be..3d3b772 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); @@ -706,7 +706,7 @@ get_definition(vahControl * ctl, const char *xmlStr) goto exit; } - if (!(ctl->xmlconf = virDomainXMLConfNew(NULL, NULL, NULL))) { + if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL))) { vah_error(ctl, 0, _("Failed to create XML config object")); goto exit; } @@ -723,7 +723,7 @@ get_definition(vahControl * ctl, const char *xmlStr) } ctl->def = virDomainDefParseString(xmlStr, - ctl->caps, ctl->xmlconf, + ctl->caps, ctl->xmlopt, -1, VIR_DOMAIN_XML_INACTIVE); if (ctl->def == NULL) { vah_error(ctl, 0, _("could not parse XML")); diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 01dd871..5915d21 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -82,7 +82,7 @@ struct _testConn { char *path; int nextDomID; virCapsPtr caps; - virDomainXMLConfPtr xmlconf; + virDomainXMLOptionPtr xmlopt; virNodeInfo nodeInfo; virDomainObjListPtr domains; virNetworkObjList networks; @@ -150,12 +150,12 @@ static void testDomainObjPrivateFree(void *data) } -static virDomainXMLConfPtr +static virDomainXMLOptionPtr testBuildXMLConfig(void) { virDomainXMLPrivateDataCallbacks priv = { .alloc = testDomainObjPrivateAlloc, .free = testDomainObjPrivateFree }; - return virDomainXMLConfNew(NULL, &priv, NULL); + return virDomainXMLOptionNew(NULL, &priv, NULL); } @@ -507,7 +507,7 @@ testDomainStartState(virConnectPtr conn, dom->def->id = privconn->nextDomID++; if (virDomainObjSetDefTransient(privconn->caps, - privconn->xmlconf, + privconn->xmlopt, dom, false) < 0) { goto cleanup; } @@ -574,14 +574,14 @@ 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(defaultDomainXML, privconn->caps, - privconn->xmlconf, + privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE))) goto error; @@ -590,7 +590,7 @@ static int testOpenDefault(virConnectPtr conn) { goto error; if (!(domobj = virDomainObjListAdd(privconn->domains, domdef, - privconn->xmlconf, + privconn->xmlopt, 0, NULL))) goto error; domdef = NULL; @@ -809,7 +809,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))) { @@ -924,7 +924,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } def = virDomainDefParseFile(absFile, privconn->caps, - privconn->xmlconf, + privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); VIR_FREE(absFile); @@ -932,7 +932,7 @@ static int testOpenFromFile(virConnectPtr conn, goto error; } else { if ((def = virDomainDefParseNode(xml, domains[i], - privconn->caps, privconn->xmlconf, + privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto error; @@ -941,7 +941,7 @@ static int testOpenFromFile(virConnectPtr conn, if (testDomainGenerateIfnames(def) < 0 || !(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, 0, NULL))) { virDomainDefFree(def); goto error; @@ -1197,7 +1197,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); @@ -1335,7 +1335,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, virCheckFlags(0, NULL); testDriverLock(privconn); - if ((def = virDomainDefParseString(xml,privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(xml,privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -1344,7 +1344,7 @@ testDomainCreateXML(virConnectPtr conn, const char *xml, goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1950,7 +1950,7 @@ testDomainRestoreFlags(virConnectPtr conn, } xml[len] = '\0'; - def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE); if (!def) @@ -1960,7 +1960,7 @@ testDomainRestoreFlags(virConnectPtr conn, goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_LIVE | VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) @@ -2169,7 +2169,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; @@ -2248,7 +2248,7 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, } if (!(persistentDef = virDomainObjGetPersistentDef(privconn->caps, - privconn->xmlconf, + privconn->xmlopt, privdom))) goto cleanup; @@ -2501,7 +2501,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, virDomainDefPtr oldDef = NULL; testDriverLock(privconn); - if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlconf, + if ((def = virDomainDefParseString(xml, privconn->caps, privconn->xmlopt, 1 << VIR_DOMAIN_VIRT_TEST, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; @@ -2510,7 +2510,7 @@ static virDomainPtr testDomainDefineXML(virConnectPtr conn, goto cleanup; if (!(dom = virDomainObjListAdd(privconn->domains, def, - privconn->xmlconf, + privconn->xmlopt, 0, &oldDef))) goto cleanup; 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 cda7110..c18819a 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -526,7 +526,7 @@ umlStartup(bool privileged, if ((uml_driver->caps = umlCapsInit()) == NULL) goto out_of_memory; - if (!(uml_driver->xmlconf = virDomainXMLConfNew(¨DriverDomainDefParserConfig, + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig, &privcb, NULL))) goto error; @@ -566,7 +566,7 @@ umlStartup(bool privileged, uml_driver->configDir, uml_driver->autostartDir, 0, uml_driver->caps, - uml_driver->xmlconf, + uml_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_UML, NULL, NULL) < 0) goto error; @@ -622,7 +622,7 @@ umlReload(void) { uml_driver->configDir, uml_driver->autostartDir, 0, uml_driver->caps, - uml_driver->xmlconf, + uml_driver->xmlopt, 1 << VIR_DOMAIN_VIRT_UML, umlNotifyLoadDomain, uml_driver); umlDriverUnlock(uml_driver); @@ -661,7 +661,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 */ @@ -1085,7 +1085,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; @@ -1119,7 +1119,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); @@ -1526,13 +1526,13 @@ static virDomainPtr umlDomainCreate(virConnectPtr conn, const char *xml, virCheckFlags(VIR_DOMAIN_START_AUTODESTROY, NULL); umlDriverLock(driver); - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -1946,13 +1946,13 @@ static virDomainPtr umlDomainDefine(virConnectPtr conn, const char *xml) { virDomainPtr dom = NULL; umlDriverLock(driver); - if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if (!(def = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_UML, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; if (!(vm = virDomainObjListAdd(driver->domains, def, - driver->xmlconf, + driver->xmlopt, 0, NULL))) goto cleanup; def = NULL; @@ -2100,7 +2100,7 @@ static int umlDomainAttachDevice(virDomainPtr dom, const char *xml) goto cleanup; } - dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlconf, + dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) @@ -2218,7 +2218,7 @@ static int umlDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(xml, vm->def, driver->caps, driver->xmlconf, + 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 79ee2c0..3c3d519 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; @@ -849,10 +849,10 @@ static virDomainDefParserConfig vboxDomainDefParserConfig = { }; -static virDomainXMLConfPtr +static virDomainXMLOptionPtr vboxXMLConfInit(void) { - return virDomainXMLConfNew(&vboxDomainDefParserConfig, + return virDomainXMLOptionNew(&vboxDomainDefParserConfig, NULL, NULL); } @@ -981,7 +981,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) */ @@ -1041,7 +1041,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; } @@ -5047,7 +5047,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) { #endif nsresult rc; - if (!(def = virDomainDefParseString(xml, data->caps, data->xmlconf, + if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt, 1 << VIR_DOMAIN_VIRT_VBOX, VIR_DOMAIN_XML_INACTIVE))) { goto cleanup; @@ -5391,7 +5391,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, goto cleanup; } - dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlconf, + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -5626,7 +5626,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) { goto cleanup; } - dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlconf, + dev = virDomainDeviceDefParse(xml, def, data->caps, data->xmlopt, VIR_DOMAIN_XML_INACTIVE); if (dev == NULL) goto cleanup; @@ -5927,7 +5927,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 999b7c3..573fb33 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); } @@ -163,12 +163,12 @@ vmwareLoadDomains(struct vmware_driver *driver) goto cleanup; if ((vmdef = - virVMXParseConfig(&ctx, driver->xmlconf, vmx)) == NULL) { + virVMXParseConfig(&ctx, driver->xmlopt, vmx)) == NULL) { goto cleanup; } if (!(vm = virDomainObjListAdd(driver->domains, vmdef, - driver->xmlconf, + driver->xmlopt, 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 d27acc3..c7e493f 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(NULL, &priv, NULL); + return virDomainXMLOptionNew(NULL, &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,13 +324,13 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) ctx.formatFileName = vmwareCopyVMXFileName; vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; /* generate vmx file */ - vmx = virVMXFormatConfig(&ctx, driver->xmlconf, vmdef, 7); + vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7); if (vmx == NULL) goto cleanup; @@ -347,7 +347,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml) /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, vmdef, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -595,13 +595,13 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, vmwareDriverLock(driver); - if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlconf, + if ((vmdef = virDomainDefParseString(xml, driver->caps, driver->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE)) == NULL) goto cleanup; /* generate vmx file */ - vmx = virVMXFormatConfig(&ctx, driver->xmlconf, vmdef, 7); + vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7); if (vmx == NULL) goto cleanup; @@ -618,7 +618,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml, /* assign def */ if (!(vm = virDomainObjListAdd(driver->domains, vmdef, - driver->xmlconf, + driver->xmlopt, VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, NULL))) goto cleanup; @@ -943,7 +943,7 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, ctx.parseFileName = vmwareCopyVMXFileName; - def = virVMXParseConfig(&ctx, driver->xmlconf, 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 d69fc0e..5dc5046 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -526,10 +526,10 @@ virDomainDefParserConfig virVMXDomainDefParserConfig = { }; -virDomainXMLConfPtr +virDomainXMLOptionPtr virVMXDomainXMLConfInit(void) { - return virDomainXMLConfNew(&virVMXDomainDefParserConfig, + return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL, NULL); } @@ -948,7 +948,7 @@ virVMXFloppyDiskNameToUnit(const char *name, int *unit) static int -virVMXVerifyDiskAddress(virDomainXMLConfPtr xmlconf, virDomainDiskDefPtr disk) +virVMXVerifyDiskAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr disk) { virDomainDiskDef def; virDomainDeviceDriveAddressPtr drive; @@ -967,7 +967,7 @@ virVMXVerifyDiskAddress(virDomainXMLConfPtr xmlconf, virDomainDiskDefPtr disk) def.dst = disk->dst; def.bus = disk->bus; - if (virDomainDiskDefAssignAddress(xmlconf, &def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, &def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not verify disk address")); return -1; @@ -1225,7 +1225,7 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *vmx) { bool success = false; @@ -1603,7 +1603,7 @@ virVMXParseConfig(virVMXContext *ctx, continue; } - if (virVMXParseDisk(ctx, xmlconf, 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; @@ -1614,7 +1614,7 @@ virVMXParseConfig(virVMXContext *ctx, continue; } - if (virVMXParseDisk(ctx, xmlconf, 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; @@ -1629,7 +1629,7 @@ virVMXParseConfig(virVMXContext *ctx, /* def:disks (ide) */ for (bus = 0; bus < 2; ++bus) { for (unit = 0; unit < 2; ++unit) { - if (virVMXParseDisk(ctx, xmlconf, 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; @@ -1640,7 +1640,7 @@ virVMXParseConfig(virVMXContext *ctx, continue; } - if (virVMXParseDisk(ctx, xmlconf, 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; @@ -1654,7 +1654,7 @@ virVMXParseConfig(virVMXContext *ctx, /* def:disks (floppy) */ for (unit = 0; unit < 2; ++unit) { - if (virVMXParseDisk(ctx, xmlconf, 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; @@ -1965,7 +1965,7 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, int -virVMXParseDisk(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, virConfPtr conf, +virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr conf, int device, int busType, int controllerOrBus, int unit, virDomainDiskDefPtr *def) { @@ -2299,7 +2299,7 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, virConfPtr conf goto cleanup; } - if (virDomainDiskDefAssignAddress(xmlconf, *def) < 0) { + if (virDomainDiskDefAssignAddress(xmlopt, *def) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not assign address to disk '%s'"), (*def)->src); goto cleanup; @@ -3037,7 +3037,7 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def) */ char * -virVMXFormatConfig(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, virDomainDefPtr def, +virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, int virtualHW_version) { char *vmx = NULL; @@ -3246,7 +3246,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, virDomainDef /* def:disks */ for (i = 0; i < def->ndisks; ++i) { - if (virVMXVerifyDiskAddress(xmlconf, 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 b9d623d..ec63317 100644 --- a/src/vmx/vmx.h +++ b/src/vmx/vmx.h @@ -29,7 +29,7 @@ typedef struct _virVMXContext virVMXContext; -virDomainXMLConfPtr virVMXDomainXMLConfInit(void); +virDomainXMLOptionPtr virVMXDomainXMLConfInit(void); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -80,7 +80,7 @@ char *virVMXConvertToUTF8(const char *encoding, const char *string); */ virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, - virDomainXMLConfPtr xmlconf, + virDomainXMLOptionPtr xmlopt, const char *vmx); int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def); @@ -88,7 +88,7 @@ int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def); int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, int *virtualDev); -int virVMXParseDisk(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, +int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr conf, int device, int busType, int controllerOrBus, int unit, virDomainDiskDefPtr *def); @@ -110,7 +110,7 @@ int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def); * Domain XML -> VMX */ -char *virVMXFormatConfig(virVMXContext *ctx, virDomainXMLConfPtr xmlconf, +char *virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def, int virtualHW_version); int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer); diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 4f8b711..fb65573 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -287,10 +287,10 @@ virDomainDefParserConfig xenDomainDefParserConfig = { }; -virDomainXMLConfPtr +virDomainXMLOptionPtr xenDomainXMLConfInit(void) { - return virDomainXMLConfNew(&xenDomainDefParserConfig, + return virDomainXMLOptionNew(&xenDomainDefParserConfig, NULL, NULL); } @@ -430,7 +430,7 @@ xenUnifiedOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags) goto fail; } - if (!(priv->xmlconf = xenDomainXMLConfInit())) + if (!(priv->xmlopt = xenDomainXMLConfInit())) goto fail; #if WITH_XEN_INOTIFY @@ -480,7 +480,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) @@ -1463,7 +1463,7 @@ xenUnifiedDomainXMLToNative(virConnectPtr conn, goto cleanup; } - if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(xmlData, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, 0))) goto cleanup; diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index 568de07..702b1e8 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 */ @@ -226,7 +226,7 @@ typedef struct _xenUnifiedPrivate *xenUnifiedPrivatePtr; char *xenDomainUsedCpus(virDomainPtr dom); -virDomainXMLConfPtr xenDomainXMLConfInit(void); +virDomainXMLOptionPtr xenDomainXMLConfInit(void); void xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr info); int xenUnifiedAddDomainInfo(xenUnifiedDomainInfoListPtr info, diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 03d08fc..7f5d43a 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(xmlDesc, priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) return NULL; @@ -2519,7 +2519,7 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2679,7 +2679,7 @@ xenDaemonUpdateDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -2786,7 +2786,7 @@ xenDaemonDetachDeviceFlags(virDomainPtr domain, NULL))) goto cleanup; - if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlconf, + if (!(dev = virDomainDeviceDefParse(xml, def, priv->caps, priv->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -3127,7 +3127,7 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) return NULL; - if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt, 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 618d4f1..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(xml, priv->caps, priv->xmlconf, + if (!(def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) { xenUnifiedUnlock(priv); @@ -1312,7 +1312,7 @@ xenXMDomainAttachDeviceFlags(virDomainPtr domain, if (!(dev = virDomainDeviceDefParse(xml, entry->def, priv->caps, - priv->xmlconf, + priv->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; @@ -1406,7 +1406,7 @@ xenXMDomainDetachDeviceFlags(virDomainPtr domain, if (!(dev = virDomainDeviceDefParse(xml, entry->def, priv->caps, - priv->xmlconf, + priv->xmlopt, VIR_DOMAIN_XML_INACTIVE))) goto cleanup; diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index 35d00a2..ff097e6 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -178,7 +178,7 @@ xenapiOpen(virConnectPtr conn, virConnectAuthPtr auth, goto error; } - if (!(privP->xmlconf = virDomainXMLConfNew(&xenapiDomainDefParserConfig, + if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig, NULL, NULL))) { xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, _("Failed to create XML conf object")); @@ -224,7 +224,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); @@ -248,7 +248,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); @@ -544,7 +544,7 @@ xenapiDomainCreateXML(virConnectPtr conn, virCheckFlags(0, NULL); virDomainDefPtr defPtr = virDomainDefParseString(xmlDesc, - priv->caps, priv->xmlconf, + priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, flags); createVMRecordFromXml(conn, defPtr, &record, &vm); @@ -1698,7 +1698,7 @@ xenapiDomainDefineXML(virConnectPtr conn, const char *xml) if (!priv->caps) return NULL; virDomainDefPtr defPtr = virDomainDefParseString(xml, - priv->caps, priv->xmlconf, + priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, 0); if (!defPtr) 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 e6bd3a6..6f1c600 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(&driver))) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) 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 b7c010f..e0f99f4 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(inXmlData, caps, xmlconf, + if (!(def = virDomainDefParseString(inXmlData, caps, xmlopt, 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 810bddd..9167d88 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(&driver))) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) 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 d6f1d64..24685c7 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(NULL))) + !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) 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 02d0213..0712fb3 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(xml, driver.caps, driver.xmlconf, + if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, 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(&driver))) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) return EXIT_FAILURE; VIR_FREE(driver.config->stateDir); if ((driver.config->stateDir = strdup("/nowhere")) == NULL) @@ -931,7 +931,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 8c7f6af..aa058bd 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(inXmlData, driver.caps, driver.xmlconf, + if (!(def = virDomainDefParseString(inXmlData, driver.caps, driver.xmlopt, 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(&driver))) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) 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 15628dd..e6b42dc 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(xml, driver.caps, driver.xmlconf, + if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, 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(&driver))) + if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) 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 c132927..f585f6f 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(xmlstr, caps, xmlconf, + if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, QEMU_EXPECTED_VIRT_TYPES, 0))) goto cleanup; @@ -328,7 +328,7 @@ mymain(void) if ((caps = testQemuCapsInit()) == NULL) return EXIT_FAILURE; - if (!(xmlconf = virQEMUDriverCreateXMLConf(NULL))) + if (!(xmlopt = virQEMUDriverCreateXMLConf(NULL))) 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/vmx2xmltest.c b/tests/vmx2xmltest.c index 07e7544..2d04da7 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -12,7 +12,7 @@ # include "vmx/vmx.h" static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static virVMXContext ctx; @@ -84,7 +84,7 @@ testCompareFiles(const char *vmx, const char *xml) goto failure; } - def = virVMXParseConfig(&ctx, xmlconf, vmxData); + def = virVMXParseConfig(&ctx, xmlopt, vmxData); if (def == NULL) { err = virGetLastError(); @@ -212,7 +212,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlconf = virVMXDomainXMLConfInit())) + if (!(xmlopt = virVMXDomainXMLConfInit())) return EXIT_FAILURE; ctx.opaque = NULL; @@ -290,7 +290,7 @@ mymain(void) DO_TEST("svga", "svga"); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index e19336f..b7ff48c 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(xmlData, caps, xmlconf, + if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 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 = xenDomainXMLConfInit())) + if (!(xmlopt = xenDomainXMLConfInit())) 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 27a0905..062ff07 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -16,7 +16,7 @@ #include "testutilsxen.h" static virCapsPtr caps; -static virDomainXMLConfPtr xmlconf; +static virDomainXMLOptionPtr xmlopt; static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) @@ -33,7 +33,7 @@ testCompareFiles(const char *xml, const char *sexpr, int xendConfigVersion) if (virtTestLoadFile(sexpr, &sexprData) < 0) goto fail; - if (!(def = virDomainDefParseString(xmlData, caps, xmlconf, + if (!(def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_XEN, VIR_DOMAIN_XML_INACTIVE))) goto fail; @@ -105,7 +105,7 @@ mymain(void) if (!(caps = testXenCapsInit())) return EXIT_FAILURE; - if (!(xmlconf = xenDomainXMLConfInit())) + if (!(xmlopt = xenDomainXMLConfInit())) return EXIT_FAILURE; DO_TEST("pv", "pv", "pvtest", 1); @@ -175,7 +175,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 8cc9257..86ab74a 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 void @@ -84,7 +84,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - def = virDomainDefParseString(xmlData, caps, xmlconf, + def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); @@ -92,7 +92,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) goto failure; } - formatted = virVMXFormatConfig(&ctx, xmlconf, def, virtualHW_version); + formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); if (formatted == NULL) { goto failure; @@ -230,7 +230,7 @@ mymain(void) return EXIT_FAILURE; } - if (!(xmlconf = virVMXDomainXMLConfInit())) + if (!(xmlopt = virVMXDomainXMLConfInit())) return EXIT_FAILURE; ctx.opaque = NULL; @@ -302,7 +302,7 @@ mymain(void) DO_TEST("svga", "svga", 4); virObjectUnref(caps); - virObjectUnref(xmlconf); + virObjectUnref(xmlopt); return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -- 1.8.1.5

On 03/31/2013 04:48 PM, 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 ---
Notes: Version 5: - new in series - suggested by Eric, I decided to do it after the series to avoid touching the other patches. Justification is that it anyways changes code that is already pushed.
Well, it makes no difference for someone in the future who wants to look at the code, but doesn't do anything to help those of us who want to review 01/11 in this patch series...
participants (2)
-
Laine Stump
-
Peter Krempa