Skip to contentSkip to conversation

Add support for generic notifier lists

PATCH In review Anthony Liguori 14 participants 38 messages Mar 10, 2010 – Mar 22, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 Add support for generic notifier lists

Notifiers are data-less callbacks and a notifier list is a list of registered notifiers that all are interested in a particular event.

We'll use this in a few patches to implement mouse change notification.

---
 Makefile.objs |    1 +
 notify.c      |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 notify.h      |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 notify.c
 create mode 100644 notify.h
Makefile.objs +1 -0
index e791dd5..dcb5a92 100644
@@ -104,6 +104,7 @@ common-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
 common-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
 common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
+common-obj-y += notify.o
 
 slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
 slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
notify.c new file +53 -0

53 lines not on this page · raw message

notify.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#1 lore raw

PATCH 2/7 Rewrite mouse handlers to use QTAILQ and to have an activation function

And convert usb-hid to use it (to avoid regression with bisection)

Right now, when we do info mice and we've added a usb tablet, we don't see it until the guest starts using the tablet. We implement this behavior in order to provide a means to delay registration of a mouse handler since we treat the last registered handler as the current handler.

This is a usability problem though as we would like to give the user feedback that they've either 1) not added an absolute device 2) there is an absolute device but the guest isn't using it 3) we have an absolute device and it's active.

By using QTAILQ and having an explicit activation function that moves the handler to the front of the queue, we can implement the same semantics as before with respect to automatically switching to usb tablet while providing the user with a whole lot more information.

---
 console.h    |    6 +++-
 hw/usb-hid.c |   15 ++++++--
 input.c      |  109 +++++++++++++++++++++++-----------------------------------
 3 files changed, 59 insertions(+), 71 deletions(-)
console.h +5 -1
index 71e8ff2..94d9cae 100644
@@ -28,8 +28,10 @@ typedef struct QEMUPutMouseEntry {
     int qemu_put_mouse_event_absolute;
     char *qemu_put_mouse_event_name;
 
+    int index;
+
     /* used internally by qemu for handling mice */
-    struct QEMUPutMouseEntry *next;
+    QTAILQ_ENTRY(QEMUPutMouseEntry) node;
 } QEMUPutMouseEntry;
 
 typedef struct QEMUPutLEDEntry {
@@ -43,6 +45,8 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
                                                 void *opaque, int absolute,
                                                 const char *name);
 void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
+void qemu_activate_mouse_event_handler(QEMUPutMouseEntry *entry);
+
 QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func, void *opaque);
 void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 
hw/usb-hid.c +11 -4
index 2e4e647..8e6c6e0 100644
@@ -511,8 +511,7 @@ static int usb_mouse_poll(USBHIDState *hs, uint8_t *buf, int len)
     USBMouseState *s = &hs->ptr;
 
     if (!s->mouse_grabbed) {
-	s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, hs,
-                                                  0, "QEMU USB Mouse");
+        qemu_activate_mouse_event_handler(s->eh_entry);
 	s->mouse_grabbed = 1;
     }
 
@@ -553,8 +552,7 @@ static int usb_tablet_poll(USBHIDState *hs, uint8_t *buf, int len)
     USBMouseState *s = &hs->ptr;
 
     if (!s->mouse_grabbed) {
-	s->eh_entry = qemu_add_mouse_event_handler(usb_tablet_event, hs,
-                                                  1, "QEMU USB Tablet");
+        qemu_activate_mouse_event_handler(s->eh_entry);
 	s->mouse_grabbed = 1;
     }
 
@@ -866,6 +864,15 @@ static int usb_hid_initfn(USBDevice *dev, int kind)
     USBHIDState *s = DO_UPCAST(USBHIDState, dev, dev);
     s->dev.speed = USB_SPEED_FULL;
     s->kind = kind;
+
+    if (s->kind == USB_MOUSE) {
+        s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, s,
+                                                       0, "QEMU USB Mouse");
+    } else if (s->kind == USB_TABLET) {
+        s->ptr.eh_entry = qemu_add_mouse_event_handler(usb_tablet_event, s,
+                                                       1, "QEMU USB Tablet");
+    }
+        
     /* Force poll routine to be run and grab input the first time.  */
     s->changed = 1;
     return 0;
input.c +43 -66

194 lines not on this page · raw message

Signature · 1 line
1.6.5.2
#2 lore raw

PATCH 3/7 Add kbd_mouse_has_absolute()

In reply to Anthony Liguori

kbd_mouse_is_absolute tells us whether the current mouse handler is an absolute device. kbd_mouse_has_absolute tells us whether we have any device that is capable of absolute input.

This lets us tell a user that they have configured an absolute device but that the guest is not currently using it.

---
 console.h |    5 +++++
 input.c   |   13 +++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)
