
From: Hyman Huang <yong.huang@smartx.com> Add a thorough check in the virDomainObjSave path to make sure that private data in the status XML file always exists for the running VM so that we won't lose them after restart the service. --- src/conf/domain_conf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 281846dfbe..74af08e584 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29542,9 +29542,24 @@ virDomainObjFormat(virDomainObj *obj, obj->deprecations[i]); } - if (xmlopt->privateData.format && - xmlopt->privateData.format(&buf, obj) < 0) - return NULL; + if (xmlopt->privateData.format) { + if (xmlopt->privateData.format(&buf, obj) < 0) + return NULL; + } else { + /* + * Add a thorough check in the virDomainObjSave path to make + * sure that private data in the status XML file always exists + * for the running VM so that we won't lose them after restart + * the service. + */ + if (virDomainObjIsActive(obj) && + (obj->def->virtType == VIR_DOMAIN_VIRT_KVM)) { + VIR_WARN("Do not omit private data when formatting the" + " status XML for a %s VM", + virDomainStateTypeToString(state)); + return NULL; + } + } if (virDomainDefFormatInternal(obj->def, xmlopt, &buf, flags) < 0) return NULL; -- 2.27.0