[libvirt PATCH 10/80] conf: Introduce virDomainObjIsPostcopy helper

Jiri Denemark jdenemar at redhat.com
Tue May 10 15:20:31 UTC 2022


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 src/conf/domain_conf.c   | 22 ++++++++++++++++++++++
 src/conf/domain_conf.h   |  4 ++++
 src/libvirt_private.syms |  1 +
 3 files changed, 27 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bae03422ff..e6adfb1d90 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29062,6 +29062,28 @@ virDomainObjIsFailedPostcopy(virDomainObj *dom)
 }
 
 
+bool
+virDomainObjIsPostcopy(virDomainObj *dom,
+                       virDomainJobOperation op)
+{
+    if (op != VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN &&
+        op != VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT)
+        return false;
+
+    if (op == VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN) {
+        return (dom->state.state == VIR_DOMAIN_PAUSED &&
+                dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED) ||
+               (dom->state.state == VIR_DOMAIN_RUNNING &&
+                (dom->state.reason == VIR_DOMAIN_RUNNING_POSTCOPY ||
+                 dom->state.reason == VIR_DOMAIN_RUNNING_POSTCOPY_FAILED));
+    }
+
+    return dom->state.state == VIR_DOMAIN_PAUSED &&
+           (dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY ||
+            dom->state.reason == VIR_DOMAIN_PAUSED_POSTCOPY_FAILED);
+}
+
+
 void
 virDomainObjSetState(virDomainObj *dom, virDomainState state, int reason)
 {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 2b1f86932f..3f2839bb82 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3870,6 +3870,10 @@ virDomainObjGetState(virDomainObj *obj, int *reason)
 bool
 virDomainObjIsFailedPostcopy(virDomainObj *obj)
         ATTRIBUTE_NONNULL(1);
+bool
+virDomainObjIsPostcopy(virDomainObj *dom,
+                       virDomainJobOperation op)
+        ATTRIBUTE_NONNULL(1);
 
 virSecurityLabelDef *
 virDomainDefGetSecurityLabelDef(const virDomainDef *def, const char *model);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 070551b773..84e34c1648 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -580,6 +580,7 @@ virDomainObjGetOneDefState;
 virDomainObjGetPersistentDef;
 virDomainObjGetState;
 virDomainObjIsFailedPostcopy;
+virDomainObjIsPostcopy;
 virDomainObjNew;
 virDomainObjParseFile;
 virDomainObjParseNode;
-- 
2.35.1



More information about the libvir-list mailing list