Revision d1a0739d block.h

b/block.h
350 350
#define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt)
351 351
void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event);
352 352

  
353

  
354
/* Convenience for block device models */
355

  
356
typedef struct BlockConf {
357
    BlockDriverState *bs;
358
    uint16_t physical_block_size;
359
    uint16_t logical_block_size;
360
    uint16_t min_io_size;
361
    uint32_t opt_io_size;
362
    int32_t bootindex;
363
    uint32_t discard_granularity;
364
} BlockConf;
365

  
366
static inline unsigned int get_physical_block_exp(BlockConf *conf)
367
{
368
    unsigned int exp = 0, size;
369

  
370
    for (size = conf->physical_block_size;
371
        size > conf->logical_block_size;
372
        size >>= 1) {
373
        exp++;
374
    }
375

  
376
    return exp;
377
}
378

  
379
#define DEFINE_BLOCK_PROPERTIES(_state, _conf)                          \
380
    DEFINE_PROP_DRIVE("drive", _state, _conf.bs),                       \
381
    DEFINE_PROP_UINT16("logical_block_size", _state,                    \
382
                       _conf.logical_block_size, 512),                  \
383
    DEFINE_PROP_UINT16("physical_block_size", _state,                   \
384
                       _conf.physical_block_size, 512),                 \
385
    DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0),  \
386
    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
387
    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1),        \
388
    DEFINE_PROP_UINT32("discard_granularity", _state, \
389
                       _conf.discard_granularity, 0)
390

  
353 391
#endif
354 392

  

Also available in: Unified diff