Added missing LibAFL markers.

This commit is contained in:
Romain Malmain 2023-12-19 17:49:23 +01:00
parent 587303b513
commit f2cb66d32c
3 changed files with 15 additions and 0 deletions

View File

@ -27,7 +27,10 @@
#include "qemu/option.h" #include "qemu/option.h"
#include "trace.h" #include "trace.h"
#include "migration/misc.h" #include "migration/misc.h"
//// --- Begin LibAFL code ---
#include "libafl_extras/syx-snapshot/syx-snapshot.h" #include "libafl_extras/syx-snapshot/syx-snapshot.h"
//// --- End LibAFL code ---
/* Number of coroutines to reserve per attached device model */ /* Number of coroutines to reserve per attached device model */
#define COROUTINE_POOL_RESERVATION 64 #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"); error_setg(errp, "Invalid device name");
return false; return false;
} }
//// --- Begin LibAFL code ---
if (blk_by_name(name)) { if (blk_by_name(name)) {
error_setg(errp, "Device with id '%s' already exists", name); error_setg(errp, "Device with id '%s' already exists", name);
return false; return false;
} }
//// --- End LibAFL code ---
if (blk_by_name_hash(g_str_hash(name))) { if (blk_by_name_hash(g_str_hash(name))) {
error_setg(errp, "Device with name hash '%x' already exists", g_str_hash(name)); error_setg(errp, "Device with name hash '%x' already exists", g_str_hash(name));
return false; return false;
@ -766,11 +771,13 @@ const char *blk_name(const BlockBackend *blk)
return blk->name ?: ""; return blk->name ?: "";
} }
//// --- Begin LibAFL code ---
guint blk_name_hash(const BlockBackend* blk) guint blk_name_hash(const BlockBackend* blk)
{ {
IO_CODE(); IO_CODE();
return blk->name_hash; return blk->name_hash;
} }
//// --- End LibAFL code ---
/* /*
* Return the BlockBackend with name @name if it exists, else null. * 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); 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)) { 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, rwco->ret = blk_co_do_preadv_part(rwco->blk, rwco->offset, acb->bytes, qiov,
0, rwco->flags); 0, rwco->flags);
//// --- Begin LibAFL code ---
} else { } else {
rwco->ret = 0; rwco->ret = 0;
} }
//// --- End LibAFL code ---
blk_aio_complete(acb); blk_aio_complete(acb);
} }

View File

@ -48,7 +48,9 @@ void coroutine_fn no_co_wrapper blk_co_unref(BlockBackend *blk);
void blk_remove_all_bs(void); void blk_remove_all_bs(void);
BlockBackend *blk_by_name(const char *name); BlockBackend *blk_by_name(const char *name);
//// --- Begin LibAFL code ---
BlockBackend *blk_by_name_hash(guint name_hash); BlockBackend *blk_by_name_hash(guint name_hash);
//// --- End LibAFL code ---
BlockBackend *blk_next(BlockBackend *blk); BlockBackend *blk_next(BlockBackend *blk);
BlockBackend *blk_all_next(BlockBackend *blk); BlockBackend *blk_all_next(BlockBackend *blk);
bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp); bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);

View File

@ -24,7 +24,9 @@
*/ */
const char *blk_name(const BlockBackend *blk); const char *blk_name(const BlockBackend *blk);
//// --- Begin LibAFL code ---
guint blk_name_hash(const BlockBackend* blk); guint blk_name_hash(const BlockBackend* blk);
//// --- End LibAFL code ---
BlockDriverState *blk_bs(BlockBackend *blk); BlockDriverState *blk_bs(BlockBackend *blk);