From 4323118cadc5a316f73b5b0a60b5789ed9201369 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sun, 21 Nov 2021 01:55:03 -0500 Subject: [PATCH 1/8] ui: fix incorrect scaling on highdpi with gtk/opengl Signed-off-by: Alexander Orzechowski Message-Id: <20211121065504.29101-2-orzechowski.alexander@gmail.com> [ kraxel: codestyle fix ] Signed-off-by: Gerd Hoffmann --- ui/gtk-gl-area.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 461da7712f..01e4e74ee3 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -41,15 +41,16 @@ void gd_gl_area_draw(VirtualConsole *vc) #ifdef CONFIG_GBM QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf; #endif - int ww, wh, y1, y2; + int ww, wh, ws, y1, y2; if (!vc->gfx.gls) { return; } gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); - ww = gtk_widget_get_allocated_width(vc->gfx.drawing_area); - wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area); + ws = gdk_window_get_scale_factor(gtk_widget_get_window(vc->gfx.drawing_area)); + ww = gtk_widget_get_allocated_width(vc->gfx.drawing_area) * ws; + wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area) * ws; if (vc->gfx.scanout_mode) { if (!vc->gfx.guest_fb.framebuffer) { From f14aab420c58b57e07189d6d9e6d3fbfab4761a6 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Sun, 21 Nov 2021 01:55:04 -0500 Subject: [PATCH 2/8] ui: fix incorrect pointer position on highdpi with gtk Signed-off-by: Alexander Orzechowski Message-Id: <20211121065504.29101-3-orzechowski.alexander@gmail.com> [ kraxel: codestyle fix ] Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index d2892ea6b4..dc4a1491f0 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -838,10 +838,11 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, { VirtualConsole *vc = opaque; GtkDisplayState *s = vc->s; + GdkWindow *window; int x, y; int mx, my; int fbh, fbw; - int ww, wh; + int ww, wh, ws; if (!vc->gfx.ds) { return TRUE; @@ -850,8 +851,10 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, fbw = surface_width(vc->gfx.ds) * vc->gfx.scale_x; fbh = surface_height(vc->gfx.ds) * vc->gfx.scale_y; - ww = gdk_window_get_width(gtk_widget_get_window(vc->gfx.drawing_area)); - wh = gdk_window_get_height(gtk_widget_get_window(vc->gfx.drawing_area)); + window = gtk_widget_get_window(vc->gfx.drawing_area); + ww = gdk_window_get_width(window); + wh = gdk_window_get_height(window); + ws = gdk_window_get_scale_factor(window); mx = my = 0; if (ww > fbw) { @@ -861,8 +864,8 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, my = (wh - fbh) / 2; } - x = (motion->x - mx) / vc->gfx.scale_x; - y = (motion->y - my) / vc->gfx.scale_y; + x = (motion->x - mx) / vc->gfx.scale_x * ws; + y = (motion->y - my) / vc->gfx.scale_y * ws; if (qemu_input_is_absolute()) { if (x < 0 || y < 0 || From c3abdb2faff62e3ded21bf8c3ef493ed70785623 Mon Sep 17 00:00:00 2001 From: Dongwon Kim Date: Sun, 21 Nov 2021 09:22:37 -0800 Subject: [PATCH 3/8] ui/gtk: graphic_hw_gl_flushed after closing dmabuf->fence_fd The dmabuf often becomes invalid right after unblocking pipeline and graphic_hw_gl_flushed in case a new scanout blob is submitted because the dmabuf associated with the current guest scanout is freed after swapping. So both graphic_hw_gl_block and graphic_hw_gl_flushed should be executed after closing fence_fd for the current dmabuf. Cc: Gerd Hoffmann Cc: Vivek Kasireddy Signed-off-by: Dongwon Kim Message-Id: <20211121172237.14937-1-dongwon.kim@intel.com> Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index dc4a1491f0..428f02f2df 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -589,11 +589,11 @@ void gd_hw_gl_flushed(void *vcon) VirtualConsole *vc = vcon; QemuDmaBuf *dmabuf = vc->gfx.guest_fb.dmabuf; - graphic_hw_gl_block(vc->gfx.dcl.con, false); - graphic_hw_gl_flushed(vc->gfx.dcl.con); qemu_set_fd_handler(dmabuf->fence_fd, NULL, NULL, NULL); close(dmabuf->fence_fd); dmabuf->fence_fd = -1; + graphic_hw_gl_block(vc->gfx.dcl.con, false); + graphic_hw_gl_flushed(vc->gfx.dcl.con); } /** DisplayState Callbacks (opengl version) **/ From 2e572baf659f5a457c876c6b2d02a217afb401c5 Mon Sep 17 00:00:00 2001 From: Vladimir Sementsov-Ogievskiy Date: Wed, 10 Nov 2021 11:38:00 +0100 Subject: [PATCH 4/8] ui/vnc-clipboard: fix adding notifier twice vnc_server_cut_text_caps() is not guaranteed to be called only once. If it called twice, we finally call notifier_list_add() twice with same element. Which leads to loopback QLIST. So, on next notifier_list_notify() we'll loop forever and QEMU stuck. So, let's only register new notifier if it's not yet registered. Note, that similar check is used in vdagent_chr_recv_caps() (before call qemu_clipboard_peer_register()), and also before qemu_clipboard_peer_unregister() call in vdagent_disconnect() and in vnc_disconnect_finish(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20211110103800.2266729-1-vsementsov@virtuozzo.com> Signed-off-by: Gerd Hoffmann --- ui/vnc-clipboard.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c index 9f077965d0..67284b556c 100644 --- a/ui/vnc-clipboard.c +++ b/ui/vnc-clipboard.c @@ -316,8 +316,10 @@ void vnc_server_cut_text_caps(VncState *vs) caps[1] = 0; vnc_clipboard_send(vs, 2, caps); - vs->cbpeer.name = "vnc"; - vs->cbpeer.update.notify = vnc_clipboard_notify; - vs->cbpeer.request = vnc_clipboard_request; - qemu_clipboard_peer_register(&vs->cbpeer); + if (!vs->cbpeer.update.notify) { + vs->cbpeer.name = "vnc"; + vs->cbpeer.update.notify = vnc_clipboard_notify; + vs->cbpeer.request = vnc_clipboard_request; + qemu_clipboard_peer_register(&vs->cbpeer); + } } From 4067691a2fed9a7639b1264b07c131d8e11f2b4f Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Tue, 16 Nov 2021 08:28:40 +0100 Subject: [PATCH 5/8] migration: fix dump-vmstate with modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To work correctly -dump-vmstate and vmstate-static-checker.py need to dump all the supported vmstates. But as some devices can be modules, they are not loaded at startup and not dumped. Fix that by loading all available modules before dumping the machine vmstate. Fixes: 7ab6e7fcce97 ("qdev: device module support") Cc: kraxel@redhat.com Signed-off-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211116072840.132731-1-lvivier@redhat.com> Signed-off-by: Gerd Hoffmann --- softmmu/vl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/softmmu/vl.c b/softmmu/vl.c index 1159a64bce..620a1f1367 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3766,6 +3766,7 @@ void qemu_init(int argc, char **argv, char **envp) if (vmstate_dump_file) { /* dump and exit */ + module_load_qom_all(); dump_vmstate_json_to_file(vmstate_dump_file); exit(0); } From d612405ed2a1163a142f94552a9874ad4b02de30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 17 Nov 2021 18:43:31 +0100 Subject: [PATCH 6/8] hw/i386/microvm: Reduce annoying debug message in dt_setup_microvm() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: f5918a99283 ("microvm: add device tree support.") Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Sergio Lopez Reviewed-by: Darren Kenny Message-Id: <20211117174331.1715144-1-philmd@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/i386/microvm-dt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c index 875ba91963..6ee6c42904 100644 --- a/hw/i386/microvm-dt.c +++ b/hw/i386/microvm-dt.c @@ -327,7 +327,9 @@ void dt_setup_microvm(MicrovmMachineState *mms) dt_setup_sys_bus(mms); /* add to fw_cfg */ - fprintf(stderr, "%s: add etc/fdt to fw_cfg\n", __func__); + if (debug) { + fprintf(stderr, "%s: add etc/fdt to fw_cfg\n", __func__); + } fw_cfg_add_file(x86ms->fw_cfg, "etc/fdt", mms->fdt, size); if (debug) { From 1b38ccc9a1fa865a8838c89216dc36df87e9c9d5 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 8 Nov 2021 14:07:17 +0100 Subject: [PATCH 7/8] microvm: add missing g_free() call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: CID 1465240 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20211108130718.840216-2-kraxel@redhat.com> --- hw/i386/microvm-dt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c index 6ee6c42904..a6a59a6e12 100644 --- a/hw/i386/microvm-dt.c +++ b/hw/i386/microvm-dt.c @@ -143,6 +143,8 @@ static void dt_add_pcie(MicrovmMachineState *mms) nr_pcie_buses = PCIE_ECAM_SIZE / PCIE_MMCFG_SIZE_MIN; qemu_fdt_setprop_cells(mms->fdt, nodename, "bus-range", 0, nr_pcie_buses - 1); + + g_free(nodename); } static void dt_add_ioapic(MicrovmMachineState *mms, SysBusDevice *dev) From b9e5628ca5d42994cc6f82752d9bf0bc98f51f64 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Mon, 8 Nov 2021 14:07:18 +0100 Subject: [PATCH 8/8] microvm: check g_file_set_contents() return value Fixes: CID 1465239 Signed-off-by: Gerd Hoffmann Message-Id: <20211108130718.840216-3-kraxel@redhat.com> --- hw/i386/microvm-dt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/i386/microvm-dt.c b/hw/i386/microvm-dt.c index a6a59a6e12..9c3c4995b4 100644 --- a/hw/i386/microvm-dt.c +++ b/hw/i386/microvm-dt.c @@ -336,7 +336,10 @@ void dt_setup_microvm(MicrovmMachineState *mms) if (debug) { fprintf(stderr, "%s: writing microvm.fdt\n", __func__); - g_file_set_contents("microvm.fdt", mms->fdt, size, NULL); + if (!g_file_set_contents("microvm.fdt", mms->fdt, size, NULL)) { + fprintf(stderr, "%s: writing microvm.fdt failed\n", __func__); + return; + } int ret = system("dtc -I dtb -O dts microvm.fdt"); if (ret != 0) { fprintf(stderr, "%s: oops, dtc not installed?\n", __func__);