|
|
255e5e |
From df2a48c11d014c568393d4909e05b7b251baa47d Mon Sep 17 00:00:00 2001
|
|
|
255e5e |
From: jmaloy <jmaloy@redhat.com>
|
|
|
255e5e |
Date: Thu, 7 May 2020 21:51:47 +0100
|
|
|
255e5e |
Subject: [PATCH 1/2] vnc: add magic cookie to VncState
|
|
|
255e5e |
MIME-Version: 1.0
|
|
|
255e5e |
Content-Type: text/plain; charset=UTF-8
|
|
|
255e5e |
Content-Transfer-Encoding: 8bit
|
|
|
255e5e |
|
|
|
255e5e |
RH-Author: jmaloy <jmaloy@redhat.com>
|
|
|
255e5e |
Message-id: <20200507215148.1201876-2-jmaloy@redhat.com>
|
|
|
255e5e |
Patchwork-id: 96346
|
|
|
255e5e |
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 1/2] vnc: add magic cookie to VncState
|
|
|
255e5e |
Bugzilla: 1816763
|
|
|
255e5e |
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
255e5e |
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
|
|
|
255e5e |
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
255e5e |
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
255e5e |
|
|
|
255e5e |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
255e5e |
|
|
|
255e5e |
Set magic cookie on initialization. Clear on cleanup. Sprinkle a bunch
|
|
|
255e5e |
of assert()s checking the cookie, to verify the pointer is valid.
|
|
|
255e5e |
|
|
|
255e5e |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
255e5e |
Message-id: 20180507102254.12107-1-kraxel@redhat.com
|
|
|
255e5e |
|
|
|
255e5e |
(cherry picked from commit f31f9c1080d8907c95f1501c6abab038eceb5490)
|
|
|
255e5e |
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
|
|
|
255e5e |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
255e5e |
---
|
|
|
255e5e |
ui/vnc-jobs.c | 4 ++++
|
|
|
255e5e |
ui/vnc.c | 10 +++++++++-
|
|
|
255e5e |
ui/vnc.h | 3 +++
|
|
|
255e5e |
3 files changed, 16 insertions(+), 1 deletion(-)
|
|
|
255e5e |
|
|
|
255e5e |
diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c
|
|
|
255e5e |
index 868ddde..b0b15d4 100644
|
|
|
255e5e |
--- a/ui/vnc-jobs.c
|
|
|
255e5e |
+++ b/ui/vnc-jobs.c
|
|
|
255e5e |
@@ -82,6 +82,7 @@ VncJob *vnc_job_new(VncState *vs)
|
|
|
255e5e |
{
|
|
|
255e5e |
VncJob *job = g_new0(VncJob, 1);
|
|
|
255e5e |
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
job->vs = vs;
|
|
|
255e5e |
vnc_lock_queue(queue);
|
|
|
255e5e |
QLIST_INIT(&job->rectangles);
|
|
|
255e5e |
@@ -214,6 +215,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
|
|
|
255e5e |
/* Here job can only be NULL if queue->exit is true */
|
|
|
255e5e |
job = QTAILQ_FIRST(&queue->jobs);
|
|
|
255e5e |
vnc_unlock_queue(queue);
|
|
|
255e5e |
+ assert(job->vs->magic == VNC_MAGIC);
|
|
|
255e5e |
|
|
|
255e5e |
if (queue->exit) {
|
|
|
255e5e |
return -1;
|
|
|
255e5e |
@@ -236,6 +238,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue)
|
|
|
255e5e |
|
|
|
255e5e |
/* Make a local copy of vs and switch output buffers */
|
|
|
255e5e |
vnc_async_encoding_start(job->vs, &vs);
|
|
|
255e5e |
+ vs.magic = VNC_MAGIC;
|
|
|
255e5e |
|
|
|
255e5e |
/* Start sending rectangles */
|
|
|
255e5e |
n_rectangles = 0;
|
|
|
255e5e |
@@ -289,6 +292,7 @@ disconnected:
|
|
|
255e5e |
vnc_unlock_queue(queue);
|
|
|
255e5e |
qemu_cond_broadcast(&queue->cond);
|
|
|
255e5e |
g_free(job);
|
|
|
255e5e |
+ vs.magic = 0;
|
|
|
255e5e |
return 0;
|
|
|
255e5e |
}
|
|
|
255e5e |
|
|
|
255e5e |
diff --git a/ui/vnc.c b/ui/vnc.c
|
|
|
255e5e |
index 0bd44f1..dbbc76e 100644
|
|
|
255e5e |
--- a/ui/vnc.c
|
|
|
255e5e |
+++ b/ui/vnc.c
|
|
|
255e5e |
@@ -1157,6 +1157,7 @@ static void audio_capture_notify(void *opaque, audcnotification_e cmd)
|
|
|
255e5e |
{
|
|
|
255e5e |
VncState *vs = opaque;
|
|
|
255e5e |
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
switch (cmd) {
|
|
|
255e5e |
case AUD_CNOTIFY_DISABLE:
|
|
|
255e5e |
vnc_lock_output(vs);
|
|
|
255e5e |
@@ -1186,6 +1187,7 @@ static void audio_capture(void *opaque, void *buf, int size)
|
|
|
255e5e |
{
|
|
|
255e5e |
VncState *vs = opaque;
|
|
|
255e5e |
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
vnc_lock_output(vs);
|
|
|
255e5e |
if (vs->output.offset < vs->throttle_output_offset) {
|
|
|
255e5e |
vnc_write_u8(vs, VNC_MSG_SERVER_QEMU);
|
|
|
255e5e |
@@ -1294,6 +1296,7 @@ void vnc_disconnect_finish(VncState *vs)
|
|
|
255e5e |
vs->ioc = NULL;
|
|
|
255e5e |
object_unref(OBJECT(vs->sioc));
|
|
|
255e5e |
vs->sioc = NULL;
|
|
|
255e5e |
+ vs->magic = 0;
|
|
|
255e5e |
g_free(vs);
|
|
|
255e5e |
}
|
|
|
255e5e |
|
|
|
255e5e |
@@ -1433,7 +1436,7 @@ static void vnc_client_write_locked(VncState *vs)
|
|
|
255e5e |
|
|
|
255e5e |
static void vnc_client_write(VncState *vs)
|
|
|
255e5e |
{
|
|
|
255e5e |
-
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
vnc_lock_output(vs);
|
|
|
255e5e |
if (vs->output.offset) {
|
|
|
255e5e |
vnc_client_write_locked(vs);
|
|
|
255e5e |
@@ -1506,6 +1509,7 @@ static void vnc_jobs_bh(void *opaque)
|
|
|
255e5e |
{
|
|
|
255e5e |
VncState *vs = opaque;
|
|
|
255e5e |
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
vnc_jobs_consume_buffer(vs);
|
|
|
255e5e |
}
|
|
|
255e5e |
|
|
|
255e5e |
@@ -1556,6 +1560,8 @@ gboolean vnc_client_io(QIOChannel *ioc G_GNUC_UNUSED,
|
|
|
255e5e |
GIOCondition condition, void *opaque)
|
|
|
255e5e |
{
|
|
|
255e5e |
VncState *vs = opaque;
|
|
|
255e5e |
+
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
if (condition & G_IO_IN) {
|
|
|
255e5e |
if (vnc_client_read(vs) < 0) {
|
|
|
255e5e |
goto end;
|
|
|
255e5e |
@@ -1586,6 +1592,7 @@ end:
|
|
|
255e5e |
|
|
|
255e5e |
void vnc_write(VncState *vs, const void *data, size_t len)
|
|
|
255e5e |
{
|
|
|
255e5e |
+ assert(vs->magic == VNC_MAGIC);
|
|
|
255e5e |
if (vs->disconnecting) {
|
|
|
255e5e |
return;
|
|
|
255e5e |
}
|
|
|
255e5e |
@@ -3082,6 +3089,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
|
|
|
255e5e |
int i;
|
|
|
255e5e |
|
|
|
255e5e |
trace_vnc_client_connect(vs, sioc);
|
|
|
255e5e |
+ vs->magic = VNC_MAGIC;
|
|
|
255e5e |
vs->sioc = sioc;
|
|
|
255e5e |
object_ref(OBJECT(vs->sioc));
|
|
|
255e5e |
vs->ioc = QIO_CHANNEL(sioc);
|
|
|
255e5e |
diff --git a/ui/vnc.h b/ui/vnc.h
|
|
|
255e5e |
index 7b29def..7626329 100644
|
|
|
255e5e |
--- a/ui/vnc.h
|
|
|
255e5e |
+++ b/ui/vnc.h
|
|
|
255e5e |
@@ -255,8 +255,11 @@ typedef enum {
|
|
|
255e5e |
VNC_STATE_UPDATE_FORCE,
|
|
|
255e5e |
} VncStateUpdate;
|
|
|
255e5e |
|
|
|
255e5e |
+#define VNC_MAGIC ((uint64_t)0x05b3f069b3d204bb)
|
|
|
255e5e |
+
|
|
|
255e5e |
struct VncState
|
|
|
255e5e |
{
|
|
|
255e5e |
+ uint64_t magic;
|
|
|
255e5e |
QIOChannelSocket *sioc; /* The underlying socket */
|
|
|
255e5e |
QIOChannel *ioc; /* The channel currently used for I/O */
|
|
|
255e5e |
guint ioc_tag;
|
|
|
255e5e |
--
|
|
|
255e5e |
1.8.3.1
|
|
|
255e5e |
|