From: Scott Garfinkle <seg(a)us.ibm.com>
virsh migrate-getmaxdowntime local/libvirt enablement
Signed-off-by: Scott Garfinkle <seg(a)us.ibm.com>
---
include/libvirt/libvirt-domain.h | 4 ++++
src/driver-hypervisor.h | 6 ++++++
src/libvirt-domain.c | 45 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 12 +++++++++++
src/remote/remote_driver.c | 1 +
tools/virsh-domain.c | 46 ++++++++++++++++++++++++++++++++++++++++
tools/virsh.pod | 18 ++++++++++++++++
7 files changed, 132 insertions(+)
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 45f939a..ed3c461 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1043,6 +1043,10 @@ int virDomainMigrateSetMaxDowntime (virDomainPtr domain,
unsigned long long downtime,
unsigned int flags);
+int virDomainMigrateGetMaxDowntime (virDomainPtr domain,
+ unsigned long long *downtime,
+ unsigned int flags);
+
int virDomainMigrateGetCompressionCache(virDomainPtr domain,
unsigned long long *cacheSize,
unsigned int flags);
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 3053d7a..7d32cad 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -702,6 +702,11 @@ typedef int
unsigned int flags);
typedef int
+(*virDrvDomainMigrateGetMaxDowntime)(virDomainPtr domain,
+ unsigned long long *downtime,
+ unsigned int flags);
+
+typedef int
(*virDrvDomainMigrateGetCompressionCache)(virDomainPtr domain,
unsigned long long *cacheSize,
unsigned int flags);
@@ -1412,6 +1417,7 @@ struct _virHypervisorDriver {
virDrvDomainGetJobInfo domainGetJobInfo;
virDrvDomainGetJobStats domainGetJobStats;
virDrvDomainAbortJob domainAbortJob;
+ virDrvDomainMigrateGetMaxDowntime domainMigrateGetMaxDowntime;
virDrvDomainMigrateSetMaxDowntime domainMigrateSetMaxDowntime;
virDrvDomainMigrateGetCompressionCache domainMigrateGetCompressionCache;
virDrvDomainMigrateSetCompressionCache domainMigrateSetCompressionCache;
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 4033ae8..b78ea1c 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -8781,6 +8781,51 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain,
/**
+ * virDomainMigrateGetMaxDowntime:
+ * @domain: a domain object
+ * @downtime: return value of the maximum tolerable downtime for live
+ * migration, in milliseconds
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Gets current maximum tolerable time for which the domain may be paused
+ * at the end of live migration. It's supposed to be called while the domain is
+ * being live-migrated as a reaction to migration progress.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ */
+int
+virDomainMigrateGetMaxDowntime(virDomainPtr domain,
+ unsigned long long *downtime,
+ unsigned int flags)
+{
+ virConnectPtr conn;
+
+ VIR_DOMAIN_DEBUG(domain, "downtime = %p, flags=%x", downtime, flags);
+
+ virResetLastError();
+
+ virCheckDomainReturn(domain, -1);
+ conn = domain->conn;
+
+ virCheckNonNullArgGoto(downtime, error);
+
+ /* unlike SetMaxDowntime, it's okay for the connection to be readonly */
+
+ if (conn->driver->domainMigrateGetMaxDowntime) {
+ if (conn->driver->domainMigrateGetMaxDowntime(domain,
+ downtime, flags) < 0)
+ goto error;
+ return 0;
+ }
+
+ virReportUnsupportedError();
+ error:
+ virDispatchError(conn);
+ return -1;
+}
+
+
+/**
* virDomainMigrateGetCompressionCache:
* @domain: a domain object
* @cacheSize: return value of current size of the cache (in bytes)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2b0afcc..b17a60b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -2552,6 +2552,18 @@ qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
int
+qemuMonitorGetMigrationDowntime(qemuMonitorPtr mon,
+ unsigned long long *downtime)
+{
+ VIR_DEBUG("downtime=%p", downtime);
+
+ QEMU_CHECK_MONITOR_JSON(mon);
+
+ return qemuMonitorJSONGetMigrationDowntime(mon, downtime);
+}
+
+
+int
qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
unsigned long long *cacheSize)
{
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a57d25f..aa8d8a1 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8400,6 +8400,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainGetJobInfo = remoteDomainGetJobInfo, /* 0.7.7 */
.domainGetJobStats = remoteDomainGetJobStats, /* 1.0.3 */
.domainAbortJob = remoteDomainAbortJob, /* 0.7.7 */
+ .domainMigrateGetMaxDowntime = remoteDomainMigrateGetMaxDowntime, /* 3.6.0 */
.domainMigrateSetMaxDowntime = remoteDomainMigrateSetMaxDowntime, /* 0.8.0 */
.domainMigrateGetCompressionCache = remoteDomainMigrateGetCompressionCache, /* 1.0.3
*/
.domainMigrateSetCompressionCache = remoteDomainMigrateSetCompressionCache, /* 1.0.3
*/
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0684979..10fdd0f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -10720,6 +10720,46 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
}
/*
+ * "migrate-getmaxdowntime" command
+ */
+static const vshCmdInfo info_migrate_getmaxdowntime[] = {
+ {.name = "help",
+ .data = N_("get maximum tolerable downtime")
+ },
+ {.name = "desc",
+ .data = N_("Get maximum tolerable downtime (in milliseconds)for a domain which
is being live-migrated to another host.")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_migrate_getmaxdowntime[] = {
+ VIRSH_COMMON_OPT_DOMAIN_FULL,
+ {.name = NULL}
+};
+
+static bool
+cmdMigrateGetMaxDowntime(vshControl *ctl, const vshCmd *cmd)
+{
+ virDomainPtr dom = NULL;
+ unsigned long long downtime;
+ bool ret = false;
+
+ if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ if (virDomainMigrateGetMaxDowntime(dom, &downtime, 0))
+ goto done;
+
+ vshPrint(ctl, "%llu\n", downtime);
+
+ ret = true;
+
+ done:
+ virshDomainFree(dom);
+ return ret;
+}
+
+/*
* "migrate-compcache" command
*/
static const vshCmdInfo info_migrate_compcache[] = {
@@ -13845,6 +13885,12 @@ const vshCmdDef domManagementCmds[] = {
.info = info_migrate_setmaxdowntime,
.flags = 0
},
+ {.name = "migrate-getmaxdowntime",
+ .handler = cmdMigrateGetMaxDowntime,
+ .opts = opts_migrate_getmaxdowntime,
+ .info = info_migrate_getmaxdowntime,
+ .flags = 0
+ },
{.name = "migrate-compcache",
.handler = cmdMigrateCompCache,
.opts = opts_migrate_compcache,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 43d6f0c..fc0a46c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1869,6 +1869,24 @@ is supposed to be used while the domain is being live-migrated as a
reaction
to migration progress and increasing number of compression cache misses
obtained from domjobinfo.
+=item B<migrate-getmaxdowntime> I<domain>
+
+Get the maximum tolerable downtime for a domain which is being live-migrated to
+another host. This is the number of milliseconds the guest is allowed
+to be down at the end of live migration.
+
+=item B<migrate-compcache> I<domain> [I<--size> B<bytes>]
+
+Sets and/or gets size of the cache (in bytes) used for compressing repeatedly
+transferred memory pages during live migration. When called without I<size>,
+the command just prints current size of the compression cache. When I<size>
+is specified, the hypervisor is asked to change compression cache to I<size>
+bytes and then the current size is printed (the result may differ from the
+requested size due to rounding done by the hypervisor). The I<size> option
+is supposed to be used while the domain is being live-migrated as a reaction
+to migration progress and increasing number of compression cache misses
+obtained from domjobinfo.
+
=item B<migrate-setspeed> I<domain> I<bandwidth>
Set the maximum migration bandwidth (in MiB/s) for a domain which is being
--
1.8.3.1