Skip to contentSkip to conversation

Kraxel 20220614 patches

GIT PULL Applied Gerd Hoffmann 5 participants 21 messages Jun 14, 2022 – May 2, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

The following changes since commit debd0753663bc89c86f5462a53268f2e3f680f60:

Merge tag 'pull-testing-next-140622-1' of https://github.com/stsquad/qemu into staging (2022-06-13 21:10:57 -0700)

are available in the Git repository at:

git://git.kraxel.org/qemu tags/kraxel-20220614-pull-request

for you to fetch changes up to b95b56311a0890da0c9f7fc624529c3d7f8dbce0:

virtio-gpu: Respect UI refresh rate for EDID (2022-06-14 10:34:37 +0200)

----------------------------------------------------------------
usb: add CanoKey device, fixes for ehci + redir
ui: fixes for gtk and cocoa, rework refresh rate
virtio-gpu: scanout flush fix

----------------------------------------------------------------

Akihiko Odaki (4):
ui/cocoa: Fix poweroff request code
ui/console: Do not return a value with ui_info
ui: Deliver refresh rate via QemuUIInfo
virtio-gpu: Respect UI refresh rate for EDID

Arnout Engelen (1):
hw/usb/hcd-ehci: fix writeback order

Dongwon Kim (1):
virtio-gpu: update done only on the scanout associated with rect

Hongren (Zenithal) Zheng (6):
hw/usb: Add CanoKey Implementation
hw/usb/canokey: Add trace events
meson: Add CanoKey
docs: Add CanoKey documentation docs/system/devices/usb: Add CanoKey to USB devices examples
MAINTAINERS: add myself as CanoKey maintainer

Joelle van Dyne (1):
usbredir: avoid queuing hello packet on snapshot restore

Volker Rümelin (2):
ui/gtk-gl-area: implement GL context destruction ui/gtk-gl-area: create the requested GL context version

 meson_options.txt                |   2 +
 hw/usb/canokey.h                 |  69 +++++++
 include/hw/virtio/virtio-gpu.h   |   1 +
 include/ui/console.h             |   4 +-
 include/ui/gtk.h                 |   2 +-
 hw/display/virtio-gpu-base.c     |   7 +-
 hw/display/virtio-gpu.c          |   4 +
 hw/display/virtio-vga.c          |   5 +-
 hw/display/xenfb.c               |  14 +-
 hw/usb/canokey.c                 | 313 +++++++++++++++++++++++++++++++
 hw/usb/hcd-ehci.c                |   5 +-
 hw/usb/redirect.c                |   3 +-
 hw/vfio/display.c                |   8 +-
 ui/console.c                     |   6 -
 ui/gtk-egl.c                     |   4 +-
 ui/gtk-gl-area.c                 |  42 ++++-
 ui/gtk.c                         |  45 +++--
 MAINTAINERS                      |   8 +
 docs/system/device-emulation.rst |   1 +
 docs/system/devices/canokey.rst  | 168 +++++++++++++++++
 docs/system/devices/usb.rst      |   4 +
 hw/usb/Kconfig                   |   5 +
 hw/usb/meson.build               |   5 +
 hw/usb/trace-events              |  16 ++
 meson.build                      |   6 +
 scripts/meson-buildoptions.sh    |   3 +
 ui/cocoa.m                       |   6 +-
 ui/trace-events                  |   2 +
 28 files changed, 707 insertions(+), 51 deletions(-)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
 create mode 100644 docs/system/devices/canokey.rst
Signature · 1 line
2.36.1
#1 lore raw

[PULL 01/15] ui/gtk-gl-area: implement GL context destruction

From: Volker Rümelin <[email protected]>

The counterpart function for gd_gl_area_create_context() is currently empty. Implement the gd_gl_area_destroy_context() function to avoid GL context leaks.

Message-Id: <[email protected]>

---
 ui/gtk-gl-area.c | 8 +++++++-
 ui/trace-events  | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
ui/gtk-gl-area.c +7 -1
index fc5a082eb846..0e20ea031d34 100644
@@ -201,7 +201,13 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
 
 void gd_gl_area_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx)
 {
-    /* FIXME */
+    GdkGLContext *current_ctx = gdk_gl_context_get_current();
+
+    trace_gd_gl_area_destroy_context(ctx, current_ctx);
+    if (ctx == current_ctx) {
+        gdk_gl_context_clear_current();
+    }
+    g_clear_object(&ctx);
 }
 
 void gd_gl_area_scanout_texture(DisplayChangeListener *dcl,
ui/trace-events +1 -0
index f78b5e66061f..1040ba0f88c7 100644
@@ -26,6 +26,7 @@ gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *action)
 gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, dev=%s, reason=%s"
 gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
 gd_keymap_windowing(const char *name) "backend=%s"
+gd_gl_area_destroy_context(void *ctx, void *current_ctx) "ctx=%p, current_ctx=%p"
 
 # vnc-auth-sasl.c
 # vnc-auth-vencrypt.c
Signature · 1 line
2.36.1
#2 lore raw

[PULL 02/15] ui/gtk-gl-area: create the requested GL context version

In reply to Gerd Hoffmann

From: Volker Rümelin <[email protected]>

Since about 2018 virglrenderer (commit fa835b0f88 "vrend: don't hardcode context version") tries to open the highest available GL context version. This is done by creating the known GL context versions from the highest to the lowest until (*create_gl_context) returns a context != NULL.

This does not work properly with
the current QEMU gd_gl_area_create_context() function, because gdk_gl_context_realize() on Wayland creates a version 3.0 legacy context if the requested GL context version can't be created.

In order for virglrenderer to find the highest available GL context version, return NULL if the created context version is lower than the requested version.

This fixes the following error:
QEMU started with -device virtio-vga-gl -display gtk,gl=on. Under Wayland, the guest window remains black and the following information can be seen on the host.

gl_version 30 - compat profile
(qemu:5978): Gdk-WARNING **: 16:19:01.533:
gdk_gl_context_set_required_version
- GL context versions less than 3.2 are not supported.

(qemu:5978): Gdk-WARNING **: 16:19:01.537:
gdk_gl_context_set_required_version -
GL context versions less than 3.2 are not supported.

(qemu:5978): Gdk-WARNING **: 16:19:01.554:
gdk_gl_context_set_required_version -
GL context versions less than 3.2 are not supported.
vrend_renderer_fill_caps: Entering with stale GL error: 1282

To reproduce this error, an OpenGL driver is required on the host that doesn't have the latest OpenGL extensions fully implemented. An example for this is the Intel i965 driver on a Haswell processor.

Message-Id: <[email protected]>

---
 ui/gtk-gl-area.c | 31 ++++++++++++++++++++++++++++++-
 ui/trace-events  |  1 +
 2 files changed, 31 insertions(+), 1 deletion(-)
ui/gtk-gl-area.c +30 -1
index 0e20ea031d34..2e0129c28cd4 100644
@@ -170,6 +170,23 @@ void gd_gl_area_switch(DisplayChangeListener *dcl,
     }
 }
 
