summaryrefslogtreecommitdiffstats
path: root/blockdev.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-05-28 15:22:40 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-05-28 15:22:40 +0100
commit3ee933c9d4869891a5614fba4815a3857dc3ef8f (patch)
treeab2a3c5fac9f46379737f18872b5d728f8df2343 /blockdev.c
parent052367ba8573809957f1abd288f79fbbda05a284 (diff)
parentfbab9ccbdbb4d8a18abf07b6dc05b3b4a2164cd0 (diff)
downloadhqemu-3ee933c9d4869891a5614fba4815a3857dc3ef8f.zip
hqemu-3ee933c9d4869891a5614fba4815a3857dc3ef8f.tar.gz
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Block pull request # gpg: Signature made Wed 28 May 2014 13:31:15 BST using RSA key ID 81AB73C8 # gpg: Can't check signature: public key not found * remotes/stefanha/tags/block-pull-request: (33 commits) block/sheepdog: Don't use qerror_report() block/sheepdog: Fix silent sd_open(), sd_create() failures block/sheepdog: Propagate errors to open and create methods block/sheepdog: Propagate errors through find_vdi_name() block/sheepdog: Propagate errors through do_sd_create() block/sheepdog: Propagate errors through sd_prealloc() block/sheepdog: Propagate errors through get_sheep_fd() block/sheepdog: Propagate errors through connect_to_sdog() block/vvfat: Propagate errors through init_directories() block/vvfat: Propagate errors through enable_write_target() block/ssh: Propagate errors to open and create methods block/ssh: Propagate errors through connect_to_ssh() block/ssh: Propagate errors through authenticate() block/ssh: Propagate errors through check_host_key() block/ssh: Drop superfluous libssh2_session_last_errno() calls block/rbd: Propagate errors to open and create methods qemu-nbd: Don't use qerror_report() blockdev: Don't use qerror_report() in do_drive_del() blockdev: Don't use qerror_report_err() in drive_init() docs: Define refcount_bits value ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/blockdev.c b/blockdev.c
index 1cbcc1c..8cc42fb 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -34,7 +34,6 @@
#include "hw/block/block.h"
#include "block/blockjob.h"
#include "monitor/monitor.h"
-#include "qapi/qmp/qerror.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qapi/qmp/types.h"
@@ -730,7 +729,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
&error_abort);
qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);
if (local_err) {
- qerror_report_err(local_err);
+ error_report("%s", error_get_pretty(local_err));
error_free(local_err);
goto fail;
}
@@ -942,7 +941,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
dinfo = blockdev_init(filename, bs_opts, &local_err);
if (dinfo == NULL) {
if (local_err) {
- qerror_report_err(local_err);
+ error_report("%s", error_get_pretty(local_err));
error_free(local_err);
}
goto fail;
@@ -1334,8 +1333,8 @@ static void external_snapshot_prepare(BlkTransactionState *common,
return;
}
- if (bdrv_in_use(state->old_bs)) {
- error_set(errp, QERR_DEVICE_IN_USE, device);
+ if (bdrv_op_is_blocked(state->old_bs,
+ BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT, errp)) {
return;
}
@@ -1557,8 +1556,7 @@ exit:
static void eject_device(BlockDriverState *bs, int force, Error **errp)
{
- if (bdrv_in_use(bs)) {
- error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_EJECT, errp)) {
return;
}
if (!bdrv_dev_has_removable_media(bs)) {
@@ -1760,14 +1758,16 @@ int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const char *id = qdict_get_str(qdict, "id");
BlockDriverState *bs;
+ Error *local_err = NULL;
bs = bdrv_find(id);
if (!bs) {
- qerror_report(QERR_DEVICE_NOT_FOUND, id);
+ error_report("Device '%s' not found", id);
return -1;
}
- if (bdrv_in_use(bs)) {
- qerror_report(QERR_DEVICE_IN_USE, id);
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
+ error_report("%s", error_get_pretty(local_err));
+ error_free(local_err);
return -1;
}
@@ -1888,6 +1888,10 @@ void qmp_block_stream(const char *device, bool has_base,
return;
}
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
+ return;
+ }
+
if (base) {
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
@@ -1932,6 +1936,10 @@ void qmp_block_commit(const char *device,
return;
}
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT, errp)) {
+ return;
+ }
+
/* default top_bs is the active layer */
top_bs = bs;
@@ -2023,8 +2031,7 @@ void qmp_drive_backup(const char *device, const char *target,
}
}
- if (bdrv_in_use(bs)) {
- error_set(errp, QERR_DEVICE_IN_USE, device);
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_BACKUP_SOURCE, errp)) {
return;
}
@@ -2157,8 +2164,7 @@ void qmp_drive_mirror(const char *device, const char *target,
}
}
- if (bdrv_in_use(bs)) {
- error_set(errp, QERR_DEVICE_IN_USE, device);
+ if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR, errp)) {
return;
}
OpenPOWER on IntegriCloud