Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20180827-v4-pull…
Browse files Browse the repository at this point in the history
…-request' into staging

ui: misc fixes which piled up during 3.0 release freeze

# gpg: Signature made Mon 27 Aug 2018 09:53:07 BST
# gpg:                using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/ui-20180827-v4-pull-request:
  util: promote qemu_egl_rendernode_open() to libqemuutil
  dmabuf: add y0_top, pass it to spice
  ui/vnc: Remove useless parenthesis around DIV_ROUND_UP macro
  ui/sdl2: Fix broken -full-screen CLI option
  spice-display: fix qemu_spice_cursor_refresh_bh locking
  spice-display: access ptr_x/ptr_y under Mutex
  vnc: remove support for deprecated tls, x509, x509verify options
  doc: switch to modern syntax for VNC TLS setup
  sdl2: redraw correctly when scanout_mode enabled.
  ui: use enum to string helpers
  vnc: fix memleak of the "vnc-worker-output" name
  ui/sdl2: Remove the obsolete SDL_INIT_NOPARACHUTE flag

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Aug 27, 2018
2 parents 235c82a + b1d3803 commit 025573b
Show file tree
Hide file tree
Showing 17 changed files with 139 additions and 237 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,7 @@ S: Odd Fixes
F: ui/
F: include/ui/
F: qapi/ui.json
F: util/drm.c

Cocoa graphics
M: Peter Maydell <peter.maydell@linaro.org>
Expand Down
6 changes: 6 additions & 0 deletions include/qemu/drm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef QEMU_DRM_H_
#define QEMU_DRM_H_

int qemu_drm_rendernode_open(const char *rendernode);

#endif
1 change: 1 addition & 0 deletions include/ui/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ struct QemuDmaBuf {
uint32_t stride;
uint32_t fourcc;
uint32_t texture;
bool y0_top;
};

typedef struct DisplayChangeListenerOps {
Expand Down
20 changes: 0 additions & 20 deletions qemu-deprecated.texi
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,6 @@ which is the default.
The ``-no-kvm'' argument is now a synonym for setting
``-machine accel=tcg''.

@subsection -vnc tls (since 2.5.0)

The ``-vnc tls'' argument is now a synonym for setting
``-object tls-creds-anon,id=tls0'' combined with
``-vnc tls-creds=tls0'

@subsection -vnc x509 (since 2.5.0)

The ``-vnc x509=/path/to/certs'' argument is now a
synonym for setting
``-object tls-creds-x509,dir=/path/to/certs,id=tls0,verify-peer=no''
combined with ``-vnc tls-creds=tls0'

@subsection -vnc x509verify (since 2.5.0)

The ``-vnc x509verify=/path/to/certs'' argument is now a
synonym for setting
``-object tls-creds-x509,dir=/path/to/certs,id=tls0,verify-peer=yes''
combined with ``-vnc tls-creds=tls0'

@subsection -tftp (since 2.6.0)

The ``-tftp /some/dir'' argument is replaced by either
Expand Down
20 changes: 15 additions & 5 deletions qemu-doc.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,9 @@ support provides a secure session, but no authentication. This allows any
client to connect, and provides an encrypted session.

@example
qemu-system-i386 [...OPTIONS...] -vnc :1,tls,x509=/etc/pki/qemu -monitor stdio
qemu-system-i386 [...OPTIONS...] \
-object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=no \
-vnc :1,tls-creds=tls0 -monitor stdio
@end example

In the above example @code{/etc/pki/qemu} should contain at least three files,
Expand All @@ -1118,10 +1120,14 @@ only be readable by the user owning it.
Certificates can also provide a means to authenticate the client connecting.
The server will request that the client provide a certificate, which it will
then validate against the CA certificate. This is a good choice if deploying
in an environment with a private internal certificate authority.
in an environment with a private internal certificate authority. It uses the
same syntax as previously, but with @code{verify-peer} set to @code{yes}
instead.

@example
qemu-system-i386 [...OPTIONS...] -vnc :1,tls,x509verify=/etc/pki/qemu -monitor stdio
qemu-system-i386 [...OPTIONS...] \
-object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
-vnc :1,tls-creds=tls0 -monitor stdio
@end example


Expand All @@ -1132,7 +1138,9 @@ Finally, the previous method can be combined with VNC password authentication
to provide two layers of authentication for clients.

@example
qemu-system-i386 [...OPTIONS...] -vnc :1,password,tls,x509verify=/etc/pki/qemu -monitor stdio
qemu-system-i386 [...OPTIONS...] \
-object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
-vnc :1,tls-creds=tls0,password -monitor stdio
(qemu) change vnc password
Password: ********
(qemu)
Expand Down Expand Up @@ -1169,7 +1177,9 @@ credentials. This can be enabled, by combining the 'sasl' option
with the aforementioned TLS + x509 options:

@example
qemu-system-i386 [...OPTIONS...] -vnc :1,tls,x509,sasl -monitor stdio
qemu-system-i386 [...OPTIONS...] \
-object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
-vnc :1,tls-creds=tls0,sasl -monitor stdio
@end example

@node vnc_setup_sasl
Expand Down
2 changes: 1 addition & 1 deletion qemu-keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void walk_map(struct xkb_keymap *map, xkb_keycode_t code, void *data)
}
fprintf(outfile, "# evdev %d (0x%x), QKeyCode \"%s\", number 0x%x\n",
evdev, evdev,
QKeyCode_lookup.array[qcode],
QKeyCode_str(qcode),
qcode_to_number(qcode));

