* [Qemu-devel] [PATCH] block/raw-posix: Use raw_normalize_devicepath()
@ 2015-08-12 15:33 Max Reitz
2015-08-13 13:50 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Max Reitz @ 2015-08-12 15:33 UTC (permalink / raw)
To: qemu-block; +Cc: Kevin Wolf, qemu-devel, Max Reitz
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 <mreitz@redhat.com>
---
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);
--
2.4.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] block/raw-posix: Use raw_normalize_devicepath()
2015-08-12 15:33 [Qemu-devel] [PATCH] block/raw-posix: Use raw_normalize_devicepath() Max Reitz
@ 2015-08-13 13:50 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2015-08-13 13:50 UTC (permalink / raw)
To: Max Reitz; +Cc: qemu-devel, qemu-block
Am 12.08.2015 um 17:33 hat Max Reitz geschrieben:
> 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 <mreitz@redhat.com>
The patch isn't actually doing as much as the commit message suggests:
Some calls of qemu_open() where we know that normalising wouldn't change
anything (because we're not on NetBSD or not using a block device) still
don't have the raw_normalize_devicepath() call (e.g. raw_create() and
cdrom_reopen()).
I'm applying the patch anyway because the result is the same.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-13 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-12 15:33 [Qemu-devel] [PATCH] block/raw-posix: Use raw_normalize_devicepath() Max Reitz
2015-08-13 13:50 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).