From: Zheng Yan <yanzheng759(a)huawei.com>
The 'display-reload' QMP command had been introduced from QEMU 6.0.0:
https://gitlab.com/qemu-project/qemu/-/commit/9cc07651655ee86eca41059f5ea...
Currently it only supports reloading TLS certificates for VNC.
https://issues.redhat.com/browse/RHEL-16333
Signed-off-by: Zheng Yan <yanzheng759(a)huawei.com>
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor.c | 10 +++++++
src/qemu/qemu_monitor.h | 5 ++++
src/qemu/qemu_monitor_json.c | 23 +++++++++++++++
src/qemu/qemu_monitor_json.h | 4 +++
5 files changed, 96 insertions(+)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 448e6b1591..22e9f743cb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -19932,6 +19932,59 @@ qemuDomainFDAssociate(virDomainPtr domain,
return ret;
}
+static int
+qemuDomainGraphicsReload(virDomainPtr domain,
+ unsigned int type,
+ unsigned int flags)
+{
+ int ret = -1;
+ virDomainObj *vm = NULL;
+ qemuDomainObjPrivate *priv;
+
+ if (!(vm = qemuDomainObjFromDomain(domain)))
+ return -1;
+
+ if (virDomainGraphicsReloadEnsureACL(domain->conn, vm->def))
+ goto cleanup;
+
+ virCheckFlagsGoto(0, cleanup);
+
+ if (type == VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_ANY) {
+ size_t i;
+ for (i = 0; i < vm->def->ngraphics; i++) {
+ if (vm->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC)
+ break;
+ }
+ if (i == vm->def->ngraphics) {
+ ret = 0;
+ goto cleanup;
+ }
+ }
+
+ if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto endjob;
+ }
+
+ priv = vm->privateData;
+
+ qemuDomainObjEnterMonitor(vm);
+
+ ret = qemuMonitorDisplayReload(priv->mon, "vnc", true);
+
+ qemuDomainObjExitMonitor(vm);
+
+ endjob:
+ virDomainObjEndJob(vm);
+
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
static virHypervisorDriver qemuHypervisorDriver = {
.name = QEMU_DRIVER_NAME,
@@ -20182,6 +20235,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
.domainSetLaunchSecurityState = qemuDomainSetLaunchSecurityState, /* 8.0.0 */
.domainFDAssociate = qemuDomainFDAssociate, /* 9.0.0 */
+ .domainGraphicsReload = qemuDomainGraphicsReload, /* 10.2.0 */
};
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 0f29fb02b4..34e2ccab97 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4501,3 +4501,13 @@ qemuMonitorGetStatsByQOMPath(virJSONValue *arr,
return NULL;
}
+
+int
+qemuMonitorDisplayReload(qemuMonitor *mon,
+ const char *type,
+ bool tlsCerts)
+{
+ QEMU_CHECK_MONITOR(mon);
+
+ return qemuMonitorJSONDisplayReload(mon, type, tlsCerts);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 981c609e9f..6e81945201 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1581,3 +1581,8 @@ qemuMonitorExtractQueryStats(virJSONValue *info);
virJSONValue *
qemuMonitorGetStatsByQOMPath(virJSONValue *arr,
char *qom_path);
+
+int
+qemuMonitorDisplayReload(qemuMonitor *mon,
+ const char *type,
+ bool tlsCerts);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 7aab34c7c4..eb84a3d938 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -8873,3 +8873,26 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon,
return virJSONValueObjectStealArray(reply, "return");
}
+
+int qemuMonitorJSONDisplayReload(qemuMonitor *mon,
+ const char *type,
+ bool tlsCerts)
+{
+ g_autoptr(virJSONValue) reply = NULL;
+ g_autoptr(virJSONValue) cmd = NULL;
+
+ cmd = qemuMonitorJSONMakeCommand("display-reload",
+ "s:type", type,
+ "b:tls-certs", tlsCerts,
+ NULL);
+ if (!cmd)
+ return -1;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ return -1;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ return -1;
+
+ return 0;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index ed0027c118..9684660d86 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -825,3 +825,7 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon,
qemuMonitorQueryStatsTargetType target,
char **vcpus,
GPtrArray *providers);
+
+int qemuMonitorJSONDisplayReload(qemuMonitor *mon,
+ const char *type,
+ bool tlsCerts);
--
2.43.2