On Thu, Jul 25, 2013 at 01:55:26PM +0300, Michael S. Tsirkin wrote:
> On Thu, Jul 25, 2013 at 12:29:52PM +0200, Gerd Hoffmann wrote:
> > On 07/24/13 18:02, Michael S. Tsirkin wrote:
> > > Add API to find pvpanic device and get its io port.
> > > Will be used to fill in guest info structure.
> > 
> > > +uint16_t pvpanic_port(void)
> > > +{
> > > +    Object *o = object_resolve_path_type("", TYPE_ISA_PVPANIC_DEVICE, 
> > > NULL);
> > > +    PVPanicState *s;
> > > +    if (!o) {
> > > +        return 0;
> > > +    }
> > 
> >        return object_property_get_int(o, "ioport");
> > }
> > 
> > Then you don't need PVPanicState access and can place the code into
> > acpi-build.c.
> > 
> > cheers,
> >   Gerd
> 
> I can change the implementation but I don't think it's
> a good idea to copy property names around:
> it's too fragile, compiler won't warn us if we
> change the name or value semantics, or make
> a mistake in acpi-build.c

And even within pvpanic.c, this will make me copy-paste
the "ioport" string or create yet another macro.

    s = ISA_PVPANIC_DEVICE(o);
    return s->ioport;

seems nicer.

> Same applies to TYPE_ISA_PVPANIC_DEVICE: better
> to expose an API than expose the type externally.



> -- 
> MST

Reply via email to