console.h +5 -0
index 94d9cae..f3c619f 100644
@@ -53,8 +53,13 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry);
 void kbd_put_keycode(int keycode);
 void kbd_put_ledstate(int ledstate);
 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
+
+/* Does the current mouse generate absolute events */
 int kbd_mouse_is_absolute(void);
 
+/* Of all the mice, is there one that generates absolute events */
+int kbd_mouse_has_absolute(void);
+
 struct MouseTransformInfo {
     /* Touchscreen resolution */
     int x;
input.c +13 -0
index 397bfc5..8d5a14d 100644
@@ -153,6 +153,19 @@ int kbd_mouse_is_absolute(void)
     return QTAILQ_FIRST(&mouse_handlers)->qemu_put_mouse_event_absolute;
 }
 
+int kbd_mouse_has_absolute(void)
+{
+    QEMUPutMouseEntry *entry;
+
+    QTAILQ_FOREACH(entry, &mouse_handlers, node) {
+        if (entry->qemu_put_mouse_event_absolute) {
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
 static void info_mice_iter(QObject *data, void *opaque)
 {
     QDict *mouse;
Signature · 1 line
1.6.5.2
#3 lore raw

PATCH 4/7 Add notifier for mouse mode changes

In reply to Anthony Liguori

Right now, DisplayState clients rely on polling the mouse mode to determine when the device is changed to an absolute device. Use a notification list to add an explicit notification.

---
 console.h |    3 +++
 input.c   |   37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletions(-)
console.h +3 -0
index f3c619f..cb928cf 100644
@@ -3,6 +3,7 @@
 
 #include "qemu-char.h"
 #include "qdict.h"
+#include "notify.h"
 
 /* keyboard/mouse support */
 
@@ -56,6 +57,8 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
 
 /* Does the current mouse generate absolute events */
 int kbd_mouse_is_absolute(void);
+void qemu_add_mouse_mode_change_notifier(QEMUNotifier *notify);
+void qemu_remove_mouse_mode_change_notifier(QEMUNotifier *notify);
 
 /* Of all the mice, is there one that generates absolute events */
 int kbd_mouse_has_absolute(void);
input.c +36 -1
index 8d5a14d..cbf55b7 100644
@@ -28,12 +28,13 @@
 #include "console.h"
 #include "qjson.h"
 
-
 static QEMUPutKBDEvent *qemu_put_kbd_event;
 static void *qemu_put_kbd_event_opaque;
 static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers = QTAILQ_HEAD_INITIALIZER(led_handlers);
 static QTAILQ_HEAD(, QEMUPutMouseEntry) mouse_handlers =
     QTAILQ_HEAD_INITIALIZER(mouse_handlers);
+static QEMUNotifierList mouse_mode_notifiers = 
+    QEMU_NOTIFIER_LIST_INITIALIZER(mouse_mode_notifiers);
 
 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
 {
@@ -41,6 +42,24 @@ void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque)
     qemu_put_kbd_event = func;
 }
 
+static void check_mode_change(void)
+{
+    static int current_is_absolute, current_has_absolute;
+    int is_absolute;
+    int has_absolute;
+
+    is_absolute = kbd_mouse_is_absolute();
+    has_absolute = kbd_mouse_has_absolute();
+
+    if (is_absolute != current_is_absolute ||
+        has_absolute != current_has_absolute) {
+        qemu_notifier_list_notify(&mouse_mode_notifiers);
+    }
+
+    current_is_absolute = is_absolute;
+    current_has_absolute = has_absolute;
+}
+
 QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
                                                 void *opaque, int absolute,
                                                 const char *name)
@@ -58,6 +77,8 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
 
     QTAILQ_INSERT_TAIL(&mouse_handlers, s, node);
 
+    check_mode_change();
+
     return s;
 }
 
@@ -75,6 +96,8 @@ void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry)
 
     qemu_free(entry->qemu_put_mouse_event_name);
     qemu_free(entry);
+
+    check_mode_change();
 }
 
 QEMUPutLEDEntry *qemu_add_led_event_handler(QEMUPutLEDEvent *func,
@@ -256,4 +279,16 @@ void do_mouse_set(Monitor *mon, const QDict *qdict)
     if (!found) {
         monitor_printf(mon, "Mouse at given index not found\n");
     }
+
+    check_mode_change();
+}
+
+void qemu_add_mouse_mode_change_notifier(QEMUNotifier *notify)
+{
+    qemu_notifier_list_add(&mouse_mode_notifiers, notify);
+}
+
+void qemu_remove_mouse_mode_change_notifier(QEMUNotifier *notify)
+{
+    qemu_notifier_list_remove(&mouse_mode_notifiers, notify);
 }
Signature · 1 line
1.6.5.2
#4 lore raw

PATCH 5/7 Expose whether a mouse is an absolute device via QMP and the human monitor.

