[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] fix diagnostic when execute openvz commands



On Thu, Jul 10, 2008 at 08:27:25AM -0400, Daniel Veillard wrote:
> On Thu, Jul 10, 2008 at 09:23:36AM +0200, Jim Meyering wrote:
> > Evgeniy Sokolov <evg openvz org> wrote:
> [...]
> > > +void
> > > +error (virConnectPtr conn, virErrorNumber code, const char *fmt, ...)
> > 
> > Now that you've given it external scope, please use a different name.
> > There are already at least two other "error" functions,
> > including the static one in remote_internal.c, and the
> > external one in glibc/gnulib.
> 
>   Hum, maybe we could just rename the one in remote_internal.c to rem_error()
> to avoid confusion.

The fact that every single driver duplicates the same code to wrap
__virRaiseError suggests we need simpler shared version to me. The
only thing that differs is the VIR_FROM_QEMU, FROM_XEN, etc, param

I'd suggest we add a

  __virRaiseSimpleError(virConnectPtr conn, int from, int code, const cha *fmt, ...)
  {
    va_list args;
    char errorMessage[1024];
    const char *virerr;

    if (fmt) {
        va_start(args, fmt);
        vsnprintf(errorMessage, sizeof(errorMessage)-1, fmt, args);
        va_end(args);
    } else {
        errorMessage[0] = '\0';
    }

    virerr = __virErrorMsg(code, (errorMessage[0] ? errorMessage : NULL));
    __virRaiseError(conn, dom, net, from, code, VIR_ERR_ERROR,
                    virerr, errorMessage, NULL, -1, -1, virerr, errorMessage);
  }

and then each driver can 'wrap' it with a macro

  #define ERROR(conn, code, fmt, ...) \
     __virRaiseeSimpleError((conn), VIR_FROM_QEMU, (code), (fmt), __VA_ARGS__)

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]