Message ID | 20191023173154.30051-11-marcandre.lureau@redhat.com |
---|---|
State | New |
Headers | show |
Series | Clean-ups: qom-ify serial and remove QDEV_PROP_PTR | expand |
On Wed, 23 Oct 2019 at 18:33, Marc-André Lureau <marcandre.lureau@redhat.com> wrote: > > This property will be used to move common vmstate registration to > device realize in following patch. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/char/serial.c | 3 +++ > include/hw/char/serial.h | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/hw/char/serial.c b/hw/char/serial.c > index 069d8715d0..0b61a71e4e 100644 > --- a/hw/char/serial.c > +++ b/hw/char/serial.c > @@ -990,6 +990,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > s->irq = irq; > qdev_prop_set_uint32(dev, "baudbase", baudbase); > qdev_prop_set_chr(dev, "chardev", chr); > + qdev_prop_set_int32(dev, "instance-id", base); > serial_realize_core(s, &error_fatal); > qdev_set_legacy_instance_id(dev, base, 2); > qdev_init_nofail(dev); > @@ -1003,6 +1004,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > static Property serial_properties[] = { > DEFINE_PROP_CHR("chardev", SerialState, chr), > DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200), > + DEFINE_PROP_INT32("instance-id", SerialState, instance_id, 0), This could use an explanatory comment, because I have no idea what it does or when a user of the device would want or need to set it... (I am guessing that part of the answer may be "needed only by legacy users of this device that don't want to break migration compatibility" ?) > DEFINE_PROP_END_OF_LIST(), > }; thanks -- PMM
Hi On Mon, Nov 18, 2019 at 6:30 PM Peter Maydell <peter.maydell@linaro.org> wrote: > > On Wed, 23 Oct 2019 at 18:33, Marc-André Lureau > <marcandre.lureau@redhat.com> wrote: > > > > This property will be used to move common vmstate registration to > > device realize in following patch. > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > --- > > hw/char/serial.c | 3 +++ > > include/hw/char/serial.h | 1 + > > 2 files changed, 4 insertions(+) > > > > diff --git a/hw/char/serial.c b/hw/char/serial.c > > index 069d8715d0..0b61a71e4e 100644 > > --- a/hw/char/serial.c > > +++ b/hw/char/serial.c > > @@ -990,6 +990,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > > s->irq = irq; > > qdev_prop_set_uint32(dev, "baudbase", baudbase); > > qdev_prop_set_chr(dev, "chardev", chr); > > + qdev_prop_set_int32(dev, "instance-id", base); > > serial_realize_core(s, &error_fatal); > > qdev_set_legacy_instance_id(dev, base, 2); > > qdev_init_nofail(dev); > > @@ -1003,6 +1004,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > > static Property serial_properties[] = { > > DEFINE_PROP_CHR("chardev", SerialState, chr), > > DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200), > > + DEFINE_PROP_INT32("instance-id", SerialState, instance_id, 0), > > This could use an explanatory comment, because I have no > idea what it does or when a user of the device would want > or need to set it... (I am guessing that part of the answer > may be "needed only by legacy users of this device that don't > want to break migration compatibility" ?) That's right, I'll add that comment. > > > DEFINE_PROP_END_OF_LIST(), > > }; > > thanks > -- PMM >
Hi On Wed, Oct 23, 2019 at 9:33 PM Marc-André Lureau <marcandre.lureau@redhat.com> wrote: > > This property will be used to move common vmstate registration to > device realize in following patch. > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> I realize adding a "instance-id" property instead of calling qdev_set_legacy_instance_id() manually doesn't really help. Patch dropped. > --- > hw/char/serial.c | 3 +++ > include/hw/char/serial.h | 1 + > 2 files changed, 4 insertions(+) > > diff --git a/hw/char/serial.c b/hw/char/serial.c > index 069d8715d0..0b61a71e4e 100644 > --- a/hw/char/serial.c > +++ b/hw/char/serial.c > @@ -990,6 +990,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > s->irq = irq; > qdev_prop_set_uint32(dev, "baudbase", baudbase); > qdev_prop_set_chr(dev, "chardev", chr); > + qdev_prop_set_int32(dev, "instance-id", base); > serial_realize_core(s, &error_fatal); > qdev_set_legacy_instance_id(dev, base, 2); > qdev_init_nofail(dev); > @@ -1003,6 +1004,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, > static Property serial_properties[] = { > DEFINE_PROP_CHR("chardev", SerialState, chr), > DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200), > + DEFINE_PROP_INT32("instance-id", SerialState, instance_id, 0), > DEFINE_PROP_END_OF_LIST(), > }; > > @@ -1073,6 +1075,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, > s->irq = irq; > qdev_prop_set_uint32(dev, "baudbase", baudbase); > qdev_prop_set_chr(dev, "chardev", chr); > + qdev_prop_set_int32(dev, "instance-id", base); > > serial_realize_core(s, &error_fatal); > qdev_set_legacy_instance_id(dev, base, 2); > diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h > index 3dc618598e..b472c7cd57 100644 > --- a/include/hw/char/serial.h > +++ b/include/hw/char/serial.h > @@ -78,6 +78,7 @@ typedef struct SerialState { > > QEMUTimer *modem_status_poll; > MemoryRegion io; > + int instance_id; > } SerialState; > > extern const VMStateDescription vmstate_serial; > -- > 2.23.0.606.g08da6496b6 >
diff --git a/hw/char/serial.c b/hw/char/serial.c index 069d8715d0..0b61a71e4e 100644 --- a/hw/char/serial.c +++ b/hw/char/serial.c @@ -990,6 +990,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->irq = irq; qdev_prop_set_uint32(dev, "baudbase", baudbase); qdev_prop_set_chr(dev, "chardev", chr); + qdev_prop_set_int32(dev, "instance-id", base); serial_realize_core(s, &error_fatal); qdev_set_legacy_instance_id(dev, base, 2); qdev_init_nofail(dev); @@ -1003,6 +1004,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, static Property serial_properties[] = { DEFINE_PROP_CHR("chardev", SerialState, chr), DEFINE_PROP_UINT32("baudbase", SerialState, baudbase, 115200), + DEFINE_PROP_INT32("instance-id", SerialState, instance_id, 0), DEFINE_PROP_END_OF_LIST(), }; @@ -1073,6 +1075,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, s->irq = irq; qdev_prop_set_uint32(dev, "baudbase", baudbase); qdev_prop_set_chr(dev, "chardev", chr); + qdev_prop_set_int32(dev, "instance-id", base); serial_realize_core(s, &error_fatal); qdev_set_legacy_instance_id(dev, base, 2); diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 3dc618598e..b472c7cd57 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -78,6 +78,7 @@ typedef struct SerialState { QEMUTimer *modem_status_poll; MemoryRegion io; + int instance_id; } SerialState; extern const VMStateDescription vmstate_serial;
This property will be used to move common vmstate registration to device realize in following patch. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> --- hw/char/serial.c | 3 +++ include/hw/char/serial.h | 1 + 2 files changed, 4 insertions(+)