On Wed, Mar 07, 2007 at 07:25:59AM +0000, Mark McLoughlin wrote:
On Tue, 2007-03-06 at 22:52 +0000, Daniel P. Berrange wrote:
> This feels kind of sick - inventing a common shared struct between the
> two driver tables, when there isn't any common stuff to share :-(
Yeah. Although, as a way to share more code between domains and
networks (especially in qemud), it might make sense.
> Looking at the code, IMHO, the whole approach of iterating over the
> driver
> table soo many times is just wrong, when we can simply have an integer
> count recording how many drivers are registered. This eliminates both
> for(;;) loops, and reduces the amount of code to the point where I
> don't
> think there's anything to be gained by having a generic
> _virDriverRegister
> with all the type-casting this entails.
That sounds fine.
> @@ -203,7 +166,21 @@ _virRegisterDriver(void *driver, int isN
> int
> virRegisterNetworkDriver(virNetworkDriverPtr driver)
> {
> - return _virRegisterDriver(driver, 1);
> + if (virInitialize() < 0)
> + return -1;
> +
> + if (driver == NULL) {
> + virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
> + return(-1);
> + }
> +
> + if (virNetworkDriverTabCount >=
(sizeof(virNetworkDriverTab)/sizeof(virNetworkDriverPtr))) {
Just use MAX_DRIVERS?
Committed with this change applied.
I also fixed virConnectOpenReadonly which was not passing the readonly
flag down to the network driver.
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 -=|