From patchwork Sun Jul 21 08:43:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: pingfan liu X-Patchwork-Id: 260502 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5737A2C00B9 for ; Sun, 21 Jul 2013 18:52:46 +1000 (EST) Received: from localhost ([::1]:47346 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0pNj-000677-Sw for incoming@patchwork.ozlabs.org; Sun, 21 Jul 2013 04:52:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0pMh-0004tv-FL for qemu-devel@nongnu.org; Sun, 21 Jul 2013 04:51:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0pMg-0007Mt-Hs for qemu-devel@nongnu.org; Sun, 21 Jul 2013 04:51:39 -0400 Received: from mail-ie0-x22c.google.com ([2607:f8b0:4001:c03::22c]:33407) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0pMg-0007Mn-55 for qemu-devel@nongnu.org; Sun, 21 Jul 2013 04:51:38 -0400 Received: by mail-ie0-f172.google.com with SMTP id 17so463058iea.3 for ; Sun, 21 Jul 2013 01:51:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=H00JNUytxcA4Pjgz9E/UPiMRgp68AcdePDZ4+V4MqHE=; b=XXOxoaTtQD91hLzxL8FZCX2w5PFpsuJ5QtxlpbqzfXHsZD68Kns/9woW19sJ7Kb80f sCbx89+14D2whpimzMKUUFVAmTTOODXb2S8JUKXBu5b6okjWGWuonoPJt/gLhQW55YLr tRY5OGbnk140xnt18iOYfTp4d1Su3K6cRB3Mwdr5pRFapkVUHHfHmpg0K7VYneDFK3CH IrCn2gKiTP+vgjIF6HXOlDjMBBe2MSJvYsBrKrL3jcg2cMACTEpP2vgDQkgSxaBe/BQ0 iuKFKClFNpJ5dqG/q1xgfHuwnu16cFOUhZuWyzmy70GUBCEkTpQsJZ0D9+n0dosPMxW+ ehwA== X-Received: by 10.42.113.197 with SMTP id d5mr14682594icq.46.1374396697478; Sun, 21 Jul 2013 01:51:37 -0700 (PDT) Received: from localhost ([111.199.191.161]) by mx.google.com with ESMTPSA id nr4sm26833411igb.0.2013.07.21.01.51.32 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 21 Jul 2013 01:51:36 -0700 (PDT) From: Liu Ping Fan To: qemu-devel@nongnu.org Date: Sun, 21 Jul 2013 16:43:04 +0800 Message-Id: <1374396185-10870-8-git-send-email-pingfank@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1374396185-10870-1-git-send-email-pingfank@linux.vnet.ibm.com> References: <1374396185-10870-1-git-send-email-pingfank@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::22c Cc: Kevin Wolf , Stefan Hajnoczi , Jan Kiszka , Alex Bligh , Anthony Liguori , Paolo Bonzini Subject: [Qemu-devel] [RFC 7/8] block: associate BlockDriverState with AioContext 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 The default aio for BDS is qemu_aio_context, while for data plane, it will has its own ctx. Relating BDS with AioContext can help block layer to determine its running environment. Some stuff like timers need such info, so that they can run in the correct environment. Signed-off-by: Liu Ping Fan --- block.c | 6 ++++++ hw/block/dataplane/virtio-blk.c | 1 + include/block/block.h | 1 + include/block/block_int.h | 1 + 4 files changed, 9 insertions(+) diff --git a/block.c b/block.c index daf5717..c6b7b6c 100644 --- a/block.c +++ b/block.c @@ -315,6 +315,12 @@ BlockDriverState *bdrv_new(const char *device_name) return bs; } +void bdrv_set_aio_context(BlockDriverState *bs, AioContext *ctx) +{ + assert(ctx); + bs->ctx = ctx; +} + void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify) { notifier_list_add(&bs->close_notifiers, notify); diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 5fde06f..ec477b0 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -378,6 +378,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) } s->ctx = aio_context_new(); + bdrv_set_aio_context(s->bs, s->ctx); /* Set up guest notifier (irq) */ if (k->set_guest_notifiers(qbus->parent, 1, true) != 0) { diff --git a/include/block/block.h b/include/block/block.h index cb44f27..23e743d 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -128,6 +128,7 @@ int bdrv_create(BlockDriver *drv, const char* filename, QEMUOptionParameter *options); int bdrv_create_file(const char* filename, QEMUOptionParameter *options); BlockDriverState *bdrv_new(const char *device_name); +void bdrv_set_aio_context(BlockDriverState *bs, AioContext *ctx); void bdrv_make_anon(BlockDriverState *bs); void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old); void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top); diff --git a/include/block/block_int.h b/include/block/block_int.h index cd0e0a8..801d1c1 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -299,6 +299,7 @@ struct BlockDriverState { QLIST_HEAD(, BdrvTrackedRequest) tracked_requests; + AioContext *ctx; /* long-running background operation */ BlockJob *job;