
On Mon, Mar 31, 2014 at 03:46:43PM +0200, Michal Privoznik wrote:
On 30.03.2014 21:03, Matthias Bolte wrote:
This allows to implement libvirt functions that use streams, such as virDoaminScreenshot, without the need to store the downloaded data in a temporary file first. The stream driver directly interacts with libcurl to send and receive data.
The driver uses the libcurl multi interface that allows to do a transfer in multiple curl_multi_perform() calls. The easy interface would do the whole transfer in a single curl_easy_perform() call. This doesn't work with the libvirt stream API that is driven by multiple calls to the virStreamSend() and virStreamRecv() functions.
The curl_multi_wait() function is used to do blocking operations. But it was added in libcurl 7.28.0. For older versions it is emulated using the socket callback of the multi interface.
The current driver only supports blocking operations. There is already some code in place for non-blocking mode but it's incomplete. As you can tell from the copyright date I implemeted this in 2012, but never came around to publish it then. I did some work in 2013 and now it's 2014 and I don't want to hold it back any longer. --- po/POTFILES.in | 1 + src/Makefile.am | 1 + src/esx/esx_stream.c | 478 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/esx/esx_stream.h | 32 ++++ src/esx/esx_vi.c | 222 +++++++++++++++++++++++- src/esx/esx_vi.h | 19 +- 6 files changed, 749 insertions(+), 4 deletions(-) create mode 100644 src/esx/esx_stream.c create mode 100644 src/esx/esx_stream.h
diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c new file mode 100644 index 0000000..fb9abbc --- /dev/null +++ b/src/esx/esx_stream.c @@ -0,0 +1,478 @@ +/* + * esx_stream.c: libcurl based stream driver + * + * Copyright (C) 2012-2014 Matthias Bolte <matthias.bolte@googlemail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#include <config.h> + +#include "internal.h" +#include "datatypes.h" +#include "viralloc.h" +#include "virstring.h" +#include "esx_stream.h" + +#define VIR_FROM_THIS VIR_FROM_ESX
I believe we want something like this too:
VIR_LOG_INIT("esx.esx_stream");
Only if there are actually any VIR_DEBUG statements in the file. You'd see a compile failure if you had debug statements, but no log init. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|