From 98289620e0460fa595581020ab20127da4a2fc44 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 10 Jul 2013 15:47:39 +0200 Subject: block: Don't parse protocol from file.filename One of the major reasons for doing something new for -blockdev and blockdev-add was that the old block layer code parses filenames instead of just taking them literally. So we should really leave it untouched when it's passing using the new interfaces (like -drive file.filename=...). This allows opening relative file names that contain a colon. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- include/block/block.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/block/block.h b/include/block/block.h index dd8eca1be1..eeb48162af 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -111,7 +111,8 @@ bool bdrv_io_limits_enabled(BlockDriverState *bs); void bdrv_init(void); void bdrv_init_with_whitelist(void); -BlockDriver *bdrv_find_protocol(const char *filename); +BlockDriver *bdrv_find_protocol(const char *filename, + bool allow_protocol_prefix); BlockDriver *bdrv_find_format(const char *format_name); BlockDriver *bdrv_find_whitelisted_format(const char *format_name, bool readonly); -- cgit v1.2.3-55-g7522 From f0f0fdfeec6c67ad374114ecc4b3e3ccde5e94d2 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 5 Jul 2013 13:48:01 +0200 Subject: block: Add return value for bdrv_flush_all() bdrv_flush() can fail, and bdrv_flush_all() should return an error as well if this happens for a block device. It returns the first error return now, but still at least tries to flush the remaining devices even in error cases. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- block.c | 10 ++++++++-- include/block/block.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/block.c b/block.c index 2df65c88bf..b56024113b 100644 --- a/block.c +++ b/block.c @@ -2910,13 +2910,19 @@ int bdrv_get_flags(BlockDriverState *bs) return bs->open_flags; } -void bdrv_flush_all(void) +int bdrv_flush_all(void) { BlockDriverState *bs; + int result = 0; QTAILQ_FOREACH(bs, &bdrv_states, list) { - bdrv_flush(bs); + int ret = bdrv_flush(bs); + if (ret < 0 && !result) { + result = ret; + } } + + return result; } int bdrv_has_zero_init_1(BlockDriverState *bs) diff --git a/include/block/block.h b/include/block/block.h index eeb48162af..b6b9014a9c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -267,7 +267,7 @@ void bdrv_clear_incoming_migration_all(void); /* Ensure contents are flushed to disk. */ int bdrv_flush(BlockDriverState *bs); int coroutine_fn bdrv_co_flush(BlockDriverState *bs); -void bdrv_flush_all(void); +int bdrv_flush_all(void); void bdrv_close_all(void); void bdrv_drain_all(void); -- cgit v1.2.3-55-g7522 From 5698346391b306c2c84358c68ee897c095d714cc Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Fri, 5 Jul 2013 13:49:54 +0200 Subject: cpus: Add return value for vm_stop() If flushing the block devices fails, return an error. The VM is stopped anyway. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- cpus.c | 20 +++++++++++++------- include/sysemu/sysemu.h | 4 ++-- stubs/vm-stop.c | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/cpus.c b/cpus.c index f141428225..29277e109f 100644 --- a/cpus.c +++ b/cpus.c @@ -434,17 +434,21 @@ bool cpu_is_stopped(CPUState *cpu) return !runstate_is_running() || cpu->stopped; } -static void do_vm_stop(RunState state) +static int do_vm_stop(RunState state) { + int ret = 0; + if (runstate_is_running()) { cpu_disable_ticks(); pause_all_vcpus(); runstate_set(state); vm_state_notify(0, state); bdrv_drain_all(); - bdrv_flush_all(); + ret = bdrv_flush_all(); monitor_protocol_event(QEVENT_STOP, NULL); } + + return ret; } static bool cpu_can_run(CPUState *cpu) @@ -1070,7 +1074,7 @@ void cpu_stop_current(void) } } -void vm_stop(RunState state) +int vm_stop(RunState state) { if (qemu_in_vcpu_thread()) { qemu_system_vmstop_request(state); @@ -1079,19 +1083,21 @@ void vm_stop(RunState state) * vm_stop() has been requested. */ cpu_stop_current(); - return; + return 0; } - do_vm_stop(state); + + return do_vm_stop(state); } /* does a state transition even if the VM is already stopped, current state is forgotten forever */ -void vm_stop_force_state(RunState state) +int vm_stop_force_state(RunState state) { if (runstate_is_running()) { - vm_stop(state); + return vm_stop(state); } else { runstate_set(state); + return 0; } } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index d85bdc0cac..3caeb66eb2 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -35,8 +35,8 @@ void vm_state_notify(int running, RunState state); #define VMRESET_REPORT true void vm_start(void); -void vm_stop(RunState state); -void vm_stop_force_state(RunState state); +int vm_stop(RunState state); +int vm_stop_force_state(RunState state); typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER = 0, diff --git a/stubs/vm-stop.c b/stubs/vm-stop.c index 45689354f6..f82c897dfe 100644 --- a/stubs/vm-stop.c +++ b/stubs/vm-stop.c @@ -1,7 +1,7 @@ #include "qemu-common.h" #include "sysemu/sysemu.h" -void vm_stop(RunState state) +int vm_stop(RunState state) { abort(); } -- cgit v1.2.3-55-g7522