From patchwork Wed Jan 15 22:06:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 311472 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 750EF2C009C for ; Thu, 16 Jan 2014 09:07:04 +1100 (EST) Received: from localhost ([::1]:57477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3Yc1-0004Lt-Ad for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2014 17:07:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3Ybf-00040a-Hm for qemu-devel@nongnu.org; Wed, 15 Jan 2014 17:06:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3Yba-0006wj-2A for qemu-devel@nongnu.org; Wed, 15 Jan 2014 17:06:39 -0500 Received: from mail-ea0-x22b.google.com ([2a00:1450:4013:c01::22b]:55112) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3YbZ-0006wc-Rc; Wed, 15 Jan 2014 17:06:33 -0500 Received: by mail-ea0-f171.google.com with SMTP id h10so748112eak.16 for ; Wed, 15 Jan 2014 14:06:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=n6GPngy9Wo4bC8rDW98VjAYNYfacrtgH7Ka/ajX4tJg=; b=bs06CWnlhHOHu3PDyycEDh95b6GLfZOzSC6A+bAt0B8ASOfbRuMdhq9ZuThIhCoZHe 6099wDNXSUqHMn5LH8RVv7NuyAeJvt/aO+Sbc2gzrcj8vVBHfcvZnSp3w7MNZJESaGWd uapagwDok5iN7NK5sF0b0006zjiWs9xQJ1avQUGzByFZFVgswClzJw9lf3TWF8vCb+4M nAE7nFjabfSsgzrZLtkK7UXUy8OzwednC4lyxFLvOC/YJMHJo+wefso8eNghperqldzg 6MDGjwqWJT8oY+zhoitd+Bg8wi8ZW+JGXD4i+Y/DoAzPkB+Qekc9CqcLS3nA23R8OvYe oIug== X-Received: by 10.15.51.13 with SMTP id m13mr9840eew.103.1389823590631; Wed, 15 Jan 2014 14:06:30 -0800 (PST) Received: from yakj.usersys.redhat.com (net-2-35-197-229.cust.dsl.vodafone.it. [2.35.197.229]) by mx.google.com with ESMTPSA id 1sm13606651eeg.4.2014.01.15.14.06.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 14:06:28 -0800 (PST) Message-ID: <52D7065F.9020203@redhat.com> Date: Wed, 15 Jan 2014 23:06:23 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 MIME-Version: 1.0 To: Peter Maydell References: <1389806638-3114-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1389806638-3114-1-git-send-email-peter.maydell@linaro.org> X-Enigmail-Version: 1.6 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22b Cc: Kevin Wolf , patches@linaro.org, qemu-devel@nongnu.org, Stefan Hajnoczi , qemu-stable@nongnu.org Subject: Re: [Qemu-devel] [PATCH] block/curl: Implement the libcurl timer callback interface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Il 15/01/2014 18:23, Peter Maydell ha scritto: > 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. > > Signed-off-by: Peter Maydell > --- > This fixes the problem I was seeing where trying to use the curl block > backend just hung. I'm not sure whether all libcurl versions that provide > the timer callback API require its use, but it shouldn't hurt. It still hangs here, but the adding the following patch on top fixes curl on Fedora for me! Signed-off-by: Paolo Bonzini diff --git a/block/curl.c b/block/curl.c index 5238961..e0cf138 100644 --- a/block/curl.c +++ b/block/curl.c @@ -232,20 +232,10 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len, return FIND_RET_NONE; } -static void curl_multi_do(void *arg) +static void curl_multi_read(BDRVCURLState *s) { - BDRVCURLState *s = (BDRVCURLState *)arg; - int running; - int r; int msgs_in_queue; - if (!s->multi) - return; - - do { - r = curl_multi_socket_all(s->multi, &running); - } while(r == CURLM_CALL_MULTI_PERFORM); - /* Try to find done transfers, so we can free the easy * handle again. */ do { @@ -289,6 +279,37 @@ static void curl_multi_do(void *arg) } while(msgs_in_queue); } +static void curl_multi_do(void *arg) +{ + BDRVCURLState *s = (BDRVCURLState *)arg; + int running; + int r; + + if (!s->multi) { + return; + } + + do { + r = curl_multi_socket_all(s->multi, &running); + } while(r == CURLM_CALL_MULTI_PERFORM); + + curl_multi_read(s); +} + +static void curl_multi_timeout_do(void *arg) +{ + BDRVCURLState *s = (BDRVCURLState *)arg; + int running; + + if (!s->multi) { + return; + } + + curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running); + + curl_multi_read(s); +} + static CURLState *curl_init_state(BDRVCURLState *s) { CURLState *state = NULL; @@ -498,7 +519,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, aio_timer_init(bdrv_get_aio_context(bs), &s->timer, QEMU_CLOCK_REALTIME, SCALE_NS, - curl_multi_do, s); + curl_multi_timeout_do, s); // Now we know the file exists and its size, so let's // initialize the multi interface!