cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: --enable-threaded-resolver "breaks" qemu's curl driver

From: Richard W.M. Jones <rjones_at_redhat.com>
Date: Fri, 7 Jun 2013 22:43:58 +0100

On Fri, Jun 07, 2013 at 11:29:31PM +0200, Daniel Stenberg wrote:
> On Fri, 7 Jun 2013, Richard W.M. Jones wrote:
>
> >For a long time we've not been able to use Fedora's curl with
> >qemu, but upstream curl from git just worked. A simple way to
> >test this is to run:
> >
> > qemu-io http://libguestfs.org/index.html -c 'read -v 0 512'
> >
> >It will either print something or hang forever.
>
> Thanks for your detailed report and I also read your bugzilla entry
> on this issue.

Thanks.

> What exactly is that command line doing HTTP-wise? Is it "just"
> asking for the first 512 bytes from that URL? If so, shouldn't the
> plain curl command line tool also repeat the problem if it was truly
> a pure libcurl problem?

Well one thing we do know is that the curl CLI does *not* exhibit this
problem. In other words, it doesn't seem to be a problem in curl. So
either it's a bug in how qemu uses the curl API, or in qemu for some
other reason (eg. coroutines, threads).

I'll try to look into the items below when I have time, but it'd be
great if you could just skip over the code here:

http://git.qemu.org/?p=qemu.git;a=blob;f=block/curl.c;h=b8935fd9916363640df142d303b93756c8acf167;hb=HEAD

and tell us if there's anything obviously broken about how it's using
the API. (Note I didn't write any of it.)

> Any chance you can try to write up a
> smallish more plain libcurl-using code that can be used to attempt
> to repeat the problem?
>
> Oh and btw, when it hangs, does it show it the resolver thread
> function as the culprit in a gdb stack trace?

No, it appears there is only one thread running when qemu / qemu-io
goes to 100%:

(gdb) t a a bt

Thread 1 (Thread 0x7ffff7fb9880 (LWP 22558)):
#0 g_array_remove_range (farray=farray_at_entry=0x555555c08230,
    index_=index__at_entry=0, length=1) at garray.c:677
#1 0x00007ffff76cdd7c in g_array_set_size (farray=0x555555c08230,
    length=length_at_entry=0) at garray.c:556
#2 0x00005555555636df in aio_poll (ctx=0x555555c08020,
    blocking=blocking_at_entry=true) at aio-posix.c:200
#3 0x000055555559e989 in qemu_aio_wait () at main-loop.c:484
#4 0x000055555556ace5 in bdrv_rwv_co (bs=bs_at_entry=0x555555c123f0,
    sector_num=sector_num_at_entry=0, qiov=qiov_at_entry=0x7fffffffb7c0,
    is_write=is_write_at_entry=false) at block.c:2216
#5 0x000055555556ae80 in bdrv_rw_co (is_write=false,
    nb_sectors=<optimized out>, buf=<optimized out>, sector_num=0, bs=
    0x555555c123f0) at block.c:2235
#6 bdrv_read (bs=bs_at_entry=0x555555c123f0, sector_num=sector_num_at_entry=0,
    buf=buf_at_entry=0x7fffffffbab0 "", nb_sectors=nb_sectors_at_entry=4)
    at block.c:2242
#7 0x000055555556b212 in bdrv_pread (bs=0x555555c123f0, offset=offset_at_entry=
    0, buf=buf_at_entry=0x7fffffffbab0, count1=count1_at_entry=2048) at block.c:2304
#8 0x000055555556b900 in find_image_format (pdrv=<synthetic pointer>,
    filename=0x7fffffffe1d1 "http://192.168.0.249/scratch/winxp.img",
    bs=<optimized out>) at block.c:542
#9 bdrv_open (bs=0x555555c0e9b0, filename=filename_at_entry=
    0x7fffffffe1d1 "http://192.168.0.249/scratch/winxp.img", options=
    0x555555c103b0, options_at_entry=0x0, flags=24578, drv=drv_at_entry=0x0)
    at block.c:1055
#10 0x00005555555bb835 in openfile (growable=0, flags=<optimized out>, name=
    0x7fffffffe1d1 "http://192.168.0.249/scratch/winxp.img") at qemu-io.c:1812
#11 openfile (name=0x7fffffffe1d1 "http://192.168.0.249/scratch/winxp.img",
    flags=<optimized out>, growable=<optimized out>) at qemu-io.c:1797
#12 0x0000555555563129 in main (argc=<optimized out>, argv=0x7fffffffde28)
    at qemu-io.c:2055

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-06-07