[libvirt] [PATCH] qemu: blockCopy: Allow shallow block copy into a raw image
by Peter Krempa
The documentation states that for shallow block copy the image has to
have the same guest visible content as backing file of the current
image. This condition can be achieved also with a raw file (or a qcow
without a backing file) so remove the condition that would disallow it.
(This patch additionally fixes crash described in
https://bugzilla.redhat.com/show_bug.cgi?id=1215569 since it removes
the code)
---
src/qemu/qemu_driver.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 70bf7aa..f979d33 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16815,16 +16815,6 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm,
if (qemuDomainDetermineDiskChain(driver, vm, disk, false, true) < 0)
goto endjob;
- if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) &&
- mirror->format == VIR_STORAGE_FILE_RAW &&
- disk->src->backingStore->path) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("disk '%s' has backing file, so raw shallow copy "
- "is not possible"),
- disk->dst);
- goto endjob;
- }
-
/* Prepare the destination file. */
/* XXX Allow non-file mirror destinations */
if (!virStorageSourceIsLocalStorage(mirror)) {
--
2.3.5
9 years, 7 months
[libvirt] [BUG?] EAGAIN not triggering error and 'events' gets cleared
by Pavel Boldin
Dear Libvirt Developers,
There seems to be a bug or at least a bad behavior in
`src/qemu/qemu_monitor.c' lines 683-689 function `qemuMonitorIO':
if (qemuMonitorIOWrite(mon) < 0) {
error = true;
if (errno == ECONNRESET)
hangup = true;
}
events &= ~VIR_EVENT_HANDLE_WRITABLE;
The `qemuMonitorIOWrite' is returning 0 in case 'write' returns EAGAIN thus
'events' is always cleared of `VIR_EVENT_HANDLE_WRITABLE' even in case no
message have been sent indeed.
The question is: who is responsible for handling this? It seems like
'errno' is getting overwritten inside all of qemuMonitorJSON* functions so
the caller can't rely on it and it needs to be fixed inside the
`qemuMonitorIO'.
Pavel
9 years, 7 months
[libvirt] [PATCH v1] [libvirt-php] add stream support and upload/resize/download for volume
by Vasiliy Tolstov
This patch add to libvirt php binding libvirt stream support
Also provide resize/upload/download for libvirt volume
Signed-off-by: Vasiliy Tolstov <v.tolstov(a)selfip.ru>
---
configure.ac | 3 +-
src/libvirt-php.c | 382 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/libvirt-php.h | 17 +++
3 files changed, 395 insertions(+), 7 deletions(-)
diff --git a/configure.ac b/configure.ac
index b854153..7099f9d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,6 @@
AC_INIT([libvirt-php], [0.5.0], [http://libvirt.org])
-AM_INIT_AUTOMAKE([-Wall -Werror])
+AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability])
AC_CONFIG_FILES([Makefile tools/Makefile src/Makefile tests/Makefile docs/Makefile])
-AM_INIT_AUTOMAKE([-Wno-portability])
AM_MAINTAINER_MODE([enable])
dnl Checks for programs.
diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 6d6fa81..0adc4be 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -61,6 +61,7 @@ int le_libvirt_storagepool;
int le_libvirt_volume;
int le_libvirt_network;
int le_libvirt_nodedev;
+int le_libvirt_stream;
#if LIBVIR_VERSION_NUMBER>=8000
int le_libvirt_snapshot;
#endif
@@ -90,6 +91,13 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_connect_get_maxvcpus, NULL)
PHP_FE(libvirt_connect_get_encrypted, NULL)
PHP_FE(libvirt_connect_get_secure, NULL)
+ /* Stream functions */
+ PHP_FE(libvirt_stream_create, NULL)
+ PHP_FE(libvirt_stream_close, NULL)
+ PHP_FE(libvirt_stream_abort, NULL)
+ PHP_FE(libvirt_stream_finish, NULL)
+ PHP_FE(libvirt_stream_send, NULL)
+ PHP_FE(libvirt_stream_recv, NULL)
/* Domain functions */
PHP_FE(libvirt_domain_new, NULL)
PHP_FE(libvirt_domain_new_get_vnc, NULL)
@@ -148,7 +156,7 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_domain_get_screen_dimensions, NULL)
PHP_FE(libvirt_domain_send_keys, NULL)
PHP_FE(libvirt_domain_send_pointer_event, NULL)
- PHP_FE(libvirt_domain_update_device, NULL)
+ PHP_FE(libvirt_domain_update_device, NULL)
/* Domain snapshot functions */
PHP_FE(libvirt_domain_has_current_snapshot, NULL)
PHP_FE(libvirt_domain_snapshot_create, NULL)
@@ -169,6 +177,9 @@ static zend_function_entry libvirt_functions[] = {
PHP_FE(libvirt_storagevolume_create_xml,NULL)
PHP_FE(libvirt_storagevolume_create_xml_from,NULL)
PHP_FE(libvirt_storagevolume_delete,NULL)
+ PHP_FE(libvirt_storagevolume_download,NULL)
+ PHP_FE(libvirt_storagevolume_upload,NULL)
+ PHP_FE(libvirt_storagevolume_resize,NULL)
PHP_FE(libvirt_storagepool_get_uuid_string, NULL)
PHP_FE(libvirt_storagepool_get_name, NULL)
PHP_FE(libvirt_storagepool_lookup_by_uuid_string, NULL)
@@ -370,6 +381,8 @@ char *translate_counter_type(int type)
break;
case INT_RESOURCE_DOMAIN: return "domain";
break;
+ case INT_RESOURCE_STREAM: return "stream";
+ break;
case INT_RESOURCE_NETWORK: return "network";
break;
case INT_RESOURCE_NODEDEV: return "node device";
@@ -444,7 +457,7 @@ void free_tokens(tTokenizer t)
Private function name: resource_change_counter
Since version: 0.4.2
Description: Function to increment (inc = 1) / decrement (inc = 0) the resource pointers count including the memory location
- Arguments: @type [int]: type of resource (INT_RESOURCE_x defines where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT })
+ Arguments: @type [int]: type of resource (INT_RESOURCE_x defines where x can be { CONNECTION | DOMAIN | NETWORK | NODEDEV | STORAGEPOOL | VOLUME | SNAPSHOT | STREAM })
@conn [virConnectPtr]: libvirt connection pointer associated with the resource, NULL for libvirt connection objects
@mem [pointer]: Pointer to memory location for the resource. Will be converted to appropriate uint for the arch.
@inc [int/bool]: Increment the counter (1 = add memory location) or decrement the counter (0 = remove memory location) from entries.
@@ -724,6 +737,18 @@ void free_resource(int type, arch_uint mem TSRMLS_DC)
}
}
+ if (type == INT_RESOURCE_STREAM) {
+ rv = virStreamFree( (virStreamPtr)mem );
+ if (rv != 0) {
+ DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, 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__, (virStreamPtr)mem);
+ resource_change_counter(INT_RESOURCE_STREAM, NULL, (virStreamPtr)mem, 0 TSRMLS_CC);
+ }
+ }
+
if (type == INT_RESOURCE_NETWORK) {
rv = virNetworkFree( (virNetworkPtr)mem );
if (rv != 0) {
@@ -986,6 +1011,36 @@ static void php_libvirt_domain_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
}
}
+/* Destructor for stream resource */
+static void php_libvirt_stream_dtor(zend_rsrc_list_entry *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(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
@@ -1144,6 +1199,7 @@ PHP_MINIT_FUNCTION(libvirt)
/* register resource types and their descriptors */
le_libvirt_connection = zend_register_list_destructors_ex(php_libvirt_connection_dtor, NULL, PHP_LIBVIRT_CONNECTION_RES_NAME, module_number);
le_libvirt_domain = zend_register_list_destructors_ex(php_libvirt_domain_dtor, NULL, PHP_LIBVIRT_DOMAIN_RES_NAME, module_number);
+ le_libvirt_stream = zend_register_list_destructors_ex(php_libvirt_stream_dtor, NULL, PHP_LIBVIRT_STREAM_RES_NAME, module_number);
le_libvirt_storagepool = zend_register_list_destructors_ex(php_libvirt_storagepool_dtor, NULL, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, module_number);
le_libvirt_volume = zend_register_list_destructors_ex(php_libvirt_volume_dtor, NULL, PHP_LIBVIRT_VOLUME_RES_NAME, module_number);
le_libvirt_network = zend_register_list_destructors_ex(php_libvirt_network_dtor, NULL, PHP_LIBVIRT_NETWORK_RES_NAME, module_number);
@@ -1171,6 +1227,11 @@ PHP_MINIT_FUNCTION(libvirt)
REGISTER_LONG_CONSTANT("VIR_DOMAIN_SHUTOFF", 5, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_CRASHED", 6, CONST_CS | CONST_PERSISTENT);
+ /* Volume constants */
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_ALLOCATE", 1, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_DELTA", 2, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("VIR_STORAGE_VOL_RESIZE_SHRINK", 4, CONST_CS | CONST_PERSISTENT);
+
/* Domain vCPU flags */
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CONFIG", VIR_DOMAIN_VCPU_CONFIG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("VIR_DOMAIN_VCPU_CURRENT", VIR_DOMAIN_VCPU_CURRENT, CONST_CS | CONST_PERSISTENT);
@@ -3456,6 +3517,207 @@ 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;
+ }
+ ZEND_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, -1, 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);
+ ZEND_REGISTER_RESOURCE(return_value, 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);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, 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, 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);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, 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);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, 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 close stream from 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;
+ char *recv_buf;
+ php_libvirt_stream *stream=NULL;
+ int retval = -1;
+ long length = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ recv_buf = emalloc(length + 1);
+ memset(recv_buf, 0, length + 1);
+
+ retval = virStreamRecv(stream->stream, recv_buf, length);
+ if (retval < 0) {
+ efree(recv_buf);
+ zval_dtor(zbuf);
+ Z_TYPE_P(zbuf) = IS_NULL;
+ } else {
+ recv_buf[retval] = '\0';
+ /* Rebuild buffer zval */
+ zval_dtor(zbuf);
+ Z_STRVAL_P(zbuf) = recv_buf;
+ Z_STRLEN_P(zbuf) = retval;
+ Z_TYPE_P(zbuf) = IS_STRING;
+ }
+
+ if (retval == -1) {
+ set_error("Cannot recv from stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_stream_send
+ Since version: 0.5.0
+ Description: Function is used to close stream from 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;
+ long length = 0;
+ char *cstr;
+ //int cstrlen;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ cstr = Z_STRVAL_P(zbuf);
+ //cstrlen = Z_STRLEN_P(zbuf);
+
+ retval = virStreamSend(stream->stream, cstr, length);
+ if (retval == -1) {
+ set_error("Cannot send to stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ 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
@@ -3544,13 +3806,12 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string)
@opaque [void *]: used for file descriptor
Returns: write() error code as it's calling write
*/
-
static int streamSink(virStreamPtr st ATTRIBUTE_UNUSED,
const char *bytes, size_t nbytes, void *opaque)
{
- int *fd = (int *)opaque;
+ int *fd = (int *)opaque;
- return write(*fd, bytes, nbytes);
+ return write(*fd, bytes, nbytes);
}
/*
@@ -6782,6 +7043,117 @@ PHP_FUNCTION(libvirt_storagevolume_delete)
}
/*
+ Function name: libvirt_storagevolume_resize
+ Since version: 0.5.0
+ Description: Function is used to resize volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @capacity [int]: capacity for the storage volume
+ @flags [int]: optional flags for the storage volume resize for virStorageVolResize()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_resize)
+{
+ php_libvirt_volume *volume=NULL;
+ zval *zvolume;
+ long flags = 0;
+ long capacity = 0;
+ int retval = -1;
+
+ GET_VOLUME_FROM_ARGS("rl|l", &zvolume, &capacity, &flags);
+
+ retval = virStorageVolResize(volume->volume, capacity, flags);
+ DPRINTF("%s: virStorageVolResize(%p, %d, %d) returned %d\n", PHPFUNC, volume->volume, (int) capacity, (int) flags, retval);
+ if (retval != 0) {
+ set_error_if_unset("Cannot resize storage volume" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_storagevolume_download
+ Since version: 0.5.0
+ Description: Function is used to download volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @stream [resource]: stream to use as output
+ @offset [int]: position to start reading from
+ @length [int] : limit on amount of data to download
+ @flags [int]: optional flags for the storage volume download for virStorageVolDownload()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_download)
+{
+ php_libvirt_volume *volume=NULL;
+ php_libvirt_stream *stream=NULL;
+ zval *zvolume;
+ zval *zstream;
+ long flags = 0;
+ long offset = 0;
+ long length = 0;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);
+ if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval);
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags);
+ DPRINTF("%s: virStorageVolDownload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval);
+
+ if (retval == -1) {
+ set_error("Cannot download from stream" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
+ Function name: libvirt_storagevolume_upload
+ Since version: 0.5.0
+ Description: Function is used to upload volume identified by it's resource
+ Arguments: @res [resource]: libvirt storagevolume resource
+ @stream [resource]: stream to use as input
+ @offset [int]: position to start writing to
+ @length [int] : limit on amount of data to upload
+ @flags [int]: optional flags for the storage volume upload for virStorageVolUpload()
+ Returns: int
+*/
+PHP_FUNCTION(libvirt_storagevolume_upload)
+{
+ php_libvirt_volume *volume=NULL;
+ php_libvirt_stream *stream=NULL;
+ zval *zvolume;
+ zval *zstream;
+ long flags = 0;
+ long offset = 0;
+ long length = 0;
+ int retval = -1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) {
+ RETURN_LONG(retval);
+ }
+ ZEND_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, -1, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);
+ if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval);
+ ZEND_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, -1, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream);
+ if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval);
+
+ retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags);
+ DPRINTF("%s: virStorageVolUpload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval);
+
+ if (retval == -1) {
+ set_error_if_unset("Cannot upload storage volume" TSRMLS_CC);
+ RETURN_LONG(retval);
+ }
+
+ RETURN_LONG(retval);
+}
+
+/*
Function name: libvirt_storagepool_get_uuid_string
Since version: 0.4.1(-1)
Description: Function is used to get storage pool by UUID string
diff --git a/src/libvirt-php.h b/src/libvirt-php.h
index 450fbea..3bcc682 100644
--- a/src/libvirt-php.h
+++ b/src/libvirt-php.h
@@ -214,6 +214,7 @@ ZEND_END_MODULE_GLOBALS(libvirt)
#define INT_RESOURCE_STORAGEPOOL 0x10
#define INT_RESOURCE_VOLUME 0x20
#define INT_RESOURCE_SNAPSHOT 0x40
+#define INT_RESOURCE_STREAM 0x50
typedef struct tVMDisk {
char *path;
@@ -257,6 +258,11 @@ typedef struct _php_libvirt_connection {
long resource_id;
} php_libvirt_connection;
+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;
@@ -311,6 +317,7 @@ int gdebug;
#define PHP_LIBVIRT_CONNECTION_RES_NAME "Libvirt connection"
#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"
@@ -347,6 +354,13 @@ PHP_FUNCTION(libvirt_node_get_info);
PHP_FUNCTION(libvirt_node_get_cpu_stats);
PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu);
PHP_FUNCTION(libvirt_node_get_mem_stats);
+/* 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);
@@ -427,6 +441,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc);
PHP_FUNCTION(libvirt_storagevolume_create_xml);
PHP_FUNCTION(libvirt_storagevolume_create_xml_from);
PHP_FUNCTION(libvirt_storagevolume_delete);
+PHP_FUNCTION(libvirt_storagevolume_download);
+PHP_FUNCTION(libvirt_storagevolume_upload);
+PHP_FUNCTION(libvirt_storagevolume_resize);
PHP_FUNCTION(libvirt_storagepool_get_uuid_string);
PHP_FUNCTION(libvirt_storagepool_get_name);
PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string);
--
2.3.3
9 years, 7 months
[libvirt] ANNOUNCE: libvirt 1.2.9.3 maintenance release
by Cole Robinson
libvirt 1.2.9.3 is now available. This is a maintenance release of
libvirt 1.2.9 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-1.2.9.3.tar.gz
Changes in this version:
* storage: fs: Ignore volumes that fail to open with EACCESS/EPERM
* domain: conf: Don't validate VM ostype/arch at daemon startup
* domain: conf: Better errors on bad os <type> values
* Report original error when QMP probing fails with new QEMU
* cpu: Add {Haswell,Broadwell}-noTSX CPU models
* storage: qemu: Fix security labelling of new image chain elements
* Ignore CPU features without a model for host-passthrough
* Do not format CPU features without a model
* domcaps: Check for architecture more wisely
* daemon: Clear fake domain def object that is used to check ACL prior
to use
* util: identity: Harden virIdentitySetCurrent()
* qemu: Build nvram directory at driver startup
* qemu: Build channel autosocket directory at driver startup
* qemu: chown autoDumpPath on driver startup
* qemu: conf: Clarify paths that are relative to libDir
* avoid using deprecated udev logging functions
* qemu: Always refresh capabilities if no <guests> found
* qemu: move setting emulatorpin ahead of monitor showing up
* rpc: Don't unref identity object while callbacks still can be executed
* conf: tests: fix virDomainNetDefFormat for vhost-user in client mode
* Document that USB hostdevs do not need nodeDettach
* Document behavior of compat when creating qcow2 volumes
* Clarify the meaning of version in redirdev filters
* Strip control codes in virBufferEscapeString
* Ignore storage volumes with control codes in their names
* Strip control characters from sysfs attributes
* Add functions dealing with control characters in strings
* virNetworkDefUpdateIPDHCPHost: Don't crash when updating network
* daemon: avoid memleak when ListAll returns nothing
* conf: error out on missing dhcp host attributes
* conf: error out on invalid host id
* conf: Don't format actual network definition in migratable XML
* conf: Fix libvirtd crash and memory leak caused by
virDomainVcpuPinDel()
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
9 years, 7 months
[libvirt] ANNOUNCE: libvirt 1.2.13.1 maintenance release
by Cole Robinson
libvirt 1.2.13.1 is now available. This is a maintenance release of
libvirt 1.2.13 with additional bugfixes that have accumulated
upstream since the initial release.
This release can be downloaded at:
http://libvirt.org/sources/stable_updates/libvirt-1.2.13.1.tar.gz
Changes in this version:
* Fix memory leak in virNetSocketNewConnectUNIX
* rng: fix port number range validation
* qemu: Don't fail to reboot domains with unresponsive agent
* vircommand: fix polling in virCommandProcessIO
* util: storage: Fix possible crash when source path is NULL
* qemu: set macvtap physdevs online when macvtap is set online
* util: set MAC address for VF via netlink message to PF+VF# when
possible
* xend: Remove a couple of unused function prototypes.
* qemuDomainShutdownFlags: Set fakeReboot more frequently
* nwfilter: Partly initialize driver even for non-privileged users
* virNetSocketNewConnectUNIX: Don't unlink(NULL)
* sanlock: Use VIR_ERR_RESOURCE_BUSY if sanlock_acquire fails
* qemuMigrationPrecreateStorage: Fix debug message
* qemu_migration.c: sleep first before checking for migration status.
* qemu_driver: check caps after starting block job
* qemu_migrate: use nested job when adding NBD to cookie
* util: fix removal of callbacks in virCloseCallbacksRun
* qemu: fix race between disk mirror fail and cancel
* qemu: fix error propagation in qemuMigrationBegin
* qemu: fix crash in qemuProcessAutoDestroy
* qemu: blockCopy: Pass adjusted bandwidth when called via blockRebase
* virsh: blockCopy: Add missing jump on error path
* qemu: end the job when try to blockcopy to non-file destination
* nodeinfo: Increase the num of CPU thread siblings to a larger value
* relaxng: allow : in /dev/disk/by-path names
* qemu: Give hint about -noTSX CPU model
* build: fix race when creating the cpu_map.xml symlink
* Don't validata filesystem target type
* Document behavior of compat when creating qcow2 volumes
* Fix typo in error message
* qemu: change accidental VIR_WARNING back to VIR_DEBUG
* conf: fix parsing of NUMA settings in VM status XML
* qemu: skip precreation of network disks
* qemu: do not overwrite the error in qemuDomainObjExitMonitor
* libxl: Don't overwrite errors from xenconfig
* util: more verbose error when failing to create macvtap device
* qemu: hotplug: Use checker function to check if disk is empty
* qemu: driver: Fix cold-update of removable storage devices
* qemu: Check for negative port values in network drive configuration
* virsh: fix report of non-active commit completion
* util: don't fail if no PortData is found while getting migrateData
* Clarify the meaning of version in redirdev filters
* xenapi: Resolve Coverity REVERSE_INULL
* xenapi: Resolve Coverity REVERSE_INULL
* xenapi: Resolve Coverity NULL_RETURNS
* xenapi: Resolve Coverity NO_EFFECT
* xenapi: Resolve Coverity FORWARD_NULL
* RNG: Allow multiple parameters to be passed to an interface filter
* domain_conf: fix crash in virDomainObjListFindByUUIDInternal
* {domain, network}_conf: disable autostart when deleting config
* qemu: Remove unnecessary virReportError on networkGetNetworkAddress
return
* virQEMUCapsInitQMP: Don't dispose locked @vm
* qemu: fix memory leak in qemuAgentGetFSInfo
* docs: add a note that spice channel is usable only with spice graphics
* locking: Fix flags in virLockManagerLockDaemonNew
* tests: fix qemuxml2argvtest to be arch independent
* tests: Add test for virtio-mmio address type
* qemu: Allow spaces in disk serial
* storage: tweak condition to properly test lseek
* virsh: tweak domif-getlink link state reporting message
* qemu: snapshot: Don't skip check for qcow2 format with network disks
* networkLookupByUUID: Improve error message
* qemuProcessReconnect: Fill in pid file path
* tests : Add test for 'ppc64le' architecture.
* RNG: Add 'ppc64le' arch and newer pseries-2.* machine types
* schema: Fix interface link state schema
* conf: De-duplicate scheduling policy enums
* qemu: Don't crash in qemuDomainOpenChannel()
* virsh.pod: Update find-storage-pool-sources[-as] man page
* iscsi: Adjust error message for findStorageSources backend
* virsh.pod: Add information regarding LXC for setmem, memtune, and
dominfo
* docs: add a note that attr 'managed' is only used by PCI devices
* Check if domain is running in qemuDomainAgentIsAvailable
* Pass virDomainObjPtr to qemuDomainAgentAvailable
* Check for qemu guest agent availability after getting the job
* storage: fs: Ignore volumes that fail to open with EACCESS/EPERM
* domain: conf: Don't validate VM ostype/arch at daemon startup
* domain: conf: Better errors on bad os <type> values
* spec: Point fedora --with-loader-nvram at nightly firmware repo
* configure: Report --with-loader-nvram value in summary
* configure: Fix --loader-nvram typo
* cpu: Add {Haswell,Broadwell}-noTSX CPU models
* domcaps: Check for architecture more wisely
* daemon: Clear fake domain def object that is used to check ACL prior
to use
* util: identity: Harden virIdentitySetCurrent()
* qemu: Always refresh capabilities if no <guests> found
* qemu: Build nvram directory at driver startup
* qemu: Build channel autosocket directory at driver startup
* virQEMUDriverGetConfig: Fix memleak
* qemu: chown autoDumpPath on driver startup
* qemu: conf: Clarify paths that are relative to libDir
* Strip control codes in virBufferEscapeString
* util: buffer: Add support for adding text blocks with indentation
* Ignore storage volumes with control codes in their names
* Strip control characters from sysfs attributes
* Add functions dealing with control characters in strings
* tests: rename testStripIPv6BracketsData to testStripData
* lxc: fix starting a domain with non-strict numa memory mode
* lxc: fix starting a domain with a cpuset but no numatune
* virsh: fix regression in 'virsh event' by domain
* virsh: Improve change-media success message
* virNetSocketNewConnectUNIX: Use flocks when spawning a daemon
* rpc: Don't unref identity object while callbacks still can be executed
* lxc: create the required directories upon driver start
* qemu: read backing chain names from qemu
* daemon: avoid memleak when ListAll returns nothing
* qemu: don't fill in nicindexes for session mode libvirtd
For info about past maintenance releases, see:
http://wiki.libvirt.org/page/Maintenance_Releases
Thanks,
Cole
9 years, 7 months
[libvirt] [PATCH 0/2] tests: fix memleak in qemumonitorjsontest
by Zhang Bo
the free callback should be qemuMonitorChardevInfoFree rather than just 'free'
when virHashCreate'ing the chardevInfo hash.
Zhang Bo (2):
qemu: make qemuMonitorChardevInfoFree non-static
tests: free ChardevInfo correctly in qemumonitorjsontest
src/qemu/qemu_monitor.c | 2 +-
src/qemu/qemu_monitor.h | 1 +
tests/qemumonitorjsontest.c | 4 ++--
3 files changed, 4 insertions(+), 3 deletions(-)
--
1.7.12.4
9 years, 7 months
[libvirt] [PATCH] Fix building virnetserverclientmock with MinGW
by Martin Kletzander
Signed-off-by: Pavel Fedin <p.fedin(a)samsung.com>
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
This was a part of commit 9dc57ce2, but separable; plus the library
should be in LIBADD and not LDFLAGS. Depends on my previous cleanup [2]
[1] https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=9dc57ce2
[2] https://www.redhat.com/archives/libvir-list/2015-April/msg01336.html
v2: Use LIBADD instead of LDADDS (which doesn't even exist)
tests/Makefile.am | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc7daaa..8e2dbec 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -931,6 +931,7 @@ virnetserverclientmock_la_SOURCES = \
virnetserverclientmock.c
virnetserverclientmock_la_CFLAGS = $(AM_CFLAGS)
virnetserverclientmock_la_LDFLAGS = $(MOCKLIBS_LDFLAGS)
+virnetserverclientmock_la_LIBADD = $(GNULIB_LIBS)
if WITH_GNUTLS
virnettlscontexttest_SOURCES = \
--
2.3.6
9 years, 7 months
[libvirt] [libvirt-cim][PATCH] list_util.h: Drop inline modifiers
by Michal Privoznik
There's no need to mark a function as inline in the function
declaration. In fact, it causes a compilation error:
CC xmlgen.lo
In file included from acl_parsing.h:29:0,
from xmlgen.h:26,
from capability_parsing.c:37:
list_util.h:67:21: error: inline function ‘list_node_prev_node’ declared but never defined [-Werror]
inline list_node_t *list_node_prev_node(list_node_t *node);
^
list_util.h:66:14: error: inline function ‘list_node_prev’ declared but never defined [-Werror]
inline void *list_node_prev(list_node_t *node);
^
list_util.h:64:21: error: inline function ‘list_node_next_node’ declared but never defined [-Werror]
inline list_node_t *list_node_next_node(list_node_t *node);
^
list_util.h:63:14: error: inline function ‘list_node_next’ declared but never defined [-Werror]
inline void *list_node_next(list_node_t *node);
^
list_util.h:61:21: error: inline function ‘list_last_node’ declared but never defined [-Werror]
inline list_node_t *list_last_node(list_t *list);
^
list_util.h:60:14: error: inline function ‘list_last’ declared but never defined [-Werror]
inline void *list_last(list_t *list);
^
list_util.h:58:21: error: inline function ‘list_first_node’ declared but never defined [-Werror]
inline list_node_t *list_first_node(list_t *list);
^
list_util.h:57:14: error: inline function ‘list_first’ declared but never defined [-Werror]
inline void *list_first(list_t *list);
^
list_util.h:55:13: error: inline function ‘list_node_data_set’ declared but never defined [-Werror]
inline void list_node_data_set(list_node_t *node, void *data);
^
list_util.h:54:14: error: inline function ‘list_node_data_get’ declared but never defined [-Werror]
inline void *list_node_data_get(list_node_t *node);
^
list_util.h:52:21: error: inline function ‘list_count’ declared but never defined [-Werror]
inline unsigned int list_count(list_t *list);
^
cc1: all warnings being treated as errors
Makefile:499: recipe for target 'capability_parsing.lo' failed
make[2]: *** [capability_parsing.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
libxkutil/list_util.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/libxkutil/list_util.h b/libxkutil/list_util.h
index 6510272..6582dfe 100644
--- a/libxkutil/list_util.h
+++ b/libxkutil/list_util.h
@@ -49,22 +49,22 @@ void list_remove_node(list_t *list, list_node_t *node);
bool list_foreach(list_t *list, list_foreach_cb cb, void *user_data);
-inline unsigned int list_count(list_t *list);
+unsigned int list_count(list_t *list);
-inline void *list_node_data_get(list_node_t *node);
-inline void list_node_data_set(list_node_t *node, void *data);
+void *list_node_data_get(list_node_t *node);
+void list_node_data_set(list_node_t *node, void *data);
-inline void *list_first(list_t *list);
-inline list_node_t *list_first_node(list_t *list);
+void *list_first(list_t *list);
+list_node_t *list_first_node(list_t *list);
-inline void *list_last(list_t *list);
-inline list_node_t *list_last_node(list_t *list);
+void *list_last(list_t *list);
+list_node_t *list_last_node(list_t *list);
-inline void *list_node_next(list_node_t *node);
-inline list_node_t *list_node_next_node(list_node_t *node);
+void *list_node_next(list_node_t *node);
+list_node_t *list_node_next_node(list_node_t *node);
-inline void *list_node_prev(list_node_t *node);
-inline list_node_t *list_node_prev_node(list_node_t *node);
+void *list_node_prev(list_node_t *node);
+list_node_t *list_node_prev_node(list_node_t *node);
#ifdef __cplusplus
} /* extern "C" */
--
2.0.5
9 years, 7 months