}
-char *qemuDomainDefFormatXML(struct qemud_driver *driver,
- virDomainDefPtr def,
- unsigned int flags)
+int
+qemuDomainDefFormatBuf(struct qemud_driver *driver,
+ virDomainDefPtr def,
+ unsigned int flags,
+ virBuffer *buf)
{
- char *ret = NULL;
+ int ret = -1;
virCPUDefPtr cpu = NULL;
virCPUDefPtr def_cpu = def->cpu;
def->cpu = cpu;
}
- ret = virDomainDefFormat(def, flags);
+ ret = virDomainDefFormatInternal(def, flags, buf);
cleanup:
def->cpu = def_cpu;
return ret;
}
+char *qemuDomainDefFormatXML(struct qemud_driver *driver,
+ virDomainDefPtr def,
+ unsigned int flags)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (qemuDomainDefFormatBuf(driver, def, flags, &buf) < 0) {
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
char *qemuDomainFormatXML(struct qemud_driver *driver,
virDomainObjPtr vm,
unsigned int flags)
virDomainObjPtr obj)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+int qemuDomainDefFormatBuf(struct qemud_driver *driver,
+ virDomainDefPtr vm,
+ unsigned int flags,
+ virBuffer *buf);
+
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
virDomainDefPtr vm,
unsigned int flags);
goto cleanup;
}
- xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+ xml = qemuDomainDefFormatXML(driver, def, VIR_DOMAIN_XML_INACTIVE);
cleanup:
virDomainDefFree(def);
snap->def->current = true;
if (snap->def->dom) {
char *xml;
- if (!(xml = virDomainDefFormat(snap->def->dom,
- (VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE))))
+ if (!(xml = qemuDomainDefFormatXML(driver,
+ snap->def->dom,
+ VIR_DOMAIN_XML_INACTIVE |
+ VIR_DOMAIN_XML_SECURE)))
goto cleanup;
config = virDomainDefParseString(driver->caps, xml,
QEMU_EXPECTED_VIRT_TYPES,
static int
-qemuMigrationCookieXMLFormat(virBufferPtr buf,
+qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
+ virBufferPtr buf,
qemuMigrationCookiePtr mig)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
mig->persistent) {
virBufferAdjustIndent(buf, 2);
- if (virDomainDefFormatInternal(mig->persistent,
- VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE,
- buf) < 0)
+ if (qemuDomainDefFormatBuf(driver,
+ mig->persistent,
+ VIR_DOMAIN_XML_INACTIVE |
+ VIR_DOMAIN_XML_SECURE,
+ buf) < 0)
return -1;
virBufferAdjustIndent(buf, -2);
}
}
-static char *qemuMigrationCookieXMLFormatStr(qemuMigrationCookiePtr mig)
+static char *qemuMigrationCookieXMLFormatStr(struct qemud_driver *driver,
+ qemuMigrationCookiePtr mig)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if (qemuMigrationCookieXMLFormat(&buf, mig) < 0) {
+ if (qemuMigrationCookieXMLFormat(driver, &buf, mig) < 0) {
virBufferFreeAndReset(&buf);
return NULL;
}
qemuMigrationCookieAddPersistent(mig, dom) < 0)
return -1;
- if (!(*cookieout = qemuMigrationCookieXMLFormatStr(mig)))
+ if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;
*cookieoutlen = strlen(*cookieout) + 1;
char *xml;
int hookret;
- if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
+ if (!(xml = qemuDomainDefFormatXML(driver, def,
+ VIR_DOMAIN_XML_SECURE)))
goto cleanup;
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
/* Run an early hook to set-up missing devices */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
- char *xml = virDomainDefFormat(vm->def, 0);
+ char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
/* now that we know it is about to start call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
- char *xml = virDomainDefFormat(vm->def, 0);
+ char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
int hookret;
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
/* now that we know it's stopped call the hook if present */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
- char *xml = virDomainDefFormat(vm->def, 0);
+ char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
/* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
/* The "release" hook cleans up additional resources */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
- char *xml = virDomainDefFormat(vm->def, 0);
+ char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
/* we can't stop the operation even if the script raised an error */
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,