[Libvir] Patch: driver->open functions return declined or error status

I want to change the driver->open function so that as well as declining a name (returning -1 as now), it may also indicate that it accepts the name, but there is an error opening the name (-2). virConnectOpen fails in this second case, rather than going on and trying the next driver in sequence. Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 "[Negative numbers] darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple" (Francis Maseres FRS, mathematician, 1759)

On Wed, Feb 28, 2007 at 04:18:45PM +0000, Richard W.M. Jones wrote:
I want to change the driver->open function so that as well as declining a name (returning -1 as now), it may also indicate that it accepts the name, but there is an error opening the name (-2). virConnectOpen fails in this second case, rather than going on and trying the next driver in sequence.
This is all sane - I've certainly seen some really odd problems before from not being able to detect the difference between an operation not being supported, vs supported but failed. When we merge the Xen drivers into one those will go away, and thus addresses the open() case, so I'll commit it unless anyone objects. Regards, Dan -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Wed, 2007-02-28 at 16:18 +0000, Richard W.M. Jones wrote:
+ case VIR_DRV_OPEN_ERROR: goto failed; + case VIR_DRV_OPEN_DECLINED: + /* + * For a default connect to Xen make sure we manage to contact + * all related drivers. + */ + if (for_xen && + strncasecmp(virDriverTab[i]->name, "xen", 3) == 0 && + virDriverTab[i]->no != VIR_DRV_XEN_PROXY) + goto failed; + break;
Are there no current cases where we should return VIR_DRV_OPEN_ERROR? Also, can we change the existing open methods to use DECLINED? I was confused for a minute because I presumed ERROR was -1 ... Cheers, Mark.

Mark McLoughlin wrote:
On Wed, 2007-02-28 at 16:18 +0000, Richard W.M. Jones wrote:
+ case VIR_DRV_OPEN_ERROR: goto failed; + case VIR_DRV_OPEN_DECLINED: + /* + * For a default connect to Xen make sure we manage to contact + * all related drivers. + */ + if (for_xen && + strncasecmp(virDriverTab[i]->name, "xen", 3) == 0 && + virDriverTab[i]->no != VIR_DRV_XEN_PROXY) + goto failed; + break;
Are there no current cases where we should return VIR_DRV_OPEN_ERROR?
Also, can we change the existing open methods to use DECLINED? I was confused for a minute because I presumed ERROR was -1 ...
Oh definitely. I didn't claim that I'd fixed all the other drivers :-) Rich.
participants (3)
-
Daniel P. Berrange
-
Mark McLoughlin
-
Richard W.M. Jones