diff --git a/block/block-backend.c b/block/block-backend.c index d17bd504cc..27615e4b10 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -27,7 +27,10 @@ #include "qemu/option.h" #include "trace.h" #include "migration/misc.h" + +//// --- Begin LibAFL code --- #include "libafl_extras/syx-snapshot/syx-snapshot.h" +//// --- End LibAFL code --- /* Number of coroutines to reserve per attached device model */ #define COROUTINE_POOL_RESERVATION 64 @@ -714,10 +717,12 @@ bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp) error_setg(errp, "Invalid device name"); return false; } +//// --- Begin LibAFL code --- if (blk_by_name(name)) { error_setg(errp, "Device with id '%s' already exists", name); return false; } +//// --- End LibAFL code --- if (blk_by_name_hash(g_str_hash(name))) { error_setg(errp, "Device with name hash '%x' already exists", g_str_hash(name)); return false; @@ -766,11 +771,13 @@ const char *blk_name(const BlockBackend *blk) return blk->name ?: ""; } +//// --- Begin LibAFL code --- guint blk_name_hash(const BlockBackend* blk) { IO_CODE(); return blk->name_hash; } +//// --- End LibAFL code --- /* * Return the BlockBackend with name @name if it exists, else null. @@ -1660,12 +1667,16 @@ static void coroutine_fn blk_aio_read_entry(void *opaque) assert(qiov->size == acb->bytes); +//// --- Begin LibAFL code --- if (!syx_snapshot_cow_cache_read_entry(rwco->blk, rwco->offset, acb->bytes, qiov, 0, rwco->flags)) { +//// --- End LibAFL code --- rwco->ret = blk_co_do_preadv_part(rwco->blk, rwco->offset, acb->bytes, qiov, 0, rwco->flags); +//// --- Begin LibAFL code --- } else { rwco->ret = 0; } +//// --- End LibAFL code --- blk_aio_complete(acb); } diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/block-backend-global-state.h index 32d46c40d9..c2cfa2bf46 100644 --- a/include/sysemu/block-backend-global-state.h +++ b/include/sysemu/block-backend-global-state.h @@ -48,7 +48,9 @@ void coroutine_fn no_co_wrapper blk_co_unref(BlockBackend *blk); void blk_remove_all_bs(void); BlockBackend *blk_by_name(const char *name); +//// --- Begin LibAFL code --- BlockBackend *blk_by_name_hash(guint name_hash); +//// --- End LibAFL code --- BlockBackend *blk_next(BlockBackend *blk); BlockBackend *blk_all_next(BlockBackend *blk); bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); diff --git a/include/sysemu/block-backend-io.h b/include/sysemu/block-backend-io.h index 584e4828ad..50145b8d72 100644 --- a/include/sysemu/block-backend-io.h +++ b/include/sysemu/block-backend-io.h @@ -24,7 +24,9 @@ */ const char *blk_name(const BlockBackend *blk); +//// --- Begin LibAFL code --- guint blk_name_hash(const BlockBackend* blk); +//// --- End LibAFL code --- BlockDriverState *blk_bs(BlockBackend *blk);