Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20210323-pull-re…
Browse files Browse the repository at this point in the history
…quest' 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]>
  • Loading branch information
pm215 committed Mar 23, 2021
2 parents 2664699 + 40c5030 commit 67c1115
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 20 deletions.
48 changes: 48 additions & 0 deletions crypto/tlscredsx509.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 creds_data = x509_creds->data;
gnutls_dh_params_t creds_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 = creds_data;
x509_creds->parent_obj.dh_params = creds_dh_params;
error_propagate(errp, local_err);
return false;
}

if (creds_data) {
gnutls_certificate_free_credentials(creds_data);
}
if (creds_dh_params) {
gnutls_dh_params_deinit(creds_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)
{
Expand Down Expand Up @@ -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;

Expand Down
15 changes: 8 additions & 7 deletions hw/display/edid-generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ static const struct edid_mode {
{ .xres = 1920, .yres = 1080, .dta = 31 },

/* additional standard timings 3 (all @ 60Hz) */
{ .xres = 1920, .yres = 1440, .xtra3 = 11, .bit = 5 },
{ .xres = 1920, .yres = 1200, .xtra3 = 10, .bit = 0 },
{ .xres = 1856, .yres = 1392, .xtra3 = 10, .bit = 3 },
{ .xres = 1792, .yres = 1344, .xtra3 = 10, .bit = 5 },
{ .xres = 1600, .yres = 1200, .xtra3 = 9, .bit = 2 },
{ .xres = 1680, .yres = 1050, .xtra3 = 9, .bit = 5 },
{ .xres = 1440, .yres = 1050, .xtra3 = 8, .bit = 1 },
{ .xres = 1440, .yres = 900, .xtra3 = 8, .bit = 5 },
{ .xres = 1360, .yres = 768, .xtra3 = 8, .bit = 7 },
{ .xres = 1280, .yres = 1024, .xtra3 = 7, .bit = 1 },
{ .xres = 1280, .yres = 960, .xtra3 = 7, .bit = 3 },
{ .xres = 1280, .yres = 768, .xtra3 = 7, .bit = 6 },

{ .xres = 1920, .yres = 1440, .xtra3 = 11, .bit = 5 },
{ .xres = 1856, .yres = 1392, .xtra3 = 10, .bit = 3 },
{ .xres = 1792, .yres = 1344, .xtra3 = 10, .bit = 5 },
{ .xres = 1440, .yres = 1050, .xtra3 = 8, .bit = 1 },
{ .xres = 1360, .yres = 768, .xtra3 = 8, .bit = 7 },

/* established timings (all @ 60Hz) */
{ .xres = 1024, .yres = 768, .byte = 36, .bit = 3 },
{ .xres = 800, .yres = 600, .byte = 35, .bit = 0 },
Expand Down Expand Up @@ -109,13 +110,13 @@ static void edid_fill_modes(uint8_t *edid, uint8_t *xtra3, uint8_t *dta,

if (mode->byte) {
edid[mode->byte] |= (1 << mode->bit);
} else if (mode->xtra3 && xtra3) {
xtra3[mode->xtra3] |= (1 << mode->bit);
} else if (std < 54) {
rc = edid_std_mode(edid + std, mode->xres, mode->yres);
if (rc == 0) {
std += 2;
}
} else if (mode->xtra3 && xtra3) {
xtra3[mode->xtra3] |= (1 << mode->bit);
}

if (dta && mode->dta) {
Expand Down
8 changes: 5 additions & 3 deletions include/crypto/tlscreds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand All @@ -61,6 +62,7 @@ struct QCryptoTLSCreds {

struct QCryptoTLSCredsClass {
ObjectClass parent_class;
CryptoTLSCredsReload reload;
};


Expand Down
11 changes: 1 addition & 10 deletions include/ui/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,6 @@ PixelFormat qemu_default_pixelformat(int bpp);
DisplaySurface *qemu_create_displaysurface(int width, int height);
void qemu_free_displaysurface(DisplaySurface *surface);

static inline int is_surface_bgr(DisplaySurface *surface)
{
if (PIXMAN_FORMAT_BPP(surface->format) == 32 &&
PIXMAN_FORMAT_TYPE(surface->format) == PIXMAN_TYPE_ABGR) {
return 1;
} else {
return 0;
}
}

static inline int is_buffer_shared(DisplaySurface *surface)
{
return !(surface->flags & QEMU_ALLOCATED_FLAG);
Expand Down Expand Up @@ -476,6 +466,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);
Expand Down
17 changes: 17 additions & 0 deletions monitor/qmp-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,20 @@ 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:
#ifdef CONFIG_VNC
if (arg->u.vnc.has_tls_certs && arg->u.vnc.tls_certs) {
vnc_display_reload_certs(NULL, errp);
}
#else
error_setg(errp, "vnc is invalid, missing 'CONFIG_VNC'");
#endif
break;
default:
abort();
}
}
61 changes: 61 additions & 0 deletions qapi/ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -1168,3 +1168,64 @@
##
{ '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:
#
# -> { "execute": "display-reload",
# "arguments": { "type": "vnc", "tls-certs": true } }
# <- { "return": {} }
#
##
{ 'command': 'display-reload',
'data': 'DisplayReloadOptions',
'boxed' : true }
28 changes: 28 additions & 0 deletions ui/vnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,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
Expand Down

0 comments on commit 67c1115

Please sign in to comment.