In reply to Anthony Liguori

For QMP, we just add an attribute which is backwards compatible. For the human monitor, we add (absolute) to the end of the line.

---
 input.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
input.c +12 -6
index cbf55b7..d2a6f26 100644
@@ -195,9 +195,10 @@ static void info_mice_iter(QObject *data, void *opaque)
     Monitor *mon = opaque;
 
     mouse = qobject_to_qdict(data);
-    monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n",
+    monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n",
                   (qdict_get_bool(mouse, "current") ? '*' : ' '),
-                  qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"));
+                   qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"),
+                   qdict_get_bool(mouse, "absolute") ? " (absolute)" : "");
 }
 
 void do_info_mice_print(Monitor *mon, const QObject *data)
@@ -224,11 +225,12 @@ void do_info_mice_print(Monitor *mon, const QObject *data)
  * - "name": mouse's name
  * - "index": mouse's index
  * - "current": true if this mouse is receiving events, false otherwise
+ * - "absolute": true if the mouse generates absolute input events
  *
  * Example:
  *
- * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false },
- *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true } ]
+ * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false, "absolute": false },
+ *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true, "absolute": true } ]
  */
 void do_info_mice(Monitor *mon, QObject **ret_data)
 {
@@ -246,10 +248,14 @@ void do_info_mice(Monitor *mon, QObject **ret_data)
 
     QTAILQ_FOREACH(cursor, &mouse_handlers, node) {
         QObject *obj;
-        obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }",
+        obj = qobject_from_jsonf("{ 'name': %s,"
+                                 "  'index': %d,"
+                                 "  'current': %i,"
+                                 "  'absolute': %i }",
                                  cursor->qemu_put_mouse_event_name,
                                  cursor->index,
-                                 cursor->index == current);
+                                 cursor->index == current,
+                                 !!cursor->qemu_put_mouse_event_absolute);
         qlist_append_obj(mice_list, obj);
     }
 
Signature · 1 line
1.6.5.2
#5 lore raw

[Qemu-devel] Re: [PATCH 5/7] Expose whether a mouse is an absolute device via QMP and the human monitor.

Quoted 4 lines · On Wed, 10 Mar 2010 10:51:07 -0600 Anthony Liguori <[email protected]> wrote:

For QMP, we just add an attribute which is backwards compatible. For the human monitor, we add (absolute) to the end of the line.

Looks good to me.

Quoted 53 lines
---
 input.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
input.c +12 -6
index cbf55b7..d2a6f26 100644
@@ -195,9 +195,10 @@ static void info_mice_iter(QObject *data, void *opaque)
     Monitor *mon = opaque;
 
     mouse = qobject_to_qdict(data);
-    monitor_printf(mon, "%c Mouse #%" PRId64 ": %s\n",
+    monitor_printf(mon, "%c Mouse #%" PRId64 ": %s%s\n",
                   (qdict_get_bool(mouse, "current") ? '*' : ' '),
-                  qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"));
+                   qdict_get_int(mouse, "index"), qdict_get_str(mouse, "name"),
+                   qdict_get_bool(mouse, "absolute") ? " (absolute)" : "");
 }
 
 void do_info_mice_print(Monitor *mon, const QObject *data)
@@ -224,11 +225,12 @@ void do_info_mice_print(Monitor *mon, const QObject *data)
  * - "name": mouse's name
  * - "index": mouse's index
  * - "current": true if this mouse is receiving events, false otherwise
+ * - "absolute": true if the mouse generates absolute input events
  *
  * Example:
  *
- * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false },
- *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true } ]
+ * [ { "name": "QEMU Microsoft Mouse", "index": 0, "current": false, "absolute": false },
+ *   { "name": "QEMU PS/2 Mouse", "index": 1, "current": true, "absolute": true } ]
  */
 void do_info_mice(Monitor *mon, QObject **ret_data)
 {
@@ -246,10 +248,14 @@ void do_info_mice(Monitor *mon, QObject **ret_data)
 
     QTAILQ_FOREACH(cursor, &mouse_handlers, node) {
         QObject *obj;
-        obj = qobject_from_jsonf("{ 'name': %s, 'index': %d, 'current': %i }",
+        obj = qobject_from_jsonf("{ 'name': %s,"
+                                 "  'index': %d,"
+                                 "  'current': %i,"
+                                 "  'absolute': %i }",
                                  cursor->qemu_put_mouse_event_name,
                                  cursor->index,
-                                 cursor->index == current);
+                                 cursor->index == current,
+                                 !!cursor->qemu_put_mouse_event_absolute);
         qlist_append_obj(mice_list, obj);
     }
 
#6 lore raw

PATCH 6/7 input: make vnc use mouse mode notifiers

In reply to Anthony Liguori

When we switch to absolute mode, we send out a notification (if the client supports it). Today, we only send this notification when the client sends us a mouse event and we're in the wrong mode.

---
 vnc.c |   13 ++++++++-----
 vnc.h |    2 ++
 2 files changed, 10 insertions(+), 5 deletions(-)
vnc.c +8 -5
index 7ce73dc..f4d7f12 100644
@@ -1110,6 +1110,7 @@ static void vnc_disconnect_finish(VncState *vs)
         dcl->idle = 1;
     }
 
