summaryrefslogtreecommitdiff
path: root/include/glib-compat.h
AgeCommit message (Collapse)AuthorFilesLines
2017-10-10glib-compat: move G_SOURCE_CONTINUE/REMOVE thereMarc-André Lureau1-0/+7
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
2017-09-22migration: Teach it about G_SOURCE_REMOVEJuan Quintela1-0/+2
As this is defined on glib 2.32, add compatibility macros for older glibs. Signed-off-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com>
2017-04-26qga: Add 'guest-get-users' commandVinzenz Feenstra1-0/+6
A command that will list all currently logged in users, and the time since when they are logged in. Examples: virsh # qemu-agent-command F25 '{ "execute": "guest-get-users" }' {"return":[{"login-time":1490622289.903835,"user":"root"}]} virsh # qemu-agent-command Win2k12r2 '{ "execute": "guest-get-users" }' {"return":[{"login-time":1490351044.670552,"domain":"LADIDA", "user":"Administrator"}]} Signed-off-by: Vinzenz Feenstra <vfeenstr@redhat.com> * make g_hash_table_contains compat func inline to avoid unused warnings Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2017-03-01glib-compat: add g_test_add_data_func_full fallbackMarc-André Lureau1-0/+21
Move the fallback from qtest_add_data_func_full() to glib-compat. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2017-01-24win32: use glib gpoll if glib >= 2.50Marc-André Lureau1-1/+1
A fix has been committed in upstream glib commit 210a9796f78eb90f76f1bd6a304e9fea05e97617. (See also related bug https://bugzilla.gnome.org/show_bug.cgi?id=764415) It is desirable to use the glib version instead of qemu copy, since it provides more debugging facilities (G_MAIN_POLL_DEBUG etc), and hopefully has a better maintainance. Hopefully, we can drop the qemu copy in a few years. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-11-01tests: send error_report to test logPaolo Bonzini1-0/+13
Implement error_vprintf to send the output of error_report to the test log. This silences test-vmstate. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1477326663-67817-3-git-send-email-pbonzini@redhat.com>
2016-10-27char: set name for all I/O channels createdDaniel P. Berrange1-0/+4
Ensure that all I/O channels created for character devices are given names to distinguish their respective roles. Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-10-27io: add ability to set a name for IO channelsDaniel P. Berrange1-0/+7
The GSource object has ability to have a name, which is useful when debugging performance problems with the mainloop event callbacks that take too long. By associating a name with a QIOChannel object, we can then set the name on any GSource associated with the channel. Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-09-08glib-compat: add g_(s)list_free_full()Marc-André Lureau1-0/+24
Those functions are only available since glib 2.28. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2016-08-19glib: add compatibility implementation for g_dir_make_tmp()Sascha Silbe1-0/+20
We're going to make use of g_dir_make_tmp() in test-logging. Provide a compatibility implementation of it for glib < 2.30. May behave differently in some edge cases (e.g. pattern only at the end of the template, the file name is not part of the error message), but good enough in practice. Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com> Message-id: 1471545963-11720-2-git-send-email-silbe@linux.vnet.ibm.com [PMM: removed variable "template" which caused compilation failures when C++ files include glib-compat.h] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-06-29vhost-user-test: fix g_cond_wait_until compat implementationPaolo Bonzini1-0/+26
This fixes compilation with glib versions up to 2.30, such as the one in CentOS 6. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-10-30glib: add compatibility interface for g_hash_table_add()Markus Armbruster1-0/+8
The next commit will use it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
2015-10-19glib-compat: add 2.38/2.40/2.46 assertsMarc-André Lureau1-0/+61
Those are mostly useful for writing tests. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Claudio Fontana <claudio.fontana@huawei.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2015-05-22glib: remove stale compat functionsJohn Snow1-35/+0
Since we're bumping the version to 2.22+, remove the now-stale compat functions. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 1431469140-22208-2-git-send-email-jsnow@redhat.com
2015-05-08glib-compat.h: change assert to g_assertMichael Tokarev1-3/+3
include/glib-compat.h defines a bunch of functions based on glib primitives, and uses assert() without including assert.h. Replace assert() with g_assert() to make the file more self-contained, and to fix compilation breakage after 28507a415a9b1e. Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Laurent Desnogues <laurent.desnogues@gmail.com>
2015-04-02glib-compat: fix problems with not-quite glib 2.22Cornelia Huck1-1/+3
Commit 89b516d8b9444ece8ccabb322a9389587c7a7b83 ("glib: add compatibility interface for g_get_monotonic_time()") aimed at making qemu build with old glib versions. At least SLES11SP3, however, contains a backport of g_get_monotonic_time() while keeping the reported glib version at 2.22. Let's work around this by a strategically placed #define. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Message-id: 1427987865-433-2-git-send-email-cornelia.huck@de.ibm.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-10-16glib: add compatibility interface for g_strcmp0()Gonglei1-0/+17
This patch fixes compilation errors when building against glib < 2.16.0 due to the missing g_strcmp0() function. Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Gonglei <arei.gonglei@huawei.com> Message-id: 1413457177-10132-1-git-send-email-arei.gonglei@huawei.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-10-15glib: add compatibility interface for g_get_monotonic_time()Stefan Hajnoczi1-0/+19
This patch fixes compilation errors when building against glib <2.28.0 due to the missing g_get_monotonic_time() function. The compilation error in tests/libqos/virtio.c was introduced in commit 70556264a89a268efba1d7e8e341adcdd7881eb4 ("libqos: use microseconds instead of iterations for virtio timeout"). Add a simple g_get_monotonic_time() implementation to glib-compat.h based on code from vhost-user-test.c. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> [Igor: add G_TIME_SPAN_SECOND, include glib-compat.h in libqtest.h] Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2014-06-10glib-compat.h: add new thread API emulation on top of pre-2.31 APIMichael Tokarev1-0/+119
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, by providing non-opaque definitions of the base types (GCond and GMutex) using GOnces. 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. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> [Use GOnce to support lazy initialization; introduce CompatGMutex and CompatGCond. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2014-05-09glib: fix g_poll early timeout on windowsSangho Park1-1/+8
g_poll has a problem on Windows when using timeouts < 10ms, in glib/gpoll.c: /* If not, and we have a significant timeout, poll again with * timeout then. Note that this will return indication for only * one event, or only for messages. We ignore timeouts less than * ten milliseconds as they are mostly pointless on Windows, the * MsgWaitForMultipleObjectsEx() call will timeout right away * anyway. */ if (retval == 0 && (timeout == INFINITE || timeout >= 10)) retval = poll_rest (poll_msgs, handles, nhandles, fds, nfds, timeout); so whenever g_poll is called with timeout < 10ms it does a quick poll instead of wait, this causes significant performance degradation of QEMU, thus we should use WaitForMultipleObjectsEx directly Signed-off-by: Stanislav Vorobiov <s.vorobiov@samsung.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2014-05-07glib: move g_poll() replacement into glib-compat.hStefan Hajnoczi1-0/+12
We have a dedicated header file for wrappers to smooth over glib version differences. Move the g_poll() definition into glib-compat.h for consistency. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Cc: qemu-trivial@nongnu.org
2013-03-25glib: add a compatibility interface for g_timeout_add_secondsAnthony Liguori1-0/+27
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>