On 26.07.2016 19:18, Halil Pasic wrote: > > > On 07/26/2016 05:42 PM, Max Reitz wrote: >>> +++ b/block/raw-posix.c >>>> @@ -485,6 +485,7 @@ static int raw_open_common(BlockDriverState *bs, QDict >>>> *options, >>>> s->fd = -1; >>>> fd = qemu_open(filename, s->open_flags, 0644); >>>> if (fd < 0) { >>>> + error_setg_errno(errp, errno, "Could not open file"); >> We don't guarantee that error_setg_errno() does not modify errno. (In >> practice it should not, but we don't guarantee that.) >> > > > Thank you very much for your review. I have double checked, and I > remembered correctly: error_setg_errno saves and restores the original > errno, so that is why I assumed it does not. > >> Therefore, the common pattern is to save the errno value before calling >> this function, i.e. to put the function call... >> >>>> ret = -errno; >> ...here. >> >> With that fixed, the patch should be good. >> >> Max >> > > But now that you have this pointed out, I understand, it is better to > have no function calls between failure and saving the errno. I will post > a v3 and keep this in mind for the future. Sorry for the extra work. > > Frankly, I'm a bit uncomfortable with asking (do not want to be pushy), > but do you have an opinion on the 'error_report_err' issue (pointed > out in the cover letter part)?
You are using drive_add with QMP? As far as I know, one can only do so with human-monitor-command which returns the error string like so: {"return": "Could not open file: No such file or directory\r\n"} Apart from that, as for QMP, in theory you're supposed to use blockdev-add and device_add, I think (although blockdev-add is still considered experimental...). And blockdev-add will return the error string like so: {"error": {"class": "GenericError", "desc": "Could not open file: No such file or directory"}} Max
signature.asc
Description: OpenPGP digital signature