[libvirt PATCH v2 08/81] conf: Introduce virDomainObjIsPostcopy helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 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 34ecc7e7a9..05fd64b1c3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29249,6 +29249,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 da85c6ecd4..1efdb439ac 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3889,6 +3889,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 0c6dd4fa49..770dfe459a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -578,6 +578,7 @@ virDomainObjGetOneDefState;
 virDomainObjGetPersistentDef;
 virDomainObjGetState;
 virDomainObjIsFailedPostcopy;
+virDomainObjIsPostcopy;
 virDomainObjNew;
 virDomainObjParseFile;
 virDomainObjParseNode;
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux