Skip to contentSkip to conversation

libcacard-standalone (glib compat & libcacard) series for 2014-05-08

GIT PULL Michael Tokarev 2 participants 7 messages May 8, 2014 – May 11, 2014

lore
Share & tools
lore
#0 lore raw

Here's a pull request for glib pre-2.31 compatibility layer and libcacard cleanups on top of it. It has been submitted for review previously:

v1: http://thread.gmane.org/gmane.comp.emulators.qemu/269432
v2: http://thread.gmane.org/gmane.comp.emulators.qemu/270259

Previous attempt of adding glib compat layer by Stefan Hajnoczi:

    http://thread.gmane.org/gmane.comp.emulators.qemu/253830

Changes since v2 submission:

- dropped 3 trivial changes which were applied meantime
- fixed coding style (identation/spacing) in first patch
alevy: I hope these tiny spacing changes are okay for you to keep your reviewed-by ;)

Please consider applying. Since this touches several areas of qemu, there's no clear maintainer so I'm not really sure which maintainer tree should pick this up. And it isn't very suitable for -trival either :)

Thanks,

/mjt

The following changes since commit ff788b6fe67f694666781f821c1af812e8c7999b:

Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-2014-05-07' into staging (2014-05-07 18:38:39 +0100)

are available in the git repository at:

git://git.corpit.ru/qemu.git libcacard-standalone

for you to fetch changes up to 90dfe3ee62d65cf2fc62e9dd9ee51f5da3aaeb7b:

libcacard: actually use symbols file (2014-05-08 12:13:38 +0400)

----------------------------------------------------------------
libcacard-standalone patch queue for 2014-05-08

----------------------------------------------------------------
Michael Tokarev (4):
glib-compat.h: add new thread API emulation on top of pre-2.31 API
vscclient: use glib thread primitives not qemu
libcacard: replace qemu thread primitives with glib ones
libcacard: actually use symbols file

 coroutine-gthread.c   |   30 +++++---------
 include/glib-compat.h |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 libcacard/Makefile    |   10 +----
 libcacard/event.c     |   25 ++++++------
 libcacard/vreader.c   |   19 +++++----
 libcacard/vscclient.c |   75 +++++++++++++++++++---------------
 trace/simple.c        |   50 ++++++-----------------
 7 files changed, 196 insertions(+), 119 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/4] glib-compat.h: add new thread API emulation on top of pre-2.31 API

Thread API changed in glib-2.31 significantly. Before that version, conditionals and mutexes were only allocated dynamically, using _new()/_free() interface. in 2.31 and up, they're allocated statically as regular variables, and old interface is deprecated.

(Note: glib docs says the new interface is available since version 2.32, but it was actually introduced in version 2.31).

Create the new interface using old primitives, re-defining the base types (GCond and GMutex) to be pointers.

Replace #ifdeffery around GCond and GMutex in trace/simple.c and coroutine-gthread.c too because it does not work anymore with the new glib-compat.h.

---
 coroutine-gthread.c   |   30 +++++---------
 include/glib-compat.h |  106 +++++++++++++++++++++++++++++++++++++++++++++++++
 trace/simple.c        |   50 ++++++-----------------
 3 files changed, 129 insertions(+), 57 deletions(-)
coroutine-gthread.c +10 -20
index a61efe0..a4813d9 100644
@@ -30,20 +30,14 @@ typedef struct {
     CoroutineAction action;
 } CoroutineGThread;
 
-static GStaticMutex coroutine_lock = G_STATIC_MUTEX_INIT;
+static GMutex coroutine_lock;
+static GCond coroutine_cond;
 
 /* GLib 2.31 and beyond deprecated various parts of the thread API,
  * but the new interfaces are not available in older GLib versions
  * so we have to cope with both.
  */
 #if GLIB_CHECK_VERSION(2, 31, 0)
-/* Default zero-initialisation is sufficient for 2.31+ GCond */
-static GCond the_coroutine_cond;
-static GCond *coroutine_cond = &the_coroutine_cond;
-static inline void init_coroutine_cond(void)
-{
-}
-
 /* Awkwardly, the GPrivate API doesn't provide a way to update the
  * GDestroyNotify handler for the coroutine key dynamically. So instead
  * we track whether or not the CoroutineGThread should be freed on
@@ -84,11 +78,6 @@ static inline GThread *create_thread(GThreadFunc func, gpointer data)
 #else
 
 /* Handle older GLib versions */
-static GCond *coroutine_cond;
-static inline void init_coroutine_cond(void)
-{
-    coroutine_cond = g_cond_new();
-}
 
 static GStaticPrivate coroutine_key = G_STATIC_PRIVATE_INIT;
 
@@ -121,21 +110,22 @@ static void __attribute__((constructor)) coroutine_init(void)
     }
 #endif
 
-    init_coroutine_cond();
+    g_cond_init_static(&coroutine_cond);
+    g_mutex_init_static(&coroutine_lock);
 }
 
 static void coroutine_wait_runnable_locked(CoroutineGThread *co)
 {
     while (!co->runnable) {
-        g_cond_wait(coroutine_cond, g_static_mutex_get_mutex(&coroutine_lock));
+        g_cond_wait(&coroutine_cond, &coroutine_lock);
     }
 }
 
 static void coroutine_wait_runnable(CoroutineGThread *co)
 {
-    g_static_mutex_lock(&coroutine_lock);
+    g_mutex_lock(&coroutine_lock);
     coroutine_wait_runnable_locked(co);
-    g_static_mutex_unlock(&coroutine_lock);
+    g_mutex_unlock(&coroutine_lock);
 }
 
 static gpointer coroutine_thread(gpointer opaque)
@@ -177,17 +167,17 @@ CoroutineAction qemu_coroutine_switch(Coroutine *from_,
     CoroutineGThread *from = DO_UPCAST(CoroutineGThread, base, from_);
     CoroutineGThread *to = DO_UPCAST(CoroutineGThread, base, to_);
 
-    g_static_mutex_lock(&coroutine_lock);
+    g_mutex_lock(&coroutine_lock);
     from->runnable = false;
     from->action = action;
     to->runnable = true;
     to->action = action;
-    g_cond_broadcast(coroutine_cond);
+    g_cond_broadcast(&coroutine_cond);
 
     if (action != COROUTINE_TERMINATE) {
         coroutine_wait_runnable_locked(from);
     }
-    g_static_mutex_unlock(&coroutine_lock);
+    g_mutex_unlock(&coroutine_lock);
     return from->action;
 }
 
include/glib-compat.h +106 -0

116 lines not on this page · raw message

trace/simple.c +13 -37

88 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

[Qemu-devel] [PULL 2/4] vscclient: use glib thread primitives not qemu

In reply to Michael Tokarev

Use glib-provided thread primitives in vscclient instead of qemu ones, and do not use qemu sockets in there (open-code call to WSAStartup() for windows to initialize things).

This way, vscclient becomes more stand-alone, independent on qemu internals.

---
 libcacard/vscclient.c |   75 +++++++++++++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 31 deletions(-)
libcacard/vscclient.c +44 -31
index 3477ab3..5f87d1c 100644
@@ -12,12 +12,10 @@
 
 #ifndef _WIN32
 #include <netdb.h>
+#define closesocket(x) close(x)
 #endif
-#include <glib.h>
 
 #include "qemu-common.h"
-#include "qemu/thread.h"
-#include "qemu/sockets.h"
 
 #include "vscard_common.h"
 
@@ -54,7 +52,7 @@ print_usage(void) {
 
 static GIOChannel *channel_socket;
 static GByteArray *socket_to_send;
-static QemuMutex socket_to_send_lock;
+static GMutex socket_to_send_lock;
 static guint socket_tag;
 
 static void
@@ -103,7 +101,7 @@ send_msg(
 ) {
     VSCMsgHeader mhHeader;
 
-    qemu_mutex_lock(&socket_to_send_lock);
+    g_mutex_lock(&socket_to_send_lock);
 
     if (verbose > 10) {
         printf("sending type=%d id=%u, len =%u (0x%x)\n",
@@ -117,18 +115,18 @@ send_msg(
     g_byte_array_append(socket_to_send, (guint8 *)msg, length);
     g_idle_add(socket_prepare_sending, NULL);
 
-    qemu_mutex_unlock(&socket_to_send_lock);
+    g_mutex_unlock(&socket_to_send_lock);
 
     return 0;
 }
 
 static VReader *pending_reader;
-static QemuMutex pending_reader_lock;
-static QemuCond pending_reader_condition;
+static GMutex pending_reader_lock;
+static GCond pending_reader_condition;
 
 #define MAX_ATR_LEN 40
-static void *
-event_thread(void *arg)
+static gpointer
+event_thread(gpointer arg)
 {
     unsigned char atr[MAX_ATR_LEN];
     int atr_len = MAX_ATR_LEN;
@@ -149,20 +147,20 @@ event_thread(void *arg)
             /* ignore events from readers qemu has rejected */
             /* if qemu is still deciding on this reader, wait to see if need to
              * forward this event */
-            qemu_mutex_lock(&pending_reader_lock);
+            g_mutex_lock(&pending_reader_lock);
             if (!pending_reader || (pending_reader != event->reader)) {
                 /* wasn't for a pending reader, this reader has already been
                  * rejected by qemu */
-                qemu_mutex_unlock(&pending_reader_lock);
+                g_mutex_unlock(&pending_reader_lock);
                 vevent_delete(event);
                 continue;
             }
             /* this reader hasn't been told its status from qemu yet, wait for
              * that status */
             while (pending_reader != NULL) {
-                qemu_cond_wait(&pending_reader_condition, &pending_reader_lock);
+                g_cond_wait(&pending_reader_condition, &pending_reader_lock);
             }
-            qemu_mutex_unlock(&pending_reader_lock);
+            g_mutex_unlock(&pending_reader_lock);
             /* now recheck the id */
             reader_id = vreader_get_id(event->reader);
             if (reader_id == VSCARD_UNDEFINED_READER_ID) {
@@ -178,12 +176,12 @@ event_thread(void *arg)
             /* wait until qemu has responded to our first reader insert
              * before we send a second. That way we won't confuse the responses
              * */
-            qemu_mutex_lock(&pending_reader_lock);
+            g_mutex_lock(&pending_reader_lock);
             while (pending_reader != NULL) {
-                qemu_cond_wait(&pending_reader_condition, &pending_reader_lock);
+                g_cond_wait(&pending_reader_condition, &pending_reader_lock);
             }
             pending_reader = vreader_reference(event->reader);
-            qemu_mutex_unlock(&pending_reader_lock);
+            g_mutex_unlock(&pending_reader_lock);
             reader_name = vreader_get_name(event->reader);
             if (verbose > 10) {
                 printf(" READER INSERT: %s\n", reader_name);
@@ -246,7 +244,6 @@ on_host_init(VSCMsgHeader *mhHeader, VSCMsgInit *incoming)
     int num_capabilities =
         1 + ((mhHeader->length - sizeof(VSCMsgInit)) / sizeof(uint32_t));
     int i;
-    QemuThread thread_id;
 
     incoming->version = ntohl(incoming->version);
     if (incoming->version != VSCARD_VERSION) {
@@ -269,7 +266,7 @@ on_host_init(VSCMsgHeader *mhHeader, VSCMsgInit *incoming)
     send_msg(VSC_ReaderRemove, VSCARD_MINIMAL_READER_ID, NULL, 0);
     /* launch the event_thread. This will trigger reader adds for all the
      * existing readers */
-    qemu_thread_create(&thread_id, "vsc/event", event_thread, NULL, 0);
+    g_thread_new("vsc/event", event_thread, NULL);
     return 0;
 }
 
@@ -379,26 +376,26 @@ do_socket_read(GIOChannel *source,
         case VSC_Error:
             error_msg = (VSCMsgError *) pbSendBuffer;
             if (error_msg->code == VSC_SUCCESS) {
-                qemu_mutex_lock(&pending_reader_lock);
+                g_mutex_lock(&pending_reader_lock);
                 if (pending_reader) {
                     vreader_set_id(pending_reader, mhHeader.reader_id);
                     vreader_free(pending_reader);
                     pending_reader = NULL;
-                    qemu_cond_signal(&pending_reader_condition);
+                    g_cond_signal(&pending_reader_condition);
                 }
-                qemu_mutex_unlock(&pending_reader_lock);
+                g_mutex_unlock(&pending_reader_lock);
                 break;
             }
             printf("warning: qemu refused to add reader\n");
             if (error_msg->code == VSC_CANNOT_ADD_MORE_READERS) {
                 /* clear pending reader, qemu can't handle any more */
-                qemu_mutex_lock(&pending_reader_lock);
+                g_mutex_lock(&pending_reader_lock);
                 if (pending_reader) {
                     pending_reader = NULL;
                     /* make sure the event loop doesn't hang */
-                    qemu_cond_signal(&pending_reader_condition);
+                    g_cond_signal(&pending_reader_condition);
                 }
-                qemu_mutex_unlock(&pending_reader_lock);
+                g_mutex_unlock(&pending_reader_lock);
             }
             break;
         case VSC_Init:
@@ -602,7 +599,7 @@ connect_to_qemu(
     struct addrinfo *server;
     int ret, sock;
 
-    sock = qemu_socket(AF_INET, SOCK_STREAM, 0);
+    sock = socket(AF_INET, SOCK_STREAM, 0);
     if (sock < 0) {
         /* Error */
         fprintf(stderr, "Error opening socket!\n");
@@ -655,8 +652,20 @@ main(
     int cert_count = 0;
     int c, sock;
 
-    if (socket_init() != 0)
+#ifdef _WIN32
+    WSADATA Data;
+
+    if (WSAStartup(MAKEWORD(2, 2), &Data) != 0) {
+        c = WSAGetLastError();
+        fprintf(stderr, "WSAStartup: %d\n", c);
         return 1;
+    }
+#endif
+#if !GLIB_CHECK_VERSION(2, 31, 0)
+    if (!g_thread_supported()) {
+         g_thread_init(NULL);
+    }
+#endif
 
     while ((c = getopt(argc, argv, "c:e:pd:")) != -1) {
         switch (c) {
@@ -723,13 +732,13 @@ main(
     }
 
     socket_to_send = g_byte_array_new();
-    qemu_mutex_init(&socket_to_send_lock);
-    qemu_mutex_init(&pending_reader_lock);
-    qemu_cond_init(&pending_reader_condition);
+    g_mutex_init_static(&socket_to_send_lock);
+    g_mutex_init_static(&pending_reader_lock);
+    g_cond_init_static(&pending_reader_condition);
 
     vcard_emul_init(command_line_options);
 
-    loop = g_main_loop_new(NULL, true);
+    loop = g_main_loop_new(NULL, TRUE);
 
     printf("> ");
     fflush(stdout);
@@ -764,6 +773,10 @@ main(
     g_io_channel_unref(channel_socket);
     g_byte_array_free(socket_to_send, TRUE);
 
+    g_mutex_clear_static(&socket_to_send_lock);
+    g_mutex_clear_static(&pending_reader_lock);
+    g_cond_clear_static(&pending_reader_condition);
+
     closesocket(sock);
     return 0;
 }
Signature · 1 line
1.7.10.4
#3 lore raw

[Qemu-devel] [PULL 3/4] libcacard: replace qemu thread primitives with glib ones

In reply to Michael Tokarev

Replace QemuMutex with GMutex and QemuCond with GCond (with corresponding function changes), to make libcacard independent of qemu internal functions.

After this step, none of libcacard internals use any qemu-provided symbols. Maybe it's a good idea to stop including qemu-common.h internally too.

---
 libcacard/Makefile  |    8 +-------
 libcacard/event.c   |   25 ++++++++++++-------------
 libcacard/vreader.c |   19 +++++++++----------
 3 files changed, 22 insertions(+), 30 deletions(-)
libcacard/Makefile +1 -7
index 6b06448..89a5942 100644
@@ -3,13 +3,7 @@ libcacard_includedir=$(includedir)/cacard
 TOOLS += vscclient$(EXESUF)
 
 # objects linked into a shared library, built with libtool with -fPIC if required
-libcacard-obj-y = $(stub-obj-y) $(libcacard-y)
-libcacard-obj-y += util/osdep.o util/cutils.o util/qemu-timer-common.o
-libcacard-obj-y += util/error.o util/qemu-error.o
-libcacard-obj-$(CONFIG_WIN32) += util/oslib-win32.o util/qemu-thread-win32.o
-libcacard-obj-$(CONFIG_POSIX) += util/oslib-posix.o util/qemu-thread-posix.o
-libcacard-obj-y += $(filter trace/%, $(util-obj-y))
-
+libcacard-obj-y = $(libcacard-y)
 libcacard-lobj-y=$(patsubst %.o,%.lo,$(libcacard-obj-y))
 
 # libtool will build the .o files, too
libcacard/event.c +12 -13
index 2d7500f..be11596 100644
@@ -6,7 +6,6 @@
  */
 
 #include "qemu-common.h"
-#include "qemu/thread.h"
 
 #include "vcard.h"
 #include "vreader.h"
@@ -43,13 +42,13 @@ vevent_delete(VEvent *vevent)
 
 static VEvent *vevent_queue_head;
 static VEvent *vevent_queue_tail;
-static QemuMutex vevent_queue_lock;
-static QemuCond vevent_queue_condition;
+static GMutex vevent_queue_lock;
+static GCond vevent_queue_condition;
 
 void vevent_queue_init(void)
 {
-    qemu_mutex_init(&vevent_queue_lock);
-    qemu_cond_init(&vevent_queue_condition);
+    g_mutex_init_static(&vevent_queue_lock);
+    g_cond_init_static(&vevent_queue_condition);
     vevent_queue_head = vevent_queue_tail = NULL;
 }
 
@@ -57,7 +56,7 @@ void
 vevent_queue_vevent(VEvent *vevent)
 {
     vevent->next = NULL;
-    qemu_mutex_lock(&vevent_queue_lock);
+    g_mutex_lock(&vevent_queue_lock);
     if (vevent_queue_head) {
         assert(vevent_queue_tail);
         vevent_queue_tail->next = vevent;
@@ -65,8 +64,8 @@ vevent_queue_vevent(VEvent *vevent)
         vevent_queue_head = vevent;
     }
     vevent_queue_tail = vevent;
-    qemu_cond_signal(&vevent_queue_condition);
-    qemu_mutex_unlock(&vevent_queue_lock);
+    g_cond_signal(&vevent_queue_condition);
+    g_mutex_unlock(&vevent_queue_lock);
 }
 
 /* must have lock */
@@ -86,11 +85,11 @@ VEvent *vevent_wait_next_vevent(void)
 {
     VEvent *vevent;
 
-    qemu_mutex_lock(&vevent_queue_lock);
+    g_mutex_lock(&vevent_queue_lock);
     while ((vevent = vevent_dequeue_vevent()) == NULL) {
-        qemu_cond_wait(&vevent_queue_condition, &vevent_queue_lock);
+        g_cond_wait(&vevent_queue_condition, &vevent_queue_lock);
     }
-    qemu_mutex_unlock(&vevent_queue_lock);
+    g_mutex_unlock(&vevent_queue_lock);
     return vevent;
 }
 
@@ -98,9 +97,9 @@ VEvent *vevent_get_next_vevent(void)
 {
     VEvent *vevent;
 
-    qemu_mutex_lock(&vevent_queue_lock);
+    g_mutex_lock(&vevent_queue_lock);
     vevent = vevent_dequeue_vevent();
-    qemu_mutex_unlock(&vevent_queue_lock);
+    g_mutex_unlock(&vevent_queue_lock);
     return vevent;
 }
 
libcacard/vreader.c +9 -10
index 7720295..d1e05af 100644
@@ -9,10 +9,8 @@
 #undef G_LOG_DOMAIN
 #endif
 #define G_LOG_DOMAIN "libcacard"
-#include <glib.h>
 
 #include "qemu-common.h"
-#include "qemu/thread.h"
 
 #include "vcard.h"
 #include "vcard_emul.h"
@@ -28,7 +26,7 @@ struct VReaderStruct {
     VCard *card;
     char *name;
     vreader_id_t id;
-    QemuMutex lock;
+    GMutex lock;
     VReaderEmul  *reader_private;
     VReaderEmulFree reader_private_free;
 };
@@ -97,13 +95,13 @@ apdu_ins_to_string(int ins)
 static inline void
 vreader_lock(VReader *reader)
 {
-    qemu_mutex_lock(&reader->lock);
+    g_mutex_lock(&reader->lock);
 }
 
 static inline void
 vreader_unlock(VReader *reader)
 {
-    qemu_mutex_unlock(&reader->lock);
+    g_mutex_unlock(&reader->lock);
 }
 
 /*
@@ -116,7 +114,7 @@ vreader_new(const char *name, VReaderEmul *private,
     VReader *reader;
 
     reader = (VReader *)g_malloc(sizeof(VReader));
-    qemu_mutex_init(&reader->lock);
+    g_mutex_init(&reader->lock);
     reader->reference_count = 1;
     reader->name = g_strdup(name);
     reader->card = NULL;
@@ -152,6 +150,7 @@ vreader_free(VReader *reader)
         return;
     }
     vreader_unlock(reader);
+    g_mutex_clear(&reader->lock);
     if (reader->card) {
         vcard_free(reader->card);
     }
@@ -413,25 +412,25 @@ vreader_dequeue(VReaderList *list, VReaderListEntry *entry)
 }
 
 static VReaderList *vreader_list;
-static QemuMutex vreader_list_mutex;
+static GMutex vreader_list_mutex;
 
 static void
 vreader_list_init(void)
 {
     vreader_list = vreader_list_new();
-    qemu_mutex_init(&vreader_list_mutex);
+    g_mutex_init_static(&vreader_list_mutex);
 }
 
 static void
 vreader_list_lock(void)
 {
-    qemu_mutex_lock(&vreader_list_mutex);
+    g_mutex_lock(&vreader_list_mutex);
 }
 
 static void
 vreader_list_unlock(void)
 {
-    qemu_mutex_unlock(&vreader_list_mutex);
+    g_mutex_unlock(&vreader_list_mutex);
 }
 
 static VReaderList *
Signature · 1 line
1.7.10.4
#4 lore raw

[Qemu-devel] [PULL 4/4] libcacard: actually use symbols file

In reply to Michael Tokarev

libtool has an argument for .syms file, which is -export-symbols. There's no argument `-export-syms', and it looks like at least on linux, -export-syms is just ignored. Use the correct argument, -export-symbols, to actually get the right export list.

---
 libcacard/Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libcacard/Makefile +1 -1
index 89a5942..b620c28 100644
@@ -18,7 +18,7 @@ vscclient$(EXESUF): libcacard/vscclient.o libcacard.la
 # Rules for building libcacard standalone library
 
 libcacard.la: LDFLAGS += -rpath $(libdir) -no-undefined \
-	-export-syms $(SRC_PATH)/libcacard/libcacard.syms
+	-export-symbols $(SRC_PATH)/libcacard/libcacard.syms
 libcacard.la: LIBS = $(libcacard_libs)
 libcacard.la: $(libcacard-lobj-y)
 	$(call LINK,$^)
Signature · 1 line
1.7.10.4
#5 lore raw
In reply to Michael Tokarev
Quoted 16 lines · Michael Tokarev

Here's a pull request for glib pre-2.31 compatibility layer and libcacard cleanups on top of it. It has been submitted for review previously:

v1: http://thread.gmane.org/gmane.comp.emulators.qemu/269432
v2: http://thread.gmane.org/gmane.comp.emulators.qemu/270259

Previous attempt of adding glib compat layer by Stefan Hajnoczi:

    http://thread.gmane.org/gmane.comp.emulators.qemu/253830

Changes since v2 submission:

- dropped 3 trivial changes which were applied meantime
- fixed coding style (identation/spacing) in first patch
alevy: I hope these tiny spacing changes are okay for you to keep your reviewed-by ;)

Quoted 4 lines

Please consider applying. Since this touches several areas of qemu, there's no clear maintainer so I'm not really sure which maintainer tree should pick this up. And it isn't very suitable for -trival either :)

I'm still a bit dubious about the approach this patchset takes to glib back-compatibility (ie using #defines etc to fake up the new glib API on older glib versions, rather than defining wrappers), and it sounded from the conversation on IRC today as if Stefan was also not completely convinced. So I don't think there's enough consensus to apply this yet, and I'd rather we had more discussion/review first.

thanks
-- PMM

#6 lore raw

09.05.2014 18:53, Peter Maydell пишет:

Quoted 22 lines · Michael Tokarev
Quoted 16 lines

Here's a pull request for glib pre-2.31 compatibility layer and libcacard cleanups on top of it. It has been submitted for review previously:

v1: http://thread.gmane.org/gmane.comp.emulators.qemu/269432
v2: http://thread.gmane.org/gmane.comp.emulators.qemu/270259

Previous attempt of adding glib compat layer by Stefan Hajnoczi:

    http://thread.gmane.org/gmane.comp.emulators.qemu/253830

Changes since v2 submission:

- dropped 3 trivial changes which were applied meantime
- fixed coding style (identation/spacing) in first patch
alevy: I hope these tiny spacing changes are okay for you to keep your reviewed-by ;)

Quoted 4 lines

Please consider applying. Since this touches several areas of qemu, there's no clear maintainer so I'm not really sure which maintainer tree should pick this up. And it isn't very suitable for -trival either :)

Quoted 7 lines

I'm still a bit dubious about the approach this patchset takes to glib back-compatibility (ie using #defines etc to fake up the new glib API on older glib versions, rather than defining wrappers), and it sounded from the conversation on IRC today as if Stefan was also not completely convinced. So I don't think there's enough consensus to apply this yet, and I'd rather we had more discussion/review first.

This whole thing is almost moot really. It is an old glib API, and no one cares about it anymore except redhat, because it is the only distribution nowadays which is relevant and ships that old glib. We're discussing adding compat layer in qemu for thing which is almost irrelevant for everyone else who moved on to the new API and don't care about old crap. I tried to make old redhat glib API to be almost compatible with current glib, _just_ to not introduce additional version requiriment. For an API which is frozen and wont change anymore, and which is almost unused in whole qemu too. The layer which I provided actually works and is actually tested on several different platforms.

For me, I don't care a damn about this old crap. New glib API works on all relevant versions of Debian for example, so I can just clean up crap in libcacard using new API directly - ofcourse it wont be upstreamable due to that old glib api which is still relevant, but at least we'll have a proper libcacard in Debian.

I just wanted to do the dirty work for everyone's benefit without adding new complexity. If that's not needed, no worries from me. The 2 remaining libcacard patches are small and trivial enough to keep in debian tree.

Thanks,

/mjt