Skip to content

Commit 67c1115

Browse files
committed
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210323-pull-request' into staging
fixes for 6.0 # gpg: Signature made Tue 23 Mar 2021 15:36:06 GMT # gpg: using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <[email protected]>" [full] # gpg: aka "Gerd Hoffmann <[email protected]>" [full] # gpg: aka "Gerd Hoffmann (private) <[email protected]>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20210323-pull-request: edid: prefer standard timings include/ui/console.h: Delete is_surface_bgr() qmp: add new qmp display-reload vnc: support reload x509 certificates for vnc crypto: add reload for QCryptoTLSCredsClass Signed-off-by: Peter Maydell <[email protected]>
2 parents 2664699 + 40c5030 commit 67c1115

File tree

7 files changed

+168
-20
lines changed

7 files changed

+168
-20
lines changed

crypto/tlscredsx509.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,51 @@ qcrypto_tls_creds_x509_prop_get_sanity(Object *obj,
770770
}
771771

772772

773+
#ifdef CONFIG_GNUTLS
774+
775+
776+
static bool
777+
qcrypto_tls_creds_x509_reload(QCryptoTLSCreds *creds, Error **errp)
778+
{
779+
QCryptoTLSCredsX509 *x509_creds = QCRYPTO_TLS_CREDS_X509(creds);
780+
Error *local_err = NULL;
781+
gnutls_certificate_credentials_t creds_data = x509_creds->data;
782+
gnutls_dh_params_t creds_dh_params = x509_creds->parent_obj.dh_params;
783+
784+
x509_creds->data = NULL;
785+
x509_creds->parent_obj.dh_params = NULL;
786+
qcrypto_tls_creds_x509_load(x509_creds, &local_err);
787+
if (local_err) {
788+
qcrypto_tls_creds_x509_unload(x509_creds);
789+
x509_creds->data = creds_data;
790+
x509_creds->parent_obj.dh_params = creds_dh_params;
791+
error_propagate(errp, local_err);
792+
return false;
793+
}
794+
795+
if (creds_data) {
796+
gnutls_certificate_free_credentials(creds_data);
797+
}
798+
if (creds_dh_params) {
799+
gnutls_dh_params_deinit(creds_dh_params);
800+
}
801+
return true;
802+
}
803+
804+
805+
#else /* ! CONFIG_GNUTLS */
806+
807+
808+
static bool
809+
qcrypto_tls_creds_x509_reload(QCryptoTLSCreds *creds, Error **errp)
810+
{
811+
return false;
812+
}
813+
814+
815+
#endif /* ! CONFIG_GNUTLS */
816+
817+
773818
static void
774819
qcrypto_tls_creds_x509_complete(UserCreatable *uc, Error **errp)
775820
{
@@ -800,6 +845,9 @@ static void
800845
qcrypto_tls_creds_x509_class_init(ObjectClass *oc, void *data)
801846
{
802847
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
848+
QCryptoTLSCredsClass *ctcc = QCRYPTO_TLS_CREDS_CLASS(oc);
849+
850+
ctcc->reload = qcrypto_tls_creds_x509_reload;
803851

804852
ucc->complete = qcrypto_tls_creds_x509_complete;
805853

hw/display/edid-generate.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ static const struct edid_mode {
2525
{ .xres = 1920, .yres = 1080, .dta = 31 },
2626

2727
/* additional standard timings 3 (all @ 60Hz) */
28-
{ .xres = 1920, .yres = 1440, .xtra3 = 11, .bit = 5 },
2928
{ .xres = 1920, .yres = 1200, .xtra3 = 10, .bit = 0 },
30-
{ .xres = 1856, .yres = 1392, .xtra3 = 10, .bit = 3 },
31-
{ .xres = 1792, .yres = 1344, .xtra3 = 10, .bit = 5 },
3229
{ .xres = 1600, .yres = 1200, .xtra3 = 9, .bit = 2 },
3330
{ .xres = 1680, .yres = 1050, .xtra3 = 9, .bit = 5 },
34-
{ .xres = 1440, .yres = 1050, .xtra3 = 8, .bit = 1 },
3531
{ .xres = 1440, .yres = 900, .xtra3 = 8, .bit = 5 },
36-
{ .xres = 1360, .yres = 768, .xtra3 = 8, .bit = 7 },
3732
{ .xres = 1280, .yres = 1024, .xtra3 = 7, .bit = 1 },
3833
{ .xres = 1280, .yres = 960, .xtra3 = 7, .bit = 3 },
3934
{ .xres = 1280, .yres = 768, .xtra3 = 7, .bit = 6 },
4035

36+
{ .xres = 1920, .yres = 1440, .xtra3 = 11, .bit = 5 },
37+
{ .xres = 1856, .yres = 1392, .xtra3 = 10, .bit = 3 },
38+
{ .xres = 1792, .yres = 1344, .xtra3 = 10, .bit = 5 },
39+
{ .xres = 1440, .yres = 1050, .xtra3 = 8, .bit = 1 },
40+
{ .xres = 1360, .yres = 768, .xtra3 = 8, .bit = 7 },
41+
4142
/* established timings (all @ 60Hz) */
4243
{ .xres = 1024, .yres = 768, .byte = 36, .bit = 3 },
4344
{ .xres = 800, .yres = 600, .byte = 35, .bit = 0 },
@@ -109,13 +110,13 @@ static void edid_fill_modes(uint8_t *edid, uint8_t *xtra3, uint8_t *dta,
109110

110111
if (mode->byte) {
111112
edid[mode->byte] |= (1 << mode->bit);
112-
} else if (mode->xtra3 && xtra3) {
113-
xtra3[mode->xtra3] |= (1 << mode->bit);
114113
} else if (std < 54) {
115114
rc = edid_std_mode(edid + std, mode->xres, mode->yres);
116115
if (rc == 0) {
117116
std += 2;
118117
}
118+
} else if (mode->xtra3 && xtra3) {
119+
xtra3[mode->xtra3] |= (1 << mode->bit);
119120
}
120121

121122
if (dta && mode->dta) {

include/crypto/tlscreds.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@
3030

3131
#define TYPE_QCRYPTO_TLS_CREDS "tls-creds"
3232
typedef struct QCryptoTLSCreds QCryptoTLSCreds;
33-
DECLARE_INSTANCE_CHECKER(QCryptoTLSCreds, QCRYPTO_TLS_CREDS,
34-
TYPE_QCRYPTO_TLS_CREDS)
35-
3633
typedef struct QCryptoTLSCredsClass QCryptoTLSCredsClass;
34+
DECLARE_OBJ_CHECKERS(QCryptoTLSCreds, QCryptoTLSCredsClass, QCRYPTO_TLS_CREDS,
35+
TYPE_QCRYPTO_TLS_CREDS)
36+
3737

3838
#define QCRYPTO_TLS_CREDS_DH_PARAMS "dh-params.pem"
3939

4040

41+
typedef bool (*CryptoTLSCredsReload)(QCryptoTLSCreds *, Error **);
4142
/**
4243
* QCryptoTLSCreds:
4344
*
@@ -61,6 +62,7 @@ struct QCryptoTLSCreds {
6162

6263
struct QCryptoTLSCredsClass {
6364
ObjectClass parent_class;
65+
CryptoTLSCredsReload reload;
6466
};
6567

6668

include/ui/console.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,6 @@ PixelFormat qemu_default_pixelformat(int bpp);
267267
DisplaySurface *qemu_create_displaysurface(int width, int height);
268268
void qemu_free_displaysurface(DisplaySurface *surface);
269269

270-
static inline int is_surface_bgr(DisplaySurface *surface)
271-
{
272-
if (PIXMAN_FORMAT_BPP(surface->format) == 32 &&
273-
PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) {
274-
return 1;
275-
} else {
276-
return 0;
277-
}
278-
}
279-
280270
static inline int is_buffer_shared(DisplaySurface *surface)
281271
{
282272
return !(surface->flags & QEMU_ALLOCATED_FLAG);
@@ -476,6 +466,7 @@ int vnc_display_password(const char *id, const char *password);
476466
int vnc_display_pw_expire(const char *id, time_t expires);
477467
void vnc_parse(const char *str);
478468
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
469+
bool vnc_display_reload_certs(const char *id, Error **errp);
479470

480471
/* input.c */
481472
int index_from_key(const char *key, size_t key_length);

monitor/qmp-cmds.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,20 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp)
334334

335335
return mem_info;
336336
}
337+
338+
void qmp_display_reload(DisplayReloadOptions *arg, Error **errp)
339+
{
340+
switch (arg->type) {
341+
case DISPLAY_RELOAD_TYPE_VNC:
342+
#ifdef CONFIG_VNC
343+
if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) {
344+
vnc_display_reload_certs(NULL, errp);
345+
}
346+
#else
347+
error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'");
348+
#endif
349+
break;
350+
default:
351+
abort();
352+
}
353+
}

qapi/ui.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,3 +1168,64 @@
11681168
##
11691169
{ 'command': 'query-display-options',
11701170
'returns': 'DisplayOptions' }
1171+
1172+
##
1173+
# @DisplayReloadType:
1174+
#
1175+
# Available DisplayReload types.
1176+
#
1177+
# @vnc: VNC display
1178+
#
1179+
# Since: 6.0
1180+
#
1181+
##
1182+
{ 'enum': 'DisplayReloadType',
1183+
'data': ['vnc'] }
1184+
1185+
##
1186+
# @DisplayReloadOptionsVNC:
1187+
#
1188+
# Specify the VNC reload options.
1189+
#
1190+
# @tls-certs: reload tls certs or not.
1191+
#
1192+
# Since: 6.0
1193+
#
1194+
##
1195+
{ 'struct': 'DisplayReloadOptionsVNC',
1196+
'data': { '*tls-certs': 'bool' } }
1197+
1198+
##
1199+
# @DisplayReloadOptions:
1200+
#
1201+
# Options of the display configuration reload.
1202+
#
1203+
# @type: Specify the display type.
1204+
#
1205+
# Since: 6.0
1206+
#
1207+
##
1208+
{ 'union': 'DisplayReloadOptions',
1209+
'base': {'type': 'DisplayReloadType'},
1210+
'discriminator': 'type',
1211+
'data': { 'vnc': 'DisplayReloadOptionsVNC' } }
1212+
1213+
##
1214+
# @display-reload:
1215+
#
1216+
# Reload display configuration.
1217+
#
1218+
# Returns: Nothing on success.
1219+
#
1220+
# Since: 6.0
1221+
#
1222+
# Example:
1223+
#
1224+
# -> { "execute": "display-reload",
1225+
# "arguments": { "type": "vnc", "tls-certs": true } }
1226+
# <- { "return": {} }
1227+
#
1228+
##
1229+
{ 'command': 'display-reload',
1230+
'data': 'DisplayReloadOptions',
1231+
'boxed' : true }

ui/vnc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,34 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
585585
return prev;
586586
}
587587

588+
bool vnc_display_reload_certs(const char *id, Error **errp)
589+
{
590+
VncDisplay *vd = vnc_display_find(id);
591+
QCryptoTLSCredsClass *creds = NULL;
592+
593+
if (!vd) {
594+
error_setg(errp, "Can not find vnc display");
595+
return false;
596+
}
597+
598+
if (!vd->tlscreds) {
599+
error_setg(errp, "vnc tls is not enable");
600+
return false;
601+
}
602+
603+
creds = QCRYPTO_TLS_CREDS_GET_CLASS(OBJECT(vd->tlscreds));
604+
if (creds->reload == NULL) {
605+
error_setg(errp, "%s doesn't support to reload TLS credential",
606+
object_get_typename(OBJECT(vd->tlscreds)));
607+
return false;
608+
}
609+
if (!creds->reload(vd->tlscreds, errp)) {
610+
return false;
611+
}
612+
613+
return true;
614+
}
615+
588616
/* TODO
589617
1) Get the queue working for IO.
590618
2) there is some weirdness when using the -S option (the screen is grey

0 commit comments

Comments
 (0)