On Thu, Sep 20, 2018 at 19:44:50 +0200, Marc Hartmayer wrote:
This allows the QEMU driver to use the originally used QEMU
capabilities for copying the domain. It avoids the usage of a possible
changed QEMU capability as virQEMUCapsCacheLookup might return a
different QEMU capability than used before (for example when during
the job the QEMU binary has been replaced virQEMUCapsCacheLookupCopy
will invalidate the originally used QEMU capability).
For other drivers @parseOpqaue will still be NULL, because
xmlopt->privateData.getParseOpaque is currently only implemented for
the QEMU driver.
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi(a)linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/conf/domain_conf.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1ee43950ae2d..a3f2fcb0a001 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3366,6 +3366,7 @@ virDomainObjSetDefTransient(virCapsPtr caps,
virDomainObjPtr domain)
{
int ret = -1;
+ void *parseOpaque = NULL;
if (!domain->persistent)
return 0;
@@ -3373,7 +3374,10 @@ virDomainObjSetDefTransient(virCapsPtr caps,
if (domain->newDef)
return 0;
- if (!(domain->newDef = virDomainDefCopy(domain->def, caps, xmlopt, NULL,
false)))
+ if (xmlopt->privateData.getParseOpaque)
+ parseOpaque = xmlopt->privateData.getParseOpaque(domain);
I'd prefer if the caller passes this in explicitly since virDomainDefCopy
uses it explicitly.
Additionally the caller will be aware where the pointer is taken. The
callback is really used only in the place where we are restoring the
existing domain object from the status XML and thus we really need the
specific caps they were used. Since the code is common the callback
needs to be used.
Ideally priv->qemuCaps will be cleared when the VM is NOT running so at
the point above you'd get NULL anyways in most cases.