For an active persistent domain, vm->def contains the live definition
and vm->newDef contains the persistent definition. Use vm->newDef when
VIR_DOMAIN_XML_INACTIVE is requested so that the persistent XML is
returned.

Signed-off-by: Roman Bogorodskiy <[email protected]>
---
 src/bhyve/bhyve_driver.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 1f44ea8598..2c4ec911a7 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -507,6 +507,7 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int 
flags)
 {
     struct _bhyveConn *privconn = domain->conn->privateData;
     virDomainObj *vm;
+    virDomainDef *def;
     char *ret = NULL;
 
     virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
@@ -517,7 +518,12 @@ bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int 
flags)
     if (virDomainGetXMLDescEnsureACL(domain->conn, vm->def, flags) < 0)
         goto cleanup;
 
-    ret = virDomainDefFormat(vm->def, privconn->xmlopt,
+    if ((flags & VIR_DOMAIN_XML_INACTIVE) && vm->newDef)
+        def = vm->newDef;
+    else
+        def = vm->def;
+
+    ret = virDomainDefFormat(def, privconn->xmlopt,
                              virDomainDefFormatConvertXMLFlags(flags));
 
  cleanup:
-- 
2.52.0

Reply via email to