vnc: support reload x509 certificates
v6 cover vnc: support reload x509 certificates
This series supports reload x509 certificates for vnc
1. Support reload x509 certificates.
2. Support reload vnc certificates.
3. Add new qmp display-reload and implement reload x509 certificates for vnc.
Example:
{"execute": "display-reload", "arguments":{"type": "vnc", "tls-certs": true}}
Zihao Chang (3):
crypto: add reload for QCryptoTLSCredsClass
vnc: support reload x509 certificates for vnc
qmp: add new qmp display-reload
crypto/tlscredsx509.c | 49 +++++++++++++++++++++++++++++++ include/crypto/tlscreds.h | 8 +++-- include/ui/console.h | 1 + monitor/qmp-cmds.c | 15 ++++++++++ qapi/ui.json | 62 +++++++++++++++++++++++++++++++++++++++ ui/vnc.c | 28 ++++++++++++++++++ 6 files changed, 160 insertions(+), 3 deletions(-)
Signature · 1 line
2.28.0
PATCH v6 1/3 crypto: add reload for QCryptoTLSCredsClass
This patch adds reload interface for QCryptoTLSCredsClass and implements the interface for QCryptoTLSCredsX509.
--- crypto/tlscredsx509.c | 48 +++++++++++++++++++++++++++++++++++++++ include/crypto/tlscreds.h | 8 ++++--- 2 files changed, 53 insertions(+), 3 deletions(-)
crypto/tlscredsx509.c +48 -0
@@ -770,6 +770,51 @@ qcrypto_tls_creds_x509_prop_get_sanity(Object *obj, } +#ifdef CONFIG_GNUTLS + + +static bool +qcrypto_tls_creds_x509_reload (QCryptoTLSCreds *creds,Error **errp) +{ +QCryptoTLSCredsX509 *x509_creds =QCRYPTO_TLS_CREDS_X509 (creds); +Error *local_err =NULL ; +gnutls_certificate_credentials_t old_data = x509_creds->data; +gnutls_dh_params_t old_dh_params = x509_creds->parent_obj.dh_params; + + x509_creds->data =NULL ; + x509_creds->parent_obj.dh_params =NULL ; +qcrypto_tls_creds_x509_load (x509_creds, &local_err); +if (local_err) { +qcrypto_tls_creds_x509_unload (x509_creds); + x509_creds->data = old_data; + x509_creds->parent_obj.dh_params = old_dh_params; +error_propagate (errp, local_err); +return false; + } + +if (old_data) { +gnutls_certificate_free_credentials (old_data); + } +if (old_dh_params) { +gnutls_dh_params_deinit (old_dh_params); + } +return true; +} + + +#else /* ! CONFIG_GNUTLS */ + + +static bool +qcrypto_tls_creds_x509_reload (QCryptoTLSCreds *creds,Error **errp) +{ +return false; +} + + +#endif /* ! CONFIG_GNUTLS */ + +static void qcrypto_tls_creds_x509_complete (UserCreatable *uc,Error **errp) {
@@ -800,6 +845,9 @@ static void qcrypto_tls_creds_x509_class_init(ObjectClass *oc, void *data) {UserCreatableClass *ucc =USER_CREATABLE_CLASS (oc); +QCryptoTLSCredsClass *ctcc =QCRYPTO_TLS_CREDS_CLASS (oc); + + ctcc->reload = qcrypto_tls_creds_x509_reload; ucc->complete = qcrypto_tls_creds_x509_complete;
include/crypto/tlscreds.h +5 -3
@@ -30,14 +30,15 @@#define TYPE_QCRYPTO_TLS_CREDS "tls-creds"typedef struct QCryptoTLSCreds QCryptoTLSCreds ; -DECLARE_INSTANCE_CHECKER (QCryptoTLSCreds,QCRYPTO_TLS_CREDS , - TYPE_QCRYPTO_TLS_CREDS) -typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass ; +DECLARE_OBJ_CHECKERS (QCryptoTLSCreds, QCryptoTLSCredsClass,QCRYPTO_TLS_CREDS , + TYPE_QCRYPTO_TLS_CREDS) +#define QCRYPTO_TLS_CREDS_DH_PARAMS "dh-params.pem" +typedef bool (*CryptoTLSCredsReload )(QCryptoTLSCreds *,Error **);/** * QCryptoTLSCreds: *
@@ -61,6 +62,7 @@ struct QCryptoTLSCreds {struct QCryptoTLSCredsClass {ObjectClass parent_class; +CryptoTLSCredsReload reload; };
Signature · 1 line
2.28.0
PATCH v6 2/3 vnc: support reload x509 certificates for vnc
In reply to Zihao ChangThis patch add vnc_display_reload_certs() to support update x509 certificates.
--- include/ui/console.h | 1 + ui/vnc.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
include/ui/console.h +1 -0
@@ -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);
ui/vnc.c +28 -0
@@ -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
Signature · 1 line
2.28.0
PATCH v6 3/3 qmp: add new qmp display-reload
In reply to Zihao ChangThis patch provides a new qmp to reload display configuration without restart VM, but only reloading the vnc tls certificates is implemented.
Example:
{"execute": "display-reload", "arguments":{"type": "vnc", "tls-certs": true}}
--- monitor/qmp-cmds.c | 15 +++++++++++ qapi/ui.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
monitor/qmp-cmds.c +15 -0
@@ -334,3 +334,18 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)return mem_info; } + +void qmp_display_reload (DisplayReloadOptions *arg,Error **errp) +{ +switch (arg->type) { +case DISPLAY_RELOAD_TYPE_VNC : +if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) { +vnc_display_reload_certs (NULL , errp); + } +break ; + +default : +error_setg (errp,"unsupported DisplayReloadType" ); + + } +}
qapi/ui.json +62 -0
65 lines not on this page · raw message
Signature · 1 line
2.28.0
Re: [PATCH v6 3/3] qmp: add new qmp display-reload
Quoted 23 lines · Zihao Chang
This patch provides a new qmp to reload display configuration without restart VM, but only reloading the vnc tls certificates is implemented.
Example:
{"execute": "display-reload", "arguments":{"type": "vnc", "tls-certs": true}}Signed-off-by Zihao Chang <[email protected]>--- monitor/qmp-cmds.c | 15 +++++++++++ qapi/ui.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)monitor/qmp-cmds.c +3
-0@@ -334,3 +334,18 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)return mem_info; } + +void qmp_display_reload (DisplayReloadOptions *arg,Error **errp) +{
monitor/qmp-cmds.c MemoryInfo *qmp_query_memory_size_summary(Error **errp) · line 349
Quoted 10 lines
monitor/qmp-cmds.c +10
-0+switch (arg->type) { +case DISPLAY_RELOAD_TYPE_VNC : +if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) { +vnc_display_reload_certs (NULL , errp); + } +break ; + +default : +error_setg (errp,"unsupported DisplayReloadType" ); +
Misuse of error_setg() for a programming error. Use abort().
Quoted 62 lines
monitor/qmp-cmds.c +2
-0+ } +}qapi/ui.json +52
-0@@ -1179,3 +1179,65 @@ ## { 'command': 'query-display-options', 'returns': 'DisplayOptions' } + +## +# @DisplayReloadType: +# +# Available DisplayReload types. +# +# @vnc: VNC display +# +# Since: 6.0 +# +## +{ 'enum': 'DisplayReloadType', + 'data': ['vnc'] } + +## +# @DisplayReloadOptionsVNC: +# +# Specify the VNC reload options. +# +# @tls-certs: reload tls certs or not. +# +# Since: 6.0 +# +## +{ 'struct': 'DisplayReloadOptionsVNC', + 'data': { '*tls-certs': 'bool' } } + +## +# @DisplayReloadOptions: +# +# Options of the display configuration reload. +# +# @type: Specify the display type. +# +# Since: 6.0 +# +## +{ 'union': 'DisplayReloadOptions', + 'base': {'type': 'DisplayReloadType'}, + 'discriminator': 'type', + 'data': { 'vnc': 'DisplayReloadOptionsVNC' }} + +## +# @display-reload: +# +# Reload display configuration. +# +# Returns: Nothing on success. +# +# Since: 6.0 +# +# Example:
qapi/ui.json line 1243
Quoted 10 lines
qapi/ui.json +10
-0+# +# -> { "execute": "display-reload", +# "arguments": { "type": "vnc", "tls-certs": true } } +# <- { "return": {} } +# +## +{ 'command': 'display-reload', + 'data': 'DisplayReloadOptions', + 'boxed' : true } +
Trim the blank line at the end of the file, please.
With these tidied up: