[libvirt PATCH 2/5] libvirt: Introduce virDomainGraphicsReload API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zheng Yan <yanzheng759@xxxxxxxxxx>

The new virDomainGraphicsReload API is used to make the domain reload
its certificates without restart, and avoid service interruption.

Currently, only QEMU VNC TLS certificates are supported, but parameters and
flags are also reserved for subsequent scenarios.

To reload QEMU VNC TLS certificates as an example, we can call:

  virDomainGraphicsReload(domain, 0, 0);

Then the specified QMP message would be send to QEMU:
{"execute": "display-reload", "arguments":{"type": "vnc", "tls-certs": true}}

Signed-off-by: Zheng Yan <yanzheng759@xxxxxxxxxx>
Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h | 18 ++++++++++++
 src/driver-hypervisor.h          |  6 ++++
 src/libvirt-domain.c             | 50 ++++++++++++++++++++++++++++++++
 src/libvirt_public.syms          |  5 ++++
 4 files changed, 79 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 30cce85b29..2f5b01bbfe 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -6507,4 +6507,22 @@ int virDomainFDAssociate(virDomainPtr domain,
                          int *fds,
                          unsigned int flags);
 
+/**
+ * virDomainGraphicsReloadType:
+ *
+ * Since: 10.2.0
+ */
+typedef enum {
+    VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_ANY = 0, /* reload any graphics known to libvirt (Since: 10.2.0) */
+    VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_VNC = 1, /* reload vnc graphics (Since: 10.2.0) */
+# ifdef VIR_ENUM_SENTINELS
+    VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_LAST /* (Since: 10.2.0) */
+# endif
+} virDomainGraphicsReloadType;
+
+int
+virDomainGraphicsReload(virDomainPtr domain,
+                        unsigned int type,
+                        unsigned int flags);
+
 #endif /* LIBVIRT_DOMAIN_H */
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 5219344b72..4ce8da078d 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1448,6 +1448,11 @@ typedef int
                            int *fds,
                            unsigned int flags);
 
+typedef int
+(*virDrvDomainGraphicsReload)(virDomainPtr domain,
+                              unsigned int type,
+                              unsigned int flags);
+
 typedef struct _virHypervisorDriver virHypervisorDriver;
 
 /**
@@ -1720,4 +1725,5 @@ struct _virHypervisorDriver {
     virDrvDomainGetMessages domainGetMessages;
     virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
     virDrvDomainFDAssociate domainFDAssociate;
+    virDrvDomainGraphicsReload domainGraphicsReload;
 };
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 83abad251e..5a45b16275 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -14118,3 +14118,53 @@ virDomainFDAssociate(virDomainPtr domain,
     virDispatchError(conn);
     return -1;
 }
+
+
+/**
+ * virDomainGraphicsReload:
+ * @domain: a domain object
+ * @type: graphics type; from the virDomainGraphicsReloadType enum
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Reload domain's graphics.
+ *
+ * Returns 0 in case of success, -1 otherwise.
+ *
+ * Since: 10.2.0
+ */
+int
+virDomainGraphicsReload(virDomainPtr domain,
+                        unsigned int type,
+                        unsigned int flags)
+{
+    virConnectPtr conn;
+
+    VIR_DOMAIN_DEBUG(domain, "type=%u, flags=0x%x", type, flags);
+
+    virResetLastError();
+
+    virCheckDomainReturn(domain, -1);
+    conn = domain->conn;
+    virCheckReadOnlyGoto(conn->flags, error);
+
+    if (type >= VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_LAST) {
+        virReportInvalidArg(type,
+                            _("type must be less than %1$d"),
+                            VIR_DOMAIN_GRAPHICS_RELOAD_TYPE_LAST);
+        goto error;
+    }
+
+    if (conn->driver->domainGraphicsReload) {
+        int ret;
+        ret = conn->driver->domainGraphicsReload(domain, type, flags);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virReportUnsupportedError();
+
+ error:
+    virDispatchError(domain->conn);
+    return -1;
+}
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 0304b8f824..7a3492d9d7 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -943,4 +943,9 @@ LIBVIRT_10.1.0 {
         virNodeDeviceUpdate;
 } LIBVIRT_9.7.0;
 
+LIBVIRT_10.2.0 {
+    global:
+        virDomainGraphicsReload;
+} LIBVIRT_10.1.0;
+
 # .... define new API here using predicted next version number ....
-- 
2.43.2
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux