1 /* 2 * BlockBackend RAM Registrar 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 7 #ifndef BLOCK_RAM_REGISTRAR_H 8 #define BLOCK_RAM_REGISTRAR_H 9 10 #include "exec/ramlist.h" 11 12 /** 13 * struct BlockRAMRegistrar: 14 * 15 * Keeps RAMBlock memory registered with a BlockBackend using 16 * blk_register_buf() including hotplugged memory. 17 * 18 * Emulated devices or other BlockBackend users initialize a BlockRAMRegistrar 19 * with blk_ram_registrar_init() before submitting I/O requests with the 20 * BDRV_REQ_REGISTERED_BUF flag set. 21 */ 22 typedef struct { 23 BlockBackend *blk; 24 RAMBlockNotifier notifier; 25 bool ok; 26 } BlockRAMRegistrar; 27 28 void blk_ram_registrar_init(BlockRAMRegistrar *r, BlockBackend *blk); 29 void blk_ram_registrar_destroy(BlockRAMRegistrar *r); 30 31 /* Have all RAMBlocks been registered successfully? */ 32 static inline bool blk_ram_registrar_ok(BlockRAMRegistrar *r) 33 { 34 return r->ok; 35 } 36 37 #endif /* BLOCK_RAM_REGISTRAR_H */ 38