+    qemu_remove_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
     vnc_remove_timer(vs->vd);
     qemu_remove_led_event_handler(vs->led);
     qemu_free(vs);
@@ -1427,8 +1428,11 @@ static void client_cut_text(VncState *vs, size_t len, uint8_t *text)
 {
 }
 
-static void check_pointer_type_change(VncState *vs, int absolute)
+static void check_pointer_type_change(QEMUNotifier *notifier)
 {
+    VncState *vs = container_of(notifier, VncState, mouse_mode_notifier);
+    int absolute = kbd_mouse_is_absolute();
+
     if (vnc_has_feature(vs, VNC_FEATURE_POINTER_TYPE_CHANGE) && vs->absolute != absolute) {
         vnc_write_u8(vs, 0);
         vnc_write_u8(vs, 0);
@@ -1474,8 +1478,6 @@ static void pointer_event(VncState *vs, int button_mask, int x, int y)
         vs->last_x = x;
         vs->last_y = y;
     }
-
-    check_pointer_type_change(vs, kbd_mouse_is_absolute());
 }
 
 static void reset_keys(VncState *vs)
@@ -1814,8 +1816,6 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
             break;
         }
     }
-
-    check_pointer_type_change(vs, kbd_mouse_is_absolute());
 }
 
 static void set_pixel_conversion(VncState *vs)
@@ -2431,6 +2431,9 @@ static void vnc_connect(VncDisplay *vd, int csock)
     reset_keys(vs);
     vs->led = qemu_add_led_event_handler(kbd_leds, vs);
 
+    vs->mouse_mode_notifier.notify = check_pointer_type_change;
+    qemu_add_mouse_mode_change_notifier(&vs->mouse_mode_notifier);
+
     vnc_init_timer(vd);
 
     /* vs might be free()ed here */
vnc.h +2 -0
index 0fc89bd..e1d764a 100644
@@ -167,6 +167,8 @@ struct VncState
     Buffer zlib_tmp;
     z_stream zlib_stream[4];
 
+    QEMUNotifier mouse_mode_notifier;
+
     QTAILQ_ENTRY(VncState) next;
 };
 
Signature · 1 line
1.6.5.2
#7 lore raw

[Qemu-devel] Re: [PATCH 6/7] input: make vnc use mouse mode notifiers

Quoted 3 lines · Anthony Liguori

When we switch to absolute mode, we send out a notification (if the client supports it). Today, we only send this notification when the client sends us a mouse event and we're in the wrong mode.

Very nice.

ACK for the whole patch series.

cheers,
Gerd

#8 lore raw

PATCH 7/7 sdl: use mouse mode notifier

In reply to Anthony Liguori

Today we poll the mouse mode whenever there is a mouse movement. There is a subtle usability problem with this though.

If we're in relative mode and grab is enabled, when we change to absolute mode, we break grab. This gives a user a seamless transition when the new pointer is enabled.

But because we poll for mouse change, this grab break won't occur until the user attempts to move the mouse. By using notifiers, the grab break happens as soon as possible.

---
 sdl.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)
sdl.c +20 -11
index 1d1e100..c51eb90 100644
@@ -57,6 +57,7 @@ static SDL_Cursor *guest_sprite = NULL;
 static uint8_t allocator;
 static SDL_PixelFormat host_format;
 static int scaling_active = 0;
+static QEMUNotifier mouse_mode_notifier;
 
 static void sdl_update(DisplayState *ds, int x, int y, int w, int h)
 {
@@ -485,6 +486,22 @@ static void sdl_grab_end(void)
     sdl_update_caption();
 }
 
