mirror of
https://github.com/xqemu/xqemu.git
synced 2025-04-02 11:11:56 -04:00
-----BEGIN PGP SIGNATURE----- iQJNBAABCAA3FiEE4aXFk81BneKOgxXPPCUl7RQ2DN4FAly/PhEZHHBldGVyLm1h eWRlbGxAbGluYXJvLm9yZwAKCRA8JSXtFDYM3kAfD/9SnusF4bCaeHG+oq/cRhte LbS1uCoSxynMKRvhx+s/tk7kzovW9twChMfE4xVcxHBY9hUFgMLnnq1lrJZ9GN9B 6zTrO9UDnkAfgkUq9B3lL0b+OVn4QFlcOFUl6U0q9E3zFUiCneLK9cEpw20t+2EL 78sjrpENms7nCeuUhiwZm00lbn4stY9vAiOZpu8qrg9lzDVaRivK5BrtkutfmDRn REHll2gduZp3FNkexiJs73YU+BFZMBXM+PqldU+c4iU4Cq2lUNco+Q4Ks32Q7Nf7 9/U1j5znW9M4X9jDi8jSU5Bd0rJQMid1h0wV0SrE1PWKJOAvF8w+0FPmEJDERRx/ W7Pz7+rYr2iOsOyJT4CuJQZUvJmIyMUz7JNVHOh/P8Hmb1PKp7Egy5Kamo2o7slA I/5wmI6HDAizyjaV6UL2D8KqfedihZoTS6HmCc2eX75nfa0eauDFKCMwZKOb1FYI dldRhOE1wiFKCV/jPEdBNJbE8jH9e5kH3CpcB1vnmphqkmHz1yKIToFgTDGrc8e3 mj7e67iNG1oIUys/w3zgEUYI6iSbkSyIYv9nlUv8NNSTUKK2kfpUMbJW3FyXrFR2 QvaaNOYJJHG+x8sCpPwWRBQiix/x5F/s6RKMpRgIa/QYKPwGKniEjgqcGSMdmyxM RnuxJvLfYcyAILZx20nCIA== =92OI -----END PGP SIGNATURE----- Merge tag 'v4.0.0' into merge-v4.0.0 v4.0.0 release
95 lines
3.3 KiB
C
95 lines
3.3 KiB
C
/*
|
|
* Common code for block device models
|
|
*
|
|
* Copyright (C) 2012 Red Hat, Inc.
|
|
* Copyright (c) 2003-2008 Fabrice Bellard
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or
|
|
* later. See the COPYING file in the top-level directory.
|
|
*/
|
|
|
|
#ifndef HW_BLOCK_H
|
|
#define HW_BLOCK_H
|
|
|
|
#include "exec/hwaddr.h"
|
|
#include "qapi/qapi-types-block-core.h"
|
|
|
|
/* Configuration */
|
|
|
|
typedef struct BlockConf {
|
|
BlockBackend *blk;
|
|
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;
|
|
/* geometry, not all devices use this */
|
|
uint32_t cyls, heads, secs;
|
|
OnOffAuto wce;
|
|
bool share_rw;
|
|
BlockdevOnError rerror;
|
|
BlockdevOnError werror;
|
|
} 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.blk), \
|
|
DEFINE_PROP_BLOCKSIZE("logical_block_size", _state, \
|
|
_conf.logical_block_size), \
|
|
DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \
|
|
_conf.physical_block_size), \
|
|
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_UINT32("discard_granularity", _state, \
|
|
_conf.discard_granularity, -1), \
|
|
DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \
|
|
ON_OFF_AUTO_AUTO), \
|
|
DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false)
|
|
|
|
#define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \
|
|
DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \
|
|
DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \
|
|
DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0)
|
|
|
|
#define DEFINE_BLOCK_ERROR_PROPERTIES(_state, _conf) \
|
|
DEFINE_PROP_BLOCKDEV_ON_ERROR("rerror", _state, _conf.rerror, \
|
|
BLOCKDEV_ON_ERROR_AUTO), \
|
|
DEFINE_PROP_BLOCKDEV_ON_ERROR("werror", _state, _conf.werror, \
|
|
BLOCKDEV_ON_ERROR_AUTO)
|
|
|
|
/* Backend access helpers */
|
|
|
|
bool blk_check_size_and_read_all(BlockBackend *blk, void *buf, hwaddr size,
|
|
Error **errp);
|
|
|
|
/* Configuration helpers */
|
|
|
|
void blkconf_locked(BlockConf *conf, bool *locked);
|
|
bool blkconf_geometry(BlockConf *conf, int *trans,
|
|
unsigned cyls_max, unsigned heads_max, unsigned secs_max,
|
|
Error **errp);
|
|
void blkconf_blocksizes(BlockConf *conf);
|
|
bool blkconf_apply_backend_options(BlockConf *conf, bool readonly,
|
|
bool resizable, Error **errp);
|
|
|
|
/* Hard disk geometry */
|
|
|
|
void hd_geometry_guess(BlockBackend *blk,
|
|
uint32_t *pcyls, uint32_t *pheads, uint32_t *psecs,
|
|
int *ptrans);
|
|
int hd_bios_chs_auto_trans(uint32_t cyls, uint32_t heads, uint32_t secs);
|
|
|
|
#endif
|