Skip to content

Commit

Permalink
block/raw-posix: Strip protocol prefix on creation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XanClic authored and stefanhaRH committed Mar 13, 2014
1 parent 18fa1c4 commit cc28c6a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions block/raw-posix.c
Expand Up @@ -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) {
Expand Down

0 comments on commit cc28c6a

Please sign in to comment.