+static int gd_cmp_gl_context_version(int major, int minor, QEMUGLParams *params)
+{
+    if (major > params->major_ver) {
+        return 1;
+    }
+    if (major < params->major_ver) {
+        return -1;
+    }
+    if (minor > params->minor_ver) {
+        return 1;
+    }
+    if (minor < params->minor_ver) {
+        return -1;
+    }
+    return 0;
+}
+
 QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
                                         QEMUGLParams *params)
 {
@@ -177,8 +194,8 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
     GdkWindow *window;
     GdkGLContext *ctx;
     GError *err = NULL;
+    int major, minor;
 
-    gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
     window = gtk_widget_get_window(vc->gfx.drawing_area);
     ctx = gdk_window_create_gl_context(window, &err);
     if (err) {
@@ -196,6 +213,18 @@ QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc,
         g_clear_object(&ctx);
         return NULL;
     }
+
+    gdk_gl_context_make_current(ctx);
+    gdk_gl_context_get_version(ctx, &major, &minor);
+    gdk_gl_context_clear_current();
+    gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
+
+    if (gd_cmp_gl_context_version(major, minor, params) == -1) {
+        /* created ctx version < requested version */
+        g_clear_object(&ctx);
+    }
+
+    trace_gd_gl_area_create_context(ctx, params->major_ver, params->minor_ver);
     return ctx;
 }
 
ui/trace-events +1 -0
index 1040ba0f88c7..a922f00e10b4 100644
@@ -26,6 +26,7 @@ gd_key_event(const char *tab, int gdk_keycode, int qkeycode, const char *action)
 gd_grab(const char *tab, const char *device, const char *reason) "tab=%s, dev=%s, reason=%s"
 gd_ungrab(const char *tab, const char *device) "tab=%s, dev=%s"
 gd_keymap_windowing(const char *name) "backend=%s"
+gd_gl_area_create_context(void *ctx, int major, int minor) "ctx=%p, major=%d, minor=%d"
 gd_gl_area_destroy_context(void *ctx, void *current_ctx) "ctx=%p, current_ctx=%p"
 
 # vnc-auth-sasl.c
Signature · 1 line
2.36.1
#3 lore raw

[PULL 03/15] ui/cocoa: Fix poweroff request code

In reply to Gerd Hoffmann

From: Akihiko Odaki <[email protected]>

Message-Id: <[email protected]>

---
 ui/cocoa.m | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
ui/cocoa.m +5 -1
index 09a62817f2a9..84c84e98fc5e 100644
@@ -35,6 +35,7 @@
 #include "ui/kbd-state.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
+#include "sysemu/runstate-action.h"
 #include "sysemu/cpu-throttle.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-block.h"
