Skip to content

Commit

Permalink
Merge tag 'misc-pull-request' of https://gitlab.com/marcandre.lureau/…
Browse files Browse the repository at this point in the history
…qemu into staging

Misc fixes and cleanups

# -----BEGIN PGP SIGNATURE-----
#
# iQJQBAABCAA6FiEEh6m9kz+HxgbSdvYt2ujhCXWWnOUFAmUcClAcHG1hcmNhbmRy
# ZS5sdXJlYXVAcmVkaGF0LmNvbQAKCRDa6OEJdZac5R5FD/9oeCDGXVzkm52K0DoW
# 90N5Blda/3exvnS49TEz+rbIxXcy9IBxEKV3aPesCDw0V7Vxy6ZijPA/aHKzQEeP
# DOX+0sELWLFRKvNNuXLxPlZcEQDgXkgqoCKf+0jp5oH7TAL2upezMhIr4XlUwG3v
# rKQstpmr0Jm9sjsBTL9uIZCJpzglWk7CIbgAlBjOX6MFz0HAManrhBBuguvSZtrW
# wYWrdkBEdTK6ranBvRA3IKi4ux/pmNsCpCtuOVT+WOLjC/wmJIE8+pBzlK9eOdqW
# bPaxuu4XK1qao1+z6EyoaUtH/UW50EUInGq7aR2Z31/S1BLxqEpFCCnPAw7RGYZO
# VlAuiR2U7K7AHFDfp8fJaUNH8a3Zh2wzpba5cyQ7LqVNRVbDhx65sQZw0pA3pjfi
# JG0brIpWldD7auJtZTdCxXcoHWxeyfqqzH3a6GpeZzrRwuuAwxv0+yGF3Y2cMJ7+
# lV9JVcei5M+Acq1UfO4BCC77UpXs4Jl0+zyRq02vOJFnfwcLMQ7VjD2A3e00yodj
# F5cPnbacI212ynNm925RNv45svaY1hD2Z8kJRV/15/04m9dRv4WHOOTuF3iwZjt1
# 9gp/p949tcEL/rBbDF+9QZiVHTWurVCQ0ZFnNhVnbKm+Hm5nHk5slc2p+VXQ0KB0
# E2mN1irWzLov0K1YZTfetiXo8A==
# =3ol2
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 03 Oct 2023 08:34:24 EDT
# gpg:                using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5
# gpg:                issuer "marcandre.lureau@redhat.com"
# gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full]
# gpg:                 aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full]
# Primary key fingerprint: 87A9 BD93 3F87 C606 D276  F62D DAE8 E109 7596 9CE5

