GVirStream: Libvirt-gobject Reference Manual

## GVirStream GVirStream |

## Functions

gint | (*GVirStreamSinkFunc) ()
gint | (*GVirStreamSourceFunc) ()
gboolean | (*GVirStreamIOFunc) ()
guint | gvir_stream_add_watch ()
guint | gvir_stream_add_watch_full ()
gssize | gvir_stream_receive_all ()
gssize | gvir_stream_receive ()
gssize | gvir_stream_send_all ()
gssize | gvir_stream_send ()

## Properties

GVirStreamHandle * | handle | Read / Write / Construct Only

## Types and Values

enum | GVirStreamIOCondition

## Object Hierarchy

        GObject
        ╰── GIOStream
            ╰── GVirStream

## Description

## Functions

### GVirStreamSinkFunc ()

    gint
    (*GVirStreamSinkFunc) (GVirStream *stream,
                           const gchar *buf,
                           gsize nbytes,
                           gpointer user_data);

#### Parameters

stream | a GVirStream |
buf | data pointer. | [out][array length=nbytes][transfer none]
nbytes | data size |
user_data | user data passed to the function |

#### Returns

the number of bytes filled, 0 upon end of file, or -1 upon error

### GVirStreamSourceFunc ()

    gint
    (*GVirStreamSourceFunc) (GVirStream *stream,
                             gchar *buf,
                             gsize nbytes,
                             gpointer user_data);

#### Parameters

stream | a GVirStream |
buf | data pointer. | [out][array length=nbytes][transfer none]
nbytes | data size |
user_data | user data passed to the function |

#### Returns

the number of bytes filled, 0 upon end of file, or -1 upon error

### GVirStreamIOFunc ()

    gboolean
    (*GVirStreamIOFunc) (GVirStream *stream,
                         GVirStreamIOCondition cond,
                         gpointer opaque);

### gvir_stream_add_watch ()

    guint
    gvir_stream_add_watch (GVirStream *stream,
                           GVirStreamIOCondition cond,
                           GVirStreamIOFunc func,
                           gpointer opaque);

Adds a watch for `stream` to the mainloop

[skip]

#### Parameters

stream | the stream |
cond | the conditions to watch for (bitfield of GVirStreamIOCondition) |
func | the function to call when the condition is satisfied. | [closure opaque]
opaque | user data to pass to `func` . | [closure]

#### Returns

the event source id

### gvir_stream_add_watch_full ()

    guint
    gvir_stream_add_watch_full (GVirStream *stream,
                                gint priority,
                                GVirStreamIOCondition cond,
                                GVirStreamIOFunc func,
                                gpointer opaque,
                                GDestroyNotify notify);

Adds a watch for `stream` to the mainloop

[rename-to gvir_stream_add_watch]

#### Parameters

stream | the stream |
priority | the priority of the GVirStream source |
cond | the conditions to watch for (bitfield of GVirStreamIOCondition) |
func | the function to call when the condition is satisfied. | [closure opaque]
opaque | user data to pass to `func` . | [closure]
notify | the function to call when the source is removed |

#### Returns

the event source id

### gvir_stream_receive_all ()

    gssize
    gvir_stream_receive_all (GVirStream *stream,
                             GCancellable *cancellable,
                             GVirStreamSinkFunc func,
                             gpointer user_data,
                             GError **error);

Receive the entire data stream, sending the data to the requested data sink. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.

#### Parameters

stream | the stream |
cancellable | cancellation notifier |
func | the callback for writing data to application. | [scope notified]
user_data | data to be passed to `callback` . | [closure]
error | GError for error reporting, or `NULL` to ignore. |

#### Returns

the number of bytes consumed or -1 upon error

### gvir_stream_receive ()

    gssize
    gvir_stream_receive (GVirStream *stream,
                         gchar *buffer,
                         gsize size,
                         GCancellable *cancellable,
                         GError **error);

Receive data (up to `size` bytes) from a stream. On error -1 is returned and `error` is set accordingly.

gvir_stream_receive() can return any number of bytes, up to `size` . If more than `size` bytes have been received, the additional data will be returned in future calls to `gvir_stream_receive()`.

If there is no data available, a `G_IO_ERROR_WOULD_BLOCK` error will be returned.

#### Parameters

stream | the stream |
buffer | a buffer to read data into (which should be at least `size` bytes long). | [array length=size][element-type guint8]
size | the number of bytes you want to read from the stream |
cancellable | a `GCancellable` or `NULL`. | [allow-none]
error | GError for error reporting, or `NULL` to ignore. |

#### Returns

Number of bytes read, or 0 if the end of stream reached, or -1 on error.

### gvir_stream_send_all ()

    gssize
    gvir_stream_send_all (GVirStream *stream,
                          GCancellable *cancellable,
                          GVirStreamSourceFunc func,
                          gpointer user_data,
                          GError **error);

Send the entire data stream, sending the data to the requested data source. This is simply a convenient alternative to virStreamRecv, for apps that do blocking-I/o.

#### Parameters

stream | the stream |
cancellable | cancellation notifier |
func | the callback for writing data to application. | [scope notified]
user_data | data to be passed to `callback` . | [closure]
error | GError for error reporting, or `NULL` to ignore. |

#### Returns

the number of bytes consumed or -1 upon error

### gvir_stream_send ()

    gssize
    gvir_stream_send (GVirStream *stream,
                      const gchar *buffer,
                      gsize size,
                      GCancellable *cancellable,
                      GError **error);

Send data (up to `size` bytes) from a stream. On error -1 is returned and `error` is set accordingly.

gvir_stream_send() can return any number of bytes, up to `size` . If more than `size` bytes have been sendd, the additional data will be returned in future calls to `gvir_stream_send()`.

If there is no data available, a `G_IO_ERROR_WOULD_BLOCK` error will be returned.

#### Parameters

stream | the stream |
buffer | a buffer to write data from (which should be at least `size` bytes long). |
size | the number of bytes you want to write to the stream |
cancellable | a `GCancellable` or `NULL`. | [allow-none]
error | GError for error reporting, or `NULL` to ignore. |

#### Returns

Number of bytes written.

## Types and Values

### enum GVirStreamIOCondition

#### Members

GVIR_STREAM_IO_CONDITION_READABLE |  |
GVIR_STREAM_IO_CONDITION_WRITABLE |  |
GVIR_STREAM_IO_CONDITION_HANGUP |  |
GVIR_STREAM_IO_CONDITION_ERROR |  |

## Property Details

### The `“handle”` property

      “handle”                   GVirStreamHandle *

The stream handle.

Owner: GVirStream

Flags: Read / Write / Construct Only