qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 15/18] qapi: implement support for variable argu


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 15/18] qapi: implement support for variable argument list
Date: Wed, 18 Apr 2012 15:09:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1

Il 18/04/2012 14:51, Luiz Capitulino ha scritto:
>>>> > >> It seems much easier to use no_gen and qemu_opts_from_qdict...  Then
>>>> > >> cmd_netdev_add can be
>>> > > 
>>> > > netdev_add/del is expected to be a stable interface, so we can't use 
>>> > > no_gen.
>> > 
>> > You can have hmp_netdev_add and the no_gen qmp_netdev_add as front-ends
>> > for the QAPI cmd_netdev_add.  I think it's fair when we have to take
>> > into account backwards-compatibility.  The conversion gives correct
>> > error propagation, so even though QemuOpts still leaks it's a step in
>> > the right direction.
> I thought Anthony had plans to replace QemuOpts with something else,
> I think it was qcfg, but I might be wrong. Anthony?

As far as I understood, QCFG is really the code name for a QemuOpts
visitor. :)

The idea is that instead of this:

static int net_init_netdev(QemuOpts *opts, void *dummy)
{
    return net_client_init(opts);
}

...

    if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev,
        NULL, 1) == -1)
        return -1;


you automatically generate functions like these:

    static int netdev_cb(QemuOpts *opts, void *cb)
    {
        Error *err = NULL;
        NetdevOpts *o = NULL;
        int ret;

        QapiDeallocVisitor *md = qapi_dealloc_visitor_new();
        QemuOptsVisitor *iv = qemu_opts_visitor_new(opts);
        Visitor *v;

        v = qemu_opts_get_visitor(iv);
        visit_type_NetdevOpts(v, (void **) &o, NULL, &err);
        qemu_opts_visitor_cleanup(iv);
        if (err) {
            qerror_report_err(err);
            ret = 1;
        } else {
            int (*p_cb)(NetdevOpts *) = cb;
            ret = p_cb(opts);
        }

        v = qapi_dealloc_get_visitor(ov);
        visit_type_NetdevOpts(v, (void **) &o, NULL, &errp);
        qapi_dealloc_visitor_cleanup(ov);
    }

    int netdev_foreach(int (*cb)(NetdevOpts *))
    {
        return qemu_opts_foreach(qemu_find_opts("netdev"), netdev_cb,
                                 cb, 1);
    }

and just do:

    netdev_foreach(net_client_init);

There was more stuff in QCFG, including extensions to QemuOpts to
represent an arbitrary QObject, but the above is pretty much it and is
really what we need at the moment.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]