* tag 'misc-pull-request' of https://gitlab.com/marcandre.lureau/qemu:
  chardev/char-pty: Avoid losing bytes when the other side just (re-)connected
  hw/display/ramfb: plug slight guest-triggerable leak on mode setting
  hw/pc: remove needless includes
  hw/core: remove needless includes
  analyze-migration: ignore RAM_SAVE_FLAG_MULTIFD_FLUSH
  ui/gtk: fix UI info precondition
  win32: avoid discarding the exception handler
  ui: add XBGR8888 and ABGR8888 in drm_format_pixman_map
  ui/console: sanitize search in qemu_graphic_console_is_multihead()
  ui/console: eliminate QOM properties from qemu_console_is_multihead()
  ui/console: only walk QemuGraphicConsoles in qemu_console_is_multihead()
  ui/console: make qemu_console_is_multihead() static
  input: Allow to choose console with qemu_input_is_absolute

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
stefanhaRH committed Oct 4, 2023
2 parents da10340 + 4f7689f commit c7c907b
Show file tree
Hide file tree
Showing 20 changed files with 90 additions and 117 deletions.
22 changes: 19 additions & 3 deletions chardev/char-pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,27 @@ static void pty_chr_update_read_handler(Chardev *chr)
static int char_pty_chr_write(Chardev *chr, const uint8_t *buf, int len)
{
PtyChardev *s = PTY_CHARDEV(chr);
GPollFD pfd;
int rc;

if (!s->connected) {
return len;
if (s->connected) {
return io_channel_send(s->ioc, buf, len);
}
return io_channel_send(s->ioc, buf, len);

/*
* The other side might already be re-connected, but the timer might
* not have fired yet. So let's check here whether we can write again:
*/
pfd.fd = QIO_CHANNEL_FILE(s->ioc)->fd;
pfd.events = G_IO_OUT;
pfd.revents = 0;
rc = RETRY_ON_EINTR(g_poll(&pfd, 1, 0));
g_assert(rc >= 0);
if (!(pfd.revents & G_IO_HUP) && (pfd.revents & G_IO_OUT)) {
io_channel_send(s->ioc, buf, len);
}

return len;
}

static GSource *pty_chr_add_watch(Chardev *chr, GIOCondition cond)
Expand Down
10 changes: 0 additions & 10 deletions hw/core/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,22 @@
*/

#include "qemu/osdep.h"
#include "qemu/option.h"
#include "qemu/accel.h"
#include "sysemu/replay.h"
#include "qemu/units.h"
#include "hw/boards.h"
#include "hw/loader.h"
#include "qapi/error.h"
#include "qapi/qapi-visit-common.h"
#include "qapi/qapi-visit-machine.h"
#include "qapi/visitor.h"
#include "qom/object_interfaces.h"
#include "hw/sysbus.h"
#include "sysemu/cpus.h"
#include "sysemu/sysemu.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
#include "sysemu/numa.h"
#include "sysemu/xen.h"
#include "qemu/error-report.h"
#include "sysemu/qtest.h"
#include "hw/pci/pci.h"
#include "hw/mem/nvdimm.h"
#include "migration/global_state.h"
#include "migration/vmstate.h"
#include "exec/confidential-guest-support.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-net.h"
#include "audio/audio.h"
Expand Down
1 change: 1 addition & 0 deletions hw/display/ramfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)

s->width = width;
s->height = height;
qemu_free_displaysurface(s->ds);
s->ds = surface;
}

Expand Down
39 changes: 0 additions & 39 deletions hw/i386/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,79 +24,40 @@

#include "qemu/osdep.h"
#include "qemu/units.h"
#include "hw/i386/x86.h"
#include "hw/i386/pc.h"
#include "hw/char/serial.h"
#include "hw/char/parallel.h"
#include "hw/i386/topology.h"
#include "hw/i386/fw_cfg.h"
#include "hw/i386/vmport.h"
#include "sysemu/cpus.h"
#include "hw/block/fdc.h"
#include "hw/ide/internal.h"
#include "hw/ide/isa.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_bus.h"
#include "hw/pci-bridge/pci_expander_bridge.h"
#include "hw/nvram/fw_cfg.h"
#include "hw/timer/hpet.h"
#include "hw/firmware/smbios.h"
#include "hw/loader.h"
#include "elf.h"
#include "migration/vmstate.h"
#include "multiboot.h"
#include "hw/rtc/mc146818rtc.h"
#include "hw/intc/i8259.h"
#include "hw/intc/ioapic.h"
#include "hw/timer/i8254.h"
#include "hw/input/i8042.h"
#include "hw/irq.h"
#include "hw/audio/pcspk.h"
#include "hw/pci/msi.h"
#include "hw/sysbus.h"
#include "sysemu/sysemu.h"
#include "sysemu/tcg.h"
#include "sysemu/numa.h"
#include "sysemu/kvm.h"
#include "sysemu/xen.h"
#include "sysemu/reset.h"
#include "sysemu/runstate.h"
#include "kvm/kvm_i386.h"
#include "hw/xen/xen.h"
#include "hw/xen/start_info.h"
#include "ui/qemu-spice.h"
#include "exec/memory.h"
#include "qemu/bitmap.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "qemu/option.h"
#include "qemu/cutils.h"
#include "hw/acpi/acpi.h"
#include "hw/acpi/cpu_hotplug.h"
#include "acpi-build.h"
#include "hw/mem/pc-dimm.h"
#include "hw/mem/nvdimm.h"
#include "hw/cxl/cxl.h"
#include "hw/cxl/cxl_host.h"
#include "qapi/error.h"
#include "qapi/qapi-visit-common.h"
#include "qapi/qapi-visit-machine.h"
#include "qapi/visitor.h"
#include "hw/core/cpu.h"
#include "hw/usb.h"
#include "hw/i386/intel_iommu.h"
#include "hw/net/ne2000-isa.h"
#include "standard-headers/asm-x86/bootparam.h"
#include "hw/virtio/virtio-iommu.h"
#include "hw/virtio/virtio-md-pci.h"
#include "hw/i386/kvm/xen_overlay.h"
#include "hw/i386/kvm/xen_evtchn.h"
#include "hw/i386/kvm/xen_gnttab.h"
#include "hw/i386/kvm/xen_xenstore.h"
#include "sysemu/replay.h"
#include "target/i386/cpu.h"
#include "e820_memory_layout.h"
#include "fw_cfg.h"
#include "trace.h"
#include CONFIG_DEVICES

