All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zihao Chang <changzihao1@huawei.com>
To: <qemu-devel@nongnu.org>
Cc: berrange@redhat.com, oscar.zhangbo@huawei.com,
	changzihao1@huawei.com, armbru@redhat.com,
	xiexiangyou@huawei.com, yebiaoxiang@huawei.com,
	kraxel@redhat.com
Subject: [PATCH v7 2/3] vnc: support reload x509 certificates for vnc
Date: Mon, 15 Mar 2021 21:16:08 +0800	[thread overview]
Message-ID: <20210315131609.2208-3-changzihao1@huawei.com> (raw)
In-Reply-To: <20210315131609.2208-1-changzihao1@huawei.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="y", Size: 1905 bytes --]

This patch add vnc_display_reload_certs() to support
update x509 certificates.

Signed-off-by: Zihao Chang <changzihao1@huawei.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/ui/console.h |  1 +
 ui/vnc.c             | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index c960b7066ccd..2714038a0fae 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -476,6 +476,7 @@ int vnc_display_password(const char *id, const char *password);
 int vnc_display_pw_expire(const char *id, time_t expires);
 void vnc_parse(const char *str);
 int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
+bool vnc_display_reload_certs(const char *id,  Error **errp);
 
 /* input.c */
 int index_from_key(const char *key, size_t key_length);
diff --git a/ui/vnc.c b/ui/vnc.c
index 310abc937812..381e21a87563 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -584,6 +584,34 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
     return prev;
 }
 
+bool vnc_display_reload_certs(const char *id, Error **errp)
+{
+    VncDisplay *vd = vnc_display_find(id);
+    QCryptoTLSCredsClass *creds = NULL;
+
+    if (!vd) {
+        error_setg(errp, "Can not find vnc display");
+        return false;
+    }
+
+    if (!vd->tlscreds) {
+        error_setg(errp, "vnc tls is not enable");
+        return false;
+    }
+
+    creds = QCRYPTO_TLS_CREDS_GET_CLASS(OBJECT(vd->tlscreds));
+    if (creds->reload == NULL) {
+        error_setg(errp, "%s doesn't support to reload TLS credential",
+                   object_get_typename(OBJECT(vd->tlscreds)));
+        return false;
+    }
+    if (!creds->reload(vd->tlscreds, errp)) {
+        return false;
+    }
+
+    return true;
+}
+
 /* TODO
    1) Get the queue working for IO.
    2) there is some weirdness when using the -S option (the screen is grey
-- 
2.28.0



  parent reply	other threads:[~2021-03-15 13:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 13:16 [PATCH v7 0/3] vnc: support reload x509 certificates Zihao Chang
2021-03-15 13:16 ` [PATCH v7 1/3] crypto: add reload for QCryptoTLSCredsClass Zihao Chang
2021-03-15 13:32   ` Daniel P. Berrangé
2021-03-15 13:16 ` Zihao Chang [this message]
2021-03-15 13:16 ` [PATCH v7 3/3] qmp: add new qmp display-reload Zihao Chang
2021-03-15 13:31   ` Daniel P. Berrangé
2021-03-15 18:07 ` [PATCH v7 0/3] vnc: support reload x509 certificates Gerd Hoffmann
2021-03-16  8:13   ` Zihao Chang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315131609.2208-3-changzihao1@huawei.com \
    --to=changzihao1@huawei.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=oscar.zhangbo@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=xiexiangyou@huawei.com \
    --cc=yebiaoxiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.