+static void sdl_mouse_mode_change(QEMUNotifier *notify)
+{
+    if (kbd_mouse_is_absolute()) {
+        if (!absolute_enabled) {
+            sdl_hide_cursor();
+            if (gui_grab) {
+                sdl_grab_end();
+            }
+            absolute_enabled = 1;
+        }
+    } else if (absolute_enabled) {
+	sdl_show_cursor();
+	absolute_enabled = 0;
+    }
+}
+
 static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state)
 {
     int buttons;
@@ -497,19 +514,8 @@ static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state
         buttons |= MOUSE_EVENT_MBUTTON;
 
     if (kbd_mouse_is_absolute()) {
-	if (!absolute_enabled) {
-	    sdl_hide_cursor();
-	    if (gui_grab) {
-		sdl_grab_end();
-	    }
-	    absolute_enabled = 1;
-	}
-
        dx = x * 0x7FFF / (width - 1);
        dy = y * 0x7FFF / (height - 1);
-    } else if (absolute_enabled) {
-	sdl_show_cursor();
-	absolute_enabled = 0;
     } else if (guest_cursor) {
         x -= guest_x;
         y -= guest_y;
@@ -875,6 +881,9 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
         dpy_resize(ds);
     }
 
+    mouse_mode_notifier.notify = sdl_mouse_mode_change;
+    qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
+
     sdl_update_caption();
     SDL_EnableKeyRepeat(250, 50);
     gui_grab = 0;
Signature · 1 line
1.6.5.2
#9 lore raw
In reply to Anthony Liguori

notify.h line 25

Quoted 5 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

Paul

#10 lore raw
Quoted 6 lines · Paul Brook

+struct QEMUNotifier

Quoted 3 lines

+{
+ void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I didn't understand this suggestion exactly, but I think it's related that I didn't understand the advantage of making QEMUNotifier a struct.
Instead of using container_of, reusing QEMUBHFunc (renamed to
QEMUCallbackFunc maybe?) in QEMUNotifierNode like this:

    struct QEMUNotifierNode {
        QEMUCallbackFunc notify;
        void *opaque;
        QTAILQ_ENTRY(QEMUNotifierNode) node;
    };

    void qemu_notifier_list_init(QEMUNotifierList *list);

    struct QEMUNotifierNode *
    qemu_notifier_list_add(QEMUNotifierList *list,
                           QEMUCallbackFunc notify, void *opaque);

    void qemu_notifier_list_remove(QEMUNotifierList *list,
                                   QEMUNotifierNode *notifier);

    void qemu_notifier_list_notify(QEMUNotifierList *list);

seems cleaner. You would place the QEMUNotifierNode in VncState in order to do the removal later.

Besides this, the patchset is very nice indeed.

Paolo

#11 lore raw
Quoted 27 lines · Paolo Bonzini
Quoted 6 lines · Paul Brook

+struct QEMUNotifier

Quoted 3 lines

+{
+ void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I didn't understand this suggestion exactly, but I think it's related that I didn't understand the advantage of making QEMUNotifier a struct. Instead of using container_of, reusing QEMUBHFunc (renamed to QEMUCallbackFunc maybe?) in QEMUNotifierNode like this:

    struct QEMUNotifierNode {
        QEMUCallbackFunc notify;
        void *opaque;
        QTAILQ_ENTRY(QEMUNotifierNode) node;
    };

    void qemu_notifier_list_init(QEMUNotifierList *list);

    struct QEMUNotifierNode *
    qemu_notifier_list_add(QEMUNotifierList *list,
                           QEMUCallbackFunc notify, void *opaque);

    void qemu_notifier_list_remove(QEMUNotifierList *list,
                                   QEMUNotifierNode *notifier);

    void qemu_notifier_list_notify(QEMUNotifierList *list);
Quoted 3 lines

seems cleaner. You would place the QEMUNotifierNode in VncState in order to do the removal later.

I disagree. container_of() is both a little more type safe, and removes the need for an extra pointer and memory object.

The caller will almost always have an object in which to embed the notifier, best to make use of it.

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw
Quoted 11 lines · Avi Kivity
Quoted 5 lines · Paolo Bonzini

I didn't understand the advantage of making QEMUNotifier a struct. Instead of using container_of, reusing QEMUBHFunc (renamed to QEMUCallbackFunc maybe?) in QEMUNotifierNode [...]
seems cleaner. You would place the QEMUNotifierNode in VncState in order to do the removal later.

I disagree. container_of() is both a little more type safe, and removes the need for an extra pointer and memory object.
The caller will almost always have an object in which to embed the notifier, best to make use of it.

It doesn't remove the need for an extra memory object. Anthony's design embeds the Notifier but not the NotifierNode. Indeed, my design does have an extra pointer (in the NotifierNode, which grows from 3 to 4 words).

I still don't like container_of much, but maybe I'll grow my appreciation of it with time. :-)

Paolo

#13 lore raw
Quoted 8 lines · Paolo Bonzini
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Paolo Bonzini

I didn't understand the advantage of making QEMUNotifier a struct. Instead of using container_of, reusing QEMUBHFunc (renamed to QEMUCallbackFunc maybe?) in QEMUNotifierNode [...]
seems cleaner. You would place the QEMUNotifierNode in VncState in order to do the removal later.

Quoted 6 lines
Quoted 4 lines

I disagree. container_of() is both a little more type safe, and removes the need for an extra pointer and memory object.
The caller will almost always have an object in which to embed the notifier, best to make use of it.

It doesn't remove the need for an extra memory object. Anthony's design embeds the Notifier but not the NotifierNode. Indeed, my design does have an extra pointer (in the NotifierNode, which grows from 3 to 4 words).

Right. Well, it should.

Quoted 1 line

I still don't like container_of much, but maybe I'll grow my appreciation of it with time. :-)

Or grow your dislike of void pointers.

Signature · 1 line
error compiling committee.c: too many arguments to function
#14 lore raw
Quoted 9 lines · Avi Kivity
Quoted 8 lines · Paolo Bonzini
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Paolo Bonzini

I didn't understand the advantage of making QEMUNotifier a struct. Instead of using container_of, reusing QEMUBHFunc (renamed to QEMUCallbackFunc maybe?) in QEMUNotifierNode [...]
seems cleaner. You would place the QEMUNotifierNode in VncState in order to do the removal later.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I disagree. container_of() is both a little more type safe, and removes the need for an extra pointer and memory object.
The caller will almost always have an object in which to embed the notifier, best to make use of it.

It doesn't remove the need for an extra memory object. Anthony's design embeds the Notifier but not the NotifierNode. Indeed, my design does have an extra pointer (in the NotifierNode, which grows from 3 to 4 words).

Right. Well, it should.

It's certainly possible (and reasonable) to stick the QTAIL_NODE() into QEMUNotifier.

Regards,

Anthony Liguori

Quoted 4 lines
Quoted 1 line

I still don't like container_of much, but maybe I'll grow my appreciation of it with time. :-)