/*
Expand Down
43 changes: 0 additions & 43 deletions qemu-options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1632,49 +1632,6 @@ will cause the VNC server socket to enable the VeNCrypt auth
mechanism. The credentials should have been previously created
using the @option{-object tls-creds} argument.

The @option{tls-creds} parameter obsoletes the @option{tls},
@option{x509}, and @option{x509verify} options, and as such
it is not permitted to set both new and old type options at
the same time.

@item tls

Require that client use TLS when communicating with the VNC server. This
uses anonymous TLS credentials so is susceptible to a man-in-the-middle
attack. It is recommended that this option be combined with either the
@option{x509} or @option{x509verify} options.

This option is now deprecated in favor of using the @option{tls-creds}
argument.

@item x509=@var{/path/to/certificate/dir}

Valid if @option{tls} is specified. Require that x509 credentials are used
for negotiating the TLS session. The server will send its x509 certificate
to the client. It is recommended that a password be set on the VNC server
to provide authentication of the client when this is used. The path following
this option specifies where the x509 certificates are to be loaded from.
See the @ref{vnc_security} section for details on generating certificates.

This option is now deprecated in favour of using the @option{tls-creds}
argument.

@item x509verify=@var{/path/to/certificate/dir}

Valid if @option{tls} is specified. Require that x509 credentials are used
for negotiating the TLS session. The server will send its x509 certificate
to the client, and request that the client send its own x509 certificate.
The server will validate the client's certificate against the CA certificate,
and reject clients when validation fails. If the certificate authority is
trusted, this is a sufficient authentication mechanism. You may still wish
to set a password on the VNC server as a second authentication layer. The
path following this option specifies where the x509 certificates are to
be loaded from. See the @ref{vnc_security} section for details on generating
certificates.

This option is now deprecated in favour of using the @option{tls-creds}
argument.

@item sasl

Require that the client use SASL to authenticate with the VNC server.
Expand Down
6 changes: 3 additions & 3 deletions ui/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -2319,7 +2319,7 @@ bool qemu_display_find_default(DisplayOptions *opts)

for (i = 0; i < ARRAY_SIZE(prio); i++) {
if (dpys[prio[i]] == NULL) {
ui_module_load_one(DisplayType_lookup.array[prio[i]]);
ui_module_load_one(DisplayType_str(prio[i]));
}
if (dpys[prio[i]] == NULL) {
continue;
Expand All @@ -2337,11 +2337,11 @@ void qemu_display_early_init(DisplayOptions *opts)
return;
}
if (dpys[opts->type] == NULL) {
ui_module_load_one(DisplayType_lookup.array[opts->type]);
ui_module_load_one(DisplayType_str(opts->type));
}
if (dpys[opts->type] == NULL) {
error_report("Display '%s' is not available.",
DisplayType_lookup.array[opts->type]);
DisplayType_str(opts->type));
exit(1);
}
if (dpys[opts->type]->early_init) {
Expand Down
51 changes: 2 additions & 49 deletions ui/egl-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include <glob.h>
#include <dirent.h>

#include "qemu/drm.h"
#include "qemu/error-report.h"
#include "ui/console.h"
#include "ui/egl-helpers.h"
Expand Down Expand Up @@ -147,57 +145,12 @@ int qemu_egl_rn_fd;
struct gbm_device *qemu_egl_rn_gbm_dev;
EGLContext qemu_egl_rn_ctx;

static int qemu_egl_rendernode_open(const char *rendernode)
{
DIR *dir;
struct dirent *e;
int r, fd;
char *p;

if (rendernode) {
return open(rendernode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
}

dir = opendir("/dev/dri");
if (!dir) {
return -1;
}

fd = -1;
while ((e = readdir(dir))) {
if (e->d_type != DT_CHR) {
continue;
}

if (strncmp(e->d_name, "renderD", 7)) {
continue;
}

p = g_strdup_printf("/dev/dri/%s", e->d_name);

r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (r < 0) {
g_free(p);
continue;
}
fd = r;
g_free(p);
break;
}

closedir(dir);
if (fd < 0) {
return -1;
}
return fd;
}

int egl_rendernode_init(const char *rendernode, DisplayGLMode mode)
{
qemu_egl_rn_fd = -1;
int rc;

qemu_egl_rn_fd = qemu_egl_rendernode_open(rendernode);
qemu_egl_rn_fd = qemu_drm_rendernode_open(rendernode);
if (qemu_egl_rn_fd == -1) {
error_report("egl: no drm render node available");
goto err;
Expand Down
5 changes: 5 additions & 0 deletions ui/sdl2-gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ void sdl2_gl_redraw(struct sdl2_console *scon)
{
assert(scon->opengl);

if (scon->scanout_mode) {
/* sdl2_gl_scanout_flush actually only care about
* the first argument. */
return sdl2_gl_scanout_flush(&scon->dcl, 0, 0, 0, 0);
}
if (scon->surface) {
sdl2_gl_render_surface(scon);
}
Expand Down
13 changes: 5 additions & 8 deletions ui/sdl2.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ static void sdl2_display_early_init(DisplayOptions *o)

