OSDN Git Service

block/curl: Implement the libcurl timer callback interface
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 24 Jan 2014 13:56:17 +0000 (14:56 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 24 Jan 2014 15:07:08 +0000 (16:07 +0100)
commit031fd1be5618c347f9aeb44ec294f14a541e42b2
treea410b58ea398e4df26543d0751352cab3a401961
parent0901f67ecdb74d9ba1451e3b4367194cd43f96b4
block/curl: Implement the libcurl timer callback interface

libcurl versions 7.16.0 and later have a timer callback interface which
must be implemented in order for libcurl to make forward progress (it
will sometimes rely on being called back on the timeout if there are
no file descriptors registered). Implement the callback, and use a
QEMU AIO timer to ensure we prod libcurl again when it asks us to.

Based on Peter's original patch plus my fix to add curl_multi_timeout_do.
Should compile just fine even on older versions of libcurl.

I also tried copy-on-read and streaming:

    $ ./qemu-img create -f qcow2 -o \
         backing_file=http://download.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso \
         foo.qcow2 1G
    $ x86_64-softmmu/qemu-system-x86_64 \
         -drive if=none,file=foo.qcow2,copy-on-read=on,id=cd \
         -device ide-cd,drive=cd --enable-kvm -m 1024

Direct http usage is probably too slow, but with copy-on-read ultimately
the image does boot!

After some time, streaming gets canceled by an EIO, which needs further
investigation.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/curl.c