block: Move BlockConf & friends from block_int.h to block.h
It's convenience stuff for block device models, so block.h isn't the ideal home either, but better than block_int.h. Permits moving some #include "block_int.h" from device model .h into .c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
e4def80b36
commit
d1a0739de5
38
block.h
38
block.h
@ -350,5 +350,43 @@ typedef enum {
|
||||
#define BLKDBG_EVENT(bs, evt) bdrv_debug_event(bs, evt)
|
||||
void bdrv_debug_event(BlockDriverState *bs, BlkDebugEvent event);
|
||||
|
||||
|
||||
/* Convenience for block device models */
|
||||
|
||||
typedef struct BlockConf {
|
||||
BlockDriverState *bs;
|
||||
uint16_t physical_block_size;
|
||||
uint16_t logical_block_size;
|
||||
uint16_t min_io_size;
|
||||
uint32_t opt_io_size;
|
||||
int32_t bootindex;
|
||||
uint32_t discard_granularity;
|
||||
} BlockConf;
|
||||
|
||||
static inline unsigned int get_physical_block_exp(BlockConf *conf)
|
||||
{
|
||||
unsigned int exp = 0, size;
|
||||
|
||||
for (size = conf->physical_block_size;
|
||||
size > conf->logical_block_size;
|
||||
size >>= 1) {
|
||||
exp++;
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
#define DEFINE_BLOCK_PROPERTIES(_state, _conf) \
|
||||
DEFINE_PROP_DRIVE("drive", _state, _conf.bs), \
|
||||
DEFINE_PROP_UINT16("logical_block_size", _state, \
|
||||
_conf.logical_block_size, 512), \
|
||||
DEFINE_PROP_UINT16("physical_block_size", _state, \
|
||||
_conf.physical_block_size, 512), \
|
||||
DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \
|
||||
DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \
|
||||
DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \
|
||||
DEFINE_PROP_UINT32("discard_granularity", _state, \
|
||||
_conf.discard_granularity, 0)
|
||||
|
||||
#endif
|
||||
|
||||
|
35
block_int.h
35
block_int.h
@ -225,39 +225,4 @@ void qemu_aio_release(void *p);
|
||||
int is_windows_drive(const char *filename);
|
||||
#endif
|
||||
|
||||
typedef struct BlockConf {
|
||||
BlockDriverState *bs;
|
||||
uint16_t physical_block_size;
|
||||
uint16_t logical_block_size;
|
||||
uint16_t min_io_size;
|
||||
uint32_t opt_io_size;
|
||||
int32_t bootindex;
|
||||
uint32_t discard_granularity;
|
||||
} BlockConf;
|
||||
|
||||
static inline unsigned int get_physical_block_exp(BlockConf *conf)
|
||||
{
|
||||
unsigned int exp = 0, size;
|
||||
|
||||
for (size = conf->physical_block_size;
|
||||
size > conf->logical_block_size;
|
||||
size >>= 1) {
|
||||
exp++;
|
||||
}
|
||||
|
||||
return exp;
|
||||
}
|
||||
|
||||
#define DEFINE_BLOCK_PROPERTIES(_state, _conf) \
|
||||
DEFINE_PROP_DRIVE("drive", _state, _conf.bs), \
|
||||
DEFINE_PROP_UINT16("logical_block_size", _state, \
|
||||
_conf.logical_block_size, 512), \
|
||||
DEFINE_PROP_UINT16("physical_block_size", _state, \
|
||||
_conf.physical_block_size, 512), \
|
||||
DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \
|
||||
DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \
|
||||
DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \
|
||||
DEFINE_PROP_UINT32("discard_granularity", _state, \
|
||||
_conf.discard_granularity, 0)
|
||||
|
||||
#endif /* BLOCK_INT_H */
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "sysemu.h"
|
||||
#include "dma.h"
|
||||
#include "blockdev.h"
|
||||
#include "block_int.h"
|
||||
|
||||
#include <hw/ide/internal.h>
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
* non-internal declarations are in hw/ide.h
|
||||
*/
|
||||
#include <hw/ide.h>
|
||||
#include "block_int.h"
|
||||
#include "iorange.h"
|
||||
#include "dma.h"
|
||||
|
||||
|
@ -37,6 +37,7 @@ do { fprintf(stderr, "scsi-disk: " fmt , ## __VA_ARGS__); } while (0)
|
||||
#include "scsi-defs.h"
|
||||
#include "sysemu.h"
|
||||
#include "blockdev.h"
|
||||
#include "block_int.h"
|
||||
|
||||
#define SCSI_DMA_BUF_SIZE 131072
|
||||
#define SCSI_MAX_INQUIRY_LEN 256
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include "qdev.h"
|
||||
#include "block.h"
|
||||
#include "block_int.h"
|
||||
|
||||
#define MAX_SCSI_DEVS 255
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "qemu-error.h"
|
||||
#include "trace.h"
|
||||
#include "blockdev.h"
|
||||
#include "block_int.h"
|
||||
#include "virtio-blk.h"
|
||||
#ifdef __linux__
|
||||
# include <scsi/sg.h>
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "net.h"
|
||||
#include "qdev.h"
|
||||
#include "sysemu.h"
|
||||
#include "block_int.h"
|
||||
#include "block.h"
|
||||
#include "event_notifier.h"
|
||||
#ifdef CONFIG_LINUX
|
||||
#include "9p.h"
|
||||
|
Loading…
Reference in New Issue
Block a user