---
src/Makefile.am | 3 +-
src/libvirt-php.c | 231 +--------------------------------------------------
src/libvirt-php.h | 15 +---
src/libvirt-stream.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/libvirt-stream.h | 39 +++++++++
5 files changed, 274 insertions(+), 244 deletions(-)
create mode 100644 src/libvirt-stream.c
create mode 100644 src/libvirt-stream.h
diff --git a/src/Makefile.am b/src/Makefile.am
index ba2be62..ddfad41 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,8 @@ libvirt_php_la_SOURCES = \
sockets.c sockets.h \
libvirt-php.c libvirt-php.h \
libvirt-connection.c libvirt-connection.h \
- libvirt-node.c libvirt-node.h
+ libvirt-node.c libvirt-node.h \
+ libvirt-stream.c libvirt-stream.h
libvirt_php_la_CFLAGS = \
$(AM_CFLAGS) \
-DCOMPILE_DL_LIBVIRT=1
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 6315ec4..c84aaef 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -21,11 +21,10 @@
#include "sockets.h"
#include "libvirt-connection.h"
#include "libvirt-node.h"
+#include "libvirt-stream.h"
DEBUG_INIT("core");
-
-
#ifndef EXTWIN
/* Additional binaries */
const char *features[] = { "screenshot", "create-image",
"screenshot-convert", NULL };
@@ -41,7 +40,6 @@ int le_libvirt_storagepool;
int le_libvirt_volume;
int le_libvirt_network;
int le_libvirt_nodedev;
-int le_libvirt_stream;
int le_libvirt_snapshot;
int le_libvirt_nwfilter;
@@ -476,15 +474,8 @@ ZEND_END_ARG_INFO()
static zend_function_entry libvirt_functions[] = {
/* Common functions */
PHP_FE(libvirt_get_last_error, arginfo_libvirt_void)
- /* Connect functions */
PHP_FE_LIBVIRT_CONNECTION
- /* Stream functions */
- PHP_FE(libvirt_stream_create, arginfo_libvirt_conn)
- PHP_FE(libvirt_stream_close, arginfo_libvirt_conn)
- PHP_FE(libvirt_stream_abort, arginfo_libvirt_conn)
- PHP_FE(libvirt_stream_finish, arginfo_libvirt_conn)
- PHP_FE(libvirt_stream_send, arginfo_libvirt_stream_send)
- PHP_FE(libvirt_stream_recv, arginfo_libvirt_stream_recv)
+ PHP_FE_LIBVIRT_STREAM
/* Domain functions */
PHP_FE(libvirt_domain_new, arginfo_libvirt_domain_new)
PHP_FE(libvirt_domain_new_get_vnc, arginfo_libvirt_void)
@@ -1357,33 +1348,6 @@ static void php_libvirt_domain_dtor(virt_resource *rsrc TSRMLS_DC)
}
}
-/* Destructor for stream resource */
-static void php_libvirt_stream_dtor(virt_resource *rsrc TSRMLS_DC)
-{
- php_libvirt_stream *stream = (php_libvirt_stream *)rsrc->ptr;
- int rv = 0;
-
- if (stream != NULL) {
- if (stream->stream != NULL) {
- if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream
TSRMLS_CC)) {
- stream->stream = NULL;
- efree(stream);
- return;
- }
- rv = virStreamFree(stream->stream);
- if (rv != 0) {
- DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n",
__FUNCTION__, stream->stream, rv, LIBVIRT_G(last_error));
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed
with %i on destructor: %s", rv, LIBVIRT_G(last_error));
- } else {
- DPRINTF("%s: virStreamFree(%p) completed successfully\n",
__FUNCTION__, stream->stream);
- resource_change_counter(INT_RESOURCE_STREAM, NULL, stream->stream, 0
TSRMLS_CC);
- }
- stream->stream = NULL;
- }
- efree(stream);
- }
-}
-
/* Destructor for storagepool resource */
static void php_libvirt_storagepool_dtor(virt_resource *rsrc TSRMLS_DC)
{
@@ -3251,197 +3215,6 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string)
}
/*
- * Function name: libvirt_stream_create
- * Since version: 0.5.0
- * Description: Function is used to create new stream from libvirt conn
- * Arguments: @res [resource]: libvirt connection resource from libvirt_connect()
- * Returns: resource libvirt stream resource
- */
-PHP_FUNCTION(libvirt_stream_create)
-{
- php_libvirt_connection *conn = NULL;
- zval *zconn;
- virStreamPtr stream = NULL;
- php_libvirt_stream *res_stream;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) ==
FAILURE)
- RETURN_FALSE;
- VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn,
PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);
- if ((conn == NULL) || (conn->conn == NULL))
- RETURN_FALSE;
-
- stream = virStreamNew(conn->conn, 0);
- if (stream == NULL) {
- set_error("Cannot create new stream" TSRMLS_CC);
- RETURN_FALSE;
- }
-
- res_stream = (php_libvirt_stream *)emalloc(sizeof(php_libvirt_stream));
- res_stream->stream = stream;
- res_stream->conn = conn;
-
- resource_change_counter(INT_RESOURCE_STREAM, conn->conn, res_stream->stream, 1
TSRMLS_CC);
-
- VIRT_REGISTER_RESOURCE(res_stream, le_libvirt_stream);
-}
-
-/*
- * Function name: libvirt_stream_close
- * Since version: 0.5.0
- * Description: Function is used to close stream
- * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
- * Returns: int
- */
-PHP_FUNCTION(libvirt_stream_close)
-{
- zval *zstream;
- php_libvirt_stream *stream = NULL;
- int retval = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
- RETURN_LONG(retval);
- VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
- if ((stream == NULL) || (stream->stream == NULL))
- RETURN_LONG(retval);
-
- retval = virStreamFree(stream->stream);
- if (retval != 0) {
- set_error("Cannot free stream" TSRMLS_CC);
- RETURN_LONG(retval);
- }
-
- resource_change_counter(INT_RESOURCE_STREAM, stream->conn->conn,
stream->stream, 0 TSRMLS_CC);
- RETURN_LONG(retval);
-}
-
-/*
- * Function name: libvirt_stream_abort
- * Since version: 0.5.0
- * Description: Function is used to abort transfer
- * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
- * Returns: int
- */
-PHP_FUNCTION(libvirt_stream_abort)
-{
- zval *zstream;
- php_libvirt_stream *stream = NULL;
- int retval = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
- RETURN_LONG(retval);
- VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
- if ((stream == NULL) || (stream->stream == NULL))
- RETURN_LONG(retval);
-
- retval = virStreamAbort(stream->stream);
- if (retval != 0) {
- set_error("Cannot abort stream" TSRMLS_CC);
- RETURN_LONG(retval);
- }
- RETURN_LONG(retval);
-}
-
-/*
- * Function name: libvirt_stream_finish
- * Since version: 0.5.0
- * Description: Function is used to finish transfer
- * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
- * Returns: int
- */
-PHP_FUNCTION(libvirt_stream_finish)
-{
- zval *zstream;
- php_libvirt_stream *stream = NULL;
- int retval = -1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
- RETURN_LONG(retval);
- VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
- if ((stream == NULL) || (stream->stream == NULL))
- RETURN_LONG(retval);
-
- retval = virStreamFinish(stream->stream);
- if (retval != 0) {
- set_error("Cannot finish stream" TSRMLS_CC);
- RETURN_LONG(retval);
- }
- RETURN_LONG(retval);
-}
-
-/*
- * Function name: libvirt_stream_recv
- * Since version: 0.5.0
- * Description: Function is used to recv from stream via libvirt conn
- * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
- * @data [string]: buffer
- * @len [int]: amout of data to recieve
- * Returns: int
- */
-PHP_FUNCTION(libvirt_stream_recv)
-{
- zval *zstream, *zbuf;
- php_libvirt_stream *stream = NULL;
- char *recv_buf = NULL;
- int retval = -1;
- zend_long length = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream,
&zbuf, &length) == FAILURE)
- RETURN_LONG(retval);
- VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
- if ((stream == NULL) || (stream->stream == NULL))
- RETURN_LONG(retval);
-
- recv_buf = emalloc(length + 1);
-
- retval = virStreamRecv(stream->stream, recv_buf, length);
- if (retval < 0) {
- zval_dtor(zbuf);
- ZVAL_NULL(zbuf);
- } else {
- recv_buf[retval] = '\0';
- VIRT_ZVAL_STRINGL(zbuf, recv_buf, retval);
- }
-
- if (retval == -1)
- set_error("Cannot recv from stream" TSRMLS_CC);
-
- efree(recv_buf);
- RETURN_LONG(retval);
-}
-
-/*
- * Function name: libvirt_stream_send
- * Since version: 0.5.0
- * Description: Function is used to send to stream via libvirt conn
- * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
- * @data [string]: buffer
- * @length [int]: amout of data to send
- * Returns: int
- */
-PHP_FUNCTION(libvirt_stream_send)
-{
- zval *zstream, *zbuf;
- php_libvirt_stream *stream = NULL;
- int retval = -1;
- zend_long length = 0;
- char *cstr;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream,
&zbuf, &length) == FAILURE)
- RETURN_LONG(retval);
- VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
- if ((stream == NULL) || (stream->stream == NULL))
- RETURN_LONG(retval);
-
- cstr = Z_STRVAL_P(zbuf);
-
- retval = virStreamSend(stream->stream, cstr, length);
- if (retval == -1)
- set_error("Cannot send to stream" TSRMLS_CC);
-
- RETURN_LONG(retval);
-}
-
-/*
* Function name: libvirt_domain_lookup_by_id
* Since version: 0.4.1(-1)
* Description: Function is used to get domain by it's ID, applicable only to
running guests
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index a701235..49bcdc9 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -127,7 +127,6 @@ typedef uint64_t arch_uint;
#define INT_RESOURCE_STORAGEPOOL 0x10
#define INT_RESOURCE_VOLUME 0x20
#define INT_RESOURCE_SNAPSHOT 0x40
-#define INT_RESOURCE_STREAM 0x50
#define INT_RESOURCE_NWFILTER 0x60
typedef struct tTokenizer {
@@ -161,11 +160,6 @@ typedef struct tVMNetwork {
typedef struct _php_libvirt_connection php_libvirt_connection;
/* Libvirt-php types */
-typedef struct _php_libvirt_stream {
- virStreamPtr stream;
- php_libvirt_connection* conn;
-} php_libvirt_stream;
-
typedef struct _php_libvirt_domain {
virDomainPtr domain;
php_libvirt_connection* conn;
@@ -228,6 +222,7 @@ void set_error(char *msg TSRMLS_DC);
void reset_error(TSRMLS_D);
int count_resources(int type TSRMLS_DC);
int resource_change_counter(int type, virConnectPtr conn, void *mem, int inc TSRMLS_DC);
+int check_resource_allocation(virConnectPtr conn, int type, void *mem TSRMLS_DC);
void free_resource(int type, void *mem TSRMLS_DC);
char *connection_get_emulator(virConnectPtr conn, char *arch TSRMLS_DC);
int is_local_connection(virConnectPtr conn);
@@ -238,7 +233,6 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int
*retVal);
char **get_array_from_xpath(char *xml, char *xpath, int *num);
#define PHP_LIBVIRT_DOMAIN_RES_NAME "Libvirt domain"
-#define PHP_LIBVIRT_STREAM_RES_NAME "Libvirt stream"
#define PHP_LIBVIRT_STORAGEPOOL_RES_NAME "Libvirt storagepool"
#define PHP_LIBVIRT_VOLUME_RES_NAME "Libvirt volume"
#define PHP_LIBVIRT_NETWORK_RES_NAME "Libvirt virtual network"
@@ -254,13 +248,6 @@ PHP_MINFO_FUNCTION(libvirt);
/* Common functions */
PHP_FUNCTION(libvirt_get_last_error);
-/* Stream functions */
-PHP_FUNCTION(libvirt_stream_create);
-PHP_FUNCTION(libvirt_stream_close);
-PHP_FUNCTION(libvirt_stream_abort);
-PHP_FUNCTION(libvirt_stream_finish);
-PHP_FUNCTION(libvirt_stream_recv);
-PHP_FUNCTION(libvirt_stream_send);
/* Domain functions */
PHP_FUNCTION(libvirt_domain_new);
PHP_FUNCTION(libvirt_domain_new_get_vnc);
diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c
new file mode 100644
index 0000000..f1fc1ff
--- /dev/null
+++ b/src/libvirt-stream.c
@@ -0,0 +1,230 @@
+/*
+ * libvirt-stream.c: The PHP bindings to libvirt stream API
+ *
+ * See COPYING for the license of this software
+ */
+
+#include <libvirt/libvirt.h>
+
+#include "libvirt-php.h"
+#include "libvirt-stream.h"
+
+DEBUG_INIT("stream");
+
+void
+php_libvirt_stream_dtor(virt_resource *rsrc TSRMLS_DC)
+{
+ php_libvirt_stream *stream = (php_libvirt_stream *)rsrc->ptr;
+ int rv = 0;
+
+ if (stream != NULL) {
+ if (stream->stream != NULL) {
+ if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream
TSRMLS_CC)) {
+ stream->stream = NULL;
+ efree(stream);
+ return;
+ }
+ rv = virStreamFree(stream->stream);
+ if (rv != 0) {
+ DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n",
__FUNCTION__, stream->stream, rv, LIBVIRT_G(last_error));
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed
with %i on destructor: %s", rv, LIBVIRT_G(last_error));
+ } else {
+ DPRINTF("%s: virStreamFree(%p) completed successfully\n",
__FUNCTION__, stream->stream);
+ resource_change_counter(INT_RESOURCE_STREAM, NULL, stream->stream, 0
TSRMLS_CC);
+ }
+ stream->stream = NULL;
+ }
+ efree(stream);
+ }
+}
+
+/*
+ * Function name: libvirt_stream_create
+ * Since version: 0.5.0
+ * Description: Function is used to create new stream from libvirt conn
+ * Arguments: @res [resource]: libvirt connection resource from libvirt_connect()
+ * Returns: resource libvirt stream resource
+ */
+PHP_FUNCTION(libvirt_stream_create)
+{
+ php_libvirt_connection *conn = NULL;
+ zval *zconn;
+ virStreamPtr stream = NULL;
+ php_libvirt_stream *res_stream;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) ==
FAILURE)
+ RETURN_FALSE;
+ VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn,
PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);
+ if ((conn == NULL) || (conn->conn == NULL))
+ RETURN_FALSE;
+
+ stream = virStreamNew(conn->conn, 0);
+ if (stream == NULL) {
+ set_error("Cannot create new stream" TSRMLS_CC);
+ RETURN_FALSE;
+ }
+
+ res_stream = (php_libvirt_stream *)emalloc(sizeof(php_libvirt_stream));
+ res_stream->stream = stream;
+ res_stream->conn = conn;
+
+ resource_change_counter(INT_RESOURCE_STREAM, conn->conn, res_stream->stream, 1
TSRMLS_CC);
+
+ VIRT_REGISTER_RESOURCE(res_stream, le_libvirt_stream);
+}
+
+/*
+ * Function name: libvirt_stream_close
+ * Since version: 0.5.0
+ * Description: Function is used to close stream
+ * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
+ * Returns: int
+ */
+PHP_FUNCTION(libvirt_stream_close)
+{
+ zval *zstream;
+ php_libvirt_stream *stream = NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
+ RETURN_LONG(retval);
+ VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream == NULL) || (stream->stream == NULL))
+ RETURN_LONG(retval);
+
+ retval = virStreamFree(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot free stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ resource_change_counter(INT_RESOURCE_STREAM, stream->conn->conn,
stream->stream, 0 TSRMLS_CC);
+ RETURN_LONG(retval);
+}
+
+/*
+ * Function name: libvirt_stream_abort
+ * Since version: 0.5.0
+ * Description: Function is used to abort transfer
+ * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
+ * Returns: int
+ */
+PHP_FUNCTION(libvirt_stream_abort)
+{
+ zval *zstream;
+ php_libvirt_stream *stream = NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
+ RETURN_LONG(retval);
+ VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream == NULL) || (stream->stream == NULL))
+ RETURN_LONG(retval);
+
+ retval = virStreamAbort(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot abort stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+ RETURN_LONG(retval);
+}
+
+/*
+ * Function name: libvirt_stream_finish
+ * Since version: 0.5.0
+ * Description: Function is used to finish transfer
+ * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
+ * Returns: int
+ */
+PHP_FUNCTION(libvirt_stream_finish)
+{
+ zval *zstream;
+ php_libvirt_stream *stream = NULL;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) ==
FAILURE)
+ RETURN_LONG(retval);
+ VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream == NULL) || (stream->stream == NULL))
+ RETURN_LONG(retval);
+
+ retval = virStreamFinish(stream->stream);
+ if (retval != 0) {
+ set_error("Cannot finish stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+ RETURN_LONG(retval);
+}
+
+/*
+ * Function name: libvirt_stream_recv
+ * Since version: 0.5.0
+ * Description: Function is used to recv from stream via libvirt conn
+ * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
+ * @data [string]: buffer
+ * @len [int]: amout of data to recieve
+ * Returns: int
+ */
+PHP_FUNCTION(libvirt_stream_recv)
+{
+ zval *zstream, *zbuf;
+ php_libvirt_stream *stream = NULL;
+ char *recv_buf = NULL;
+ int retval = -1;
+ zend_long length = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream,
&zbuf, &length) == FAILURE)
+ RETURN_LONG(retval);
+ VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream == NULL) || (stream->stream == NULL))
+ RETURN_LONG(retval);
+
+ recv_buf = emalloc(length + 1);
+
+ retval = virStreamRecv(stream->stream, recv_buf, length);
+ if (retval < 0) {
+ zval_dtor(zbuf);
+ ZVAL_NULL(zbuf);
+ } else {
+ recv_buf[retval] = '\0';
+ VIRT_ZVAL_STRINGL(zbuf, recv_buf, retval);
+ }
+
+ if (retval == -1)
+ set_error("Cannot recv from stream" TSRMLS_CC);
+
+ efree(recv_buf);
+ RETURN_LONG(retval);
+}
+
+/*
+ * Function name: libvirt_stream_send
+ * Since version: 0.5.0
+ * Description: Function is used to send to stream via libvirt conn
+ * Arguments: @res [resource]: libvirt stream resource from
libvirt_stream_create()
+ * @data [string]: buffer
+ * @length [int]: amout of data to send
+ * Returns: int
+ */
+PHP_FUNCTION(libvirt_stream_send)
+{
+ zval *zstream, *zbuf;
+ php_libvirt_stream *stream = NULL;
+ int retval = -1;
+ zend_long length = 0;
+ char *cstr;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream,
&zbuf, &length) == FAILURE)
+ RETURN_LONG(retval);
+ VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream,
PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream == NULL) || (stream->stream == NULL))
+ RETURN_LONG(retval);
+
+ cstr = Z_STRVAL_P(zbuf);
+
+ retval = virStreamSend(stream->stream, cstr, length);
+ if (retval == -1)
+ set_error("Cannot send to stream" TSRMLS_CC);
+
+ RETURN_LONG(retval);
+}
diff --git a/src/libvirt-stream.h b/src/libvirt-stream.h
new file mode 100644
index 0000000..89b28a6
--- /dev/null
+++ b/src/libvirt-stream.h
@@ -0,0 +1,39 @@
+/*
+ * libvirt-stream.h: The PHP bindings to libvirt stream API
+ *
+ * See COPYING for the license of this software
+ */
+
+#ifndef __LIBVIRT_STREAM_H__
+# define __LIBVIRT_STREAM_H__
+
+# include "libvirt-connection.h"
+
+# define PHP_LIBVIRT_STREAM_RES_NAME "Libvirt stream"
+# define INT_RESOURCE_STREAM 0x50
+
+# define PHP_FE_LIBVIRT_STREAM \
+ PHP_FE(libvirt_stream_create, arginfo_libvirt_conn) \
+ PHP_FE(libvirt_stream_close, arginfo_libvirt_conn) \
+ PHP_FE(libvirt_stream_abort, arginfo_libvirt_conn) \
+ PHP_FE(libvirt_stream_finish, arginfo_libvirt_conn) \
+ PHP_FE(libvirt_stream_send, arginfo_libvirt_stream_send) \
+ PHP_FE(libvirt_stream_recv, arginfo_libvirt_stream_recv)
+
+int le_libvirt_stream;
+
+typedef struct _php_libvirt_stream {
+ virStreamPtr stream;
+ php_libvirt_connection* conn;
+} php_libvirt_stream;
+
+void php_libvirt_stream_dtor(virt_resource *rsrc TSRMLS_DC);
+
+PHP_FUNCTION(libvirt_stream_create);
+PHP_FUNCTION(libvirt_stream_close);
+PHP_FUNCTION(libvirt_stream_abort);
+PHP_FUNCTION(libvirt_stream_finish);
+PHP_FUNCTION(libvirt_stream_recv);
+PHP_FUNCTION(libvirt_stream_send);
+
+#endif
--
2.13.3