@@ -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;
+}
@@ -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
@@ -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;
+}
@@ -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 */