mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
qemu: implement qemuDomainGraphicsReload
The 'display-reload' QMP command had been introduced from QEMU 6.0.0:
9cc0765165
Currently it only supports reloading TLS certificates for VNC.
Resloves: https://issues.redhat.com/browse/RHEL-16333
Signed-off-by: Zheng Yan <yanzheng759@huawei.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
21e68a9ce7
commit
a74897efe6
@ -19932,6 +19932,68 @@ qemuDomainFDAssociate(virDomainPtr domain,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
qemuDomainGraphicsReload(virDomainPtr domain,
|
||||
unsigned int type,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret = -1;
|
||||
virDomainObj *vm = NULL;
|
||||
qemuDomainObjPrivate *priv;
|
||||
|
||||
virCheckFlagsGoto(0, cleanup);
|
||||
|
||||
if (type >= VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_LAST) {
|
||||
virReportInvalidArg(type,
|
||||
_("type must be less than %1$d"),
|
||||
VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_LAST);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(vm = qemuDomainObjFromDomain(domain)))
|
||||
return -1;
|
||||
|
||||
if (virDomainGraphicsReloadEnsureACL(domain->conn, vm->def))
|
||||
goto 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 +20244,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
|
||||
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
|
||||
.domainSetLaunchSecurityState = qemuDomainSetLaunchSecurityState, /* 8.0.0 */
|
||||
.domainFDAssociate = qemuDomainFDAssociate, /* 9.0.0 */
|
||||
.domainGraphicsReload = qemuDomainGraphicsReload, /* 10.2.0 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1581,3 +1581,8 @@ qemuMonitorExtractQueryStats(virJSONValue *info);
|
||||
virJSONValue *
|
||||
qemuMonitorGetStatsByQOMPath(virJSONValue *arr,
|
||||
char *qom_path);
|
||||
|
||||
int
|
||||
qemuMonitorDisplayReload(qemuMonitor *mon,
|
||||
const char *type,
|
||||
bool tlsCerts);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -825,3 +825,7 @@ qemuMonitorJSONQueryStats(qemuMonitor *mon,
|
||||
qemuMonitorQueryStatsTargetType target,
|
||||
char **vcpus,
|
||||
GPtrArray *providers);
|
||||
|
||||
int qemuMonitorJSONDisplayReload(qemuMonitor *mon,
|
||||
const char *type,
|
||||
bool tlsCerts);
|
||||
|
Loading…
Reference in New Issue
Block a user