Or grow your dislike of void pointers.

#15 lore raw
In reply to Paolo Bonzini
Quoted 11 lines · Paul Brook
Quoted 7 lines

+struct QEMUNotifier

Quoted 3 lines

+{
+ void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I didn't understand this suggestion exactly, but I think it's related that I didn't understand the advantage of making QEMUNotifier a struct.

My point is that we already have a mechanism for providing event notification callbacks, specifically QEMUBH. Why invent a new one?

Paul

#16 lore raw
Quoted 7 lines · Paul Brook
Quoted 7 lines · Paul Brook
Quoted 6 lines

+struct QEMUNotifier

Quoted 3 lines

+{
+ void (*notify)(QEMUNotifier *notifier);
+};

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I suggest combining this with QEMUBH.

I didn't understand this suggestion exactly, but I think it's related that I didn't understand the advantage of making QEMUNotifier a struct.

My point is that we already have a mechanism for providing event notification callbacks, specifically QEMUBH. Why invent a new one?

QEMUBH seems seriously overengineered for this simple task.

Paolo

#17 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Quoted 6 lines · Paul Brook

+struct QEMUNotifier

Quoted 3 lines

+{
+ void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I didn't understand this suggestion exactly, but I think it's related that I didn't understand the advantage of making QEMUNotifier a struct. Instead of using container_of, reusing QEMUBHFunc (renamed to QEMUCallbackFunc maybe?) in QEMUNotifierNode like this:

I like treating a slot as a single object instead of as function pointer/opaque pair. It gives us better type safety and reduces the amount of parameters that need to be passed around.

Regards,

Anthony Liguori

#18 lore raw
In reply to Paul Brook
Quoted 8 lines · Paul Brook

notify.h line 25

Quoted 6 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

Regards,

Anthony Liguori

Quoted 4 lines

Paul

#19 lore raw
Quoted 10 lines · Paul Brook
Quoted 6 lines

notify.h line 25

Quoted 4 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

It's unclear to me why you've invented a new thing in the first place.

Paul

#20 lore raw
Quoted 9 lines · Paul Brook
Quoted 9 lines · Paul Brook
Quoted 8 lines

notify.h line 25

Quoted 6 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

Quoted 5 lines
Quoted 3 lines

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

It's unclear to me why you've invented a new thing in the first place.

This style of callback has a number of advantages:

- It provides better type safety since
- It's a more compact representation
- It maps to a function object (functor) which is a pretty common
pattern in most high level languages

Regards,

Anthony Liguori

Quoted 2 lines

Paul

#21 lore raw
Quoted 10 lines · Anthony Liguori
Quoted 3 lines
Quoted 2 lines

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

It's unclear to me why you've invented a new thing in the first place.

This style of callback has a number of advantages:

- It provides better type safety since
- It's a more compact representation
- It maps to a function object (functor) which is a pretty common
pattern in most high level languages

- The name isn't an eyesore

Signature · 1 line
error compiling committee.c: too many arguments to function
#22 lore raw
In reply to Paul Brook
Quoted 9 lines · Paul Brook
Quoted 9 lines · Paul Brook
Quoted 8 lines

notify.h line 25

Quoted 6 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

Quoted 5 lines
Quoted 3 lines

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

It's unclear to me why you've invented a new thing in the first place.

It's a better approximation of the command pattern because the command is a single object as opposed to a tuple. Because the command is an object, you can also do things like binding. For instance:

Which now gives you a notifier that has an fd bound to it's second argument (which is pretty useful for IO dispatch).

You can do this with a tuple representation, but it gets awkward. One could argue for formalizing the tuple as a struct but extending by nesting becomes more complicated. Also, for the most part, you already have a state for the command and embedding the object means less dynamic memory allocation and less code to handle that.

Regards,

Anthony Liguori

#23 lore raw
Quoted 7 lines · Anthony Liguori
Quoted 6 lines · Paul Brook
Quoted 6 lines · Paul Brook
Quoted 5 lines

notify.h line 25

Quoted 4 lines
notify.h new file +4 -0
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};

I suggest combining this with QEMUBH.

Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

I take it your not opposed to converting QEMUBH to be a QEMUNotifier? If so, I'm happy to do it.

It's unclear to me why you've invented a new thing in the first place.

It's a better approximation of the command pattern because the command is a single object as opposed to a tuple. Because the command is an object, you can also do things like binding. For instance:

typedef struct IONotifier
{
Notifier parent;
void (*notify)(IONotifier *notifier, int fd);
int fd;
} IONotifier;

It's been a long day...

Quoted 8 lines

Which now gives you a notifier that has an fd bound to it's second argument (which is pretty useful for IO dispatch).

You can do this with a tuple representation, but it gets awkward. One could argue for formalizing the tuple as a struct but extending by nesting becomes more complicated. Also, for the most part, you already have a state for the command and embedding the object means less dynamic memory allocation and less code to handle that.

Regards,

Anthony Liguori

Regards,

Anthony Liguori

#24 lore raw
In reply to Anthony Liguori
Quoted 27 lines · Anthony Liguori
notify.h new file +26 -0
+
+#ifndef QEMU_NOTIFY_H
+#define QEMU_NOTIFY_H
+
+#include "qemu-queue.h"
+
+typedef struct QEMUNotifier QEMUNotifier;
+typedef struct QEMUNotifierNode QEMUNotifierNode;
+
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};
+
+struct QEMUNotifierNode
+{
+    QEMUNotifier *notifier;
+    QTAILQ_ENTRY(QEMUNotifierNode) node;
+};
+
+typedef struct QEMUNotifierList
+{
+    QTAILQ_HEAD(, QEMUNotifierNode) notifiers;
+} QEMUNotifierList;
+
+#define QEMU_NOTIFIER_LIST_INITIALIZER(head) \

