qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/3] Expose a mechanisem to trace block writes
@ 2009-09-07  9:23 lirans
  0 siblings, 0 replies; 2+ messages in thread
From: lirans @ 2009-09-07  9:23 UTC (permalink / raw)
  To: qemu-devel

To support live migration without shared storage we need to be able to trace
writes to disk while migrating. This Patch expose handler registration for 
above components to be notified about block writes.

diff --git a/block.c b/block.c
index cefbe77..b13da08 100644
--- a/block.c
+++ b/block.c
@@ -63,6 +63,8 @@ BlockDriverState *bdrv_first;
 
 static BlockDriver *first_drv;
 
+static BlockDriverDirtyHandler *bdrv_dirty_handler = NULL;
+
 int path_is_absolute(const char *path)
 {
     const char *p;
@@ -613,6 +615,10 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return -EIO;
 
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+
     return drv->bdrv_write(bs, sector_num, buf, nb_sectors);
 }
 
@@ -1144,6 +1150,11 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
         return -ENOTSUP;
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return -EIO;
+    
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+    
     return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
 }
 
@@ -1338,7 +1349,11 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
         return NULL;
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return NULL;
-
+    
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+    
     ret = drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors,
                                cb, opaque);
 
@@ -1632,6 +1647,17 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
     return NULL;
 }
 
+void register_bdrv_dirty_tracking(BlockDriverDirtyHandler *dirty_handler)
+{
+  bdrv_dirty_handler = dirty_handler;
+}
+
+void unregister_bdrv_dirty_tracking(void)
+{
+  bdrv_dirty_handler = NULL;
+}
+
+
 void *qemu_blockalign(BlockDriverState *bs, size_t size)
 {
     return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size);
diff --git a/block.h b/block.h
index 71e87fc..7f7db12 100644
--- a/block.h
+++ b/block.h
@@ -79,6 +79,8 @@ void bdrv_register(BlockDriver *bdrv);
 typedef struct BlockDriverAIOCB BlockDriverAIOCB;
 typedef void BlockDriverCompletionFunc(void *opaque, int ret);
 
+typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector,
+				    int sector_num);
 BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
                                  QEMUIOVector *iov, int nb_sectors,
                                  BlockDriverCompletionFunc *cb, void *opaque);
@@ -165,4 +167,7 @@ int bdrv_put_buffer(BlockDriverState *bs, const uint8_t *buf,
 
 int bdrv_get_buffer(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size);
 
+void register_bdrv_dirty_tracking(BlockDriverDirtyHandler *dirty_handler);
+void unregister_bdrv_dirty_tracking(void);
+
 #endif
diff --git a/block_int.h b/block_int.h
index 830b7e9..c066485 100644
--- a/block_int.h
+++ b/block_int.h
@@ -156,6 +156,7 @@ struct BlockDriverState {
     int cyls, heads, secs, translation;
     int type;
     char device_name[32];
+    void *dirty_control;
     BlockDriverState *next;
     void *private;
 };

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] [PATCH 1/3] Expose a mechanisem to trace block writes
@ 2009-09-10 10:24 lirans
  0 siblings, 0 replies; 2+ messages in thread
From: lirans @ 2009-09-10 10:24 UTC (permalink / raw)
  To: qemu-devel

To support live migration without shared storage we need to be able to trace
writes to disk while migrating. This Patch expose handler registration for 
above components to be notified about block writes.

diff --git a/block.c b/block.c
index cefbe77..b13da08 100644
--- a/block.c
+++ b/block.c
@@ -63,6 +63,8 @@ BlockDriverState *bdrv_first;
 
 static BlockDriver *first_drv;
 
+static BlockDriverDirtyHandler *bdrv_dirty_handler = NULL;
+
 int path_is_absolute(const char *path)
 {
     const char *p;
@@ -613,6 +615,10 @@ int bdrv_write(BlockDriverState *bs, int64_t sector_num,
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return -EIO;
 
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+
     return drv->bdrv_write(bs, sector_num, buf, nb_sectors);
 }
 
@@ -1144,6 +1150,11 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
         return -ENOTSUP;
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return -EIO;
+    
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+    
     return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
 }
 
@@ -1338,7 +1349,11 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
         return NULL;
     if (bdrv_check_request(bs, sector_num, nb_sectors))
         return NULL;
-
+    
+    if(bdrv_dirty_handler != NULL) {
+      bdrv_dirty_handler(bs, sector_num, nb_sectors);
+    }
+    
     ret = drv->bdrv_aio_writev(bs, sector_num, qiov, nb_sectors,
                                cb, opaque);
 
@@ -1632,6 +1647,17 @@ BlockDriverAIOCB *bdrv_aio_ioctl(BlockDriverState *bs,
     return NULL;
 }
 
+void register_bdrv_dirty_tracking(BlockDriverDirtyHandler *dirty_handler)
+{
+  bdrv_dirty_handler = dirty_handler;
+}
+
+void unregister_bdrv_dirty_tracking(void)
+{
+  bdrv_dirty_handler = NULL;
+}
+
+
 void *qemu_blockalign(BlockDriverState *bs, size_t size)
 {
     return qemu_memalign((bs && bs->buffer_alignment) ? bs->buffer_alignment : 512, size);
diff --git a/block.h b/block.h
index 71e87fc..7f7db12 100644
--- a/block.h
+++ b/block.h
@@ -79,6 +79,8 @@ void bdrv_register(BlockDriver *bdrv);
 typedef struct BlockDriverAIOCB BlockDriverAIOCB;
 typedef void BlockDriverCompletionFunc(void *opaque, int ret);
 
+typedef void BlockDriverDirtyHandler(BlockDriverState *bs, int64_t sector,
+				    int sector_num);
 BlockDriverAIOCB *bdrv_aio_readv(BlockDriverState *bs, int64_t sector_num,
                                  QEMUIOVector *iov, int nb_sectors,
                                  BlockDriverCompletionFunc *cb, void *opaque);
@@ -165,4 +167,7 @@ int bdrv_put_buffer(BlockDriverState *bs, const uint8_t *buf,
 
 int bdrv_get_buffer(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size);
 
+void register_bdrv_dirty_tracking(BlockDriverDirtyHandler *dirty_handler);
+void unregister_bdrv_dirty_tracking(void);
+
 #endif
diff --git a/block_int.h b/block_int.h
index 830b7e9..c066485 100644
--- a/block_int.h
+++ b/block_int.h
@@ -156,6 +156,7 @@ struct BlockDriverState {
     int cyls, heads, secs, translation;
     int type;
     char device_name[32];
+    void *dirty_control;
     BlockDriverState *next;
     void *private;
 };

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-09-10  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-10 10:24 [Qemu-devel] [PATCH 1/3] Expose a mechanisem to trace block writes lirans
  -- strict thread matches above, loose matches on Subject: below --
2009-09-07  9:23 lirans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).