block: Monitor command commit neglects to report some errors
The non-live bdrv_commit() function may return one of the following errors: -ENOTSUP, -EBUSY, -EACCES, -EIO. The only error that is checked in the HMP handler is -EBUSY, so the monitor command 'commit' silently fails for all error cases other than 'Device is in use'. Report error using monitor_printf() and strerror(), and convert existing qerror_report() calls in do_commit() to monitor_printf(). Signed-off-by: Jeff Cody <jcody@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
11c29918be
commit
58513bde83
14
blockdev.c
14
blockdev.c
@ -642,21 +642,17 @@ void do_commit(Monitor *mon, const QDict *qdict)
|
|||||||
|
|
||||||
if (!strcmp(device, "all")) {
|
if (!strcmp(device, "all")) {
|
||||||
ret = bdrv_commit_all();
|
ret = bdrv_commit_all();
|
||||||
if (ret == -EBUSY) {
|
|
||||||
qerror_report(QERR_DEVICE_IN_USE, device);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bs = bdrv_find(device);
|
bs = bdrv_find(device);
|
||||||
if (!bs) {
|
if (!bs) {
|
||||||
qerror_report(QERR_DEVICE_NOT_FOUND, device);
|
monitor_printf(mon, "Device '%s' not found\n", device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ret = bdrv_commit(bs);
|
ret = bdrv_commit(bs);
|
||||||
if (ret == -EBUSY) {
|
}
|
||||||
qerror_report(QERR_DEVICE_IN_USE, device);
|
if (ret < 0) {
|
||||||
return;
|
monitor_printf(mon, "'commit' error for '%s': %s\n", device,
|
||||||
}
|
strerror(-ret));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user