notify.h line 48

Quoted 10 lines
notify.h new file +10 -0
+    { QTAILQ_HEAD_INITIALIZER((head).notifiers) }
+
+void qemu_notifier_list_init(QEMUNotifierList *list);
+
+void qemu_notifier_list_add(QEMUNotifierList *list, QEMUNotifier *notifier);
+
+void qemu_notifier_list_remove(QEMUNotifierList *list, QEMUNotifier *notifier);
+
+void qemu_notifier_list_notify(QEMUNotifierList *list);
+

Why the qemu_ prefixes everywhere? They make sense when wrapping library calls, but in native qemu code they're just noise.

Signature · 1 line
error compiling committee.c: too many arguments to function
#25 lore raw
Quoted 34 lines · Avi Kivity
Quoted 33 lines · Anthony Liguori
notify.h new file +31 -0
+
+#ifndef QEMU_NOTIFY_H
+#define QEMU_NOTIFY_H
+
+#include "qemu-queue.h"
+
+typedef struct QEMUNotifier QEMUNotifier;
+typedef struct QEMUNotifierNode QEMUNotifierNode;
+
+struct QEMUNotifier
+{
+    void (*notify)(QEMUNotifier *notifier);
+};
+
+struct QEMUNotifierNode
+{
+    QEMUNotifier *notifier;
+    QTAILQ_ENTRY(QEMUNotifierNode) node;
+};
+
+typedef struct QEMUNotifierList
+{
+    QTAILQ_HEAD(, QEMUNotifierNode) notifiers;
+} QEMUNotifierList;
+
+#define QEMU_NOTIFIER_LIST_INITIALIZER(head) \
+    { QTAILQ_HEAD_INITIALIZER((head).notifiers) }
+
+void qemu_notifier_list_init(QEMUNotifierList *list);
+
+void qemu_notifier_list_add(QEMUNotifierList *list, QEMUNotifier 

*notifier);
+

Quoted 8 lines

notify.h line 48

Quoted 5 lines

+void qemu_notifier_list_remove(QEMUNotifierList *list, QEMUNotifier *notifier);

notify.h new file +3 -0
+
+void qemu_notifier_list_notify(QEMUNotifierList *list);
+

Why the qemu_ prefixes everywhere? They make sense when wrapping library calls, but in native qemu code they're just noise.

I don't disagree, but we do this a lot in code today. I think if folks generally agreed that qemu prefixes were just noise, we should make a concerted effort in the future to prevent people from introducing more of them and make a note in CODING_STYLE.

