From patchwork Tue May 25 08:36:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshiaki Tamura X-Patchwork-Id: 102125 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4P8gXOI030583 for ; Tue, 25 May 2010 08:42:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756473Ab0EYImF (ORCPT ); Tue, 25 May 2010 04:42:05 -0400 Received: from sh.osrg.net ([192.16.179.4]:34884 "EHLO sh.osrg.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756269Ab0EYIkk (ORCPT ); Tue, 25 May 2010 04:40:40 -0400 Received: from fs.osrg.net (postfix@fs.osrg.net [10.0.0.12]) by sh.osrg.net (8.14.3/8.14.3/OSRG-NET) with ESMTP id o4P8eJlT010208; Tue, 25 May 2010 17:40:19 +0900 Received: from localhost (hype-wd0.osrg.net [10.72.1.16]) by fs.osrg.net (Postfix) with ESMTP id D184B3E0303; Tue, 25 May 2010 17:40:17 +0900 (JST) From: Yoshiaki Tamura To: kvm@vger.kernel.org, qemu-devel@nongnu.org Cc: avi@redhat.com, aliguori@us.ibm.com, mtosatti@redhat.com, ohmura.kei@lab.ntt.co.jp, Yoshiaki Tamura Subject: [RFC PATCH 12/23] Insent event-tap callbacks to net/block layer. Date: Tue, 25 May 2010 17:36:53 +0900 Message-Id: <1274776624-16435-14-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Mailer: git-send-email 1.7.0.31.g1df487 In-Reply-To: <1274776624-16435-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> References: <1274776624-16435-1-git-send-email-tamura.yoshiaki@lab.ntt.co.jp> X-Dispatcher: imput version 20070423(IM149) Lines: 138 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 25 May 2010 08:42:34 +0000 (UTC) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-3.0 (sh.osrg.net [192.16.179.4]); Tue, 25 May 2010 17:40:19 +0900 (JST) X-Virus-Scanned: clamav-milter 0.96 at sh X-Virus-Status: Clean Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/block.c b/block.c index 31d1ba4..cf73c47 100644 --- a/block.c +++ b/block.c @@ -59,6 +59,8 @@ BlockDriverState *bdrv_first; static BlockDriver *first_drv; +static int (*bdrv_event_tap)(void); + /* If non-zero, use only whitelisted block drivers */ static int use_bdrv_whitelist; @@ -787,6 +789,10 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num, set_dirty_bitmap(bs, sector_num, nb_sectors, 1); } + if (bdrv_event_tap != NULL) { + bdrv_event_tap(); + } + return drv->bdrv_write(bs, sector_num, buf, nb_sectors); } @@ -1851,6 +1857,10 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) MultiwriteCB *mcb; int i; + if (bdrv_event_tap != NULL) { + bdrv_event_tap(); + } + if (num_reqs == 0) { return 0; } @@ -2277,3 +2287,15 @@ int64_t bdrv_get_dirty_count(BlockDriverState *bs) { return bs->dirty_count; } + +void bdrv_event_tap_register(int (*cb)(void)) +{ + if (bdrv_event_tap == NULL) { + bdrv_event_tap = cb; + } +} + +void bdrv_event_tap_unregister(void) +{ + bdrv_event_tap = NULL; +} diff --git a/block.h b/block.h index edf5704..b5139db 100644 --- a/block.h +++ b/block.h @@ -207,4 +207,8 @@ int bdrv_get_dirty(BlockDriverState *bs, int64_t sector); void bdrv_reset_dirty(BlockDriverState *bs, int64_t cur_sector, int nr_sectors); int64_t bdrv_get_dirty_count(BlockDriverState *bs); + +void bdrv_event_tap_register(int (*cb)(void)); +void bdrv_event_tap_unregister(void); + #endif diff --git a/net/queue.c b/net/queue.c index 2ea6cd0..a542efe 100644 --- a/net/queue.c +++ b/net/queue.c @@ -57,6 +57,8 @@ struct NetQueue { unsigned delivering : 1; }; +static int (*net_event_tap)(void); + NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver, NetPacketDeliverIOV *deliver_iov, void *opaque) @@ -151,6 +153,8 @@ static ssize_t qemu_net_queue_deliver(NetQueue *queue, ssize_t ret = -1; queue->delivering = 1; + if (net_event_tap) + net_event_tap(); ret = queue->deliver(sender, flags, data, size, queue->opaque); queue->delivering = 0; @@ -166,6 +170,8 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *queue, ssize_t ret = -1; queue->delivering = 1; + if (net_event_tap) + net_event_tap(); ret = queue->deliver_iov(sender, flags, iov, iovcnt, queue->opaque); queue->delivering = 0; @@ -258,3 +264,15 @@ void qemu_net_queue_flush(NetQueue *queue) qemu_free(packet); } } + +void qemu_net_event_tap_register(int (*cb)(void)) +{ + if (net_event_tap == NULL) { + net_event_tap = cb; + } +} + +void qemu_net_event_tap_unregister(void) +{ + net_event_tap = NULL; +} diff --git a/net/queue.h b/net/queue.h index a31958e..5b031c1 100644 --- a/net/queue.h +++ b/net/queue.h @@ -68,4 +68,7 @@ ssize_t qemu_net_queue_send_iov(NetQueue *queue, void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from); void qemu_net_queue_flush(NetQueue *queue); +void qemu_net_event_tap_register(int (*cb)(void)); +void qemu_net_event_tap_unregister(void); + #endif /* QEMU_NET_QUEUE_H */