From patchwork Wed Apr 18 13:12:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 153506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 09714B6FDC for ; Wed, 18 Apr 2012 23:13:00 +1000 (EST) Received: from localhost ([::1]:58525 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKUgp-0003iq-Fh for incoming@patchwork.ozlabs.org; Wed, 18 Apr 2012 09:12:55 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKUgV-0003GK-Bd for qemu-devel@nongnu.org; Wed, 18 Apr 2012 09:12:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKUgK-0005MX-IN for qemu-devel@nongnu.org; Wed, 18 Apr 2012 09:12:34 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:56612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKUgK-0005IP-AF for qemu-devel@nongnu.org; Wed, 18 Apr 2012 09:12:24 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so10390781pbc.4 for ; Wed, 18 Apr 2012 06:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=p+jpcyKkYNJT8WZQZrkeKNeoiYp8TWUzU8RDtg8x3GU=; b=dhFjLHSnWj1z5jx3uYuK5tXAnByj961bhgo98A7XNoFOGqVIoSWrDtG0LxfC3XNfAV 3THN1z2VAHGor1F+Fik6yq4C4xHi9XFbTCj1mgEIVYxQHmnQxsxtn/qPpYr3gMSoIw4J A6H2EtL+2E8eA4rnK4Qf03SiLjwmUWuWdMnuj1bp1AEQ1T97u3hN22wiuaL34JyNfQia cA4hyy1w+r6ze3xWEm0DSVtqalY6zIj5htJE3IYJ9DHvgTKfs6IElmzEpWcBIbfIVtdU XGKIUhXaOhvjvzyZ0axthZSzylZEF+zSJoPixqHHADcje+ER4GSzhGu79mQBeWTDPgV2 4zog== Received: by 10.68.194.198 with SMTP id hy6mr6634575pbc.0.1334754738517; Wed, 18 Apr 2012 06:12:18 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id nz8sm15709851pbb.68.2012.04.18.06.12.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Apr 2012 06:12:17 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 18 Apr 2012 15:12:01 +0200 Message-Id: <1334754723-11153-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.3 In-Reply-To: <1334754723-11153-1-git-send-email-pbonzini@redhat.com> References: <1334754723-11153-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: kwolf@redhat.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 1/3] block: allow interrupting a co_sleep_ns 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 In the next patch we want to reenter the coroutine from block_job_cancel_sync and cancel the timer. Signed-off-by: Paolo Bonzini --- qemu-coroutine-sleep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qemu-coroutine-sleep.c b/qemu-coroutine-sleep.c index fd65274..d7083ee 100644 --- a/qemu-coroutine-sleep.c +++ b/qemu-coroutine-sleep.c @@ -23,7 +23,6 @@ static void co_sleep_cb(void *opaque) { CoSleepCB *sleep_cb = opaque; - qemu_free_timer(sleep_cb->ts); qemu_coroutine_enter(sleep_cb->co, NULL); } @@ -35,4 +34,6 @@ void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns) sleep_cb.ts = qemu_new_timer(clock, SCALE_NS, co_sleep_cb, &sleep_cb); qemu_mod_timer(sleep_cb.ts, qemu_get_clock_ns(clock) + ns); qemu_coroutine_yield(); + qemu_del_timer(sleep_cb.ts); + qemu_free_timer(sleep_cb.ts); }