conf: add caps to virDomainDefFormat*

And use the newly added caps->host.netprefix (if it exists) for
interface names that match the autogenerated target names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
This commit is contained in:
Joao Martins 2016-02-03 21:40:35 +00:00 committed by Daniel P. Berrange
parent 481e9bd0f6
commit d239a5427f
31 changed files with 86 additions and 53 deletions

View File

@ -488,7 +488,9 @@ bhyveDomainGetOSType(virDomainPtr dom)
static char * static char *
bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
{ {
bhyveConnPtr privconn = conn->privateData;
virDomainObjPtr vm; virDomainObjPtr vm;
virCapsPtr caps = NULL;
char *ret = NULL; char *ret = NULL;
if (!(vm = bhyveDomObjFromDomain(domain))) if (!(vm = bhyveDomObjFromDomain(domain)))
@ -497,9 +499,14 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
if (virDomainGetXMLDescEnsureACL(domain->conn, vm->def, flags) < 0) if (virDomainGetXMLDescEnsureACL(domain->conn, vm->def, flags) < 0)
goto cleanup; goto cleanup;
ret = virDomainDefFormat(vm->def, caps = bhyveDriverGetCapabilities(privconn);
if (!caps)
goto cleanup;
ret = virDomainDefFormat(vm->def, caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
virObjectUnref(caps);
cleanup: cleanup:
if (vm) if (vm)
virObjectUnlock(vm); virObjectUnlock(vm);

View File

@ -18201,8 +18201,8 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
error: error:
err = virSaveLastError(); err = virSaveLastError();
strSrc = virDomainDefFormat(src, 0); strSrc = virDomainDefFormat(src, NULL, 0);
strDst = virDomainDefFormat(dst, 0); strDst = virDomainDefFormat(dst, NULL, 0);
VIR_DEBUG("XMLs that failed stability check were: src=\"%s\", dst=\"%s\"", VIR_DEBUG("XMLs that failed stability check were: src=\"%s\", dst=\"%s\"",
NULLSTR(strSrc), NULLSTR(strDst)); NULLSTR(strSrc), NULLSTR(strDst));
VIR_FREE(strSrc); VIR_FREE(strSrc);
@ -19890,6 +19890,7 @@ virDomainVirtioNetDriverFormat(char **outstr,
int int
virDomainNetDefFormat(virBufferPtr buf, virDomainNetDefFormat(virBufferPtr buf,
virDomainNetDefPtr def, virDomainNetDefPtr def,
char *prefix,
unsigned int flags) unsigned int flags)
{ {
unsigned int actualType = virDomainNetGetActualType(def); unsigned int actualType = virDomainNetGetActualType(def);
@ -20067,7 +20068,8 @@ virDomainNetDefFormat(virBufferPtr buf,
virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name); virBufferEscapeString(buf, "<backenddomain name='%s'/>\n", def->domain_name);
if (def->ifname && if (def->ifname &&
!((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) && !((flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE) &&
(STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX)))) { (STRPREFIX(def->ifname, VIR_NET_GENERATED_PREFIX) ||
(prefix && STRPREFIX(def->ifname, prefix))))) {
/* Skip auto-generated target names for inactive config. */ /* Skip auto-generated target names for inactive config. */
virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname); virBufferEscapeString(buf, "<target dev='%s'/>\n", def->ifname);
} }
@ -21617,6 +21619,7 @@ virDomainDefHasCapabilitiesFeatures(virDomainDefPtr def)
* Return -1 on failure. */ * Return -1 on failure. */
int int
virDomainDefFormatInternal(virDomainDefPtr def, virDomainDefFormatInternal(virDomainDefPtr def,
virCapsPtr caps,
unsigned int flags, unsigned int flags,
virBufferPtr buf) virBufferPtr buf)
{ {
@ -21627,6 +21630,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
size_t i; size_t i;
virBuffer childrenBuf = VIR_BUFFER_INITIALIZER; virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
int indent; int indent;
char *netprefix = NULL;
virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS | virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS |
VIR_DOMAIN_DEF_FORMAT_STATUS | VIR_DOMAIN_DEF_FORMAT_STATUS |
@ -22324,8 +22328,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0) if (virDomainFSDefFormat(buf, def->fss[n], flags) < 0)
goto error; goto error;
if (caps)
netprefix = caps->host.netprefix;
for (n = 0; n < def->nnets; n++) for (n = 0; n < def->nnets; n++)
if (virDomainNetDefFormat(buf, def->nets[n], flags) < 0) if (virDomainNetDefFormat(buf, def->nets[n], netprefix, flags) < 0)
goto error; goto error;
for (n = 0; n < def->nsmartcards; n++) for (n = 0; n < def->nsmartcards; n++)
@ -22495,12 +22501,12 @@ unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags)
char * char *
virDomainDefFormat(virDomainDefPtr def, unsigned int flags) virDomainDefFormat(virDomainDefPtr def, virCapsPtr caps, unsigned int flags)
{ {
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL); virCheckFlags(VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS, NULL);
if (virDomainDefFormatInternal(def, flags, &buf) < 0) if (virDomainDefFormatInternal(def, caps, flags, &buf) < 0)
return NULL; return NULL;
return virBufferContentAndReset(&buf); return virBufferContentAndReset(&buf);
@ -22534,7 +22540,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
xmlopt->privateData.format(&buf, obj) < 0) xmlopt->privateData.format(&buf, obj) < 0)
goto error; goto error;
if (virDomainDefFormatInternal(obj->def, flags, &buf) < 0) if (virDomainDefFormatInternal(obj->def, NULL, flags, &buf) < 0)
goto error; goto error;
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);
@ -22724,7 +22730,7 @@ virDomainSaveConfig(const char *configDir,
int ret = -1; int ret = -1;
char *xml; char *xml;
if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE))) if (!(xml = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_SECURE)))
goto cleanup; goto cleanup;
if (virDomainSaveXML(configDir, def, xml)) if (virDomainSaveXML(configDir, def, xml))
@ -23024,7 +23030,7 @@ virDomainDefCopy(virDomainDefPtr src,
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE; format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
/* Easiest to clone via a round-trip through XML. */ /* Easiest to clone via a round-trip through XML. */
if (!(xml = virDomainDefFormat(src, format_flags))) if (!(xml = virDomainDefFormat(src, caps, format_flags)))
return NULL; return NULL;
ret = virDomainDefParseString(xml, caps, xmlopt, parse_flags); ret = virDomainDefParseString(xml, caps, xmlopt, parse_flags);
@ -23511,6 +23517,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE; int flags = VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_SECURE;
char *xmlStr = NULL; char *xmlStr = NULL;
int rc = -1; int rc = -1;
char *netprefix;
switch ((virDomainDeviceType) src->type) { switch ((virDomainDeviceType) src->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
@ -23523,7 +23530,8 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
rc = virDomainFSDefFormat(&buf, src->data.fs, flags); rc = virDomainFSDefFormat(&buf, src->data.fs, flags);
break; break;
case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_NET:
rc = virDomainNetDefFormat(&buf, src->data.net, flags); netprefix = caps->host.netprefix;
rc = virDomainNetDefFormat(&buf, src->data.net, netprefix, flags);
break; break;
case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_INPUT:
rc = virDomainInputDefFormat(&buf, src->data.input, flags); rc = virDomainInputDefFormat(&buf, src->data.input, flags);

View File

@ -2734,11 +2734,13 @@ void virDomainIOThreadSchedDelId(virDomainDefPtr def, unsigned int iothread_id);
unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags); unsigned int virDomainDefFormatConvertXMLFlags(unsigned int flags);
char *virDomainDefFormat(virDomainDefPtr def, char *virDomainDefFormat(virDomainDefPtr def,
virCapsPtr caps,
unsigned int flags); unsigned int flags);
char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt, char *virDomainObjFormat(virDomainXMLOptionPtr xmlopt,
virDomainObjPtr obj, virDomainObjPtr obj,
unsigned int flags); unsigned int flags);
int virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDefFormatInternal(virDomainDefPtr def,
virCapsPtr caps,
unsigned int flags, unsigned int flags,
virBufferPtr buf); virBufferPtr buf);
@ -2749,6 +2751,7 @@ int virDomainDiskSourceFormat(virBufferPtr buf,
int virDomainNetDefFormat(virBufferPtr buf, int virDomainNetDefFormat(virBufferPtr buf,
virDomainNetDefPtr def, virDomainNetDefPtr def,
char *prefix,
unsigned int flags); unsigned int flags);
typedef enum { typedef enum {

View File

@ -702,7 +702,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
virBufferAddLit(&buf, "</disks>\n"); virBufferAddLit(&buf, "</disks>\n");
} }
if (def->dom) { if (def->dom) {
if (virDomainDefFormatInternal(def->dom, flags, &buf) < 0) { if (virDomainDefFormatInternal(def->dom, NULL, flags, &buf) < 0) {
virBufferFreeAndReset(&buf); virBufferFreeAndReset(&buf);
return NULL; return NULL;
} }

View File

@ -2749,7 +2749,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) if (powerState != esxVI_VirtualMachinePowerState_PoweredOff)
def->id = id; def->id = id;
xml = virDomainDefFormat(def, xml = virDomainDefFormat(def, priv->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
} }
@ -2805,7 +2805,8 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
def = virVMXParseConfig(&ctx, priv->xmlopt, priv->caps, nativeConfig); def = virVMXParseConfig(&ctx, priv->xmlopt, priv->caps, nativeConfig);
if (def) if (def)
xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE); xml = virDomainDefFormat(def, priv->caps,
VIR_DOMAIN_DEF_FORMAT_INACTIVE);
virDomainDefFree(def); virDomainDefFree(def);

View File

@ -885,7 +885,7 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
/* FIXME: devices section is totally missing */ /* FIXME: devices section is totally missing */
xml = virDomainDefFormat(def, xml = virDomainDefFormat(def, NULL,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:

View File

@ -1066,7 +1066,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
goto cleanup_dom; goto cleanup_dom;
if ((dom_xml = virDomainDefFormat(vm->def, 0)) == NULL) if ((dom_xml = virDomainDefFormat(vm->def, cfg->caps, 0)) == NULL)
goto cleanup_dom; goto cleanup_dom;
if (libxl_userdata_store(cfg->ctx, domid, "libvirt-xml", if (libxl_userdata_store(cfg->ctx, domid, "libvirt-xml",

View File

@ -1674,7 +1674,7 @@ libxlDoDomainSave(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
goto cleanup; goto cleanup;
} }
if ((xml = virDomainDefFormat(vm->def, 0)) == NULL) if ((xml = virDomainDefFormat(vm->def, cfg->caps, 0)) == NULL)
goto cleanup; goto cleanup;
xml_len = strlen(xml) + 1; xml_len = strlen(xml) + 1;
@ -2555,6 +2555,8 @@ libxlDomainGetVcpus(virDomainPtr dom, virVcpuInfoPtr info, int maxinfo,
static char * static char *
libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
{ {
libxlDriverPrivatePtr driver = dom->conn->privateData;
libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainDefPtr def; virDomainDefPtr def;
char *ret = NULL; char *ret = NULL;
@ -2572,12 +2574,13 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
else else
def = vm->def; def = vm->def;
ret = virDomainDefFormat(def, ret = virDomainDefFormat(def, cfg->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
if (vm) if (vm)
virObjectUnlock(vm); virObjectUnlock(vm);
virObjectUnref(cfg);
return ret; return ret;
} }
@ -2630,7 +2633,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
goto cleanup; goto cleanup;
} }
xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE); xml = virDomainDefFormat(def, cfg->caps, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);

View File

@ -254,7 +254,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
if (!libxlDomainMigrationIsAllowed(def)) if (!libxlDomainMigrationIsAllowed(def))
goto endjob; goto endjob;
xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE); xml = virDomainDefFormat(def, cfg->caps, VIR_DOMAIN_DEF_FORMAT_SECURE);
endjob: endjob:
if (!libxlDomainObjEndJob(driver, vm)) if (!libxlDomainObjEndJob(driver, vm))

View File

@ -1027,6 +1027,7 @@ lxcDomainGetMemoryParameters(virDomainPtr dom,
static char *lxcDomainGetXMLDesc(virDomainPtr dom, static char *lxcDomainGetXMLDesc(virDomainPtr dom,
unsigned int flags) unsigned int flags)
{ {
virLXCDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm; virDomainObjPtr vm;
char *ret = NULL; char *ret = NULL;
@ -1040,6 +1041,7 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom,
ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) &&
vm->newDef ? vm->newDef : vm->def, vm->newDef ? vm->newDef : vm->def,
driver->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
@ -1072,7 +1074,7 @@ static char *lxcConnectDomainXMLFromNative(virConnectPtr conn,
if (!(def = lxcParseConfigString(nativeConfig, caps, driver->xmlopt))) if (!(def = lxcParseConfigString(nativeConfig, caps, driver->xmlopt)))
goto cleanup; goto cleanup;
xml = virDomainDefFormat(def, 0); xml = virDomainDefFormat(def, caps, 0);
cleanup: cleanup:
virObjectUnref(caps); virObjectUnref(caps);

View File

@ -177,7 +177,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
/* now that we know it's stopped call the hook if present */ /* now that we know it's stopped call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
/* we can't stop the operation even if the script raised an error */ /* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
@ -238,7 +238,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
/* The "release" hook cleans up additional resources */ /* The "release" hook cleans up additional resources */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
/* we can't stop the operation even if the script raised an error */ /* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
@ -1278,7 +1278,7 @@ int virLXCProcessStart(virConnectPtr conn,
/* Run an early hook to set-up missing devices */ /* Run an early hook to set-up missing devices */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
int hookret; int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
@ -1390,7 +1390,7 @@ int virLXCProcessStart(virConnectPtr conn,
/* now that we know it is about to start call the hook if present */ /* now that we know it is about to start call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
int hookret; int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
@ -1532,7 +1532,7 @@ int virLXCProcessStart(virConnectPtr conn,
/* finally we can call the 'started' hook script if any */ /* finally we can call the 'started' hook script if any */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
int hookret; int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name, hookret = virHookCall(VIR_HOOK_DRIVER_LXC, vm->def->name,
@ -1697,7 +1697,7 @@ virLXCProcessReconnectDomain(virDomainObjPtr vm,
/* now that we know it's reconnected call the hook if present */ /* now that we know it's reconnected call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_LXC)) { if (virHookPresent(VIR_HOOK_DRIVER_LXC)) {
char *xml = virDomainDefFormat(vm->def, 0); char *xml = virDomainDefFormat(vm->def, driver->caps, 0);
int hookret; int hookret;
/* we can't stop the operation even if the script raised an error */ /* we can't stop the operation even if the script raised an error */

View File

@ -200,11 +200,11 @@ networkRunHook(virNetworkObjPtr network,
virBufferAddLit(&buf, "<hookData>\n"); virBufferAddLit(&buf, "<hookData>\n");
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
if (iface && virDomainNetDefFormat(&buf, iface, 0) < 0) if (iface && virDomainNetDefFormat(&buf, iface, NULL, 0) < 0)
goto cleanup; goto cleanup;
if (virNetworkDefFormatBuf(&buf, network->def, 0) < 0) if (virNetworkDefFormatBuf(&buf, network->def, 0) < 0)
goto cleanup; goto cleanup;
if (dom && virDomainDefFormatInternal(dom, 0, &buf) < 0) if (dom && virDomainDefFormatInternal(dom, NULL, 0, &buf) < 0)
goto cleanup; goto cleanup;
virBufferAdjustIndent(&buf, -2); virBufferAdjustIndent(&buf, -2);

View File

@ -573,7 +573,7 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
goto cleanup; goto cleanup;
} }
ret = virDomainDefFormat(vm->def, ret = virDomainDefFormat(vm->def, driver->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
@ -2274,7 +2274,8 @@ openvzDomainMigrateBegin3Params(virDomainPtr domain,
goto cleanup; goto cleanup;
} }
xml = virDomainDefFormat(vm->def, VIR_DOMAIN_DEF_FORMAT_SECURE); xml = virDomainDefFormat(vm->def, driver->caps,
VIR_DOMAIN_DEF_FORMAT_SECURE);
cleanup: cleanup:
if (vm) if (vm)

View File

@ -3303,7 +3303,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
if (virDomainDefSetVcpus(&def, vcpus) < 0) if (virDomainDefSetVcpus(&def, vcpus) < 0)
goto err; goto err;
return virDomainDefFormat(&def, return virDomainDefFormat(&def, phyp_driver->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
err: err:

View File

@ -2160,7 +2160,7 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
} }
ret = virDomainDefFormatInternal(def, ret = virDomainDefFormatInternal(def, driver->caps,
virDomainDefFormatConvertXMLFlags(flags), virDomainDefFormatConvertXMLFlags(flags),
buf); buf);

View File

@ -1982,7 +1982,7 @@ testDomainSaveFlags(virDomainPtr domain, const char *path,
if (!(privdom = testDomObjFromDomain(domain))) if (!(privdom = testDomObjFromDomain(domain)))
goto cleanup; goto cleanup;
xml = virDomainDefFormat(privdom->def, xml = virDomainDefFormat(privdom->def, privconn->caps,
VIR_DOMAIN_DEF_FORMAT_SECURE); VIR_DOMAIN_DEF_FORMAT_SECURE);
if (xml == NULL) { if (xml == NULL) {
@ -2591,6 +2591,7 @@ testDomainGetVcpuPinInfo(virDomainPtr dom,
static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
{ {
testDriverPtr privconn = domain->conn->privateData;
virDomainDefPtr def; virDomainDefPtr def;
virDomainObjPtr privdom; virDomainObjPtr privdom;
char *ret = NULL; char *ret = NULL;
@ -2603,7 +2604,8 @@ static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
def = (flags & VIR_DOMAIN_XML_INACTIVE) && def = (flags & VIR_DOMAIN_XML_INACTIVE) &&
privdom->newDef ? privdom->newDef : privdom->def; privdom->newDef ? privdom->newDef : privdom->def;
ret = virDomainDefFormat(def, virDomainDefFormatConvertXMLFlags(flags)); ret = virDomainDefFormat(def, privconn->caps,
virDomainDefFormatConvertXMLFlags(flags));
virDomainObjEndAPI(&privdom); virDomainObjEndAPI(&privdom);
return ret; return ret;

View File

@ -1986,7 +1986,7 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom,
goto cleanup; goto cleanup;
ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ? ret = virDomainDefFormat((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef ?
vm->newDef : vm->def, vm->newDef : vm->def, driver->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:

View File

@ -3996,7 +3996,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
/* dump USB devices/filters if active */ /* dump USB devices/filters if active */
vboxHostDeviceGetXMLDesc(data, def, machine); vboxHostDeviceGetXMLDesc(data, def, machine);
ret = virDomainDefFormat(def, virDomainDefFormatConvertXMLFlags(flags)); ret = virDomainDefFormat(def, data->caps,
virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
VBOX_RELEASE(machine); VBOX_RELEASE(machine);

View File

@ -1005,7 +1005,7 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
goto cleanup; goto cleanup;
} }
ret = virDomainDefFormat(vm->def, ret = virDomainDefFormat(vm->def, driver->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
@ -1040,7 +1040,8 @@ vmwareConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
def = virVMXParseConfig(&ctx, driver->xmlopt, driver->caps, nativeConfig); def = virVMXParseConfig(&ctx, driver->xmlopt, driver->caps, nativeConfig);
if (def != NULL) if (def != NULL)
xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE); xml = virDomainDefFormat(def, driver->caps,
VIR_DOMAIN_DEF_FORMAT_INACTIVE);
virDomainDefFree(def); virDomainDefFree(def);

View File

@ -642,6 +642,7 @@ vzDomainGetState(virDomainPtr domain,
static char * static char *
vzDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) vzDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
{ {
vzConnPtr privconn = domain->conn->privateData;
virDomainDefPtr def; virDomainDefPtr def;
virDomainObjPtr privdom; virDomainObjPtr privdom;
char *ret = NULL; char *ret = NULL;
@ -654,7 +655,7 @@ vzDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
def = (flags & VIR_DOMAIN_XML_INACTIVE) && def = (flags & VIR_DOMAIN_XML_INACTIVE) &&
privdom->newDef ? privdom->newDef : privdom->def; privdom->newDef ? privdom->newDef : privdom->def;
ret = virDomainDefFormat(def, flags); ret = virDomainDefFormat(def, privconn->caps, flags);
cleanup: cleanup:
if (privdom) if (privdom)

View File

@ -1530,7 +1530,7 @@ xenUnifiedDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus); def = xenDaemonDomainGetXMLDesc(dom->conn, minidef, cpus);
if (def) if (def)
ret = virDomainDefFormat(def, ret = virDomainDefFormat(def, priv->caps,
virDomainDefFormatConvertXMLFlags(flags)); virDomainDefFormatConvertXMLFlags(flags));
cleanup: cleanup:
@ -1586,7 +1586,7 @@ xenUnifiedConnectDomainXMLFromNative(virConnectPtr conn,
if (!def) if (!def)
goto cleanup; goto cleanup;
ret = virDomainDefFormat(def, 0); ret = virDomainDefFormat(def, priv->caps, 0);
cleanup: cleanup:
virDomainDefFree(def); virDomainDefFree(def);

View File

@ -1402,7 +1402,8 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
xen_vm vm = NULL; xen_vm vm = NULL;
xen_vm_set *vms; xen_vm_set *vms;
xen_string_string_map *result = NULL; xen_string_string_map *result = NULL;
xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session; struct _xenapiPrivate *priv = conn->privateData;
xen_session *session = priv->session;
virDomainDefPtr defPtr = NULL; virDomainDefPtr defPtr = NULL;
char *boot_policy = NULL; char *boot_policy = NULL;
unsigned long memory = 0; unsigned long memory = 0;
@ -1580,7 +1581,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
xen_vif_set_free(vif_set); xen_vif_set_free(vif_set);
} }
xen_vm_set_free(vms); xen_vm_set_free(vms);
xml = virDomainDefFormat(defPtr, flags); xml = virDomainDefFormat(defPtr, priv->caps, flags);
virDomainDefFree(defPtr); virDomainDefFree(defPtr);
return xml; return xml;

View File

@ -40,7 +40,7 @@ testCompareXMLToConfigFiles(const char *xml,
goto fail; goto fail;
if (vmdef) { if (vmdef) {
if (!(actualxml = virDomainDefFormat(vmdef, 0))) if (!(actualxml = virDomainDefFormat(vmdef, caps, 0)))
goto fail; goto fail;
if (virtTestLoadFile(xml, &expectxml) < 0) if (virtTestLoadFile(xml, &expectxml) < 0)

View File

@ -115,7 +115,7 @@ testReadNetworkConf(const void *data ATTRIBUTE_UNUSED)
goto cleanup; goto cleanup;
} }
actual = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_INACTIVE); actual = virDomainDefFormat(def, NULL, VIR_DOMAIN_DEF_FORMAT_INACTIVE);
if (actual == NULL) { if (actual == NULL) {
err = virGetLastError(); err = virGetLastError();

View File

@ -87,7 +87,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto fail; goto fail;
} }
if (!(actualxml = virDomainDefFormat(vmdef, 0))) if (!(actualxml = virDomainDefFormat(vmdef, driver.caps, 0)))
goto fail; goto fail;
if (blankProblemElements(expectxml) < 0 || if (blankProblemElements(expectxml) < 0 ||

View File

@ -182,7 +182,8 @@ testQemuHotplugCheckResult(virDomainObjPtr vm,
int ret; int ret;
vm->def->id = -1; vm->def->id = -1;
actual = virDomainDefFormat(vm->def, VIR_DOMAIN_DEF_FORMAT_SECURE); actual = virDomainDefFormat(vm->def, driver.caps,
VIR_DOMAIN_DEF_FORMAT_SECURE);
if (!actual) if (!actual)
return -1; return -1;
vm->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID; vm->def->id = QEMU_HOTPLUG_TEST_DOMAIN_ID;

View File

@ -62,7 +62,7 @@ testCompareFiles(const char *xml, const char *sexpr)
goto fail; goto fail;
} }
if (!(gotxml = virDomainDefFormat(def, 0))) if (!(gotxml = virDomainDefFormat(def, caps, 0)))
goto fail; goto fail;
if (virtTestCompareToFile(gotxml, xml) < 0) if (virtTestCompareToFile(gotxml, xml) < 0)

View File

@ -1091,7 +1091,7 @@ testCompareDomXML2XMLFiles(virCapsPtr caps, virDomainXMLOptionPtr xmlopt,
goto fail; goto fail;
} }
if (!(actual = virDomainDefFormat(def, format_flags))) if (!(actual = virDomainDefFormat(def, caps, format_flags)))
goto fail; goto fail;
if (virtTestCompareToFile(actual, outfile) < 0) if (virtTestCompareToFile(actual, outfile) < 0)

View File

@ -86,7 +86,8 @@ testCompareFiles(const char *vmx, const char *xml)
goto cleanup; goto cleanup;
} }
if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE))) if (!(formatted = virDomainDefFormat(def, caps,
VIR_DOMAIN_DEF_FORMAT_SECURE)))
goto cleanup; goto cleanup;
if (virtTestCompareToFile(formatted, xml) < 0) if (virtTestCompareToFile(formatted, xml) < 0)

View File

@ -116,7 +116,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
if (!(def = xenParseXL(conf, caps, xmlopt))) if (!(def = xenParseXL(conf, caps, xmlopt)))
goto fail; goto fail;
if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE | if (!(gotxml = virDomainDefFormat(def, caps, VIR_DOMAIN_XML_INACTIVE |
VIR_DOMAIN_XML_SECURE))) VIR_DOMAIN_XML_SECURE)))
goto fail; goto fail;

View File

@ -121,7 +121,7 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
if (!(def = xenParseXM(conf, caps, xmlopt))) if (!(def = xenParseXM(conf, caps, xmlopt)))
goto fail; goto fail;
if (!(gotxml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE))) if (!(gotxml = virDomainDefFormat(def, caps, VIR_DOMAIN_DEF_FORMAT_SECURE)))
goto fail; goto fail;
if (virtTestCompareToFile(gotxml, xml) < 0) if (virtTestCompareToFile(gotxml, xml) < 0)