@@ -1290,7 +1291,10 @@ - (void)applicationWillTerminate:(NSNotification *)aNotification
 {
     COCOA_DEBUG("QemuCocoaAppController: applicationWillTerminate\n");
 
-    qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
+    with_iothread_lock(^{
+        shutdown_action = SHUTDOWN_ACTION_POWEROFF;
+        qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
+    });
 
     /*
      * Sleep here, because returning will cause OSX to kill us
Signature · 1 line
2.36.1
#4 lore raw

[PULL 04/15] hw/usb: Add CanoKey Implementation

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

This commit added a new emulated device called CanoKey to QEMU.

CanoKey implements platform independent features in canokey-core
https://github.com/canokeys/canokey-core, and leaves the USB implementation to the platform.

In this commit the USB part was implemented in QEMU using QEMU's USB APIs, therefore the emulated CanoKey can communicate with the guest OS using USB.

Message-Id: <YoY6Mgph6f6Hc/zI@Sun>

---
 hw/usb/canokey.h |  69 +++++++++++
 hw/usb/canokey.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 369 insertions(+)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
hw/usb/canokey.h new file +69 -0
new file mode 100644
index 000000000000..24cf30420346
@@ -0,0 +1,69 @@
+/*
+ * CanoKey QEMU device header.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */
+
+#ifndef CANOKEY_H
+#define CANOKEY_H
+
+#include "hw/qdev-core.h"
+
+#define TYPE_CANOKEY "canokey"
+#define CANOKEY(obj) \
+    OBJECT_CHECK(CanoKeyState, (obj), TYPE_CANOKEY)
+
+/*
+ * State of Canokey (i.e. hw/canokey.c)
+ */
+
+/* CTRL INTR BULK */
+#define CANOKEY_EP_NUM 3
+/* BULK/INTR IN can be up to 1352 bytes, e.g. get key info */
+#define CANOKEY_EP_IN_BUFFER_SIZE 2048
+/* BULK OUT can be up to 270 bytes, e.g. PIV import cert */
+#define CANOKEY_EP_OUT_BUFFER_SIZE 512
+
+typedef enum {
+    CANOKEY_EP_IN_WAIT,
+    CANOKEY_EP_IN_READY,
+    CANOKEY_EP_IN_STALL
+} CanoKeyEPState;
+
+typedef struct CanoKeyState {
+    USBDevice dev;
+
+    /* IN packets from canokey device loop */
+    uint8_t ep_in[CANOKEY_EP_NUM][CANOKEY_EP_IN_BUFFER_SIZE];
+    /*
+     * See canokey_emu_transmit
+     *
+     * For large INTR IN, receive multiple data from canokey device loop
+     * in this case ep_in_size would increase with every call
+     */
+    uint32_t ep_in_size[CANOKEY_EP_NUM];
+    /*
+     * Used in canokey_handle_data
+     * for IN larger than p->iov.size, we would do multiple handle_data()
+     *
+     * The difference between ep_in_pos and ep_in_size:
+     * We first increase ep_in_size to fill ep_in buffer in device_loop,
+     * then use ep_in_pos to submit data from ep_in buffer in handle_data
+     */
+    uint32_t ep_in_pos[CANOKEY_EP_NUM];
+    CanoKeyEPState ep_in_state[CANOKEY_EP_NUM];
+
+    /* OUT pointer to canokey recv buffer */
+    uint8_t *ep_out[CANOKEY_EP_NUM];
+    uint32_t ep_out_size[CANOKEY_EP_NUM];
+    /* For large BULK OUT, multiple write to ep_out is needed */
+    uint8_t ep_out_buffer[CANOKEY_EP_NUM][CANOKEY_EP_OUT_BUFFER_SIZE];
+
+    /* Properties */
+    char *file; /* canokey-file */
+} CanoKeyState;
+
+#endif /* CANOKEY_H */
hw/usb/canokey.c new file +300 -0

300 lines not on this page · raw message

Signature · 1 line
2.36.1
#5 lore raw

Apache license usage (was Re: [PULL 04/15] hw/usb: Add CanoKey Implementation)

Quoted 42 lines · Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

This commit added a new emulated device called CanoKey to QEMU.

CanoKey implements platform independent features in canokey-core
https://github.com/canokeys/canokey-core, and leaves the USB implementation to the platform.

In this commit the USB part was implemented in QEMU using QEMU's USB APIs, therefore the emulated CanoKey can communicate with the guest OS using USB.

Message-Id: <YoY6Mgph6f6Hc/zI@Sun>

---
 hw/usb/canokey.h |  69 +++++++++++
 hw/usb/canokey.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 369 insertions(+)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
hw/usb/canokey.h new file +8 -0
new file mode 100644
index 000000000000..24cf30420346
@@ -0,0 +1,69 @@
+/*
+ * CanoKey QEMU device header.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */
hw/usb/canokey.c new file +0 -0
new file mode 100644
index 000000000000..6cb8b7cdb089

hw/usb/canokey.c line 8

Quoted 8 lines
hw/usb/canokey.c new file +8 -0
@@ -0,0 +1,300 @@
+/*
+ * CanoKey QEMU device implementation.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */

In the process of auditing licensing in QEMU I found this patch adding code that is Apache-2.0 licensed, and as such I don't think we should have ever merged the patch as is.

QEMU as a combined work is GPLv2-only.

There is disagreement between the Apache foundation and FSF on this topic[1], but FSF considered Apache 2.0 to be incompatible with the GPL-v2. Fedora licensing follows the same view of Apache being GPLv2 incompatible.

More generally I think it is a little dubious to write new devices while claiming a license that's different from normal QEMU code license. I expect there is inevitably a degree of cut+paste from existing QEMU code to handle the device boilerplate code which would be sufficient to expect a GPLv2-or-later license to apply.

The two added files in this commit are the only occurrence of Apache licensing in QEMU that I see.

Hongren, IIUC from the attribution above, you wrote the code but Canokeys.org claims copyright. Could you report whether Canokeys.org will agree to change the licensing on these files to QEMU's normal GPLv2-or-later licensing.

With regards,
Daniel

[1] https://www.apache.org/licenses/GPL-compatibility.html

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw

Re: Apache license usage (was Re: [PULL 04/15] hw/usb: Add CanoKey Implementation)

Quoted 69 lines · Daniel P. Berrangé
Quoted 42 lines · Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

This commit added a new emulated device called CanoKey to QEMU.

CanoKey implements platform independent features in canokey-core
https://github.com/canokeys/canokey-core, and leaves the USB implementation to the platform.

In this commit the USB part was implemented in QEMU using QEMU's USB APIs, therefore the emulated CanoKey can communicate with the guest OS using USB.

Message-Id: <YoY6Mgph6f6Hc/zI@Sun>

---
 hw/usb/canokey.h |  69 +++++++++++
 hw/usb/canokey.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 369 insertions(+)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
hw/usb/canokey.h new file +8 -0
new file mode 100644
index 000000000000..24cf30420346
@@ -0,0 +1,69 @@
+/*
+ * CanoKey QEMU device header.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */
hw/usb/canokey.c new file +0 -0
new file mode 100644
index 000000000000..6cb8b7cdb089

hw/usb/canokey.c line 8

Quoted 8 lines
hw/usb/canokey.c new file +8 -0
@@ -0,0 +1,300 @@
+/*
+ * CanoKey QEMU device implementation.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */

In the process of auditing licensing in QEMU I found this patch adding code that is Apache-2.0 licensed, and as such I don't think we should have ever merged the patch as is.

QEMU as a combined work is GPLv2-only.

There is disagreement between the Apache foundation and FSF on this topic[1], but FSF considered Apache 2.0 to be incompatible with the GPL-v2. Fedora licensing follows the same view of Apache being GPLv2 incompatible.

More generally I think it is a little dubious to write new devices while claiming a license that's different from normal QEMU code license. I expect there is inevitably a degree of cut+paste from existing QEMU code to handle the device boilerplate code which would be sufficient to expect a GPLv2-or-later license to apply.

Quoted 7 lines

The two added files in this commit are the only occurrence of Apache licensing in QEMU that I see.

Hongren, IIUC from the attribution above, you wrote the code but Canokeys.org claims copyright. Could you report whether Canokeys.org will agree to change the licensing on these files to QEMU's normal GPLv2-or-later licensing.

I have discussed it internally with canokeys.org and they agreed to re-license it under GPLv2+

I will send a patch modifying the license.

In the meantime, canokey.c was also modified by
MkfsSion <[email protected]>

I've Cc'ed MkfsSion for their attitude on this.

Quoted 10 lines

With regards,
Daniel

[1] https://www.apache.org/licenses/GPL-compatibility.html

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Acked-by
#7 lore raw

Re: Apache license usage (was Re: [PULL 04/15] hw/usb: Add CanoKey Implementation)

Quoted 81 lines · Hongren (Zenithal) Zheng
Quoted 69 lines · Daniel P. Berrangé
Quoted 42 lines · Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

This commit added a new emulated device called CanoKey to QEMU.

CanoKey implements platform independent features in canokey-core
https://github.com/canokeys/canokey-core, and leaves the USB implementation to the platform.

In this commit the USB part was implemented in QEMU using QEMU's USB APIs, therefore the emulated CanoKey can communicate with the guest OS using USB.

Message-Id: <YoY6Mgph6f6Hc/zI@Sun>

---
 hw/usb/canokey.h |  69 +++++++++++
 hw/usb/canokey.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 369 insertions(+)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
hw/usb/canokey.h new file +8 -0
new file mode 100644
index 000000000000..24cf30420346
@@ -0,0 +1,69 @@
+/*
+ * CanoKey QEMU device header.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */
hw/usb/canokey.c new file +0 -0
new file mode 100644
index 000000000000..6cb8b7cdb089

hw/usb/canokey.c line 8

Quoted 8 lines
hw/usb/canokey.c new file +8 -0
@@ -0,0 +1,300 @@
+/*
+ * CanoKey QEMU device implementation.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */

In the process of auditing licensing in QEMU I found this patch adding code that is Apache-2.0 licensed, and as such I don't think we should have ever merged the patch as is.

QEMU as a combined work is GPLv2-only.

There is disagreement between the Apache foundation and FSF on this topic[1], but FSF considered Apache 2.0 to be incompatible with the GPL-v2. Fedora licensing follows the same view of Apache being GPLv2 incompatible.

More generally I think it is a little dubious to write new devices while claiming a license that's different from normal QEMU code license. I expect there is inevitably a degree of cut+paste from existing QEMU code to handle the device boilerplate code which would be sufficient to expect a GPLv2-or-later license to apply.

Quoted 7 lines

The two added files in this commit are the only occurrence of Apache licensing in QEMU that I see.

Hongren, IIUC from the attribution above, you wrote the code but Canokeys.org claims copyright. Could you report whether Canokeys.org will agree to change the licensing on these files to QEMU's normal GPLv2-or-later licensing.

I have discussed it internally with canokeys.org and they agreed to re-license it under GPLv2+

Quoted 6 lines

I will send a patch modifying the license.

In the meantime, canokey.c was also modified by
MkfsSion <[email protected]>

I've Cc'ed MkfsSion for their attitude on this.

Quoted 11 lines
Quoted 11 lines

With regards,
Daniel

[1] https://www.apache.org/licenses/GPL-compatibility.html

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#8 lore raw

Re: Apache license usage (was Re: [PULL 04/15] hw/usb: Add CanoKey Implementation)

Quoted 82 lines · MkfsSion
Quoted 81 lines · Hongren (Zenithal) Zheng
Quoted 69 lines · Daniel P. Berrangé
Quoted 42 lines · Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

This commit added a new emulated device called CanoKey to QEMU.

CanoKey implements platform independent features in canokey-core
https://github.com/canokeys/canokey-core, and leaves the USB implementation to the platform.

In this commit the USB part was implemented in QEMU using QEMU's USB APIs, therefore the emulated CanoKey can communicate with the guest OS using USB.

Message-Id: <YoY6Mgph6f6Hc/zI@Sun>

---
 hw/usb/canokey.h |  69 +++++++++++
 hw/usb/canokey.c | 300 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 369 insertions(+)
 create mode 100644 hw/usb/canokey.h
 create mode 100644 hw/usb/canokey.c
hw/usb/canokey.h new file +8 -0
new file mode 100644
index 000000000000..24cf30420346
@@ -0,0 +1,69 @@
+/*
+ * CanoKey QEMU device header.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */
hw/usb/canokey.c new file +0 -0
new file mode 100644
index 000000000000..6cb8b7cdb089

hw/usb/canokey.c line 8

Quoted 8 lines
hw/usb/canokey.c new file +8 -0
@@ -0,0 +1,300 @@
+/*
+ * CanoKey QEMU device implementation.
+ *
+ * Copyright (c) 2021-2022 Canokeys.org <[email protected]>
+ * Written by Hongren (Zenithal) Zheng <[email protected]>
+ *
+ * This code is licensed under the Apache-2.0.
+ */

In the process of auditing licensing in QEMU I found this patch adding code that is Apache-2.0 licensed, and as such I don't think we should have ever merged the patch as is.

QEMU as a combined work is GPLv2-only.

There is disagreement between the Apache foundation and FSF on this topic[1], but FSF considered Apache 2.0 to be incompatible with the GPL-v2. Fedora licensing follows the same view of Apache being GPLv2 incompatible.

More generally I think it is a little dubious to write new devices while claiming a license that's different from normal QEMU code license. I expect there is inevitably a degree of cut+paste from existing QEMU code to handle the device boilerplate code which would be sufficient to expect a GPLv2-or-later license to apply.

Quoted 7 lines

The two added files in this commit are the only occurrence of Apache licensing in QEMU that I see.

Hongren, IIUC from the attribution above, you wrote the code but Canokeys.org claims copyright. Could you report whether Canokeys.org will agree to change the licensing on these files to QEMU's normal GPLv2-or-later licensing.

I have discussed it internally with canokeys.org and they agreed to re-license it under GPLv2+

Quoted 7 lines
Quoted 6 lines

I will send a patch modifying the license.

In the meantime, canokey.c was also modified by
MkfsSion <[email protected]>

I've Cc'ed MkfsSion for their attitude on this.

That's great, thanks to all for the quick response.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#9 lore raw

[PULL 08/15] docs/system/devices/usb: Add CanoKey to USB devices examples

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

Message-Id: <YoY6o+QFhzA7VHcZ@Sun>

---
 docs/system/devices/usb.rst | 4 ++++
 1 file changed, 4 insertions(+)
docs/system/devices/usb.rst +4 -0
index afb7d6c2268d..872d9167589b 100644
@@ -199,6 +199,10 @@ option or the ``device_add`` monitor command. Available devices are:
 ``u2f-{emulated,passthru}``
    Universal Second Factor device
 
+``canokey``
+   An Open-source Secure Key implementing FIDO2, OpenPGP, PIV and more.
+   For more information, see :ref:`canokey`.
+
 Physical port addressing
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
Signature · 1 line
2.36.1
#10 lore raw

[PULL 07/15] docs: Add CanoKey documentation

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

Message-Id: <YoY6ilQimrK+l5NN@Sun>

---
 docs/system/device-emulation.rst |   1 +
 docs/system/devices/canokey.rst  | 168 +++++++++++++++++++++++++++++++
 2 files changed, 169 insertions(+)
 create mode 100644 docs/system/devices/canokey.rst
docs/system/device-emulation.rst +1 -0
index 3b729b920d7c..05060060563f 100644
@@ -92,3 +92,4 @@ Emulated Devices
    devices/vhost-user.rst
    devices/virtio-pmem.rst
    devices/vhost-user-rng.rst
+   devices/canokey.rst
docs/system/devices/canokey.rst new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
2.36.1
#11 lore raw

[PULL 05/15] hw/usb/canokey: Add trace events

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

Message-Id: <YoY6RoDKQIxSkFwL@Sun>

---
 hw/usb/canokey.c    | 13 +++++++++++++
 hw/usb/trace-events | 16 ++++++++++++++++
 2 files changed, 29 insertions(+)
hw/usb/canokey.c +13 -0
index 6cb8b7cdb089..4a08b1cbd776 100644
@@ -14,6 +14,7 @@
 #include "qapi/error.h"
 #include "hw/usb.h"
 #include "hw/qdev-properties.h"
+#include "trace.h"
 #include "desc.h"
 #include "canokey.h"
 
@@ -66,6 +67,7 @@ static const USBDesc desc_canokey = {
  */
 int canokey_emu_stall_ep(void *base, uint8_t ep)
 {
+    trace_canokey_emu_stall_ep(ep);
     CanoKeyState *key = base;
     uint8_t ep_in = CANOKEY_EP_IN(ep); /* INTR IN has ep 129 */
     key->ep_in_size[ep_in] = 0;
@@ -75,6 +77,7 @@ int canokey_emu_stall_ep(void *base, uint8_t ep)
 
 int canokey_emu_set_address(void *base, uint8_t addr)
 {
+    trace_canokey_emu_set_address(addr);
     CanoKeyState *key = base;
     key->dev.addr = addr;
     return 0;
@@ -83,6 +86,7 @@ int canokey_emu_set_address(void *base, uint8_t addr)
 int canokey_emu_prepare_receive(
         void *base, uint8_t ep, uint8_t *pbuf, uint16_t size)
 {
+    trace_canokey_emu_prepare_receive(ep, size);
     CanoKeyState *key = base;
     key->ep_out[ep] = pbuf;
     key->ep_out_size[ep] = size;
@@ -92,6 +96,7 @@ int canokey_emu_prepare_receive(
 int canokey_emu_transmit(
         void *base, uint8_t ep, const uint8_t *pbuf, uint16_t size)
 {
+    trace_canokey_emu_transmit(ep, size);
     CanoKeyState *key = base;
     uint8_t ep_in = CANOKEY_EP_IN(ep); /* INTR IN has ep 129 */
     memcpy(key->ep_in[ep_in] + key->ep_in_size[ep_in],
@@ -125,6 +130,7 @@ uint32_t canokey_emu_get_rx_data_size(void *base, uint8_t ep)
  */
 static void canokey_handle_reset(USBDevice *dev)
 {
+    trace_canokey_handle_reset();
     CanoKeyState *key = CANOKEY(dev);
     for (int i = 0; i != CANOKEY_EP_NUM; ++i) {
         key->ep_in_state[i] = CANOKEY_EP_IN_WAIT;
@@ -137,6 +143,7 @@ static void canokey_handle_reset(USBDevice *dev)
 static void canokey_handle_control(USBDevice *dev, USBPacket *p,
                int request, int value, int index, int length, uint8_t *data)
 {
+    trace_canokey_handle_control_setup(request, value, index, length);
     CanoKeyState *key = CANOKEY(dev);
 
     canokey_emu_setup(request, value, index, length);
@@ -144,6 +151,7 @@ static void canokey_handle_control(USBDevice *dev, USBPacket *p,
     uint32_t dir_in = request & DeviceRequest;
     if (!dir_in) {
         /* OUT */
+        trace_canokey_handle_control_out();
         if (key->ep_out[0] != NULL) {
             memcpy(key->ep_out[0], data, length);
         }
@@ -163,6 +171,7 @@ static void canokey_handle_control(USBDevice *dev, USBPacket *p,
     case CANOKEY_EP_IN_READY:
         memcpy(data, key->ep_in[0], key->ep_in_size[0]);
         p->actual_length = key->ep_in_size[0];
+        trace_canokey_handle_control_in(p->actual_length);
         /* reset state */
         key->ep_in_state[0] = CANOKEY_EP_IN_WAIT;
         key->ep_in_size[0] = 0;
@@ -182,6 +191,7 @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p)
     uint32_t out_len;
     switch (p->pid) {
     case USB_TOKEN_OUT:
+        trace_canokey_handle_data_out(ep_out, p->iov.size);
         usb_packet_copy(p, key->ep_out_buffer[ep_out], p->iov.size);
         out_pos = 0;
         while (out_pos != p->iov.size) {
@@ -226,6 +236,7 @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p)
                 key->ep_in_size[ep_in] = 0;
                 key->ep_in_pos[ep_in] = 0;
             }
+            trace_canokey_handle_data_in(ep_in, in_len);
             break;
         }
         break;
@@ -237,6 +248,7 @@ static void canokey_handle_data(USBDevice *dev, USBPacket *p)
 
 static void canokey_realize(USBDevice *base, Error **errp)
 {
+    trace_canokey_realize();
     CanoKeyState *key = CANOKEY(base);
 
     if (key->file == NULL) {
@@ -260,6 +272,7 @@ static void canokey_realize(USBDevice *base, Error **errp)
 
 static void canokey_unrealize(USBDevice *base)
 {
+    trace_canokey_unrealize();
 }
 
 static Property canokey_properties[] = {
hw/usb/trace-events +16 -0
index 9773cb53300d..914ca7166829 100644
@@ -345,3 +345,19 @@ usb_serial_set_baud(int bus, int addr, int baud) "dev %d:%u baud rate %d"
 usb_serial_set_data(int bus, int addr, int parity, int data, int stop) "dev %d:%u parity %c, data bits %d, stop bits %d"
 usb_serial_set_flow_control(int bus, int addr, int index) "dev %d:%u flow control %d"
 usb_serial_set_xonxoff(int bus, int addr, uint8_t xon, uint8_t xoff) "dev %d:%u xon 0x%x xoff 0x%x"
+
+# canokey.c
+canokey_emu_stall_ep(uint8_t ep) "ep %d"
+canokey_emu_set_address(uint8_t addr) "addr %d"
+canokey_emu_prepare_receive(uint8_t ep, uint16_t size) "ep %d size %d"
+canokey_emu_transmit(uint8_t ep, uint16_t size) "ep %d size %d"
+canokey_thread_start(void)
+canokey_thread_stop(void)
+canokey_handle_reset(void)
+canokey_handle_control_setup(int request, int value, int index, int length) "request 0x%04X value 0x%04X index 0x%04X length 0x%04X"
+canokey_handle_control_out(void)
+canokey_handle_control_in(int actual_len) "len %d"
+canokey_handle_data_out(uint8_t ep_out, uint32_t out_len) "ep %d len %d"
+canokey_handle_data_in(uint8_t ep_in, uint32_t in_len) "ep %d len %d"
+canokey_realize(void)
+canokey_unrealize(void)
Signature · 1 line
2.36.1
#12 lore raw

[PULL 06/15] meson: Add CanoKey

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

Message-Id: <YoY6YRD6cxH21mms@Sun>

---
 meson_options.txt             | 2 ++
 hw/usb/Kconfig                | 5 +++++
 hw/usb/meson.build            | 5 +++++
 meson.build                   | 6 ++++++
 scripts/meson-buildoptions.sh | 3 +++
 5 files changed, 21 insertions(+)
meson_options.txt +2 -0
index 2de94af03712..0e8197386b99 100644
@@ -189,6 +189,8 @@ option('spice_protocol', type : 'feature', value : 'auto',
        description: 'Spice protocol support')
 option('u2f', type : 'feature', value : 'auto',
        description: 'U2F emulation support')
+option('canokey', type : 'feature', value : 'auto',
+       description: 'CanoKey support')
 option('usb_redir', type : 'feature', value : 'auto',
        description: 'libusbredir support')
 option('l2tpv3', type : 'feature', value : 'auto',
hw/usb/Kconfig +5 -0
index 53f8283ffdc1..ce4f4339763e 100644
@@ -119,6 +119,11 @@ config USB_U2F
     default y
     depends on USB
 
+config USB_CANOKEY
+    bool
+    default y
+    depends on USB
+
 config IMX_USBPHY
     bool
     default y
hw/usb/meson.build +5 -0
index de853d780dd8..793df42e2127 100644
@@ -63,6 +63,11 @@ if u2f.found()
   softmmu_ss.add(when: 'CONFIG_USB_U2F', if_true: [u2f, files('u2f-emulated.c')])
 endif
 
+# CanoKey
+if canokey.found()
+  softmmu_ss.add(when: 'CONFIG_USB_CANOKEY', if_true: [canokey, files('canokey.c')])
+endif
+
 # usb redirect
 if usbredir.found()
   usbredir_ss = ss.source_set()
meson.build +6 -0
index 21cd949082dc..0c2e11ff0715 100644
@@ -1408,6 +1408,12 @@ if have_system
                    method: 'pkg-config',
                    kwargs: static_kwargs)
 endif
+canokey = not_found
+if have_system
+  canokey = dependency('canokey-qemu', required: get_option('canokey'),
+                   method: 'pkg-config',
+                   kwargs: static_kwargs)
+endif
 usbredir = not_found
 if not get_option('usb_redir').auto() or have_system
   usbredir = dependency('libusbredirparser-0.5', required: get_option('usb_redir'),
scripts/meson-buildoptions.sh +3 -0
index 00ea4d8cd169..1fc1d2e2c362 100644
@@ -73,6 +73,7 @@ meson_options_help() {
   printf "%s\n" '  bpf             eBPF support'
   printf "%s\n" '  brlapi          brlapi character device driver'
   printf "%s\n" '  bzip2           bzip2 support for DMG images'
+  printf "%s\n" '  canokey         CanoKey support'
   printf "%s\n" '  cap-ng          cap_ng support'
   printf "%s\n" '  capstone        Whether and how to find the capstone library'
   printf "%s\n" '  cloop           cloop image format support'
@@ -204,6 +205,8 @@ _meson_option_parse() {
     --disable-brlapi) printf "%s" -Dbrlapi=disabled ;;
     --enable-bzip2) printf "%s" -Dbzip2=enabled ;;
     --disable-bzip2) printf "%s" -Dbzip2=disabled ;;
+    --enable-canokey) printf "%s" -Dcanokey=enabled ;;
+    --disable-canokey) printf "%s" -Dcanokey=disabled ;;
     --enable-cap-ng) printf "%s" -Dcap_ng=enabled ;;
     --disable-cap-ng) printf "%s" -Dcap_ng=disabled ;;
     --enable-capstone) printf "%s" -Dcapstone=enabled ;;
Signature · 1 line
2.36.1
#13 lore raw

[PULL 09/15] MAINTAINERS: add myself as CanoKey maintainer

In reply to Gerd Hoffmann

From: "Hongren (Zenithal) Zheng" <[email protected]>

Message-Id: <YoY61xI0IcFT1fOP@Sun>

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 0df25ed4b0a3..4cf6174f9f37 100644
@@ -2427,6 +2427,14 @@ F: hw/intc/s390_flic*.c
 F: include/hw/s390x/s390_flic.h
 L: [email protected]
 
+CanoKey
+M: Hongren (Zenithal) Zheng <[email protected]>
+S: Maintained
+R: Canokeys.org <[email protected]>
+F: hw/usb/canokey.c
+F: hw/usb/canokey.h
+F: docs/system/devices/canokey.rst
+
 Subsystems
 ----------
 Overall Audio backends
Signature · 1 line
2.36.1
#14 lore raw

[PULL 15/15] virtio-gpu: Respect UI refresh rate for EDID

In reply to Gerd Hoffmann

From: Akihiko Odaki <[email protected]>

Message-Id: <[email protected]>

---
 include/hw/virtio/virtio-gpu.h | 1 +
 hw/display/virtio-gpu-base.c   | 1 +
 hw/display/virtio-gpu.c        | 1 +
 3 files changed, 3 insertions(+)
include/hw/virtio/virtio-gpu.h +1 -0
index afff9e158e31..2e28507efe21 100644
@@ -80,6 +80,7 @@ struct virtio_gpu_scanout {
 struct virtio_gpu_requested_state {
     uint16_t width_mm, height_mm;
     uint32_t width, height;
+    uint32_t refresh_rate;
     int x, y;
 };
 
hw/display/virtio-gpu-base.c +1 -0
index b21d6e5b0be8..a29f191aa82e 100644
@@ -79,6 +79,7 @@ static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
 
     g->req_state[idx].x = info->xoff;
     g->req_state[idx].y = info->yoff;
+    g->req_state[idx].refresh_rate = info->refresh_rate;
     g->req_state[idx].width = info->width;
     g->req_state[idx].height = info->height;
     g->req_state[idx].width_mm = info->width_mm;
hw/display/virtio-gpu.c +1 -0
index 55c6dd576318..20cc703dcc6e 100644
@@ -217,6 +217,7 @@ virtio_gpu_generate_edid(VirtIOGPU *g, int scanout,
         .height_mm = b->req_state[scanout].height_mm,
         .prefx = b->req_state[scanout].width,
         .prefy = b->req_state[scanout].height,
+        .refresh_rate = b->req_state[scanout].refresh_rate,
     };
 
     edid->size = cpu_to_le32(sizeof(edid->edid));
Signature · 1 line
2.36.1
#15 lore raw

[PULL 10/15] hw/usb/hcd-ehci: fix writeback order

In reply to Gerd Hoffmann

From: Arnout Engelen <[email protected]>

The 'active' bit passes control over a qTD between the guest and the
controller: set to 1 by guest to enable execution by the controller, and the controller sets it to '0' to hand back control to the guest.

ehci_state_writeback write two dwords to main memory using DMA:
the third dword of the qTD (containing dt, total bytes to transfer, cpage, cerr and status) and the fourth dword of the qTD (containing the offset).

This commit makes sure the fourth dword is written before the third, avoiding a race condition where a new offset written into the qTD by the guest after it observed the status going to go to '0' gets overwritten by a 'late' DMA writeback of the previous offset.

This race condition could lead to 'cpage out of range (5)' errors, and reproduced by:

./qemu-system-x86_64 -enable-kvm -bios $SEABIOS/bios.bin -m 4096 -device usb-ehci -blockdev driver=file,read-only=on,filename=/home/aengelen/Downloads/openSUSE-Tumbleweed-DVD-i586-Snapshot20220428-Media.iso,node-name=iso -device usb-storage,drive=iso,bootindex=0 -chardev pipe,id=shell,path=/tmp/pipe -device virtio-serial -device virtconsole,chardev=shell -device virtio-rng-pci -serial mon:stdio -nographic

(press a key, select 'Installation' (2), and accept the default values. On my machine the 'cpage out of range' is reproduced while loading the Linux Kernel about once per 7 attempts. With the fix in this commit it no longer fails)

This problem was previously reported as a seabios problem in
https://mail.coreboot.org/hyperkitty/list/[email protected]/thread/OUTHT5ISSQJGXPNTUPY3O5E5EPZJCHM3/
and as a nixos CI build failure in
https://github.com/NixOS/nixpkgs/issues/170803

---
 hw/usb/hcd-ehci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
hw/usb/hcd-ehci.c +4 -1
index 33a8a377bd95..d4da8dcb8d15 100644
@@ -2011,7 +2011,10 @@ static int ehci_state_writeback(EHCIQueue *q)
     ehci_trace_qtd(q, NLPTR_GET(p->qtdaddr), (EHCIqtd *) &q->qh.next_qtd);
     qtd = (uint32_t *) &q->qh.next_qtd;
     addr = NLPTR_GET(p->qtdaddr);
-    put_dwords(q->ehci, addr + 2 * sizeof(uint32_t), qtd + 2, 2);
+    /* First write back the offset */
+    put_dwords(q->ehci, addr + 3 * sizeof(uint32_t), qtd + 3, 1);
+    /* Then write back the token, clearing the 'active' bit */
+    put_dwords(q->ehci, addr + 2 * sizeof(uint32_t), qtd + 2, 1);
     ehci_free_packet(p);
 
     /*
Signature · 1 line
2.36.1
#16 lore raw

[PULL 13/15] ui/console: Do not return a value with ui_info

In reply to Gerd Hoffmann

From: Akihiko Odaki <[email protected]>

The returned value is not used and misleading.

Message-Id: <[email protected]>

---
 include/ui/console.h         | 2 +-
 hw/display/virtio-gpu-base.c | 6 +++---
 hw/display/virtio-vga.c      | 5 ++---
 hw/vfio/display.c            | 8 +++-----
 4 files changed, 9 insertions(+), 12 deletions(-)
include/ui/console.h +1 -1
index c44b28a972ca..642d6f5248cf 100644
@@ -432,7 +432,7 @@ typedef struct GraphicHwOps {
     bool gfx_update_async; /* if true, calls graphic_hw_update_done() */
     void (*text_update)(void *opaque, console_ch_t *text);
     void (*update_interval)(void *opaque, uint64_t interval);
-    int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
+    void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
     void (*gl_block)(void *opaque, bool block);
 } GraphicHwOps;
 
hw/display/virtio-gpu-base.c +3 -3
index 790cec333c8c..b21d6e5b0be8 100644
@@ -69,12 +69,12 @@ static void virtio_gpu_notify_event(VirtIOGPUBase *g, uint32_t event_type)
     virtio_notify_config(&g->parent_obj);
 }
 
-static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
+static void virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
 {
     VirtIOGPUBase *g = opaque;
 
     if (idx >= g->conf.max_outputs) {
-        return -1;
+        return;
     }
 
     g->req_state[idx].x = info->xoff;
@@ -92,7 +92,7 @@ static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
 
     /* send event to guest */
     virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY);
-    return 0;
+    return;
 }
 
 static void
hw/display/virtio-vga.c +2 -3
index c206b5da384b..4dcb34c4a740 100644
@@ -47,15 +47,14 @@ static void virtio_vga_base_text_update(void *opaque, console_ch_t *chardata)
     }
 }
 
-static int virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
+static void virtio_vga_base_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
 {
     VirtIOVGABase *vvga = opaque;
     VirtIOGPUBase *g = vvga->vgpu;
 
     if (g->hw_ops->ui_info) {
-        return g->hw_ops->ui_info(g, idx, info);
+        g->hw_ops->ui_info(g, idx, info);
     }
-    return -1;
 }
 
 static void virtio_vga_base_gl_block(void *opaque, bool block)
hw/vfio/display.c +3 -5
index 89bc90508fb8..78f4d82c1c35 100644
@@ -106,14 +106,14 @@ err:
     return;
 }
 
-static int vfio_display_edid_ui_info(void *opaque, uint32_t idx,
-                                     QemuUIInfo *info)
+static void vfio_display_edid_ui_info(void *opaque, uint32_t idx,
+                                      QemuUIInfo *info)
 {
     VFIOPCIDevice *vdev = opaque;
     VFIODisplay *dpy = vdev->dpy;
 
     if (!dpy->edid_regs) {
-        return 0;
+        return;
     }
 
     if (info->width && info->height) {
@@ -121,8 +121,6 @@ static int vfio_display_edid_ui_info(void *opaque, uint32_t idx,
     } else {
         vfio_display_edid_update(vdev, false, 0, 0);
     }
-
-    return 0;
 }
 
 static void vfio_display_edid_init(VFIOPCIDevice *vdev)
Signature · 1 line
2.36.1
#17 lore raw

[PULL 12/15] virtio-gpu: update done only on the scanout associated with rect

In reply to Gerd Hoffmann

From: Dongwon Kim <[email protected]>

It only needs to update the scanouts containing the rect area coming with the resource-flush request from the guest.

Cc Gerd Hoffmann <[email protected]>
Cc Vivek Kasireddy <[email protected]>

Message-Id: <[email protected]>

---
 hw/display/virtio-gpu.c | 3 +++
 1 file changed, 3 insertions(+)
hw/display/virtio-gpu.c +3 -0
index cd4a56056fd9..55c6dd576318 100644
@@ -514,6 +514,9 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
         for (i = 0; i < g->parent_obj.conf.max_outputs; i++) {
             scanout = &g->parent_obj.scanout[i];
             if (scanout->resource_id == res->resource_id &&
+                rf.r.x >= scanout->x && rf.r.y >= scanout->y &&
+                rf.r.x + rf.r.width <= scanout->x + scanout->width &&
+                rf.r.y + rf.r.height <= scanout->y + scanout->height &&
                 console_has_gl(scanout->con)) {
                 dpy_gl_update(scanout->con, 0, 0, scanout->width,
                               scanout->height);
Signature · 1 line
2.36.1
#18 lore raw

[PULL 14/15] ui: Deliver refresh rate via QemuUIInfo

In reply to Gerd Hoffmann

From: Akihiko Odaki <[email protected]>

This change adds a new member, refresh_rate to QemuUIInfo in include/ui/console.h. It represents the refresh rate of the physical display backend, and it is more appropriate than GUI update interval as the refresh rate which the emulated device reports:
- sdl may set GUI update interval shorter than the refresh rate of the physical display to respond to user-generated events.
- sdl and vnc aggressively changes GUI update interval, but a guests is typically not designed to respond to frequent refresh rate changes, or frequent "display mode" changes in general. The frequency of refresh rate changes of the physical display backend matches better to the guest's expectation.

QemuUIInfo also has other members representing "display mode", which makes it suitable for refresh rate representation. It has a throttling of update notifications, and prevents frequent changes of the display mode.

Message-Id: <[email protected]>

---
 include/ui/console.h |  2 +-
 include/ui/gtk.h     |  2 +-
 hw/display/xenfb.c   | 14 +++++++++++---
 ui/console.c         |  6 ------
 ui/gtk-egl.c         |  4 ++--
 ui/gtk-gl-area.c     |  3 +--
 ui/gtk.c             | 45 +++++++++++++++++++++++++-------------------
 7 files changed, 42 insertions(+), 34 deletions(-)
include/ui/console.h +1 -1
index 642d6f5248cf..b64d82436097 100644
@@ -139,6 +139,7 @@ typedef struct QemuUIInfo {
     int       yoff;
     uint32_t  width;
     uint32_t  height;
+    uint32_t  refresh_rate;
 } QemuUIInfo;
 
 /* cursor data format is 32bit RGBA */
@@ -431,7 +432,6 @@ typedef struct GraphicHwOps {
     void (*gfx_update)(void *opaque);
     bool gfx_update_async; /* if true, calls graphic_hw_update_done() */
     void (*text_update)(void *opaque, console_ch_t *text);
-    void (*update_interval)(void *opaque, uint64_t interval);
     void (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);
     void (*gl_block)(void *opaque, bool block);
 } GraphicHwOps;
include/ui/gtk.h +1 -1
index 101b147d1b98..ae0f53740d19 100644
@@ -155,7 +155,7 @@ extern bool gtk_use_gl_area;
 
 /* ui/gtk.c */
 void gd_update_windowsize(VirtualConsole *vc);
-int gd_monitor_update_interval(GtkWidget *widget);
+void gd_update_monitor_refresh_rate(VirtualConsole *vc, GtkWidget *widget);
 void gd_hw_gl_flushed(void *vc);
 
 /* ui/gtk-egl.c */
hw/display/xenfb.c +11 -3
index cea10fe3c780..50857cd97a0b 100644
@@ -777,16 +777,24 @@ static void xenfb_update(void *opaque)
     xenfb->up_fullscreen = 0;
 }
 
-static void xenfb_update_interval(void *opaque, uint64_t interval)
+static void xenfb_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
 {
     struct XenFB *xenfb = opaque;
+    uint32_t refresh_rate;
 
     if (xenfb->feature_update) {
 #ifdef XENFB_TYPE_REFRESH_PERIOD
         if (xenfb_queue_full(xenfb)) {
             return;
         }
-        xenfb_send_refresh_period(xenfb, interval);
+
+        refresh_rate = info->refresh_rate;
+        if (!refresh_rate) {
+            refresh_rate = 75;
+        }
+
+        /* T = 1 / f = 1 [s*Hz] / f = 1000*1000 [ms*mHz] / f */
+        xenfb_send_refresh_period(xenfb, 1000 * 1000 / refresh_rate);
 #endif
     }
 }
@@ -983,5 +991,5 @@ struct XenDevOps xen_framebuffer_ops = {
 static const GraphicHwOps xenfb_ops = {
     .invalidate  = xenfb_invalidate,
     .gfx_update  = xenfb_update,
-    .update_interval = xenfb_update_interval,
+    .ui_info     = xenfb_ui_info,
 };
ui/console.c +0 -6
index 36c80cd1de85..9331b85203a0 100644
@@ -160,7 +160,6 @@ static void gui_update(void *opaque)
     uint64_t dcl_interval;
     DisplayState *ds = opaque;
     DisplayChangeListener *dcl;
-    QemuConsole *con;
 
     ds->refreshing = true;
     dpy_refresh(ds);
@@ -175,11 +174,6 @@ static void gui_update(void *opaque)
     }
     if (ds->update_interval != interval) {
         ds->update_interval = interval;
-        QTAILQ_FOREACH(con, &consoles, next) {
-            if (con->hw_ops->update_interval) {
-                con->hw_ops->update_interval(con->hw, interval);
-            }
-        }
         trace_console_refresh(interval);
     }
     ds->last_update = qemu_clock_get_ms(QEMU_CLOCK_REALTIME);
ui/gtk-egl.c +2 -2
index e3bd4bc27431..b5bffbab2522 100644
@@ -140,8 +140,8 @@ void gd_egl_refresh(DisplayChangeListener *dcl)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
-    vc->gfx.dcl.update_interval = gd_monitor_update_interval(
-            vc->window ? vc->window : vc->gfx.drawing_area);
+    gd_update_monitor_refresh_rate(
+            vc, vc->window ? vc->window : vc->gfx.drawing_area);
 
     if (!vc->gfx.esurface) {
         gd_egl_init(vc);
ui/gtk-gl-area.c +1 -2
index 2e0129c28cd4..682638a197d2 100644
@@ -121,8 +121,7 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl)
 {
     VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 
-    vc->gfx.dcl.update_interval = gd_monitor_update_interval(
-            vc->window ? vc->window : vc->gfx.drawing_area);
+    gd_update_monitor_refresh_rate(vc, vc->window ? vc->window : vc->gfx.drawing_area);
 
     if (!vc->gfx.gls) {
         if (!gtk_widget_get_realized(vc->gfx.drawing_area)) {
ui/gtk.c +26 -19

85 lines not on this page · raw message

Signature · 1 line
2.36.1
#19 lore raw

[PULL 11/15] usbredir: avoid queuing hello packet on snapshot restore

In reply to Gerd Hoffmann

From: Joelle van Dyne <[email protected]>

When launching QEMU with "-loadvm", usbredir_create_parser() should avoid setting up the hello packet (just as with "-incoming". On the latest version of libusbredir, usbredirparser_unserialize() will return error if the parser is not "pristine."

Message-Id: <[email protected]>

---
 hw/usb/redirect.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/usb/redirect.c +2 -1
index fd7df599bc0b..1bd30efc3ef0 100644
@@ -1280,7 +1280,8 @@ static void usbredir_create_parser(USBRedirDevice *dev)
     }
 #endif
 
-    if (runstate_check(RUN_STATE_INMIGRATE)) {
+    if (runstate_check(RUN_STATE_INMIGRATE) ||
+        runstate_check(RUN_STATE_PRELAUNCH)) {
         flags |= usbredirparser_fl_no_hello;
     }
     usbredirparser_init(dev->parser, VERSION, caps, USB_REDIR_CAPS_SIZE,
Signature · 1 line
2.36.1
#20 lore raw
In reply to Gerd Hoffmann
Quoted 8 lines · Gerd Hoffmann

The following changes since commit debd0753663bc89c86f5462a53268f2e3f680f60:

   Merge tag 'pull-testing-next-140622-1' of https://github.com/stsquad/qemu into staging (2022-06-13 21:10:57 -0700)

are available in the Git repository at:

   git://git.kraxel.org/qemu tags/kraxel-20220614-pull-request
Quoted 8 lines

for you to fetch changes up to b95b56311a0890da0c9f7fc624529c3d7f8dbce0:

virtio-gpu: Respect UI refresh rate for EDID (2022-06-14 10:34:37 +0200)

----------------------------------------------------------------
usb: add CanoKey device, fixes for ehci + redir
ui: fixes for gtk and cocoa, rework refresh rate
virtio-gpu: scanout flush fix

Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.

r~

Quoted 63 lines

----------------------------------------------------------------

Akihiko Odaki (4):
ui/cocoa: Fix poweroff request code
ui/console: Do not return a value with ui_info
ui: Deliver refresh rate via QemuUIInfo
virtio-gpu: Respect UI refresh rate for EDID

Arnout Engelen (1):
hw/usb/hcd-ehci: fix writeback order

Dongwon Kim (1):
virtio-gpu: update done only on the scanout associated with rect

Hongren (Zenithal) Zheng (6):
hw/usb: Add CanoKey Implementation
hw/usb/canokey: Add trace events
meson: Add CanoKey
docs: Add CanoKey documentation docs/system/devices/usb: Add CanoKey to USB devices examples
MAINTAINERS: add myself as CanoKey maintainer

Joelle van Dyne (1):
usbredir: avoid queuing hello packet on snapshot restore

Volker Rümelin (2):
ui/gtk-gl-area: implement GL context destruction ui/gtk-gl-area: create the requested GL context version

  meson_options.txt                |   2 +
  hw/usb/canokey.h                 |  69 +++++++
  include/hw/virtio/virtio-gpu.h   |   1 +
  include/ui/console.h             |   4 +-
  include/ui/gtk.h                 |   2 +-
  hw/display/virtio-gpu-base.c     |   7 +-
  hw/display/virtio-gpu.c          |   4 +
  hw/display/virtio-vga.c          |   5 +-
  hw/display/xenfb.c               |  14 +-
  hw/usb/canokey.c                 | 313 +++++++++++++++++++++++++++++++
  hw/usb/hcd-ehci.c                |   5 +-
  hw/usb/redirect.c                |   3 +-
  hw/vfio/display.c                |   8 +-
  ui/console.c                     |   6 -
  ui/gtk-egl.c                     |   4 +-
  ui/gtk-gl-area.c                 |  42 ++++-
  ui/gtk.c                         |  45 +++--
  MAINTAINERS                      |   8 +
  docs/system/device-emulation.rst |   1 +
  docs/system/devices/canokey.rst  | 168 +++++++++++++++++
  docs/system/devices/usb.rst      |   4 +
  hw/usb/Kconfig                   |   5 +
  hw/usb/meson.build               |   5 +
  hw/usb/trace-events              |  16 ++
  meson.build                      |   6 +
  scripts/meson-buildoptions.sh    |   3 +
  ui/cocoa.m                       |   6 +-
  ui/trace-events                  |   2 +
  28 files changed, 707 insertions(+), 51 deletions(-)

create mode 100644 hw/usb/canokey.h
create mode 100644 hw/usb/canokey.c
create mode 100644 docs/system/devices/canokey.rst