Il 10/01/2014 15:44, Igor Mammedov ha scritto: > On Fri, 10 Jan 2014 12:38:57 +0100 > Paolo Bonzini <pbonz...@redhat.com> wrote: > >> Il 10/01/2014 12:28, Igor Mammedov ha scritto: >>>>> Regarding the "overloading" of the realize name, I was against it in >>>>> previous discussion and I still am (I was in favor of something like >>>>> UserCreatable and naming the method "complete" or "construct"), but I >>>>> didn't want to sound too negative. :) >>> issue with naming interface as CommandLine or UserCreatable is that, it >>> could >>> be used not only by CLI/user but also it could be used internally. For >>> example >>> see "[PATCH 3/5] virtio_rng: use object_realize interface instead of calling >>> backend API", where default backend is created by frontend. >> >> I see. Yes, with something like UserCreatable, you would not have that > I'm not sure why I wouldn't have that path. It does exactly what you've > just written vvv,
You're right, I misremembered. >> patch. Instead, UserCreatable's complete method would redirect to the >> backend-specific API. > i.e. it calls cast<UserCreatable>(default_rng).complete() which > redirects to backend specific API, where UserCreatable.complete() > is rng_backend_realize() > >> >> BTW, note that UserCreatable's complete method should take a >> UserCreatable (or whatever the name is) as the first parameter, not an >> Object. This would affect that patch, too. > It does, 'void (*realize)(ObjectRealizeInterface *obj, Error **errp);' > > call_object_realize_interface(Object *obj,...) is a wrapper > that reduces casting code duplication at call sites since it's used > at more then 1 place. This is needed only because you allow creating objects that do not have ObjectRealizeInterface. With a UserCreatable interface, the dynamic cast would be in vl.c and qmp.c (to check whether the user is actually allowed to use -object on that device) and there's no duplication at the call sites of the 2nd-stage init method. > I'm fine with UserCreatable, lets wait couple days if there is no objection > or another suggestions and I'll then respin series. Thanks! Paolo