From: Scott Garfinkle <seg(a)us.ibm.com>
virsh migrate-getmaxdowntime qemu driver enablement
Signed-off-by: Scott Garfinkle <seg(a)us.ibm.com>
---
src/qemu/qemu_driver.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.h | 3 +++
src/qemu/qemu_monitor_json.c | 40 +++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 +++
4 files changed, 91 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 8d261b7..72b4d8c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13152,6 +13152,50 @@ qemuDomainMigrateSetMaxDowntime(virDomainPtr dom,
return ret;
}
+
+static int
+qemuDomainMigrateGetMaxDowntime(virDomainPtr dom,
+ unsigned long long *downtime,
+ unsigned int flags)
+{
+ virQEMUDriverPtr driver = dom->conn->privateData;
+ virDomainObjPtr vm;
+ qemuDomainObjPrivatePtr priv;
+ int ret = -1;
+
+ virCheckFlags(0, -1);
+
+ if (!(vm = qemuDomObjFromDomain(dom)))
+ goto cleanup;
+
+ if (virDomainMigrateGetMaxDowntimeEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ priv = vm->privateData;
+ qemuDomainObjEnterMonitor(driver, vm);
+
+ ret = qemuMonitorGetMigrationDowntime(priv->mon, downtime);
+
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ ret = -1;
+
+ endjob:
+ qemuDomainObjEndJob(driver, vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
static int
qemuDomainMigrateGetCompressionCache(virDomainPtr dom,
unsigned long long *cacheSize,
@@ -20796,6 +20840,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainGetJobInfo = qemuDomainGetJobInfo, /* 0.7.7 */
.domainGetJobStats = qemuDomainGetJobStats, /* 1.0.3 */
.domainAbortJob = qemuDomainAbortJob, /* 0.7.7 */
+ .domainMigrateGetMaxDowntime = qemuDomainMigrateGetMaxDowntime, /* 3.6.0 */
.domainMigrateSetMaxDowntime = qemuDomainMigrateSetMaxDowntime, /* 0.8.0 */
.domainMigrateGetCompressionCache = qemuDomainMigrateGetCompressionCache, /* 1.0.3
*/
.domainMigrateSetCompressionCache = qemuDomainMigrateSetCompressionCache, /* 1.0.3
*/
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 1697db5..d094d09 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -595,6 +595,9 @@ int qemuMonitorSavePhysicalMemory(qemuMonitorPtr mon,
int qemuMonitorSetMigrationSpeed(qemuMonitorPtr mon,
unsigned long bandwidth);
+int qemuMonitorGetMigrationDowntime(qemuMonitorPtr mon,
+ unsigned long long *downtime);
+
int qemuMonitorSetMigrationDowntime(qemuMonitorPtr mon,
unsigned long long downtime);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 65b1fbb..baf03a8 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2453,6 +2453,46 @@ int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
}
+int qemuMonitorJSONGetMigrationDowntime(qemuMonitorPtr mon,
+ unsigned long long *downtime)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr result;
+ unsigned int value = 0;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-parameters", NULL)))
+ return -1;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ goto cleanup;
+
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound"))
+ goto cleanup;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ goto cleanup;
+
+ if (!(result = virJSONValueObjectGet(reply, "return")))
+ goto cleanup;
+
+ if (virJSONValueObjectGetNumberUint(result, "downtime-limit", &value)
< 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("missing migration capabilities"));
+ goto cleanup;
+ }
+
+ *downtime = value;
+ ret = 0;
+
+ cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
+
int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
const char *dev_name,
const char *newmedia,
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index d090d57..1626085 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -128,6 +128,9 @@ int qemuMonitorJSONSetMigrationSpeed(qemuMonitorPtr mon,
int qemuMonitorJSONSetMigrationDowntime(qemuMonitorPtr mon,
unsigned long long downtime);
+int qemuMonitorJSONGetMigrationDowntime(qemuMonitorPtr mon,
+ unsigned long long *downtime);
+
int qemuMonitorJSONGetMigrationCacheSize(qemuMonitorPtr mon,
unsigned long long *cacheSize);
int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
--
1.8.3.1