[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/16] block/raw-posix: Use raw_normalize_devicepath(
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 06/16] block/raw-posix: Use raw_normalize_devicepath() |
Date: |
Fri, 4 Sep 2015 22:10:37 +0200 |
From: Max Reitz <address@hidden>
The filename given to qemu_open() in block/raw-posix.c should generally
have been processed by raw_normalize_devicepath(); unless we are only
probing (in which case the caller often checks whether the file is a
block device or not, and this property will be changed by
raw_normalize_devicepath() on NetBSD) or it is about a deprecated device
(i.e. floppy).
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/raw-posix.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/block/raw-posix.c b/block/raw-posix.c
index 855febe..30df8ad 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -670,11 +670,17 @@ static int raw_reopen_prepare(BDRVReopenState *state,
/* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */
if (raw_s->fd == -1) {
- assert(!(raw_s->open_flags & O_CREAT));
- raw_s->fd = qemu_open(state->bs->filename, raw_s->open_flags);
- if (raw_s->fd == -1) {
- error_setg_errno(errp, errno, "Could not reopen file");
- ret = -1;
+ const char *normalized_filename = state->bs->filename;
+ ret = raw_normalize_devicepath(&normalized_filename);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "Could not normalize device path");
+ } else {
+ assert(!(raw_s->open_flags & O_CREAT));
+ raw_s->fd = qemu_open(normalized_filename, raw_s->open_flags);
+ if (raw_s->fd == -1) {
+ error_setg_errno(errp, errno, "Could not reopen file");
+ ret = -1;
+ }
}
}
@@ -2314,6 +2320,12 @@ static int hdev_create(const char *filename, QemuOpts
*opts,
(void)has_prefix;
+ ret = raw_normalize_devicepath(&filename);
+ if (ret < 0) {
+ error_setg_errno(errp, -ret, "Could not normalize device path");
+ return ret;
+ }
+
/* Read out options */
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
BDRV_SECTOR_SIZE);
--
1.8.3.1
- [Qemu-devel] [PULL 00/16] Block patches, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 01/16] qemu-iotests: qemu machine type support, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 03/16] qemu-iotests: s390x: fix test 041 and 055, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 04/16] qemu-iotests: s390x: fix test 049, reject negative sizes in QemuOpts, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 02/16] qemu-iotests: disable default qemu devices for cross-platform compatibility, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 05/16] qemu-iotests: s390x: fix test 130, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 07/16] qemu-img: Fix crash in amend invocation, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 06/16] block/raw-posix: Use raw_normalize_devicepath(),
Kevin Wolf <=
- [Qemu-devel] [PULL 08/16] iotests: More options for VM.add_drive(), Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 09/16] iotests: Respect -nodefaults in tests 41 and 55, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 10/16] iotests: Do not suppress segfaults in bash tests, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 11/16] iotests: Warn if python subprocess is killed, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 15/16] qcow2: reorder fields in Qcow2CachedTable to reduce padding, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 14/16] docs: document how to configure the qcow2 L2/refcount caches, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 12/16] qcow2: mark the memory as no longer needed after qcow2_cache_empty(), Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 16/16] quorum: validate vote threshold against num_children even if read-pattern is fifo, Kevin Wolf, 2015/09/04
- [Qemu-devel] [PULL 13/16] qcow2: add option to clean unused cache entries after some time, Kevin Wolf, 2015/09/04
- Re: [Qemu-devel] [PULL 00/16] Block patches, Peter Maydell, 2015/09/07