diff options
author | Max Reitz <mreitz@redhat.com> | 2014-03-08 00:39:44 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-03-13 14:42:25 +0100 |
commit | cc28c6aa46334be01f3e65a74601ae38f94bd602 (patch) | |
tree | 58d6d060a1ed7f0f70b8ff8d8eebccf5369f9311 /block/raw-posix.c | |
parent | 18fa1c42a314a3e18f097b28ec5189a144d36f99 (diff) |
block/raw-posix: Strip protocol prefix on creation
The hdev_create() implementation in block/raw-posix.c is used by the
"host_device", "host_cdrom" and "host_floppy" protocol block drivers
together. Thus, any of the associated prefixes may occur and exactly one
should should be stripped, if it does (thus,
"host_device:host_cdrom:/dev/cdrom" is not shortened to "/dev/cdrom").
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'block/raw-posix.c')
-rw-r--r-- | block/raw-posix.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/block/raw-posix.c b/block/raw-posix.c index 697cd2ee68..1688e16c64 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1776,6 +1776,18 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options, int ret = 0; struct stat stat_buf; int64_t total_size = 0; + bool has_prefix; + + /* This function is used by all three protocol block drivers and therefore + * any of these three prefixes may be given. + * The return value has to be stored somewhere, otherwise this is an error + * due to -Werror=unused-value. */ + has_prefix = + strstart(filename, "host_device:", &filename) || + strstart(filename, "host_cdrom:" , &filename) || + strstart(filename, "host_floppy:", &filename); + + (void)has_prefix; /* Read out options */ while (options && options->name) { |