Return whether the live or persistent definition was returned. Sometimes
it's necessary to base the decisions on this.
---
src/conf/domain_conf.c | 40 ++++++++++++++++++++++++++++++++++++----
src/conf/domain_conf.h | 3 +++
src/libvirt_private.syms | 1 +
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0828041..8f48a74 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3118,22 +3118,25 @@ virDomainObjGetDefs(virDomainObjPtr vm,
/**
- * virDomainObjGetOneDef:
+ * virDomainObjGetOneDefState:
*
* @vm: Domain object
* @flags: for virDomainModificationImpact
+ * @live: set to true if live config was returned (may be omitted)
*
* Helper function to resolve @flags and return the correct domain pointer
* object. This function returns one of @vm->def or @vm->persistentDef
- * according to @flags. This helper should be used only in APIs that guarantee
+ * according to @flags. @live is set to true if the live vm config will be
+ * returned. This helper should be used only in APIs that guarantee
* that @flags contains exactly one of VIR_DOMAIN_AFFECT_LIVE or
* VIR_DOMAIN_AFFECT_CONFIG and not both.
*
* Returns the correct definition pointer or NULL on error.
*/
virDomainDefPtr
-virDomainObjGetOneDef(virDomainObjPtr vm,
- unsigned int flags)
+virDomainObjGetOneDefState(virDomainObjPtr vm,
+ unsigned int flags,
+ bool *live)
{
if (flags & VIR_DOMAIN_AFFECT_LIVE && flags &
VIR_DOMAIN_AFFECT_CONFIG) {
virReportInvalidArg(ctl, "%s",
@@ -3146,6 +3149,13 @@ virDomainObjGetOneDef(virDomainObjPtr vm,
if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
return NULL;
+ if (live) {
+ if (flags & VIR_DOMAIN_AFFECT_LIVE)
+ *live = true;
+ else
+ *live = false;
+ }
+
if (virDomainObjIsActive(vm) && flags & VIR_DOMAIN_AFFECT_CONFIG)
return vm->newDef;
else
@@ -3153,6 +3163,28 @@ virDomainObjGetOneDef(virDomainObjPtr vm,
}
+/**
+ * virDomainObjGetOneDef:
+ *
+ * @vm: Domain object
+ * @flags: for virDomainModificationImpact
+ *
+ * Helper function to resolve @flags and return the correct domain pointer
+ * object. This function returns one of @vm->def or @vm->persistentDef
+ * according to @flags. This helper should be used only in APIs that guarantee
+ * that @flags contains exactly one of VIR_DOMAIN_AFFECT_LIVE or
+ * VIR_DOMAIN_AFFECT_CONFIG and not both.
+ *
+ * Returns the correct definition pointer or NULL on error.
+ */
+virDomainDefPtr
+virDomainObjGetOneDef(virDomainObjPtr vm,
+ unsigned int flags)
+{
+ return virDomainObjGetOneDefState(vm, flags, NULL);
+}
+
+
static int
virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c14a39c..ac99b15 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2592,6 +2592,9 @@ int virDomainObjGetDefs(virDomainObjPtr vm,
unsigned int flags,
virDomainDefPtr *liveDef,
virDomainDefPtr *persDef);
+virDomainDefPtr virDomainObjGetOneDefState(virDomainObjPtr vm,
+ unsigned int flags,
+ bool *state);
virDomainDefPtr virDomainObjGetOneDef(virDomainObjPtr vm, unsigned int flags);
virDomainDefPtr virDomainDefCopy(virDomainDefPtr src,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2569772..dfaebad 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -417,6 +417,7 @@ virDomainObjFormat;
virDomainObjGetDefs;
virDomainObjGetMetadata;
virDomainObjGetOneDef;
+virDomainObjGetOneDefState;
virDomainObjGetPersistentDef;
virDomainObjGetShortName;
virDomainObjGetState;
--
2.10.0