static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
{
int flags;
uint8_t data = 0;
char *filename;
int i;
Expand All @@ -782,8 +781,7 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
setenv("SDL_VIDEODRIVER", "x11", 0);
#endif

flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
if (SDL_Init(flags)) {
if (SDL_Init(SDL_INIT_VIDEO)) {
fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",
SDL_GetError());
exit(1);
Expand All @@ -792,6 +790,8 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
memset(&info, 0, sizeof(info));
SDL_VERSION(&info.version);

gui_fullscreen = o->has_full_screen && o->full_screen;

for (i = 0;; i++) {
QemuConsole *con = qemu_console_lookup_by_index(i);
if (!con) {
Expand Down Expand Up @@ -844,17 +844,14 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
g_free(filename);
}

if (sdl2_console->opts->has_full_screen &&
sdl2_console->opts->full_screen) {
gui_fullscreen = 1;
gui_grab = 0;
if (gui_fullscreen) {
sdl_grab_start(0);
}

mouse_mode_notifier.notify = sdl_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);

gui_grab = 0;

sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
sdl_cursor_normal = SDL_GetCursor();

Expand Down
42 changes: 28 additions & 14 deletions ui/spice-display.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,29 +450,35 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd,
qemu_mutex_unlock(&ssd->lock);
}

static void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd)
void qemu_spice_cursor_refresh_bh(void *opaque)
{
SimpleSpiceDisplay *ssd = opaque;

qemu_mutex_lock(&ssd->lock);
if (ssd->cursor) {
QEMUCursor *c = ssd->cursor;
assert(ssd->dcl.con);
dpy_cursor_define(ssd->dcl.con, ssd->cursor);
cursor_get(c);
qemu_mutex_unlock(&ssd->lock);
dpy_cursor_define(ssd->dcl.con, c);
qemu_mutex_lock(&ssd->lock);
cursor_put(c);
}

if (ssd->mouse_x != -1 && ssd->mouse_y != -1) {
int x, y;
assert(ssd->dcl.con);
dpy_mouse_set(ssd->dcl.con, ssd->mouse_x, ssd->mouse_y, 1);
x = ssd->mouse_x;
y = ssd->mouse_y;
ssd->mouse_x = -1;
ssd->mouse_y = -1;
qemu_mutex_unlock(&ssd->lock);
dpy_mouse_set(ssd->dcl.con, x, y, 1);
} else {
qemu_mutex_unlock(&ssd->lock);
}
}

void qemu_spice_cursor_refresh_bh(void *opaque)
{
SimpleSpiceDisplay *ssd = opaque;

qemu_mutex_lock(&ssd->lock);
qemu_spice_cursor_refresh_unlocked(ssd);
qemu_mutex_unlock(&ssd->lock);
}

void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)
{
graphic_hw_update(ssd->dcl.con);
Expand Down Expand Up @@ -976,8 +982,10 @@ static void qemu_spice_gl_cursor_position(DisplayChangeListener *dcl,
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);

qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = pos_x;
ssd->ptr_y = pos_y;
qemu_mutex_unlock(&ssd->lock);
}

static void qemu_spice_gl_release_dmabuf(DisplayChangeListener *dcl,
Expand Down Expand Up @@ -1048,17 +1056,23 @@ static void qemu_spice_gl_update(DisplayChangeListener *dcl,
/* note: spice server will close the fd, so hand over a dup */
spice_qxl_gl_scanout(&ssd->qxl, dup(dmabuf->fd),
dmabuf->width, dmabuf->height,
dmabuf->stride, dmabuf->fourcc, false);
dmabuf->stride, dmabuf->fourcc,
dmabuf->y0_top);
}
qemu_spice_gl_monitor_config(ssd, 0, 0, dmabuf->width, dmabuf->height);
ssd->guest_dmabuf_refresh = false;
}

if (render_cursor) {
int x, y;
qemu_mutex_lock(&ssd->lock);
x = ssd->ptr_x;
y = ssd->ptr_y;
qemu_mutex_unlock(&ssd->lock);
egl_texture_blit(ssd->gls, &ssd->blit_fb, &ssd->guest_fb,
!y_0_top);
egl_texture_blend(ssd->gls, &ssd->blit_fb, &ssd->cursor_fb,
!y_0_top, ssd->ptr_x, ssd->ptr_y);
!y_0_top, x, y);
glFlush();
}

Expand Down
Loading

0 comments on commit 025573b

Please sign in to comment.