Expand Down
6 changes: 6 additions & 0 deletions include/qemu/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,10 @@
#define QEMU_ANNOTATE(x)
#endif

#if __has_attribute(used)
# define QEMU_USED __attribute__((used))
#else
# define QEMU_USED
#endif

#endif /* COMPILER_H */
1 change: 0 additions & 1 deletion include/ui/console.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ bool qemu_console_is_visible(QemuConsole *con);
bool qemu_console_is_graphic(QemuConsole *con);
bool qemu_console_is_fixedsize(QemuConsole *con);
bool qemu_console_is_gl_blocked(QemuConsole *con);
bool qemu_console_is_multihead(DeviceState *dev);
char *qemu_console_get_label(QemuConsole *con);
int qemu_console_get_index(QemuConsole *con);
uint32_t qemu_console_get_head(QemuConsole *con);
Expand Down
2 changes: 1 addition & 1 deletion include/ui/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down);
void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map,
uint32_t button_old, uint32_t button_new);

bool qemu_input_is_absolute(void);
bool qemu_input_is_absolute(QemuConsole *con);
int qemu_input_scale_axis(int value,
int min_in, int max_in,
int min_out, int max_out);
Expand Down
4 changes: 4 additions & 0 deletions include/ui/qemu-pixman.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
# define PIXMAN_LE_r8g8b8 PIXMAN_b8g8r8
# define PIXMAN_LE_a8r8g8b8 PIXMAN_b8g8r8a8
# define PIXMAN_LE_x8r8g8b8 PIXMAN_b8g8r8x8
# define PIXMAN_LE_a8b8g8r8 PIXMAN_r8g8b8a8
# define PIXMAN_LE_x8b8g8r8 PIXMAN_r8g8b8x8
#else
# define PIXMAN_BE_r8g8b8 PIXMAN_b8g8r8
# define PIXMAN_BE_x8r8g8b8 PIXMAN_b8g8r8x8
Expand All @@ -45,6 +47,8 @@
# define PIXMAN_LE_r8g8b8 PIXMAN_r8g8b8
# define PIXMAN_LE_a8r8g8b8 PIXMAN_a8r8g8b8
# define PIXMAN_LE_x8r8g8b8 PIXMAN_x8r8g8b8
# define PIXMAN_LE_a8b8g8r8 PIXMAN_a8b8g8r8
# define PIXMAN_LE_x8b8g8r8 PIXMAN_x8b8g8r8
#endif

