diff options
author | Max Reitz <mreitz@redhat.com> | 2013-09-05 14:45:29 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2013-09-12 10:12:48 +0200 |
commit | 34b5d2c68eb4082c288e70fb99c61af8f7b96fde (patch) | |
tree | 7c4c1e4e248a8e044dd891b0e54de1fcc03d7434 /qemu-io.c | |
parent | d5124c00d80b4d948509f2c7f6b54228d9981f75 (diff) | |
download | qemu-34b5d2c68eb4082c288e70fb99c61af8f7b96fde.tar.gz qemu-34b5d2c68eb4082c288e70fb99c61af8f7b96fde.tar.bz2 qemu-34b5d2c68eb4082c288e70fb99c61af8f7b96fde.zip |
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associated
functions to allow more specific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r-- | qemu-io.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -46,21 +46,27 @@ static const cmdinfo_t close_cmd = { static int openfile(char *name, int flags, int growable) { + Error *local_err = NULL; + if (qemuio_bs) { fprintf(stderr, "file open already, try 'help close'\n"); return 1; } if (growable) { - if (bdrv_file_open(&qemuio_bs, name, NULL, flags)) { - fprintf(stderr, "%s: can't open device %s\n", progname, name); + if (bdrv_file_open(&qemuio_bs, name, NULL, flags, &local_err)) { + fprintf(stderr, "%s: can't open device %s: %s\n", progname, name, + error_get_pretty(local_err)); + error_free(local_err); return 1; } } else { qemuio_bs = bdrv_new("hda"); - if (bdrv_open(qemuio_bs, name, NULL, flags, NULL) < 0) { - fprintf(stderr, "%s: can't open device %s\n", progname, name); + if (bdrv_open(qemuio_bs, name, NULL, flags, NULL, &local_err) < 0) { + fprintf(stderr, "%s: can't open device %s: %s\n", progname, name, + error_get_pretty(local_err)); + error_free(local_err); bdrv_unref(qemuio_bs); qemuio_bs = NULL; return 1; |