Regards,

Anthony Liguori

#26 lore raw

PATCH 1/1 CODING_STYLE: Reserve qemu_ prefix for library wrappers

---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +3 -0
index a579cb1..92036f3 100644
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
Signature · 1 line
1.7.0.2
Acked-by on v1 1/1
#27 lore raw

[Qemu-devel] Re: [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

Quoted 10 lines · Avi Kivity
---
  CODING_STYLE |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 55

Quoted 7 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
  Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
  QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 

But I'd like to also see others agree with this.

Regards,

Anthony Liguori

Quoted 4 lines
CODING_STYLE +0 -0
  4. Block structure
 

Every indented statement is braced; even if the block contains just one

#28 lore raw

Re: [Qemu-devel] Re: [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

Quoted 22 lines · Anthony Liguori
Quoted 15 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +2 -0
index a579cb1..92036f3 100644
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this 
Quoted 3 lines

prefix.
+

Quoted 1 line

But I'd like to also see others agree with this.

I agree - not that I've contributed any code, mind you, but I do read bits of it from time to time.

However if qemu is ever made into a library used by other applications, i.e. libqemu.a or libqemu.so, then you might decide application-visible functions should have the prefix

-- Jamie

#29 lore raw

Re: [Qemu-devel] Re: [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Anthony Liguori
Quoted 18 lines · Anthony Liguori
Quoted 10 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 53

Quoted 5 lines
CODING_STYLE +2 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this

prefix.

Quoted 7 lines

CODING_STYLE and is therefore likely to be changed.

Quoted 3 lines
CODING_STYLE +1 -0
+
 
 

But I'd like to also see others agree with this.

OK for me too.

#30 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 9 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one

ACK

Acked-by on v1 1/1
#31 lore raw

[Qemu-devel] Re: [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 9 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
Acked-by Juan Quintela
Acked-by on v1 1/1
#32 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 9 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one
Signature · 2 lines
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net
#33 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity

Review

Quoted 3 lines
(quoted diff) +2 -0
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this
 prefix. +

I'm tempted to say "When wrapping or providing functionality that could easily be confused with standard library functions [...]".

I'm not going to argue either way though.

Paul

#34 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity
Quoted 10 lines · Avi Kivity
---
 CODING_STYLE |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 9 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
 Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
 QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
 4. Block structure
 
 Every indented statement is braced; even if the block contains just one

Not sure what "standard library functions" includes but I think the qemu prefix should be allowed whenever one needs to wrap external code blocks into qemu.

I don't feel very strongly about this though. I can call my stuff wrap_xxx if I need to :)

Cheers,
Edde

#35 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines · Avi Kivity
---
  CODING_STYLE |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +3 -0
index a579cb1..92036f3 100644
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
  Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
  QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
  4. Block structure
 
Quoted 8 lines

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 2 lines
CODING_STYLE +0 -0
  Every indented statement is braced; even if the block contains just one

Not sure what "standard library functions" includes but I think the qemu prefix should be allowed whenever one needs to wrap external code blocks into qemu.

That was the intent.

Quoted 4 lines

I don't feel very strongly about this though. I can call my stuff wrap_xxx if I need to :)

A downside of a formal coding style document is that people start lawyering about it. Common sense can still be applied, if there is a use case that is similar to what is described, surely qemu_ can still hold.

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
#36 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

Quoted 29 lines · Avi Kivity
Quoted 20 lines · Edgar E. Iglesias
Quoted 18 lines · Avi Kivity
---
  CODING_STYLE |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +3 -0
index a579cb1..92036f3 100644
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
  Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
  QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
  4. Block structure
 
Quoted 7 lines

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 2 lines
CODING_STYLE +0 -0
  Every indented statement is braced; even if the block contains just one

Not sure what "standard library functions" includes but I think the qemu prefix should be allowed whenever one needs to wrap external code blocks into qemu.

Quoted 1 line

That was the intent.

Great

ACK

#37 lore raw

Re: [Qemu-devel] [PATCH] CODING_STYLE: Reserve qemu_ prefix for library wrappers

In reply to Avi Kivity
Quoted 11 lines · Avi Kivity
---
  CODING_STYLE |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
CODING_STYLE +0 -0
index a579cb1..92036f3 100644

CODING_STYLE and is therefore likely to be changed. · line 57

Quoted 9 lines
CODING_STYLE +3 -0
@@ -49,6 +49,9 @@ and is therefore likely to be changed.
  Typedefs are used to eliminate the redundant 'struct' keyword.  It is the
  QEMU coding style.
 
+When wrapping standard library functions, use the prefix qemu_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
  4. Block structure
 
  Every indented statement is braced; even if the block contains just one

Applied. Thanks.

Regards,

Anthony Liguori