* [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
@ 2012-10-19 14:27 Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 1/6] error: add error_set_errno and error_setg_errno Luiz Capitulino
` (6 more replies)
0 siblings, 7 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:27 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
By adding error propagation to bdrv_img_create() we improve error reporting
in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
Please, check individual patches for details.
o v2
- Fix small inconsistencies
- Drop patches that moved the printing of the "Formatting" message to
qemu-img
Luiz Capitulino (5):
block: bdrv_img_create(): add Error ** argument
qemu-img: img_create(): pass Error object to bdrv_img_create()
qemu-img: img_create(): drop unneeded goto and ret variable
qmp: qmp_transaction(): pass Error object to bdrv_img_create()
block: bdrv_img_create(): drop unused error handling code
Paolo Bonzini (1):
error: add error_set_errno and error_setg_errno
block.c | 60 +++++++++++++++++++++++++-----------------------------------
block.h | 6 +++---
blockdev.c | 13 +++++++------
error.c | 28 ++++++++++++++++++++++++++++
error.h | 9 +++++++++
qemu-img.c | 19 ++++++++++---------
6 files changed, 82 insertions(+), 53 deletions(-)
--
1.7.12.315.g682ce8b
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 1/6] error: add error_set_errno and error_setg_errno
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 2/6] block: bdrv_img_create(): add Error ** argument Luiz Capitulino
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
From: Paolo Bonzini <pbonzini@redhat.com>
These functions help maintaining homogeneous formatting of error
messages that include strerror values.
Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
This patch is also in a pull request from Paolo to Anthony. We can just merge
it along with this series and git will do the right thing when merging it in
master.
error.c | 28 ++++++++++++++++++++++++++++
error.h | 9 +++++++++
2 files changed, 37 insertions(+)
diff --git a/error.c b/error.c
index 1f05fc4..128d88c 100644
--- a/error.c
+++ b/error.c
@@ -43,6 +43,34 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
*errp = err;
}
+void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
+ const char *fmt, ...)
+{
+ Error *err;
+ char *msg1;
+ va_list ap;
+
+ if (errp == NULL) {
+ return;
+ }
+ assert(*errp == NULL);
+
+ err = g_malloc0(sizeof(*err));
+
+ va_start(ap, fmt);
+ msg1 = g_strdup_vprintf(fmt, ap);
+ if (os_errno != 0) {
+ err->msg = g_strdup_printf("%s: %s", msg1, strerror(os_errno));
+ g_free(msg1);
+ } else {
+ err->msg = msg1;
+ }
+ va_end(ap);
+ err->err_class = err_class;
+
+ *errp = err;
+}
+
Error *error_copy(const Error *err)
{
Error *err_new;
diff --git a/error.h b/error.h
index da7fed3..4d52e73 100644
--- a/error.h
+++ b/error.h
@@ -30,10 +30,19 @@ typedef struct Error Error;
void error_set(Error **err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4);
/**
+ * Set an indirect pointer to an error given a ErrorClass value and a
+ * printf-style human message, followed by a strerror() string if
+ * @os_error is not zero.
+ */
+void error_set_errno(Error **err, int os_error, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(4, 5);
+
+/**
* Same as error_set(), but sets a generic error
*/
#define error_setg(err, fmt, ...) \
error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
+#define error_setg_errno(err, os_error, fmt, ...) \
+ error_set_errno(err, os_error, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
/**
* Returns true if an indirect pointer to an error is pointing to a valid
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 2/6] block: bdrv_img_create(): add Error ** argument
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 1/6] error: add error_set_errno and error_setg_errno Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 3/6] qemu-img: img_create(): pass Error object to bdrv_img_create() Luiz Capitulino
` (4 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
This commit adds an Error ** argument to bdrv_img_create() and set it
appropriately on error.
Callers of bdrv_img_create() pass NULL for the new argument and still
rely on bdrv_img_create()'s return value. Next commits will change
callers to use the Error object instead.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
block.c | 22 +++++++++++++++++++++-
block.h | 2 +-
blockdev.c | 2 +-
qemu-img.c | 2 +-
4 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index e95f613..da74c05 100644
--- a/block.c
+++ b/block.c
@@ -4294,7 +4294,7 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
int bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
- char *options, uint64_t img_size, int flags)
+ char *options, uint64_t img_size, int flags, Error **errp)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *backing_fmt, *backing_file, *size;
@@ -4307,6 +4307,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
drv = bdrv_find_format(fmt);
if (!drv) {
error_report("Unknown file format '%s'", fmt);
+ error_setg(errp, "Unknown file format '%s'", fmt);
ret = -EINVAL;
goto out;
}
@@ -4314,6 +4315,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
proto_drv = bdrv_find_protocol(filename);
if (!proto_drv) {
error_report("Unknown protocol '%s'", filename);
+ error_setg(errp, "Unknown protocol '%s'", filename);
ret = -EINVAL;
goto out;
}
@@ -4333,6 +4335,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
param = parse_option_parameters(options, create_options, param);
if (param == NULL) {
error_report("Invalid options for file format '%s'.", fmt);
+ error_setg(errp, "Invalid options for file format '%s'.", fmt);
ret = -EINVAL;
goto out;
}
@@ -4343,6 +4346,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
base_filename)) {
error_report("Backing file not supported for file format '%s'",
fmt);
+ error_setg(errp, "Backing file not supported for file format '%s'",
+ fmt);
ret = -EINVAL;
goto out;
}
@@ -4352,6 +4357,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) {
error_report("Backing file format not supported for file "
"format '%s'", fmt);
+ error_setg(errp, "Backing file format not supported for file "
+ "format '%s'", fmt);
ret = -EINVAL;
goto out;
}
@@ -4362,6 +4369,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (!strcmp(filename, backing_file->value.s)) {
error_report("Error: Trying to create an image with the "
"same filename as the backing file");
+ error_setg(errp, "Error: Trying to create an image with the "
+ "same filename as the backing file");
ret = -EINVAL;
goto out;
}
@@ -4373,6 +4382,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (!backing_drv) {
error_report("Unknown backing file format '%s'",
backing_fmt->value.s);
+ error_setg(errp, "Unknown backing file format '%s'",
+ backing_fmt->value.s);
ret = -EINVAL;
goto out;
}
@@ -4396,6 +4407,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
ret = bdrv_open(bs, backing_file->value.s, back_flags, backing_drv);
if (ret < 0) {
error_report("Could not open '%s'", backing_file->value.s);
+ error_setg_errno(errp, -ret, "Could not open '%s'",
+ backing_file->value.s);
goto out;
}
bdrv_get_geometry(bs, &size);
@@ -4405,6 +4418,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
set_option_parameter(param, BLOCK_OPT_SIZE, buf);
} else {
error_report("Image creation needs a size parameter");
+ error_setg(errp, "Image creation needs a size parameter");
ret = -EINVAL;
goto out;
}
@@ -4420,12 +4434,18 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (ret == -ENOTSUP) {
error_report("Formatting or formatting option not supported for "
"file format '%s'", fmt);
+ error_setg(errp,"Formatting or formatting option not supported for "
+ "file format '%s'", fmt);
} else if (ret == -EFBIG) {
error_report("The image size is too large for file format '%s'",
fmt);
+ error_setg(errp, "The image size is too large for file format '%s'",
+ fmt);
} else {
error_report("%s: error while creating %s: %s", filename, fmt,
strerror(-ret));
+ error_setg(errp, "%s: error while creating %s: %s", filename, fmt,
+ strerror(-ret));
}
}
diff --git a/block.h b/block.h
index e2d89d7..0dac865 100644
--- a/block.h
+++ b/block.h
@@ -341,7 +341,7 @@ int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
int bdrv_img_create(const char *filename, const char *fmt,
const char *base_filename, const char *base_fmt,
- char *options, uint64_t img_size, int flags);
+ char *options, uint64_t img_size, int flags, Error **errp);
void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
void *qemu_blockalign(BlockDriverState *bs, size_t size);
diff --git a/blockdev.c b/blockdev.c
index 99828ad..9dddefd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -783,7 +783,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
ret = bdrv_img_create(new_image_file, format,
states->old_bs->filename,
states->old_bs->drv->format_name,
- NULL, -1, flags);
+ NULL, -1, flags, NULL);
if (ret) {
error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
goto delete_and_fail;
diff --git a/qemu-img.c b/qemu-img.c
index f17f187..b841012 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -362,7 +362,7 @@ static int img_create(int argc, char **argv)
}
ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
- options, img_size, BDRV_O_FLAGS);
+ options, img_size, BDRV_O_FLAGS, NULL);
out:
if (ret) {
return 1;
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 3/6] qemu-img: img_create(): pass Error object to bdrv_img_create()
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 1/6] error: add error_set_errno and error_setg_errno Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 2/6] block: bdrv_img_create(): add Error ** argument Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 4/6] qemu-img: img_create(): drop unneeded goto and ret variable Luiz Capitulino
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
qemu-img.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index b841012..a5f2969 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -301,6 +301,7 @@ static int img_create(int argc, char **argv)
const char *filename;
const char *base_filename = NULL;
char *options = NULL;
+ Error *local_err = NULL;
for(;;) {
c = getopt(argc, argv, "F:b:f:he6o:");
@@ -361,8 +362,14 @@ static int img_create(int argc, char **argv)
goto out;
}
- ret = bdrv_img_create(filename, fmt, base_filename, base_fmt,
- options, img_size, BDRV_O_FLAGS, NULL);
+ bdrv_img_create(filename, fmt, base_filename, base_fmt,
+ options, img_size, BDRV_O_FLAGS, &local_err);
+ if (error_is_set(&local_err)) {
+ error_report("%s", error_get_pretty(local_err));
+ error_free(local_err);
+ ret = -1;
+ }
+
out:
if (ret) {
return 1;
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 4/6] qemu-img: img_create(): drop unneeded goto and ret variable
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
` (2 preceding siblings ...)
2012-10-19 14:28 ` [Qemu-devel] [PATCH 3/6] qemu-img: img_create(): pass Error object to bdrv_img_create() Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 5/6] qmp: qmp_transaction(): pass Error object to bdrv_img_create() Luiz Capitulino
` (2 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
qemu-img.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index a5f2969..dafe705 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -294,7 +294,7 @@ static int add_old_style_options(const char *fmt, QEMUOptionParameter *list,
static int img_create(int argc, char **argv)
{
- int c, ret = 0;
+ int c;
uint64_t img_size = -1;
const char *fmt = "raw";
const char *base_fmt = NULL;
@@ -351,15 +351,13 @@ static int img_create(int argc, char **argv)
error_report("Invalid image size specified! You may use k, M, G or "
"T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
- ret = -1;
- goto out;
+ return 1;
}
img_size = (uint64_t)sval;
}
if (options && is_help_option(options)) {
- ret = print_block_option_help(filename, fmt);
- goto out;
+ return print_block_option_help(filename, fmt);
}
bdrv_img_create(filename, fmt, base_filename, base_fmt,
@@ -367,13 +365,9 @@ static int img_create(int argc, char **argv)
if (error_is_set(&local_err)) {
error_report("%s", error_get_pretty(local_err));
error_free(local_err);
- ret = -1;
- }
-
-out:
- if (ret) {
return 1;
}
+
return 0;
}
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 5/6] qmp: qmp_transaction(): pass Error object to bdrv_img_create()
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
` (3 preceding siblings ...)
2012-10-19 14:28 ` [Qemu-devel] [PATCH 4/6] qemu-img: img_create(): drop unneeded goto and ret variable Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 6/6] block: bdrv_img_create(): drop unused error handling code Luiz Capitulino
2012-11-02 13:25 ` [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
blockdev.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 9dddefd..f2ec780 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -701,6 +701,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
int ret = 0;
BlockdevActionList *dev_entry = dev_list;
BlkTransactionStates *states, *next;
+ Error *local_err = NULL;
QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionStates) snap_bdrv_states;
QSIMPLEQ_INIT(&snap_bdrv_states);
@@ -780,12 +781,12 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
/* create new image w/backing file */
if (mode != NEW_IMAGE_MODE_EXISTING) {
- ret = bdrv_img_create(new_image_file, format,
- states->old_bs->filename,
- states->old_bs->drv->format_name,
- NULL, -1, flags, NULL);
- if (ret) {
- error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
+ bdrv_img_create(new_image_file, format,
+ states->old_bs->filename,
+ states->old_bs->drv->format_name,
+ NULL, -1, flags, &local_err);
+ if (error_is_set(&local_err)) {
+ error_propagate(errp, local_err);
goto delete_and_fail;
}
}
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Qemu-devel] [PATCH 6/6] block: bdrv_img_create(): drop unused error handling code
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
` (4 preceding siblings ...)
2012-10-19 14:28 ` [Qemu-devel] [PATCH 5/6] qmp: qmp_transaction(): pass Error object to bdrv_img_create() Luiz Capitulino
@ 2012-10-19 14:28 ` Luiz Capitulino
2012-11-02 13:25 ` [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
6 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-10-19 14:28 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, armbru
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
block.c | 40 +++++-----------------------------------
block.h | 6 +++---
2 files changed, 8 insertions(+), 38 deletions(-)
diff --git a/block.c b/block.c
index da74c05..673f4a7 100644
--- a/block.c
+++ b/block.c
@@ -4292,9 +4292,9 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
}
-int bdrv_img_create(const char *filename, const char *fmt,
- const char *base_filename, const char *base_fmt,
- char *options, uint64_t img_size, int flags, Error **errp)
+void bdrv_img_create(const char *filename, const char *fmt,
+ const char *base_filename, const char *base_fmt,
+ char *options, uint64_t img_size, int flags, Error **errp)
{
QEMUOptionParameter *param = NULL, *create_options = NULL;
QEMUOptionParameter *backing_fmt, *backing_file, *size;
@@ -4306,18 +4306,14 @@ int bdrv_img_create(const char *filename, const char *fmt,
/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv) {
- error_report("Unknown file format '%s'", fmt);
error_setg(errp, "Unknown file format '%s'", fmt);
- ret = -EINVAL;
- goto out;
+ return;
}
proto_drv = bdrv_find_protocol(filename);
if (!proto_drv) {
- error_report("Unknown protocol '%s'", filename);
error_setg(errp, "Unknown protocol '%s'", filename);
- ret = -EINVAL;
- goto out;
+ return;
}
create_options = append_option_parameters(create_options,
@@ -4334,9 +4330,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (options) {
param = parse_option_parameters(options, create_options, param);
if (param == NULL) {
- error_report("Invalid options for file format '%s'.", fmt);
error_setg(errp, "Invalid options for file format '%s'.", fmt);
- ret = -EINVAL;
goto out;
}
}
@@ -4344,22 +4338,16 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (base_filename) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE,
base_filename)) {
- error_report("Backing file not supported for file format '%s'",
- fmt);
error_setg(errp, "Backing file not supported for file format '%s'",
fmt);
- ret = -EINVAL;
goto out;
}
}
if (base_fmt) {
if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) {
- error_report("Backing file format not supported for file "
- "format '%s'", fmt);
error_setg(errp, "Backing file format not supported for file "
"format '%s'", fmt);
- ret = -EINVAL;
goto out;
}
}
@@ -4367,11 +4355,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
if (backing_file && backing_file->value.s) {
if (!strcmp(filename, backing_file->value.s)) {
- error_report("Error: Trying to create an image with the "
- "same filename as the backing file");
error_setg(errp, "Error: Trying to create an image with the "
"same filename as the backing file");
- ret = -EINVAL;
goto out;
}
}
@@ -4380,11 +4365,8 @@ int bdrv_img_create(const char *filename, const char *fmt,
if (backing_fmt && backing_fmt->value.s) {
backing_drv = bdrv_find_format(backing_fmt->value.s);
if (!backing_drv) {
- error_report("Unknown backing file format '%s'",
- backing_fmt->value.s);
error_setg(errp, "Unknown backing file format '%s'",
backing_fmt->value.s);
- ret = -EINVAL;
goto out;
}
}
@@ -4406,7 +4388,6 @@ int bdrv_img_create(const char *filename, const char *fmt,
ret = bdrv_open(bs, backing_file->value.s, back_flags, backing_drv);
if (ret < 0) {
- error_report("Could not open '%s'", backing_file->value.s);
error_setg_errno(errp, -ret, "Could not open '%s'",
backing_file->value.s);
goto out;
@@ -4417,9 +4398,7 @@ int bdrv_img_create(const char *filename, const char *fmt,
snprintf(buf, sizeof(buf), "%" PRId64, size);
set_option_parameter(param, BLOCK_OPT_SIZE, buf);
} else {
- error_report("Image creation needs a size parameter");
error_setg(errp, "Image creation needs a size parameter");
- ret = -EINVAL;
goto out;
}
}
@@ -4429,21 +4408,14 @@ int bdrv_img_create(const char *filename, const char *fmt,
puts("");
ret = bdrv_create(drv, filename, param);
-
if (ret < 0) {
if (ret == -ENOTSUP) {
- error_report("Formatting or formatting option not supported for "
- "file format '%s'", fmt);
error_setg(errp,"Formatting or formatting option not supported for "
"file format '%s'", fmt);
} else if (ret == -EFBIG) {
- error_report("The image size is too large for file format '%s'",
- fmt);
error_setg(errp, "The image size is too large for file format '%s'",
fmt);
} else {
- error_report("%s: error while creating %s: %s", filename, fmt,
- strerror(-ret));
error_setg(errp, "%s: error while creating %s: %s", filename, fmt,
strerror(-ret));
}
@@ -4456,6 +4428,4 @@ out:
if (bs) {
bdrv_delete(bs);
}
-
- return ret;
}
diff --git a/block.h b/block.h
index 0dac865..69bb4be 100644
--- a/block.h
+++ b/block.h
@@ -339,9 +339,9 @@ int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
int64_t pos, int size);
-int bdrv_img_create(const char *filename, const char *fmt,
- const char *base_filename, const char *base_fmt,
- char *options, uint64_t img_size, int flags, Error **errp);
+void bdrv_img_create(const char *filename, const char *fmt,
+ const char *base_filename, const char *base_fmt,
+ char *options, uint64_t img_size, int flags, Error **errp);
void bdrv_set_buffer_alignment(BlockDriverState *bs, int align);
void *qemu_blockalign(BlockDriverState *bs, size_t size);
--
1.7.12.315.g682ce8b
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
` (5 preceding siblings ...)
2012-10-19 14:28 ` [Qemu-devel] [PATCH 6/6] block: bdrv_img_create(): drop unused error handling code Luiz Capitulino
@ 2012-11-02 13:25 ` Luiz Capitulino
2012-11-02 13:40 ` Kevin Wolf
6 siblings, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2012-11-02 13:25 UTC (permalink / raw)
To: kwolf; +Cc: pbonzini, qemu-devel, armbru
On Fri, 19 Oct 2012 11:27:59 -0300
Luiz Capitulino <lcapitulino@redhat.com> wrote:
> By adding error propagation to bdrv_img_create() we improve error reporting
> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
>
> Please, check individual patches for details.
Kevin, is this in your review queue?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-11-02 13:25 ` [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
@ 2012-11-02 13:40 ` Kevin Wolf
2012-11-02 13:42 ` Luiz Capitulino
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Wolf @ 2012-11-02 13:40 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: pbonzini, qemu-devel, armbru
Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> On Fri, 19 Oct 2012 11:27:59 -0300
> Luiz Capitulino <lcapitulino@redhat.com> wrote:
>
>> By adding error propagation to bdrv_img_create() we improve error reporting
>> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
>>
>> Please, check individual patches for details.
>
> Kevin, is this in your review queue?
Yes, it is. With KVM Forum and lots of other patch series, no promises
though.
Kevin
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-11-02 13:40 ` Kevin Wolf
@ 2012-11-02 13:42 ` Luiz Capitulino
2012-11-29 16:34 ` Luiz Capitulino
0 siblings, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2012-11-02 13:42 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, armbru
On Fri, 02 Nov 2012 14:40:03 +0100
Kevin Wolf <kwolf@redhat.com> wrote:
> Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> > On Fri, 19 Oct 2012 11:27:59 -0300
> > Luiz Capitulino <lcapitulino@redhat.com> wrote:
> >
> >> By adding error propagation to bdrv_img_create() we improve error reporting
> >> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
> >>
> >> Please, check individual patches for details.
> >
> > Kevin, is this in your review queue?
>
> Yes, it is. With KVM Forum and lots of other patch series, no promises
> though.
Sure, just wanted to know if you were aware about it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-11-02 13:42 ` Luiz Capitulino
@ 2012-11-29 16:34 ` Luiz Capitulino
2012-11-30 11:39 ` Kevin Wolf
0 siblings, 1 reply; 13+ messages in thread
From: Luiz Capitulino @ 2012-11-29 16:34 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, armbru
On Fri, 2 Nov 2012 11:42:32 -0200
Luiz Capitulino <lcapitulino@redhat.com> wrote:
> On Fri, 02 Nov 2012 14:40:03 +0100
> Kevin Wolf <kwolf@redhat.com> wrote:
>
> > Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> > > On Fri, 19 Oct 2012 11:27:59 -0300
> > > Luiz Capitulino <lcapitulino@redhat.com> wrote:
> > >
> > >> By adding error propagation to bdrv_img_create() we improve error reporting
> > >> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
> > >>
> > >> Please, check individual patches for details.
> > >
> > > Kevin, is this in your review queue?
> >
> > Yes, it is. With KVM Forum and lots of other patch series, no promises
> > though.
>
> Sure, just wanted to know if you were aware about it.
Still in your queue? :)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-11-29 16:34 ` Luiz Capitulino
@ 2012-11-30 11:39 ` Kevin Wolf
2012-11-30 11:44 ` Luiz Capitulino
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Wolf @ 2012-11-30 11:39 UTC (permalink / raw)
To: Luiz Capitulino; +Cc: pbonzini, qemu-devel, armbru
Am 29.11.2012 17:34, schrieb Luiz Capitulino:
> On Fri, 2 Nov 2012 11:42:32 -0200
> Luiz Capitulino <lcapitulino@redhat.com> wrote:
>
>> On Fri, 02 Nov 2012 14:40:03 +0100
>> Kevin Wolf <kwolf@redhat.com> wrote:
>>
>>> Am 02.11.2012 14:25, schrieb Luiz Capitulino:
>>>> On Fri, 19 Oct 2012 11:27:59 -0300
>>>> Luiz Capitulino <lcapitulino@redhat.com> wrote:
>>>>
>>>>> By adding error propagation to bdrv_img_create() we improve error reporting
>>>>> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
>>>>>
>>>>> Please, check individual patches for details.
>>>>
>>>> Kevin, is this in your review queue?
>>>
>>> Yes, it is. With KVM Forum and lots of other patch series, no promises
>>> though.
>>
>> Sure, just wanted to know if you were aware about it.
>
> Still in your queue? :)
Patches look good in principle, but the bdrv_img_create() calls in
qmp_drive_mirror() aren't covered yet. Please do a quick respin for these.
Kevin
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors
2012-11-30 11:39 ` Kevin Wolf
@ 2012-11-30 11:44 ` Luiz Capitulino
0 siblings, 0 replies; 13+ messages in thread
From: Luiz Capitulino @ 2012-11-30 11:44 UTC (permalink / raw)
To: Kevin Wolf; +Cc: pbonzini, qemu-devel, armbru
On Fri, 30 Nov 2012 12:39:34 +0100
Kevin Wolf <kwolf@redhat.com> wrote:
> Am 29.11.2012 17:34, schrieb Luiz Capitulino:
> > On Fri, 2 Nov 2012 11:42:32 -0200
> > Luiz Capitulino <lcapitulino@redhat.com> wrote:
> >
> >> On Fri, 02 Nov 2012 14:40:03 +0100
> >> Kevin Wolf <kwolf@redhat.com> wrote:
> >>
> >>> Am 02.11.2012 14:25, schrieb Luiz Capitulino:
> >>>> On Fri, 19 Oct 2012 11:27:59 -0300
> >>>> Luiz Capitulino <lcapitulino@redhat.com> wrote:
> >>>>
> >>>>> By adding error propagation to bdrv_img_create() we improve error reporting
> >>>>> in qmp_transaction() and simplify qemu-img.c:img_create() a bit.
> >>>>>
> >>>>> Please, check individual patches for details.
> >>>>
> >>>> Kevin, is this in your review queue?
> >>>
> >>> Yes, it is. With KVM Forum and lots of other patch series, no promises
> >>> though.
> >>
> >> Sure, just wanted to know if you were aware about it.
> >
> > Still in your queue? :)
>
> Patches look good in principle, but the bdrv_img_create() calls in
> qmp_drive_mirror() aren't covered yet. Please do a quick respin for these.
Sure.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2012-11-30 11:44 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 14:27 [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 1/6] error: add error_set_errno and error_setg_errno Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 2/6] block: bdrv_img_create(): add Error ** argument Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 3/6] qemu-img: img_create(): pass Error object to bdrv_img_create() Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 4/6] qemu-img: img_create(): drop unneeded goto and ret variable Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 5/6] qmp: qmp_transaction(): pass Error object to bdrv_img_create() Luiz Capitulino
2012-10-19 14:28 ` [Qemu-devel] [PATCH 6/6] block: bdrv_img_create(): drop unused error handling code Luiz Capitulino
2012-11-02 13:25 ` [Qemu-devel] [PATCH v2 0/6] block: bdrv_img_create(): propagate errors Luiz Capitulino
2012-11-02 13:40 ` Kevin Wolf
2012-11-02 13:42 ` Luiz Capitulino
2012-11-29 16:34 ` Luiz Capitulino
2012-11-30 11:39 ` Kevin Wolf
2012-11-30 11:44 ` Luiz Capitulino
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.