#define QEMU_PIXMAN_COLOR(r, g, b) \
Expand Down
4 changes: 4 additions & 0 deletions scripts/analyze-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class RamSection(object):
RAM_SAVE_FLAG_CONTINUE = 0x20
RAM_SAVE_FLAG_XBZRLE = 0x40
RAM_SAVE_FLAG_HOOK = 0x80
RAM_SAVE_FLAG_COMPRESS_PAGE = 0x100
RAM_SAVE_FLAG_MULTIFD_FLUSH = 0x200

def __init__(self, file, version_id, ramargs, section_key):
if version_id != 4:
Expand Down Expand Up @@ -205,6 +207,8 @@ def read(self):
raise Exception("XBZRLE RAM compression is not supported yet")
elif flags & self.RAM_SAVE_FLAG_HOOK:
raise Exception("RAM hooks don't make sense with files")
if flags & self.RAM_SAVE_FLAG_MULTIFD_FLUSH:
continue

# End of RAM section
if flags & self.RAM_SAVE_FLAG_EOS:
Expand Down
2 changes: 1 addition & 1 deletion ui/cocoa.m
Original file line number Diff line number Diff line change
Expand Up @@ -2001,7 +2001,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl)
COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n");
graphic_hw_update(NULL);

if (qemu_input_is_absolute()) {
if (qemu_input_is_absolute(dcl->con)) {
dispatch_async(dispatch_get_main_queue(), ^{
if (![cocoaView isAbsoluteEnabled]) {
if ([cocoaView isMouseGrabbed]) {
Expand Down
24 changes: 11 additions & 13 deletions ui/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -1434,25 +1434,23 @@ bool qemu_console_is_gl_blocked(QemuConsole *con)
return con->gl_block;
}

bool qemu_console_is_multihead(DeviceState *dev)
static bool qemu_graphic_console_is_multihead(QemuGraphicConsole *c)
{
QemuConsole *con;
Object *obj;
uint32_t f = 0xffffffff;
uint32_t h;

QTAILQ_FOREACH(con, &consoles, next) {
obj = object_property_get_link(OBJECT(con),
"device", &error_abort);
if (DEVICE(obj) != dev) {
QemuGraphicConsole *candidate;

if (!QEMU_IS_GRAPHIC_CONSOLE(con)) {
continue;
}

h = object_property_get_uint(OBJECT(con),
"head", &error_abort);
if (f == 0xffffffff) {
f = h;
} else if (h != f) {
candidate = QEMU_GRAPHIC_CONSOLE(con);
if (candidate->device != c->device) {
continue;
}

if (candidate->head != c->head) {
return true;
}
}
Expand All @@ -1468,7 +1466,7 @@ char *qemu_console_get_label(QemuConsole *con)
bool multihead;

dev = DEVICE(c->device);
multihead = qemu_console_is_multihead(dev);
multihead = qemu_graphic_console_is_multihead(c);
if (multihead) {
return g_strdup_printf("%s.%d", dev->id ?
dev->id :
Expand Down
6 changes: 3 additions & 3 deletions ui/dbus-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ dbus_mouse_rel_motion(DBusDisplayConsole *ddc,
{
trace_dbus_mouse_rel_motion(dx, dy);

if (qemu_input_is_absolute()) {
if (qemu_input_is_absolute(ddc->dcl.con)) {
g_dbus_method_invocation_return_error(
invocation, DBUS_DISPLAY_ERROR,
DBUS_DISPLAY_ERROR_INVALID,
Expand Down Expand Up @@ -453,7 +453,7 @@ dbus_mouse_set_pos(DBusDisplayConsole *ddc,

trace_dbus_mouse_set_pos(x, y);

if (!qemu_input_is_absolute()) {
if (!qemu_input_is_absolute(ddc->dcl.con)) {
g_dbus_method_invocation_return_error(
invocation, DBUS_DISPLAY_ERROR,
DBUS_DISPLAY_ERROR_INVALID,
Expand Down Expand Up @@ -514,7 +514,7 @@ static void
dbus_mouse_update_is_absolute(DBusDisplayConsole *ddc)
{
g_object_set(ddc->iface_mouse,
"is-absolute", qemu_input_is_absolute(),
"is-absolute", qemu_input_is_absolute(ddc->dcl.con),
NULL);
}

Expand Down
20 changes: 14 additions & 6 deletions ui/gtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static void gd_update_cursor(VirtualConsole *vc)
}

window = gtk_widget_get_window(GTK_WIDGET(vc->gfx.drawing_area));
if (s->full_screen || qemu_input_is_absolute() || s->ptr_owner == vc) {
if (s->full_screen || qemu_input_is_absolute(vc->gfx.dcl.con) || s->ptr_owner == vc) {
gdk_window_set_cursor(window, s->null_cursor);
} else {
gdk_window_set_cursor(window, NULL);
Expand Down Expand Up @@ -453,7 +453,7 @@ static void gd_mouse_set(DisplayChangeListener *dcl,
gint x_root, y_root;

if (!gtk_widget_get_realized(vc->gfx.drawing_area) ||
qemu_input_is_absolute()) {
qemu_input_is_absolute(dcl->con)) {
return;
}

Expand Down Expand Up @@ -689,7 +689,7 @@ static void gd_mouse_mode_change(Notifier *notify, void *data)

s = container_of(notify, GtkDisplayState, mouse_mode_notifier);
/* release the grab at switching to absolute mode */
if (qemu_input_is_absolute() && s->ptr_owner) {
if (s->ptr_owner && qemu_input_is_absolute(s->ptr_owner->gfx.dcl.con)) {
if (!s->ptr_owner->window) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
Expand Down Expand Up @@ -726,6 +726,10 @@ static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate)
{
QemuUIInfo info;

if (!dpy_ui_info_supported(vc->gfx.dcl.con)) {
return;
}

info = *dpy_get_ui_info(vc->gfx.dcl.con);
info.refresh_rate = refresh_rate;
dpy_set_ui_info(vc->gfx.dcl.con, &info, true);
Expand All @@ -735,6 +739,10 @@ static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height)
{
QemuUIInfo info;

if (!dpy_ui_info_supported(vc->gfx.dcl.con)) {
return;
}

info = *dpy_get_ui_info(vc->gfx.dcl.con);
info.width = width;
info.height = height;
Expand Down Expand Up @@ -903,7 +911,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
x = (motion->x - mx) / vc->gfx.scale_x * ws;
y = (motion->y - my) / vc->gfx.scale_y * ws;

if (qemu_input_is_absolute()) {
if (qemu_input_is_absolute(vc->gfx.dcl.con)) {
if (x < 0 || y < 0 ||
x >= surface_width(vc->gfx.ds) ||
y >= surface_height(vc->gfx.ds)) {
Expand All @@ -923,7 +931,7 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
s->last_y = y;
s->last_set = TRUE;

if (!qemu_input_is_absolute() && s->ptr_owner == vc) {
if (!qemu_input_is_absolute(vc->gfx.dcl.con) && s->ptr_owner == vc) {
GdkScreen *screen = gtk_widget_get_screen(vc->gfx.drawing_area);
GdkDisplay *dpy = gtk_widget_get_display(widget);
GdkWindow *win = gtk_widget_get_window(widget);
Expand Down Expand Up @@ -965,7 +973,7 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,

/* implicitly grab the input at the first click in the relative mode */
if (button->button == 1 && button->type == GDK_BUTTON_PRESS &&
!qemu_input_is_absolute() && s->ptr_owner != vc) {
!qemu_input_is_absolute(vc->gfx.dcl.con) && s->ptr_owner != vc) {
if (!vc->window) {
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
TRUE);
Expand Down

0 comments on commit c7c907b

Please sign in to comment.