[libvirt] [libvirt-glib] gir: fix introspection of asyncs and array delegate
by Marc-André Lureau
---
libvirt-gobject/libvirt-gobject-connection.c | 24 ++++++++++++------------
libvirt-gobject/libvirt-gobject-connection.h | 6 +++---
libvirt-gobject/libvirt-gobject-storage-pool.c | 8 ++++----
libvirt-gobject/libvirt-gobject-storage-pool.h | 2 +-
libvirt-gobject/libvirt-gobject-stream.h | 2 +-
5 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 90d1566..5fc0a9e 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -431,19 +431,19 @@ gvir_connection_open_helper(GSimpleAsyncResult *res,
* gvir_connection_open_async:
* @conn: the connection
* @cancellable: (allow-none)(transfer none): cancellation object
- * @callback: (transfer none): completion callback
- * @opaque: (transfer none)(allow-none): opaque data for callback
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
*/
void gvir_connection_open_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque)
+ gpointer user_data)
{
GSimpleAsyncResult *res;
res = g_simple_async_result_new(G_OBJECT(conn),
callback,
- opaque,
+ user_data,
gvir_connection_open);
g_simple_async_result_run_in_thread(res,
gvir_connection_open_helper,
@@ -828,19 +828,19 @@ gvir_connection_fetch_domains_helper(GSimpleAsyncResult *res,
* gvir_connection_fetch_domains_async:
* @conn: the connection
* @cancellable: (allow-none)(transfer none): cancellation object
- * @callback: (transfer none): completion callback
- * @opaque: (transfer none)(allow-none): opaque data for callback
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
*/
void gvir_connection_fetch_domains_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque)
+ gpointer user_data)
{
GSimpleAsyncResult *res;
res = g_simple_async_result_new(G_OBJECT(conn),
callback,
- opaque,
+ user_data,
gvir_connection_fetch_domains);
g_simple_async_result_run_in_thread(res,
gvir_connection_fetch_domains_helper,
@@ -889,19 +889,19 @@ gvir_connection_fetch_pools_helper(GSimpleAsyncResult *res,
* gvir_connection_fetch_storage_pools_async:
* @conn: the connection
* @cancellable: (allow-none)(transfer none): cancellation object
- * @callback: (transfer none): completion callback
- * @opaque: (transfer none)(allow-none): opaque data for callback
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
*/
void gvir_connection_fetch_storage_pools_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque)
+ gpointer user_data)
{
GSimpleAsyncResult *res;
res = g_simple_async_result_new(G_OBJECT(conn),
callback,
- opaque,
+ user_data,
gvir_connection_fetch_storage_pools);
g_simple_async_result_run_in_thread(res,
gvir_connection_fetch_pools_helper,
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index d05f792..2eb58ec 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -77,7 +77,7 @@ gboolean gvir_connection_open(GVirConnection *conn,
void gvir_connection_open_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque);
+ gpointer user_data);
gboolean gvir_connection_open_finish(GVirConnection *conn,
GAsyncResult *result,
GError **err);
@@ -90,7 +90,7 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn,
void gvir_connection_fetch_domains_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque);
+ gpointer user_data);
gboolean gvir_connection_fetch_domains_finish(GVirConnection *conn,
GAsyncResult *result,
GError **err);
@@ -149,7 +149,7 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
void gvir_connection_fetch_storage_pools_async(GVirConnection *conn,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque);
+ gpointer user_data);
gboolean gvir_connection_fetch_storage_pools_finish(GVirConnection *conn,
GAsyncResult *result,
GError **err);
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index 8f581eb..fc9cba9 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -385,19 +385,19 @@ gvir_storage_pool_refresh_helper(GSimpleAsyncResult *res,
* gvir_storage_pool_refresh_async:
* @pool: the storage pool
* @cancellable: (allow-none)(transfer none): cancellation object
- * @callback: (transfer none): completion callback
- * @opaque: (transfer none)(allow-none): opaque data for callback
+ * @callback: (scope async): completion callback
+ * @user_data: (closure): opaque data for callback
*/
void gvir_storage_pool_refresh_async(GVirStoragePool *pool,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque)
+ gpointer user_data)
{
GSimpleAsyncResult *res;
res = g_simple_async_result_new(G_OBJECT(pool),
callback,
- opaque,
+ user_data,
gvir_storage_pool_refresh);
g_simple_async_result_run_in_thread(res,
gvir_storage_pool_refresh_helper,
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.h b/libvirt-gobject/libvirt-gobject-storage-pool.h
index a789a6a..620f888 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.h
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.h
@@ -75,7 +75,7 @@ gboolean gvir_storage_pool_refresh(GVirStoragePool *pool,
void gvir_storage_pool_refresh_async(GVirStoragePool *pool,
GCancellable *cancellable,
GAsyncReadyCallback callback,
- gpointer opaque);
+ gpointer user_data);
gboolean gvir_storage_pool_refresh_finish(GVirStoragePool *pool,
GAsyncResult *result,
GError **err);
diff --git a/libvirt-gobject/libvirt-gobject-stream.h b/libvirt-gobject/libvirt-gobject-stream.h
index fd9c9bb..5181e24 100644
--- a/libvirt-gobject/libvirt-gobject-stream.h
+++ b/libvirt-gobject/libvirt-gobject-stream.h
@@ -62,7 +62,7 @@ struct _GVirStreamClass
/**
* GVirStreamSinkFunc:
* @stream: a #GVirStream
- * @buf: data pointer
+ * @buf: (out) (array length=nbytes) (transfer none): data pointer
* @nbytes: data size
* @user_data: user data passed to the function
* Returns: the number of bytes filled, 0 upon end
--
1.7.6.2
13 years, 6 months
[libvirt] [libvirt-glib] RFC: delay event handle freeing to avoid dead lock
by Marc-André Lureau
Can be reproduced with the updated test.
---
examples/conn-test.c | 20 +++++++++++++++-----
libvirt-glib/libvirt-glib-event.c | 17 +++++++++++++----
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/examples/conn-test.c b/examples/conn-test.c
index 08045a4..8ea5ad7 100644
--- a/examples/conn-test.c
+++ b/examples/conn-test.c
@@ -31,12 +31,19 @@ do_connection_open(GObject *source,
{
GVirConnection *conn = GVIR_CONNECTION(source);
GError *err = NULL;
- GMainLoop *loop = opaque;
if (!gvir_connection_open_finish(conn, res, &err)) {
g_error("%s", err->message);
}
g_print("Connected to libvirt\n");
+ g_object_unref(conn);
+}
+
+static void quit(gpointer data,
+ GObject *where_the_object_was)
+{
+ GMainLoop *loop = data;
+
g_main_loop_quit(loop);
}
@@ -47,19 +54,22 @@ int main(int argc, char **argv)
gvir_init_object(&argc, &argv);
- if (argc != 2)
+ if (argc != 2) {
g_error("syntax: %s URI", argv[0]);
-
- conn = gvir_connection_new(argv[1]);
+ return 1;
+ }
loop = g_main_loop_new(g_main_context_default(),
TRUE);
- gvir_connection_open_async(conn, NULL, do_connection_open, loop);
+ conn = gvir_connection_new(argv[1]);
+ g_object_weak_ref(G_OBJECT(conn), quit, loop);
+
gvir_connection_open_async(conn, NULL, do_connection_open, loop);
g_main_loop_run(loop);
+
return 0;
}
diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index a785c93..8b1bddf 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -195,6 +195,18 @@ cleanup:
g_mutex_unlock(eventlock);
}
+static gboolean
+_handle_remove(gpointer data)
+{
+ struct gvir_event_handle *h = data;
+
+ if (h->ff)
+ (h->ff)(h->opaque);
+ free(h);
+
+ return FALSE;
+}
+
static int
gvir_event_handle_remove(int watch)
{
@@ -217,10 +229,7 @@ gvir_event_handle_remove(int watch)
g_source_remove(data->source);
data->source = 0;
data->events = 0;
- if (data->ff)
- (data->ff)(data->opaque);
- free(data);
-
+ g_idle_add(_handle_remove, data);
ret = 0;
cleanup:
--
1.7.6.2
13 years, 6 months
[libvirt] [PATCH 0/2] qemu: make PCI multifunction support more manual
by Laine Stump
Problems have been encountered/realized with the practice of
unconditionally setting the multifunction bit for all functions of all
devices. PATCH 2/2 remedies that (details in its own commit
comment). PATCH 1/2 is a one-liner I fixed in the meantime which will
cause a simple conflict if it's not applied to other branches at the
same time as PATCH 2/2, so I'm sending them together.
13 years, 6 months
[libvirt] [PATCH] virsh: do not unlink NULL file
by Marc-André Lureau
error:could not take a screenshot of xp
==6216== Syscall param unlink(pathname) points to unaddressable byte(s)
==6216== at 0x373A0D4937: unlink (syscall-template.S:82)
==6216== by 0x40FD73: cmdScreenshot (virsh.c:3070)
==6216== by 0x42BA0D: vshCommandRun (virsh.c:14920)
==6216== by 0x42EC97: main (virsh.c:16379)
==6216== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==6216==
error:Requested operation is not valid: domain is not running
---
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 1909dce..89d355f 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3004,7 +3004,7 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
unsigned int screen = 0;
unsigned int flags = 0; /* currently unused */
int ret = false;
- bool created = true;
+ bool created = false;
bool generated = false;
char *mime = NULL;
@@ -3039,13 +3039,13 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd)
}
if ((fd = open(file, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0) {
- created = false;
if (errno != EEXIST ||
(fd = open(file, O_WRONLY|O_TRUNC, 0666)) < 0) {
vshError(ctl, _("cannot create file %s"), file);
goto cleanup;
}
- }
+ } else
+ created = true;
if (virStreamRecvAll(st, vshStreamSink, &fd) < 0) {
vshError(ctl, _("could not receive data from domain %s"), name);
--
1.7.6.2
13 years, 6 months