Block layer patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJW6tIJAAoJEH8JsnLIjy/WsDUP/AhuS1/89YcQKinnC7oFbdRo PDe+z4E9O8+OODFdKfo8LVaUAREJvhykjkP7nL6SeUsPmSjwqAK2FDKV1ykId24R BB+JXeH57Kwmc+8rtJE9FuqhEL0CUc1sC0/leHltVKwnsI95rrZX6NRKzJnIw4aS zOAVFbMQQCAaN1pqFI0SV/y3c4uz0ycFkW+AxvskzSjrVsS0JX9Ezg5kiDAypOQe dSeg1kQ2hVNf8inpEnLCXK1rmODBfBtWB7ckoPIUC96ePdT6buGuCBQtAIBvqGAq TuNi7CxzKIPwxygSt9Et92pTn6WGaDooN6wOZCsudY8P5qx6C/pdx1qRp+Vx/HE7 b5u7EPXGXyY5zroq7OMPg+R3JmUg16twCkyj+SuMLyJl8KwM0nbdkyIIgnEaTOoJ Z9emXUzusNGtUi5hgXnSCC5Bak/8ujsczdhfdrNHkVvIJeRMas4FNZ9euH3xN0XO 72d8SXr11Hk4LloUR0gGwrIiULLQfePF5Y0udCRoeqadh3NEHT5GgUS1cNVwsCgI Q/SUDEESj20PnFcc2tZ7ojlCZUSJmoXOZgdn3wxdTy9zF8aMxtNKlMQfqD6mifsi aww+20m+qSu1IcUZAlFZB5pfWeAMTIT84iCPqmw4XGPr5727lgePFzVnnHrQX12Y BIUtbg8gUffHuGl/J39H =OfzG -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging Block layer patches # gpg: Signature made Thu 17 Mar 2016 15:49:29 GMT using RSA key ID C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" * remotes/kevin/tags/for-upstream: (29 commits) iotests: Test QUORUM_REPORT_BAD in fifo mode quorum: Emit QUORUM_REPORT_BAD for reads in fifo mode block: Use blk_co_pwritev() in blk_co_write_zeroes() block: Use blk_aio_prwv() for aio_read/write/write_zeroes block: Use blk_prw() in blk_pread()/blk_pwrite() block: Use blk_co_pwritev() in blk_write_zeroes() block: Pull up blk_read_unthrottled() implementation block: Use blk_co_pwritev() for blk_write() block: Use blk_co_preadv() for blk_read() block: Use BdrvChild in BlockBackend block: Remove bdrv_states list block: Use bdrv_next() instead of bdrv_states block: Rewrite bdrv_next() block: Add blk_next_root_bs() block: Add bdrv_next_monitor_owned() block: Move some bdrv_*_all() functions to BB blockdev: Remove blk_hide_on_behalf_of_hmp_drive_del() blockdev: Split monitor reference from BB creation blockdev: Separate BB name management blockdev: Add list of all BlockBackends ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
6741d38ad0
133
block.c
133
block.c
@ -55,8 +55,6 @@
|
||||
|
||||
#define NOT_DONE 0x7fffffff /* used while emulated sync operation in progress */
|
||||
|
||||
struct BdrvStates bdrv_states = QTAILQ_HEAD_INITIALIZER(bdrv_states);
|
||||
|
||||
static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
|
||||
QTAILQ_HEAD_INITIALIZER(graph_bdrv_states);
|
||||
|
||||
@ -226,10 +224,7 @@ void bdrv_register(BlockDriver *bdrv)
|
||||
|
||||
BlockDriverState *bdrv_new_root(void)
|
||||
{
|
||||
BlockDriverState *bs = bdrv_new();
|
||||
|
||||
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
|
||||
return bs;
|
||||
return bdrv_new();
|
||||
}
|
||||
|
||||
BlockDriverState *bdrv_new(void)
|
||||
@ -1180,10 +1175,9 @@ static int bdrv_fill_options(QDict **options, const char *filename,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
|
||||
BlockDriverState *child_bs,
|
||||
const char *child_name,
|
||||
const BdrvChildRole *child_role)
|
||||
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
|
||||
const char *child_name,
|
||||
const BdrvChildRole *child_role)
|
||||
{
|
||||
BdrvChild *child = g_new(BdrvChild, 1);
|
||||
*child = (BdrvChild) {
|
||||
@ -1192,24 +1186,43 @@ static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
|
||||
.role = child_role,
|
||||
};
|
||||
|
||||
QLIST_INSERT_HEAD(&parent_bs->children, child, next);
|
||||
QLIST_INSERT_HEAD(&child_bs->parents, child, next_parent);
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
|
||||
BlockDriverState *child_bs,
|
||||
const char *child_name,
|
||||
const BdrvChildRole *child_role)
|
||||
{
|
||||
BdrvChild *child = bdrv_root_attach_child(child_bs, child_name, child_role);
|
||||
QLIST_INSERT_HEAD(&parent_bs->children, child, next);
|
||||
return child;
|
||||
}
|
||||
|
||||
static void bdrv_detach_child(BdrvChild *child)
|
||||
{
|
||||
QLIST_REMOVE(child, next);
|
||||
if (child->next.le_prev) {
|
||||
QLIST_REMOVE(child, next);
|
||||
child->next.le_prev = NULL;
|
||||
}
|
||||
QLIST_REMOVE(child, next_parent);
|
||||
g_free(child->name);
|
||||
g_free(child);
|
||||
}
|
||||
|
||||
void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
|
||||
void bdrv_root_unref_child(BdrvChild *child)
|
||||
{
|
||||
BlockDriverState *child_bs;
|
||||
|
||||
child_bs = child->bs;
|
||||
bdrv_detach_child(child);
|
||||
bdrv_unref(child_bs);
|
||||
}
|
||||
|
||||
void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
|
||||
{
|
||||
if (child == NULL) {
|
||||
return;
|
||||
}
|
||||
@ -1218,9 +1231,7 @@ void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
|
||||
child->bs->inherits_from = NULL;
|
||||
}
|
||||
|
||||
child_bs = child->bs;
|
||||
bdrv_detach_child(child);
|
||||
bdrv_unref(child_bs);
|
||||
bdrv_root_unref_child(child);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1671,9 +1682,9 @@ static int bdrv_open_inherit(BlockDriverState **pbs, const char *filename,
|
||||
error_setg(errp, "Block protocol '%s' doesn't support the option "
|
||||
"'%s'", drv->format_name, entry->key);
|
||||
} else {
|
||||
error_setg(errp, "Block format '%s' used by device '%s' doesn't "
|
||||
"support the option '%s'", drv->format_name,
|
||||
bdrv_get_device_name(bs), entry->key);
|
||||
error_setg(errp,
|
||||
"Block format '%s' does not support the option '%s'",
|
||||
drv->format_name, entry->key);
|
||||
}
|
||||
|
||||
ret = -EINVAL;
|
||||
@ -2230,26 +2241,10 @@ void bdrv_close_all(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Note that bs->device_list.tqe_prev is initially null,
|
||||
* and gets set to non-null by QTAILQ_INSERT_TAIL(). Establish
|
||||
* the useful invariant "bs in bdrv_states iff bs->tqe_prev" by
|
||||
* resetting it to null on remove. */
|
||||
void bdrv_device_remove(BlockDriverState *bs)
|
||||
{
|
||||
QTAILQ_REMOVE(&bdrv_states, bs, device_list);
|
||||
bs->device_list.tqe_prev = NULL;
|
||||
}
|
||||
|
||||
/* make a BlockDriverState anonymous by removing from bdrv_state and
|
||||
* graph_bdrv_state list.
|
||||
Also, NULL terminate the device_name to prevent double remove */
|
||||
/* make a BlockDriverState anonymous by removing from graph_bdrv_state list.
|
||||
* Also, NULL terminate the device_name to prevent double remove */
|
||||
void bdrv_make_anon(BlockDriverState *bs)
|
||||
{
|
||||
/* Take care to remove bs from bdrv_states only when it's actually
|
||||
* in it. */
|
||||
if (bs->device_list.tqe_prev) {
|
||||
bdrv_device_remove(bs);
|
||||
}
|
||||
if (bs->node_name[0] != '\0') {
|
||||
QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list);
|
||||
}
|
||||
@ -2276,6 +2271,14 @@ static void change_parent_backing_link(BlockDriverState *from,
|
||||
{
|
||||
BdrvChild *c, *next;
|
||||
|
||||
if (from->blk) {
|
||||
/* FIXME We bypass blk_set_bs(), so we need to make these updates
|
||||
* manually. The root problem is not in this change function, but the
|
||||
* existence of BlockDriverState.blk. */
|
||||
to->blk = from->blk;
|
||||
from->blk = NULL;
|
||||
}
|
||||
|
||||
QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
|
||||
assert(c->role != &child_backing);
|
||||
c->bs = to;
|
||||
@ -2284,13 +2287,6 @@ static void change_parent_backing_link(BlockDriverState *from,
|
||||
bdrv_ref(to);
|
||||
bdrv_unref(from);
|
||||
}
|
||||
if (from->blk) {
|
||||
blk_set_bs(from->blk, to);
|
||||
if (!to->device_list.tqe_prev) {
|
||||
QTAILQ_INSERT_BEFORE(from, to, device_list);
|
||||
}
|
||||
bdrv_device_remove(from);
|
||||
}
|
||||
}
|
||||
|
||||
static void swap_feature_fields(BlockDriverState *bs_top,
|
||||
@ -2521,26 +2517,6 @@ ro_cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int bdrv_commit_all(void)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
|
||||
QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
|
||||
aio_context_acquire(aio_context);
|
||||
if (bs->drv && bs->backing) {
|
||||
int ret = bdrv_commit(bs);
|
||||
if (ret < 0) {
|
||||
aio_context_release(aio_context);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
aio_context_release(aio_context);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return values:
|
||||
* 0 - success
|
||||
@ -2989,12 +2965,23 @@ BlockDriverState *bdrv_next_node(BlockDriverState *bs)
|
||||
return QTAILQ_NEXT(bs, node_list);
|
||||
}
|
||||
|
||||
/* Iterates over all top-level BlockDriverStates, i.e. BDSs that are owned by
|
||||
* the monitor or attached to a BlockBackend */
|
||||
BlockDriverState *bdrv_next(BlockDriverState *bs)
|
||||
{
|
||||
if (!bs) {
|
||||
return QTAILQ_FIRST(&bdrv_states);
|
||||
if (!bs || bs->blk) {
|
||||
bs = blk_next_root_bs(bs);
|
||||
if (bs) {
|
||||
return bs;
|
||||
}
|
||||
}
|
||||
return QTAILQ_NEXT(bs, device_list);
|
||||
|
||||
/* Ignore all BDSs that are attached to a BlockBackend here; they have been
|
||||
* handled by the above block already */
|
||||
do {
|
||||
bs = bdrv_next_monitor_owned(bs);
|
||||
} while (bs && bs->blk);
|
||||
return bs;
|
||||
}
|
||||
|
||||
const char *bdrv_get_node_name(const BlockDriverState *bs)
|
||||
@ -3302,10 +3289,10 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Error **errp)
|
||||
|
||||
void bdrv_invalidate_cache_all(Error **errp)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *bs = NULL;
|
||||
Error *local_err = NULL;
|
||||
|
||||
QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
|
||||
while ((bs = bdrv_next(bs)) != NULL) {
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
|
||||
aio_context_acquire(aio_context);
|
||||
@ -3335,10 +3322,10 @@ static int bdrv_inactivate(BlockDriverState *bs)
|
||||
|
||||
int bdrv_inactivate_all(void)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *bs = NULL;
|
||||
int ret;
|
||||
|
||||
QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
|
||||
while ((bs = bdrv_next(bs)) != NULL) {
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
|
||||
aio_context_acquire(aio_context);
|
||||
@ -3844,10 +3831,10 @@ bool bdrv_recurse_is_first_non_filter(BlockDriverState *bs,
|
||||
*/
|
||||
bool bdrv_is_first_non_filter(BlockDriverState *candidate)
|
||||
{
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *bs = NULL;
|
||||
|
||||
/* walk down the bs forest recursively */
|
||||
QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
|
||||
while ((bs = bdrv_next(bs)) != NULL) {
|
||||
bool perm;
|
||||
|
||||
/* try to recurse in this top level bs */
|
||||
|
File diff suppressed because it is too large
Load Diff
44
block/io.c
44
block/io.c
@ -44,12 +44,6 @@ static int coroutine_fn bdrv_co_readv_em(BlockDriverState *bs,
|
||||
static int coroutine_fn bdrv_co_writev_em(BlockDriverState *bs,
|
||||
int64_t sector_num, int nb_sectors,
|
||||
QEMUIOVector *iov);
|
||||
static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
static BlockAIOCB *bdrv_co_aio_rw_vector(BlockDriverState *bs,
|
||||
int64_t sector_num,
|
||||
QEMUIOVector *qiov,
|
||||
@ -621,20 +615,6 @@ int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
||||
return bdrv_rw_co(bs, sector_num, buf, nb_sectors, false, 0);
|
||||
}
|
||||
|
||||
/* Just like bdrv_read(), but with I/O throttling temporarily disabled */
|
||||
int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
|
||||
uint8_t *buf, int nb_sectors)
|
||||
{
|
||||
bool enabled;
|
||||
int ret;
|
||||
|
||||
enabled = bs->io_limits_enabled;
|
||||
bs->io_limits_enabled = false;
|
||||
ret = bdrv_read(bs, sector_num, buf, nb_sectors);
|
||||
bs->io_limits_enabled = enabled;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return < 0 if error. Important errors are:
|
||||
-EIO generic I/O error (may happen for all errors)
|
||||
-ENOMEDIUM No media inserted.
|
||||
@ -939,7 +919,7 @@ out:
|
||||
/*
|
||||
* Handle a read request in coroutine context
|
||||
*/
|
||||
static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
@ -1284,7 +1264,7 @@ fail:
|
||||
/*
|
||||
* Handle a write request in coroutine context
|
||||
*/
|
||||
static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
||||
int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags)
|
||||
{
|
||||
@ -1445,26 +1425,6 @@ int coroutine_fn bdrv_co_write_zeroes(BlockDriverState *bs,
|
||||
BDRV_REQ_ZERO_WRITE | flags);
|
||||
}
|
||||
|
||||
int bdrv_flush_all(void)
|
||||
{
|
||||
BlockDriverState *bs = NULL;
|
||||
int result = 0;
|
||||
|
||||
while ((bs = bdrv_next(bs))) {
|
||||
AioContext *aio_context = bdrv_get_aio_context(bs);
|
||||
int ret;
|
||||
|
||||
aio_context_acquire(aio_context);
|
||||
ret = bdrv_flush(bs);
|
||||
if (ret < 0 && !result) {
|
||||
result = ret;
|
||||
}
|
||||
aio_context_release(aio_context);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct BdrvCoGetBlockStatusData {
|
||||
BlockDriverState *bs;
|
||||
BlockDriverState *base;
|
||||
|
@ -478,7 +478,7 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
file = blk_new_open("image", filename, NULL, NULL,
|
||||
file = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (file == NULL) {
|
||||
|
@ -121,11 +121,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
goto fail;
|
||||
}
|
||||
if (header.version != QCOW_VERSION) {
|
||||
char version[64];
|
||||
snprintf(version, sizeof(version), "QCOW version %" PRIu32,
|
||||
header.version);
|
||||
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
||||
bdrv_get_device_or_node_name(bs), "qcow", version);
|
||||
error_setg(errp, "Unsupported qcow version %" PRIu32, header.version);
|
||||
ret = -ENOTSUP;
|
||||
goto fail;
|
||||
}
|
||||
@ -797,7 +793,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
qcow_blk = blk_new_open("image", filename, NULL, NULL,
|
||||
qcow_blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (qcow_blk == NULL) {
|
||||
|
@ -198,22 +198,8 @@ static void cleanup_unknown_header_ext(BlockDriverState *bs)
|
||||
}
|
||||
}
|
||||
|
||||
static void GCC_FMT_ATTR(3, 4) report_unsupported(BlockDriverState *bs,
|
||||
Error **errp, const char *fmt, ...)
|
||||
{
|
||||
char msg[64];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, sizeof(msg), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
||||
bdrv_get_device_or_node_name(bs), "qcow2", msg);
|
||||
}
|
||||
|
||||
static void report_unsupported_feature(BlockDriverState *bs,
|
||||
Error **errp, Qcow2Feature *table, uint64_t mask)
|
||||
static void report_unsupported_feature(Error **errp, Qcow2Feature *table,
|
||||
uint64_t mask)
|
||||
{
|
||||
char *features = g_strdup("");
|
||||
char *old;
|
||||
@ -238,7 +224,7 @@ static void report_unsupported_feature(BlockDriverState *bs,
|
||||
g_free(old);
|
||||
}
|
||||
|
||||
report_unsupported(bs, errp, "%s", features);
|
||||
error_setg(errp, "Unsupported qcow2 feature(s): %s", features);
|
||||
g_free(features);
|
||||
}
|
||||
|
||||
@ -855,7 +841,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
goto fail;
|
||||
}
|
||||
if (header.version < 2 || header.version > 3) {
|
||||
report_unsupported(bs, errp, "QCOW version %" PRIu32, header.version);
|
||||
error_setg(errp, "Unsupported qcow2 version %" PRIu32, header.version);
|
||||
ret = -ENOTSUP;
|
||||
goto fail;
|
||||
}
|
||||
@ -935,7 +921,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
void *feature_table = NULL;
|
||||
qcow2_read_extensions(bs, header.header_length, ext_end,
|
||||
&feature_table, NULL);
|
||||
report_unsupported_feature(bs, errp, feature_table,
|
||||
report_unsupported_feature(errp, feature_table,
|
||||
s->incompatible_features &
|
||||
~QCOW2_INCOMPAT_MASK);
|
||||
ret = -ENOTSUP;
|
||||
@ -2173,7 +2159,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
blk = blk_new_open("image", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
@ -2238,7 +2224,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||
*/
|
||||
options = qdict_new();
|
||||
qdict_put(options, "driver", qstring_from_str("qcow2"));
|
||||
blk = blk_new_open("image-qcow2", filename, NULL, options,
|
||||
blk = blk_new_open(filename, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
@ -2300,7 +2286,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,
|
||||
/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
|
||||
options = qdict_new();
|
||||
qdict_put(options, "driver", qstring_from_str("qcow2"));
|
||||
blk = blk_new_open("image-flush", filename, NULL, options,
|
||||
blk = blk_new_open(filename, NULL, options,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
|
@ -400,11 +400,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
|
||||
}
|
||||
if (s->header.features & ~QED_FEATURE_MASK) {
|
||||
/* image uses unsupported feature bits */
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%" PRIx64,
|
||||
s->header.features & ~QED_FEATURE_MASK);
|
||||
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
||||
bdrv_get_device_or_node_name(bs), "QED", buf);
|
||||
error_setg(errp, "Unsupported QED features: %" PRIx64,
|
||||
s->header.features & ~QED_FEATURE_MASK);
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (!qed_is_cluster_size_valid(s->header.cluster_size)) {
|
||||
@ -577,7 +574,7 @@ static int qed_create(const char *filename, uint32_t cluster_size,
|
||||
return ret;
|
||||
}
|
||||
|
||||
blk = blk_new_open("image", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
|
@ -284,9 +284,17 @@ static void quorum_aio_cb(void *opaque, int ret)
|
||||
QuorumChildRequest *sacb = opaque;
|
||||
QuorumAIOCB *acb = sacb->parent;
|
||||
BDRVQuorumState *s = acb->common.bs->opaque;
|
||||
QuorumOpType type;
|
||||
bool rewrite = false;
|
||||
|
||||
if (ret == 0) {
|
||||
acb->success_count++;
|
||||
} else {
|
||||
QuorumOpType type;
|
||||
type = acb->is_read ? QUORUM_OP_TYPE_READ : QUORUM_OP_TYPE_WRITE;
|
||||
quorum_report_bad(type, acb->sector_num, acb->nb_sectors,
|
||||
sacb->aiocb->bs->node_name, ret);
|
||||
}
|
||||
|
||||
if (acb->is_read && s->read_pattern == QUORUM_READ_PATTERN_FIFO) {
|
||||
/* We try to read next child in FIFO order if we fail to read */
|
||||
if (ret < 0 && (acb->child_iter + 1) < s->num_children) {
|
||||
@ -303,15 +311,8 @@ static void quorum_aio_cb(void *opaque, int ret)
|
||||
return;
|
||||
}
|
||||
|
||||
type = acb->is_read ? QUORUM_OP_TYPE_READ : QUORUM_OP_TYPE_WRITE;
|
||||
sacb->ret = ret;
|
||||
acb->count++;
|
||||
if (ret == 0) {
|
||||
acb->success_count++;
|
||||
} else {
|
||||
quorum_report_bad(type, acb->sector_num, acb->nb_sectors,
|
||||
sacb->aiocb->bs->node_name, ret);
|
||||
}
|
||||
assert(acb->count <= s->num_children);
|
||||
assert(acb->success_count <= s->num_children);
|
||||
if (acb->count < s->num_children) {
|
||||
|
@ -1646,7 +1646,7 @@ static int sd_prealloc(const char *filename, Error **errp)
|
||||
void *buf = NULL;
|
||||
int ret;
|
||||
|
||||
blk = blk_new_open("image-prealloc", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
errp);
|
||||
if (blk == NULL) {
|
||||
@ -1843,7 +1843,7 @@ static int sd_create(const char *filename, QemuOpts *opts,
|
||||
goto out;
|
||||
}
|
||||
|
||||
blk = blk_new_open("backing", backing_file, NULL, NULL,
|
||||
blk = blk_new_open(backing_file, NULL, NULL,
|
||||
BDRV_O_PROTOCOL | BDRV_O_CACHE_WB, errp);
|
||||
if (blk == NULL) {
|
||||
ret = -EIO;
|
||||
|
@ -768,7 +768,7 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
blk = blk_new_open("image", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
|
@ -1838,7 +1838,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
blk = blk_new_open("image", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
|
13
block/vmdk.c
13
block/vmdk.c
@ -661,11 +661,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
||||
compressed =
|
||||
le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
|
||||
if (le32_to_cpu(header.version) > 3) {
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
|
||||
le32_to_cpu(header.version));
|
||||
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
||||
bdrv_get_device_or_node_name(bs), "vmdk", buf);
|
||||
error_setg(errp, "Unsupported VMDK version %" PRIu32,
|
||||
le32_to_cpu(header.version));
|
||||
return -ENOTSUP;
|
||||
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR) &&
|
||||
!compressed) {
|
||||
@ -1664,7 +1661,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
blk = blk_new_open("extent", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
@ -1949,7 +1946,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
blk = blk_new_open("backing", full_backing, NULL, NULL,
|
||||
blk = blk_new_open(full_backing, NULL, NULL,
|
||||
BDRV_O_NO_BACKING | BDRV_O_CACHE_WB, errp);
|
||||
g_free(full_backing);
|
||||
if (blk == NULL) {
|
||||
@ -2021,7 +2018,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
new_blk = blk_new_open("descriptor", filename, NULL, NULL,
|
||||
new_blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (new_blk == NULL) {
|
||||
|
@ -888,7 +888,7 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
blk = blk_new_open("image", filename, NULL, NULL,
|
||||
blk = blk_new_open(filename, NULL, NULL,
|
||||
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_PROTOCOL,
|
||||
&local_err);
|
||||
if (blk == NULL) {
|
||||
|
47
blockdev.c
47
blockdev.c
@ -147,6 +147,7 @@ void blockdev_auto_del(BlockBackend *blk)
|
||||
DriveInfo *dinfo = blk_legacy_dinfo(blk);
|
||||
|
||||
if (dinfo && dinfo->auto_del) {
|
||||
monitor_remove_blk(blk);
|
||||
blk_unref(blk);
|
||||
}
|
||||
}
|
||||
@ -561,7 +562,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
|
||||
if ((!file || !*file) && !qdict_size(bs_opts)) {
|
||||
BlockBackendRootState *blk_rs;
|
||||
|
||||
blk = blk_new(qemu_opts_id(opts), errp);
|
||||
blk = blk_new(errp);
|
||||
if (!blk) {
|
||||
goto early_err;
|
||||
}
|
||||
@ -597,8 +598,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
|
||||
bdrv_flags |= BDRV_O_INACTIVE;
|
||||
}
|
||||
|
||||
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags,
|
||||
errp);
|
||||
blk = blk_new_open(file, NULL, bs_opts, bdrv_flags, errp);
|
||||
if (!blk) {
|
||||
goto err_no_bs_opts;
|
||||
}
|
||||
@ -630,6 +630,12 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
|
||||
|
||||
blk_set_on_error(blk, on_read_error, on_write_error);
|
||||
|
||||
if (!monitor_add_blk(blk, qemu_opts_id(opts), errp)) {
|
||||
blk_unref(blk);
|
||||
blk = NULL;
|
||||
goto err_no_bs_opts;
|
||||
}
|
||||
|
||||
err_no_bs_opts:
|
||||
qemu_opts_del(opts);
|
||||
QDECREF(interval_dict);
|
||||
@ -717,6 +723,13 @@ void blockdev_close_all_bdrv_states(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Iterates over the list of monitor-owned BlockDriverStates */
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs)
|
||||
{
|
||||
return bs ? QTAILQ_NEXT(bs, monitor_list)
|
||||
: QTAILQ_FIRST(&monitor_bdrv_states);
|
||||
}
|
||||
|
||||
static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
|
||||
Error **errp)
|
||||
{
|
||||
@ -1173,7 +1186,7 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
|
||||
int ret;
|
||||
|
||||
if (!strcmp(device, "all")) {
|
||||
ret = bdrv_commit_all();
|
||||
ret = blk_commit_all();
|
||||
} else {
|
||||
BlockDriverState *bs;
|
||||
AioContext *aio_context;
|
||||
@ -2413,11 +2426,6 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* This follows the convention established by bdrv_make_anon() */
|
||||
if (bs->device_list.tqe_prev) {
|
||||
bdrv_device_remove(bs);
|
||||
}
|
||||
|
||||
blk_remove_bs(blk);
|
||||
|
||||
if (!blk_dev_has_tray(blk)) {
|
||||
@ -2465,8 +2473,6 @@ static void qmp_blockdev_insert_anon_medium(const char *device,
|
||||
|
||||
blk_insert_bs(blk, bs);
|
||||
|
||||
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
|
||||
|
||||
if (!blk_dev_has_tray(blk)) {
|
||||
/* For tray-less devices, blockdev-close-tray is a no-op (or may not be
|
||||
* called at all); therefore, the medium needs to be pushed into the
|
||||
@ -2859,13 +2865,16 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
|
||||
blk_remove_bs(blk);
|
||||
}
|
||||
|
||||
/* if we have a device attached to this BlockDriverState
|
||||
* then we need to make the drive anonymous until the device
|
||||
* can be removed. If this is a drive with no device backing
|
||||
* then we can just get rid of the block driver state right here.
|
||||
/* Make the BlockBackend and the attached BlockDriverState anonymous */
|
||||
monitor_remove_blk(blk);
|
||||
if (blk_bs(blk)) {
|
||||
bdrv_make_anon(blk_bs(blk));
|
||||
}
|
||||
|
||||
/* If this BlockBackend has a device attached to it, its refcount will be
|
||||
* decremented when the device is removed; otherwise we have to do so here.
|
||||
*/
|
||||
if (blk_get_attached_dev(blk)) {
|
||||
blk_hide_on_behalf_of_hmp_drive_del(blk);
|
||||
/* Further I/O must not pause the guest */
|
||||
blk_set_on_error(blk, BLOCKDEV_ON_ERROR_REPORT,
|
||||
BLOCKDEV_ON_ERROR_REPORT);
|
||||
@ -3898,6 +3907,7 @@ void hmp_drive_add_node(Monitor *mon, const char *optstr)
|
||||
qdict = qemu_opts_to_qdict(opts, NULL);
|
||||
|
||||
if (!qdict_get_try_str(qdict, "node-name")) {
|
||||
QDECREF(qdict);
|
||||
error_report("'node-name' needs to be specified");
|
||||
goto out;
|
||||
}
|
||||
@ -3975,6 +3985,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
||||
|
||||
if (bs && bdrv_key_required(bs)) {
|
||||
if (blk) {
|
||||
monitor_remove_blk(blk);
|
||||
blk_unref(blk);
|
||||
} else {
|
||||
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
|
||||
@ -4004,6 +4015,7 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
|
||||
}
|
||||
|
||||
if (has_id) {
|
||||
/* blk_by_name() never returns a BB that is not owned by the monitor */
|
||||
blk = blk_by_name(id);
|
||||
if (!blk) {
|
||||
error_setg(errp, "Cannot find block backend %s", id);
|
||||
@ -4051,6 +4063,7 @@ void qmp_x_blockdev_del(bool has_id, const char *id,
|
||||
}
|
||||
|
||||
if (blk) {
|
||||
monitor_remove_blk(blk);
|
||||
blk_unref(blk);
|
||||
} else {
|
||||
QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);
|
||||
@ -4221,7 +4234,7 @@ QemuOptsList qemu_common_drive_opts = {
|
||||
|
||||
static QemuOptsList qemu_root_bds_opts = {
|
||||
.name = "root-bds",
|
||||
.head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head),
|
||||
.head = QTAILQ_HEAD_INITIALIZER(qemu_root_bds_opts.head),
|
||||
.desc = {
|
||||
{
|
||||
.name = "discard",
|
||||
|
5
cpus.c
5
cpus.c
@ -29,6 +29,7 @@
|
||||
#include "qapi/qmp/qerror.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "exec/gdbstub.h"
|
||||
#include "sysemu/dma.h"
|
||||
#include "sysemu/kvm.h"
|
||||
@ -734,7 +735,7 @@ static int do_vm_stop(RunState state)
|
||||
}
|
||||
|
||||
bdrv_drain_all();
|
||||
ret = bdrv_flush_all();
|
||||
ret = blk_flush_all();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1433,7 +1434,7 @@ int vm_stop_force_state(RunState state)
|
||||
bdrv_drain_all();
|
||||
/* Make sure to return an error if the flush in a previous vm_stop()
|
||||
* failed. */
|
||||
return bdrv_flush_all();
|
||||
return blk_flush_all();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,8 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict)
|
||||
|
||||
err:
|
||||
if (dinfo) {
|
||||
blk_unref(blk_by_legacy_dinfo(dinfo));
|
||||
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
|
||||
monitor_remove_blk(blk);
|
||||
blk_unref(blk);
|
||||
}
|
||||
}
|
||||
|
@ -917,7 +917,7 @@ static int blk_connect(struct XenDevice *xendev)
|
||||
|
||||
/* setup via xenbus -> create new block driver instance */
|
||||
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
|
||||
blkdev->blk = blk_new_open(blkdev->dev, blkdev->filename, NULL, options,
|
||||
blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
|
||||
qflags, &local_err);
|
||||
if (!blkdev->blk) {
|
||||
xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
|
||||
|
@ -201,7 +201,6 @@ int bdrv_create(BlockDriver *drv, const char* filename,
|
||||
int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp);
|
||||
BlockDriverState *bdrv_new_root(void);
|
||||
BlockDriverState *bdrv_new(void);
|
||||
void bdrv_device_remove(BlockDriverState *bs);
|
||||
void bdrv_make_anon(BlockDriverState *bs);
|
||||
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
|
||||
void bdrv_replace_in_backing_chain(BlockDriverState *old,
|
||||
@ -230,8 +229,6 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state);
|
||||
void bdrv_reopen_abort(BDRVReopenState *reopen_state);
|
||||
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
||||
uint8_t *buf, int nb_sectors);
|
||||
int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num,
|
||||
uint8_t *buf, int nb_sectors);
|
||||
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
||||
const uint8_t *buf, int nb_sectors);
|
||||
int bdrv_write_zeroes(BlockDriverState *bs, int64_t sector_num,
|
||||
@ -274,7 +271,6 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
|
||||
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
||||
void bdrv_refresh_limits(BlockDriverState *bs, Error **errp);
|
||||
int bdrv_commit(BlockDriverState *bs);
|
||||
int bdrv_commit_all(void);
|
||||
int bdrv_change_backing_file(BlockDriverState *bs,
|
||||
const char *backing_file, const char *backing_fmt);
|
||||
void bdrv_register(BlockDriver *bdrv);
|
||||
@ -373,7 +369,6 @@ int bdrv_inactivate_all(void);
|
||||
/* Ensure contents are flushed to disk. */
|
||||
int bdrv_flush(BlockDriverState *bs);
|
||||
int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
|
||||
int bdrv_flush_all(void);
|
||||
void bdrv_close_all(void);
|
||||
void bdrv_drain(BlockDriverState *bs);
|
||||
void bdrv_drain_all(void);
|
||||
@ -414,6 +409,7 @@ BlockDriverState *bdrv_lookup_bs(const char *device,
|
||||
bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base);
|
||||
BlockDriverState *bdrv_next_node(BlockDriverState *bs);
|
||||
BlockDriverState *bdrv_next(BlockDriverState *bs);
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
|
||||
int bdrv_is_encrypted(BlockDriverState *bs);
|
||||
int bdrv_key_required(BlockDriverState *bs);
|
||||
int bdrv_set_key(BlockDriverState *bs, const char *key);
|
||||
|
@ -442,8 +442,6 @@ struct BlockDriverState {
|
||||
char node_name[32];
|
||||
/* element of the list of named nodes building the graph */
|
||||
QTAILQ_ENTRY(BlockDriverState) node_list;
|
||||
/* element of the list of "drives" the guest sees */
|
||||
QTAILQ_ENTRY(BlockDriverState) device_list;
|
||||
/* element of the list of all BlockDriverStates (all_bdrv_states) */
|
||||
QTAILQ_ENTRY(BlockDriverState) bs_list;
|
||||
/* element of the list of monitor-owned BDS */
|
||||
@ -501,8 +499,6 @@ extern BlockDriver bdrv_file;
|
||||
extern BlockDriver bdrv_raw;
|
||||
extern BlockDriver bdrv_qcow2;
|
||||
|
||||
extern QTAILQ_HEAD(BdrvStates, BlockDriverState) bdrv_states;
|
||||
|
||||
/**
|
||||
* bdrv_setup_io_funcs:
|
||||
*
|
||||
@ -512,6 +508,13 @@ extern QTAILQ_HEAD(BdrvStates, BlockDriverState) bdrv_states;
|
||||
*/
|
||||
void bdrv_setup_io_funcs(BlockDriver *bdrv);
|
||||
|
||||
int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
||||
int64_t offset, unsigned int bytes, QEMUIOVector *qiov,
|
||||
BdrvRequestFlags flags);
|
||||
|
||||
int get_tmp_filename(char *filename, int size);
|
||||
BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
|
||||
const char *filename);
|
||||
@ -696,6 +699,11 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target,
|
||||
|
||||
void hmp_drive_add_node(Monitor *mon, const char *optstr);
|
||||
|
||||
BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
|
||||
const char *child_name,
|
||||
const BdrvChildRole *child_role);
|
||||
void bdrv_root_unref_child(BdrvChild *child);
|
||||
|
||||
void blk_set_bs(BlockBackend *blk, BlockDriverState *bs);
|
||||
|
||||
void blk_dev_change_media_cb(BlockBackend *blk, bool load);
|
||||
|
@ -100,9 +100,6 @@
|
||||
#define QERR_UNDEFINED_ERROR \
|
||||
"An undefined error has occurred"
|
||||
|
||||
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
|
||||
"'%s' uses a %s feature which is not supported by this qemu version: %s"
|
||||
|
||||
#define QERR_UNSUPPORTED \
|
||||
"this feature or command is not currently supported"
|
||||
|
||||
|
@ -59,11 +59,10 @@ typedef struct BlockDevOps {
|
||||
void (*resize_cb)(void *opaque);
|
||||
} BlockDevOps;
|
||||
|
||||
BlockBackend *blk_new(const char *name, Error **errp);
|
||||
BlockBackend *blk_new_with_bs(const char *name, Error **errp);
|
||||
BlockBackend *blk_new_open(const char *name, const char *filename,
|
||||
const char *reference, QDict *options, int flags,
|
||||
Error **errp);
|
||||
BlockBackend *blk_new(Error **errp);
|
||||
BlockBackend *blk_new_with_bs(Error **errp);
|
||||
BlockBackend *blk_new_open(const char *filename, const char *reference,
|
||||
QDict *options, int flags, Error **errp);
|
||||
int blk_get_refcnt(BlockBackend *blk);
|
||||
void blk_ref(BlockBackend *blk);
|
||||
void blk_unref(BlockBackend *blk);
|
||||
@ -71,13 +70,14 @@ void blk_remove_all_bs(void);
|
||||
const char *blk_name(BlockBackend *blk);
|
||||
BlockBackend *blk_by_name(const char *name);
|
||||
BlockBackend *blk_next(BlockBackend *blk);
|
||||
BlockDriverState *blk_next_root_bs(BlockDriverState *bs);
|
||||
bool monitor_add_blk(BlockBackend *blk, const char *name, Error **errp);
|
||||
void monitor_remove_blk(BlockBackend *blk);
|
||||
|
||||
BlockDriverState *blk_bs(BlockBackend *blk);
|
||||
void blk_remove_bs(BlockBackend *blk);
|
||||
void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs);
|
||||
|
||||
void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk);
|
||||
|
||||
void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow);
|
||||
void blk_iostatus_enable(BlockBackend *blk);
|
||||
bool blk_iostatus_is_enabled(const BlockBackend *blk);
|
||||
@ -127,6 +127,7 @@ int blk_co_discard(BlockBackend *blk, int64_t sector_num, int nb_sectors);
|
||||
int blk_co_flush(BlockBackend *blk);
|
||||
int blk_flush(BlockBackend *blk);
|
||||
int blk_flush_all(void);
|
||||
int blk_commit_all(void);
|
||||
void blk_drain(BlockBackend *blk);
|
||||
void blk_drain_all(void);
|
||||
void blk_set_on_error(BlockBackend *blk, BlockdevOnError on_read_error,
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "ui/console.h"
|
||||
#include "ui/input.h"
|
||||
#include "sysemu/blockdev.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "audio/audio.h"
|
||||
#include "disas/disas.h"
|
||||
#include "sysemu/balloon.h"
|
||||
@ -3483,7 +3484,7 @@ static void monitor_find_completion_by_table(Monitor *mon,
|
||||
int i;
|
||||
const char *ptype, *str, *name;
|
||||
const mon_cmd_t *cmd;
|
||||
BlockDriverState *bs;
|
||||
BlockBackend *blk = NULL;
|
||||
|
||||
if (nb_args <= 1) {
|
||||
/* command completion */
|
||||
@ -3538,8 +3539,8 @@ static void monitor_find_completion_by_table(Monitor *mon,
|
||||
case 'B':
|
||||
/* block device name completion */
|
||||
readline_set_completion_index(mon->rs, strlen(str));
|
||||
for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
|
||||
name = bdrv_get_device_name(bs);
|
||||
while ((blk = blk_next(blk)) != NULL) {
|
||||
name = blk_name(blk);
|
||||
if (str[0] == '\0' ||
|
||||
!strncmp(name, str, strlen(str))) {
|
||||
readline_add_completion(mon->rs, name);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "qemu-common.h"
|
||||
#include "monitor/monitor.h"
|
||||
#include "sysemu/sysemu.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
#include "qemu/error-report.h"
|
||||
#include "qemu/timer.h"
|
||||
#include "sysemu/char.h"
|
||||
@ -628,7 +629,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
bdrv_commit_all();
|
||||
blk_commit_all();
|
||||
break;
|
||||
case 'b':
|
||||
qemu_chr_be_event(chr, CHR_EVENT_BREAK);
|
||||
|
50
qemu-img.c
50
qemu-img.c
@ -245,8 +245,7 @@ static int img_open_password(BlockBackend *blk, const char *filename,
|
||||
}
|
||||
|
||||
|
||||
static BlockBackend *img_open_opts(const char *id,
|
||||
const char *optstr,
|
||||
static BlockBackend *img_open_opts(const char *optstr,
|
||||
QemuOpts *opts, int flags,
|
||||
bool require_io, bool quiet)
|
||||
{
|
||||
@ -254,7 +253,7 @@ static BlockBackend *img_open_opts(const char *id,
|
||||
Error *local_err = NULL;
|
||||
BlockBackend *blk;
|
||||
options = qemu_opts_to_qdict(opts, NULL);
|
||||
blk = blk_new_open(id, NULL, NULL, options, flags, &local_err);
|
||||
blk = blk_new_open(NULL, NULL, options, flags, &local_err);
|
||||
if (!blk) {
|
||||
error_reportf_err(local_err, "Could not open '%s'", optstr);
|
||||
return NULL;
|
||||
@ -267,7 +266,7 @@ static BlockBackend *img_open_opts(const char *id,
|
||||
return blk;
|
||||
}
|
||||
|
||||
static BlockBackend *img_open_file(const char *id, const char *filename,
|
||||
static BlockBackend *img_open_file(const char *filename,
|
||||
const char *fmt, int flags,
|
||||
bool require_io, bool quiet)
|
||||
{
|
||||
@ -280,7 +279,7 @@ static BlockBackend *img_open_file(const char *id, const char *filename,
|
||||
qdict_put(options, "driver", qstring_from_str(fmt));
|
||||
}
|
||||
|
||||
blk = blk_new_open(id, filename, NULL, options, flags, &local_err);
|
||||
blk = blk_new_open(filename, NULL, options, flags, &local_err);
|
||||
if (!blk) {
|
||||
error_reportf_err(local_err, "Could not open '%s': ", filename);
|
||||
return NULL;
|
||||
@ -294,8 +293,7 @@ static BlockBackend *img_open_file(const char *id, const char *filename,
|
||||
}
|
||||
|
||||
|
||||
static BlockBackend *img_open(const char *id,
|
||||
bool image_opts,
|
||||
static BlockBackend *img_open(bool image_opts,
|
||||
const char *filename,
|
||||
const char *fmt, int flags,
|
||||
bool require_io, bool quiet)
|
||||
@ -312,9 +310,9 @@ static BlockBackend *img_open(const char *id,
|
||||
if (!opts) {
|
||||
return NULL;
|
||||
}
|
||||
blk = img_open_opts(id, filename, opts, flags, true, quiet);
|
||||
blk = img_open_opts(filename, opts, flags, true, quiet);
|
||||
} else {
|
||||
blk = img_open_file(id, filename, fmt, flags, true, quiet);
|
||||
blk = img_open_file(filename, fmt, flags, true, quiet);
|
||||
}
|
||||
return blk;
|
||||
}
|
||||
@ -686,7 +684,7 @@ static int img_check(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt, flags, true, quiet);
|
||||
blk = img_open(image_opts, filename, fmt, flags, true, quiet);
|
||||
if (!blk) {
|
||||
return 1;
|
||||
}
|
||||
@ -878,7 +876,7 @@ static int img_commit(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt, flags, true, quiet);
|
||||
blk = img_open(image_opts, filename, fmt, flags, true, quiet);
|
||||
if (!blk) {
|
||||
return 1;
|
||||
}
|
||||
@ -1212,13 +1210,13 @@ static int img_compare(int argc, char **argv)
|
||||
goto out3;
|
||||
}
|
||||
|
||||
blk1 = img_open("image_1", image_opts, filename1, fmt1, flags, true, quiet);
|
||||
blk1 = img_open(image_opts, filename1, fmt1, flags, true, quiet);
|
||||
if (!blk1) {
|
||||
ret = 2;
|
||||
goto out3;
|
||||
}
|
||||
|
||||
blk2 = img_open("image_2", image_opts, filename2, fmt2, flags, true, quiet);
|
||||
blk2 = img_open(image_opts, filename2, fmt2, flags, true, quiet);
|
||||
if (!blk2) {
|
||||
ret = 2;
|
||||
goto out2;
|
||||
@ -1899,11 +1897,8 @@ static int img_convert(int argc, char **argv)
|
||||
|
||||
total_sectors = 0;
|
||||
for (bs_i = 0; bs_i < bs_n; bs_i++) {
|
||||
char *id = bs_n > 1 ? g_strdup_printf("source_%d", bs_i)
|
||||
: g_strdup("source");
|
||||
blk[bs_i] = img_open(id, image_opts, argv[optind + bs_i],
|
||||
blk[bs_i] = img_open(image_opts, argv[optind + bs_i],
|
||||
fmt, src_flags, true, quiet);
|
||||
g_free(id);
|
||||
if (!blk[bs_i]) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
@ -2048,8 +2043,7 @@ static int img_convert(int argc, char **argv)
|
||||
* the bdrv_create() call which takes different params.
|
||||
* Not critical right now, so fix can wait...
|
||||
*/
|
||||
out_blk = img_open_file("target", out_filename,
|
||||
out_fmt, flags, true, quiet);
|
||||
out_blk = img_open_file(out_filename, out_fmt, flags, true, quiet);
|
||||
if (!out_blk) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
@ -2240,7 +2234,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
||||
}
|
||||
g_hash_table_insert(filenames, (gpointer)filename, NULL);
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt,
|
||||
blk = img_open(image_opts, filename, fmt,
|
||||
BDRV_O_FLAGS | BDRV_O_NO_BACKING,
|
||||
false, false);
|
||||
if (!blk) {
|
||||
@ -2572,8 +2566,7 @@ static int img_map(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt,
|
||||
BDRV_O_FLAGS, true, false);
|
||||
blk = img_open(image_opts, filename, fmt, BDRV_O_FLAGS, true, false);
|
||||
if (!blk) {
|
||||
return 1;
|
||||
}
|
||||
@ -2718,8 +2711,7 @@ static int img_snapshot(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Open the image */
|
||||
blk = img_open("image", image_opts, filename, NULL,
|
||||
bdrv_oflags, true, quiet);
|
||||
blk = img_open(image_opts, filename, NULL, bdrv_oflags, true, quiet);
|
||||
if (!blk) {
|
||||
return 1;
|
||||
}
|
||||
@ -2890,7 +2882,7 @@ static int img_rebase(int argc, char **argv)
|
||||
* Ignore the old backing file for unsafe rebase in case we want to correct
|
||||
* the reference to a renamed or moved backing file.
|
||||
*/
|
||||
blk = img_open("image", image_opts, filename, fmt, flags, true, quiet);
|
||||
blk = img_open(image_opts, filename, fmt, flags, true, quiet);
|
||||
if (!blk) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
@ -2916,7 +2908,7 @@ static int img_rebase(int argc, char **argv)
|
||||
}
|
||||
|
||||
bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
|
||||
blk_old_backing = blk_new_open("old_backing", backing_name, NULL,
|
||||
blk_old_backing = blk_new_open(backing_name, NULL,
|
||||
options, src_flags, &local_err);
|
||||
if (!blk_old_backing) {
|
||||
error_reportf_err(local_err,
|
||||
@ -2933,7 +2925,7 @@ static int img_rebase(int argc, char **argv)
|
||||
options = NULL;
|
||||
}
|
||||
|
||||
blk_new_backing = blk_new_open("new_backing", out_baseimg, NULL,
|
||||
blk_new_backing = blk_new_open(out_baseimg, NULL,
|
||||
options, src_flags, &local_err);
|
||||
if (!blk_new_backing) {
|
||||
error_reportf_err(local_err,
|
||||
@ -3227,7 +3219,7 @@ static int img_resize(int argc, char **argv)
|
||||
n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0);
|
||||
qemu_opts_del(param);
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt,
|
||||
blk = img_open(image_opts, filename, fmt,
|
||||
BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
|
||||
if (!blk) {
|
||||
ret = -1;
|
||||
@ -3387,7 +3379,7 @@ static int img_amend(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
blk = img_open("image", image_opts, filename, fmt, flags, true, quiet);
|
||||
blk = img_open(image_opts, filename, fmt, flags, true, quiet);
|
||||
if (!blk) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
|
@ -61,7 +61,7 @@ static int openfile(char *name, int flags, QDict *opts)
|
||||
return 1;
|
||||
}
|
||||
|
||||
qemuio_blk = blk_new_open("hda", name, NULL, opts, flags, &local_err);
|
||||
qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
|
||||
if (!qemuio_blk) {
|
||||
error_reportf_err(local_err, "can't open%s%s: ",
|
||||
name ? " device " : "", name ?: "");
|
||||
|
@ -831,13 +831,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
options = qemu_opts_to_qdict(opts, NULL);
|
||||
qemu_opts_reset(&file_opts);
|
||||
blk = blk_new_open("hda", NULL, NULL, options, flags, &local_err);
|
||||
blk = blk_new_open(NULL, NULL, options, flags, &local_err);
|
||||
} else {
|
||||
if (fmt) {
|
||||
options = qdict_new();
|
||||
qdict_put(options, "driver", qstring_from_str(fmt));
|
||||
}
|
||||
blk = blk_new_open("hda", srcpath, NULL, options, flags, &local_err);
|
||||
blk = blk_new_open(srcpath, NULL, options, flags, &local_err);
|
||||
}
|
||||
|
||||
if (!blk) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
stub-obj-y += arch-query-cpu-def.o
|
||||
stub-obj-y += bdrv-commit-all.o
|
||||
stub-obj-y += bdrv-next-monitor-owned.o
|
||||
stub-obj-y += blk-commit-all.o
|
||||
stub-obj-y += blockdev-close-all-bdrv-states.o
|
||||
stub-obj-y += clock-warp.o
|
||||
stub-obj-y += cpu-get-clock.o
|
||||
|
8
stubs/bdrv-next-monitor-owned.c
Normal file
8
stubs/bdrv-next-monitor-owned.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu-common.h"
|
||||
#include "block/block.h"
|
||||
|
||||
BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs)
|
||||
{
|
||||
return NULL;
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#include "qemu/osdep.h"
|
||||
#include "qemu-common.h"
|
||||
#include "block/block.h"
|
||||
#include "sysemu/block-backend.h"
|
||||
|
||||
int bdrv_commit_all(void)
|
||||
int blk_commit_all(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -22,18 +22,18 @@ autoclear_features 0x0
|
||||
refcount_order 4
|
||||
header_length 104
|
||||
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Unknown incompatible feature: 8000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature
|
||||
|
||||
=== Image with multiple incompatible feature bits ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Unknown incompatible feature: e000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature, Unknown incompatible feature: 6000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature, Unknown incompatible feature: c000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test1, test2, Unknown incompatible feature: 8000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test1, test2, test3
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test2, Unknown incompatible feature: a000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: e000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: 6000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: c000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, Unknown incompatible feature: 8000000000000000
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, test3
|
||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test2, Unknown incompatible feature: a000000000000000
|
||||
=== Create image with unknown autoclear feature bit ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||
|
@ -5,16 +5,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/
|
||||
=== Unknown option ===
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
|
||||
=== Unknown protocol option ===
|
||||
|
@ -5,16 +5,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/
|
||||
=== Unknown option ===
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=on,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=1234,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
Testing: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: Block format 'qcow2' used by device 'drive0' doesn't support the option 'unknown_opt'
|
||||
QEMU_PROG: -drive file=TEST_DIR/t.qcow2,format=qcow2,unknown_opt=foo,if=none,id=drive0: Block format 'qcow2' does not support the option 'unknown_opt'
|
||||
|
||||
|
||||
=== Unknown protocol option ===
|
||||
|
@ -21,7 +21,7 @@ QMP_VERSION
|
||||
{"error": {"class": "GenericError", "desc": "Device name 'test-node' conflicts with an existing node name"}}
|
||||
{"error": {"class": "GenericError", "desc": "node-name=disk is conflicting with a device id"}}
|
||||
{"error": {"class": "GenericError", "desc": "Duplicate node name"}}
|
||||
{"error": {"class": "GenericError", "desc": "node-name=disk3 is conflicting with a device id"}}
|
||||
{"error": {"class": "GenericError", "desc": "Device name 'disk3' conflicts with an existing node name"}}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
|
||||
|
@ -35,6 +35,7 @@ sector_size = 512
|
||||
offset = 10
|
||||
|
||||
class TestQuorumEvents(iotests.QMPTestCase):
|
||||
read_pattern = 'quorum'
|
||||
|
||||
def create_blkdebug_file(self, blkdebug_file, bad_sector):
|
||||
file = open(blkdebug_file, 'w')
|
||||
@ -48,6 +49,7 @@ sector = "%d"
|
||||
|
||||
def setUp(self):
|
||||
driveopts = ['driver=quorum', 'vote-threshold=2']
|
||||
driveopts.append('read-pattern=%s' % self.read_pattern)
|
||||
for i in range(len(imgs)):
|
||||
iotests.qemu_img('create', '-f', iotests.imgfmt, imgs[i], '1M')
|
||||
self.create_blkdebug_file(img_conf[i], i + offset)
|
||||
@ -112,7 +114,11 @@ sector = "%d"
|
||||
self.vm.hmp_qemu_io("drive0", "aio_read %d %d" %
|
||||
((offset + i) * sector_size, sector_size))
|
||||
self.vm.qtest("clock_step %d" % delay)
|
||||
self.do_check_event('img%d' % i, offset + i)
|
||||
# In fifo mode only errors in the first child are detected
|
||||
if i > 0 and self.read_pattern == 'fifo':
|
||||
self.do_check_event(None)
|
||||
else:
|
||||
self.do_check_event('img%d' % i, offset + i)
|
||||
|
||||
# I/O errors in different children: all events are emitted
|
||||
delay = 2 * event_rate
|
||||
@ -120,10 +126,17 @@ sector = "%d"
|
||||
self.vm.hmp_qemu_io("drive0", "aio_read %d %d" %
|
||||
((offset + i) * sector_size, sector_size))
|
||||
self.vm.qtest("clock_step %d" % delay)
|
||||
self.do_check_event('img%d' % i, offset + i)
|
||||
# In fifo mode only errors in the first child are detected
|
||||
if i > 0 and self.read_pattern == 'fifo':
|
||||
self.do_check_event(None)
|
||||
else:
|
||||
self.do_check_event('img%d' % i, offset + i)
|
||||
|
||||
# No more pending events
|
||||
self.do_check_event(None)
|
||||
|
||||
class TestFifoQuorumEvents(TestQuorumEvents):
|
||||
read_pattern = 'fifo'
|
||||
|
||||
if __name__ == '__main__':
|
||||
iotests.main(supported_fmts=["raw"])
|
||||
|
@ -1,5 +1,5 @@
|
||||
.
|
||||
..
|
||||
----------------------------------------------------------------------
|
||||
Ran 1 tests
|
||||
Ran 2 tests
|
||||
|
||||
OK
|
||||
|
Loading…
Reference in New Issue
Block a user