mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-20 03:25:18 +00:00
qemu: Don't use virDomainDefFormat* directly
Always use appropriate qemuDomain{,Def}Format wrapper since it may do some additional magic based on the flags. (cherry picked from commit cd603008b1ddde1c549e6efd40fa2ea32fbc8053)
This commit is contained in:
parent
b5f86fc038
commit
68563e7ad6
@ -1149,11 +1149,13 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
int
|
||||||
virDomainDefPtr def,
|
qemuDomainDefFormatBuf(struct qemud_driver *driver,
|
||||||
unsigned int flags)
|
virDomainDefPtr def,
|
||||||
|
unsigned int flags,
|
||||||
|
virBuffer *buf)
|
||||||
{
|
{
|
||||||
char *ret = NULL;
|
int ret = -1;
|
||||||
virCPUDefPtr cpu = NULL;
|
virCPUDefPtr cpu = NULL;
|
||||||
virCPUDefPtr def_cpu = def->cpu;
|
virCPUDefPtr def_cpu = def->cpu;
|
||||||
|
|
||||||
@ -1173,7 +1175,7 @@ char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
|||||||
def->cpu = cpu;
|
def->cpu = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virDomainDefFormat(def, flags);
|
ret = virDomainDefFormatInternal(def, flags, buf);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
def->cpu = def_cpu;
|
def->cpu = def_cpu;
|
||||||
@ -1181,6 +1183,26 @@ cleanup:
|
|||||||
return ret;
|
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,
|
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
|
@ -240,6 +240,11 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
|||||||
virDomainObjPtr obj)
|
virDomainObjPtr obj)
|
||||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
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,
|
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
||||||
virDomainDefPtr vm,
|
virDomainDefPtr vm,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
@ -4543,7 +4543,7 @@ static char *qemuDomainXMLFromNative(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
|
xml = qemuDomainDefFormatXML(driver, def, VIR_DOMAIN_XML_INACTIVE);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
@ -10954,9 +10954,10 @@ static int qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
|
|||||||
snap->def->current = true;
|
snap->def->current = true;
|
||||||
if (snap->def->dom) {
|
if (snap->def->dom) {
|
||||||
char *xml;
|
char *xml;
|
||||||
if (!(xml = virDomainDefFormat(snap->def->dom,
|
if (!(xml = qemuDomainDefFormatXML(driver,
|
||||||
(VIR_DOMAIN_XML_INACTIVE |
|
snap->def->dom,
|
||||||
VIR_DOMAIN_XML_SECURE))))
|
VIR_DOMAIN_XML_INACTIVE |
|
||||||
|
VIR_DOMAIN_XML_SECURE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
config = virDomainDefParseString(driver->caps, xml,
|
config = virDomainDefParseString(driver->caps, xml,
|
||||||
QEMU_EXPECTED_VIRT_TYPES,
|
QEMU_EXPECTED_VIRT_TYPES,
|
||||||
|
@ -390,7 +390,8 @@ static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuMigrationCookieXMLFormat(virBufferPtr buf,
|
qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
|
||||||
|
virBufferPtr buf,
|
||||||
qemuMigrationCookiePtr mig)
|
qemuMigrationCookiePtr mig)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@ -428,10 +429,11 @@ qemuMigrationCookieXMLFormat(virBufferPtr buf,
|
|||||||
if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
|
if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
|
||||||
mig->persistent) {
|
mig->persistent) {
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
if (virDomainDefFormatInternal(mig->persistent,
|
if (qemuDomainDefFormatBuf(driver,
|
||||||
VIR_DOMAIN_XML_INACTIVE |
|
mig->persistent,
|
||||||
VIR_DOMAIN_XML_SECURE,
|
VIR_DOMAIN_XML_INACTIVE |
|
||||||
buf) < 0)
|
VIR_DOMAIN_XML_SECURE,
|
||||||
|
buf) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
}
|
}
|
||||||
@ -441,11 +443,12 @@ qemuMigrationCookieXMLFormat(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *qemuMigrationCookieXMLFormatStr(qemuMigrationCookiePtr mig)
|
static char *qemuMigrationCookieXMLFormatStr(struct qemud_driver *driver,
|
||||||
|
qemuMigrationCookiePtr mig)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (qemuMigrationCookieXMLFormat(&buf, mig) < 0) {
|
if (qemuMigrationCookieXMLFormat(driver, &buf, mig) < 0) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -717,7 +720,7 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
|
|||||||
qemuMigrationCookieAddPersistent(mig, dom) < 0)
|
qemuMigrationCookieAddPersistent(mig, dom) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(mig)))
|
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
*cookieoutlen = strlen(*cookieout) + 1;
|
*cookieoutlen = strlen(*cookieout) + 1;
|
||||||
@ -1235,7 +1238,8 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
|
|||||||
char *xml;
|
char *xml;
|
||||||
int hookret;
|
int hookret;
|
||||||
|
|
||||||
if (!(xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
|
if (!(xml = qemuDomainDefFormatXML(driver, def,
|
||||||
|
VIR_DOMAIN_XML_SECURE)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
|
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, def->name,
|
||||||
|
@ -3320,7 +3320,7 @@ int qemuProcessStart(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_QEMU)) {
|
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
|
||||||
char *xml = virDomainDefFormat(vm->def, 0);
|
char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
|
||||||
int hookret;
|
int hookret;
|
||||||
|
|
||||||
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
||||||
@ -3513,7 +3513,7 @@ int qemuProcessStart(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_QEMU)) {
|
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
|
||||||
char *xml = virDomainDefFormat(vm->def, 0);
|
char *xml = qemuDomainDefFormatXML(driver, vm->def, 0);
|
||||||
int hookret;
|
int hookret;
|
||||||
|
|
||||||
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
||||||
@ -3953,7 +3953,7 @@ void qemuProcessStop(struct qemud_driver *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_QEMU)) {
|
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 */
|
/* we can't stop the operation even if the script raised an error */
|
||||||
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
||||||
@ -4046,7 +4046,7 @@ retry:
|
|||||||
|
|
||||||
/* The "release" hook cleans up additional resources */
|
/* The "release" hook cleans up additional resources */
|
||||||
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
|
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 */
|
/* we can't stop the operation even if the script raised an error */
|
||||||
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
virHookCall(VIR_HOOK_DRIVER_QEMU, vm->def->name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user