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

[libvirt] [PATCH 3/6] Added new public API virDomainMigrateStartPostCopy



The user first start migration using the `VIR_MIGRATE_POSTCOPY` flag,
then calls `virDomainMigrateStartPostCopy` asynchronously to switch from
pre-copy to post-copy.

Signed-off-by: Cristian Klein <cristian klein cs umu se>
---
 include/libvirt/libvirt.h.in |  2 ++
 src/driver.h                 |  4 ++++
 src/libvirt.c                | 37 +++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |  5 +++++
 4 files changed, 48 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index bdc33c6..eabedfa 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1346,6 +1346,8 @@ int virDomainMigrateToURI3(virDomainPtr domain,
                            unsigned int nparams,
                            unsigned int flags);
 
+int virDomainMigrateStartPostCopy (virDomainPtr domain);
+
 int virDomainMigrateSetMaxDowntime (virDomainPtr domain,
                                     unsigned long long downtime,
                                     unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index bb748c4..6866ccd 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1212,6 +1212,9 @@ typedef int
                                   virDomainStatsRecordPtr **retStats,
                                   unsigned int flags);
 
+typedef int
+(*virDrvDomainMigrateStartPostCopy)(virDomainPtr domain);
+
 typedef struct _virDriver virDriver;
 typedef virDriver *virDriverPtr;
 
@@ -1435,6 +1438,7 @@ struct _virDriver {
     virDrvNodeGetFreePages nodeGetFreePages;
     virDrvConnectGetDomainCapabilities connectGetDomainCapabilities;
     virDrvConnectGetAllDomainStats connectGetAllDomainStats;
+    virDrvDomainMigrateStartPostCopy domainMigrateStartPostCopy;
 };
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 33aeafa..e685da2 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -17803,6 +17803,43 @@ virDomainMigrateSetCompressionCache(virDomainPtr domain,
 
 
 /**
+ * virDomainMigrateStartPostCopy:
+ * @domain: a domain object
+ *
+ * Starts post-copy migration. This function has to be called while
+ * migration (initially pre-copy) is in progress. The migration operation
+ * must be called with the VIR_MIGRATE_POSTCOPY flag.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateStartPostCopy(virDomainPtr domain)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (conn->driver->domainMigrateStartPostCopy) {
+        if (conn->driver->domainMigrateStartPostCopy(domain) < 0)
+            goto error;
+        return 0;
+    }
+
+    virReportUnsupportedError();
+ error:
+    virDispatchError(conn);
+    return -1;
+}
+
+
+/**
  * virDomainMigrateSetMaxSpeed:
  * @domain: a domain object
  * @bandwidth: migration bandwidth limit in MiB/s
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index e1f013f..ea17a07 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -679,4 +679,9 @@ LIBVIRT_1.2.8 {
         virDomainStatsRecordListFree;
 } LIBVIRT_1.2.7;
 
+LIBVIRT_1.2.9 {
+    global:
+        virDomainMigrateStartPostCopy;
+} LIBVIRT_1.2.8;
+
 # .... define new API here using predicted next version number ....
-- 
1.9.1


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