Hi team,
struct _virHypervisorDriver now have more than 260 APIs to management various hypervisor drivers,
including hardware resources and lifecycle, etc.
But, there is no API for (re)set display devices and its parameters.
Take the following uses the QEMU driver as an example.
To update the VNC TLS certificates without restart virtual machine, run the following command:
{"execute": "display-reload", "arguments":{"type": "vnc", "tls-certs": true}}
Refers:
https://gitlab.com/qemu-project/qemu/-/commit/9cc07651655ee86eca41059f5ead8c4e5607c734
Can we add a new libvirt API to set the hypervisor driver display configurations ?
If the committer team thinks it's worth doing, I can submit patches to implement the function.
e,g.
The preceding QMP commands ‘display-reload’ can be encapsulated in this way:
index 42c75f6cc5..ab5ae0a3e6 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -13218,3 +13218,16 @@ virDomainStartDirtyRateCalc(virDomainPtr domain,
virDispatchError(conn);
return -1;
}
+
+int
+virDomainSetDisplayParameters(virDomainPtr domain,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags)
+{
+ ...
+ if (conn->driver->domainSetDisplayParameters) {
+ conn->driver->domainSetDisplayParameters(domain, params, nparams, flags);
+ }
+ ...
+}
index d642af8a37..197da82556 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1410,6 +1410,12 @@ typedef int
int seconds,
unsigned int flags);
+typedef int
+(*virDrvDomainSetDisplayParameters)(virDomainPtr domain.
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
/**
@@ -1676,4 +1682,5 @@ struct _virHypervisorDriver {
virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet;
virDrvDomainGetMessages domainGetMessages;
virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
+ virDrvDomainSetDisplayParameters domainSetDisplayParameters;
};
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20454,6 +20454,21 @@ qemuDomainStartDirtyRateCalc(virDomainPtr dom,
return ret;
}
+static int
+qemuDomainSetDisplayParameters(virDomainPtr domain,
+ virTypedParameterPtr params,
+ int nparams,
+ unsigned int flags)
+{
+ ...
+ if (params has 'display-reload')
+ virDomainQemuMonitorCommand(domain, strJsonCmd, &reply,
+ VIR_DOMAIN_QEMU_MONITOR_COMMAND_DEFAULT);
+ else if (...) {
+ /* other display parameters setting */
+ }
+ ...
+}
static virHypervisorDriver qemuHypervisorDriver = {
.name = QEMU_DRIVER_NAME,
@@ -20698,6 +20713,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
.domainAuthorizedSSHKeysSet = qemuDomainAuthorizedSSHKeysSet, /* 6.10.0 */
.domainGetMessages = qemuDomainGetMessages, /* 7.1.0 */
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
+ .domainSetDisplayParameters = qemuDomainSetDisplayParameters; /* 7.2.0 */
};
Regards :)