Am 20.03.2013 um 03:27 hat Eric Blake geschrieben: > > +++ b/block/nbd.c > > @@ -174,7 +174,6 @@ static void nbd_parse_filename(const char *filename, > > QDict *options, > > > > /* extract the host_spec - fail if it's not nbd:... */ > > if (!strstart(file, "nbd:", &host_spec)) { > > - error_setg(errp, "File name string for NBD must start with > > 'nbd:'"); > > goto out; > > } > > Is this really right? The code allows me to pass both file= and > file.driver= at once; so what if I pass -drive file.driver=nbd,file=xyz. > Prior to this patch, I'd get a nice message about file=xyz not starting > with nbd:, but now there is a silent failure. > > I think it might be better if you keep the error_setg(), and instead > rewrite the if on the previous line: > > if (file && !strstart(file, "nbd:", &host_spec)) {
In fact, the additional check isn't even necessary because the function is only called for file != NULL in the first place. I've put the error back. > Also, since it looks like the code allows me to pass both file.driver= > and file= at once, if I pass both pieces of information, is there any > sanity checking that the two are identical, and/or should we error out > and declare that if driver options are used then nbd requires a NULL > filename? I've added another patch that checks that only one of host/port/filename is specified. Kevin