Hi On Mon, Jun 4, 2018 at 10:58 AM, Gerd Hoffmann <kra...@redhat.com> wrote: >> +#define TYPE_VHOST_USER_INPUT_PCI "vhost-user-input-pci" > > Patch $subject mismatch. > >> +struct VHostUserInput { >> + VirtIOInput parent_obj; >> + >> + VhostUserBackend *vhost; >> +}; > > Nothing input specific here ...
Except VirtIOInput > >> +static void vhost_input_change_active(VirtIOInput *vinput) >> +{ >> + VHostUserInput *vhi = VHOST_USER_INPUT(vinput); >> + >> + if (!vhi->vhost) { >> + return; >> + } >> + >> + if (vinput->active) { >> + vhost_user_backend_start(vhi->vhost); >> + } else { >> + vhost_user_backend_stop(vhi->vhost); >> + } >> +} > > ... and here ... Except it's a VirtIOInputClass callback > >> +static const VMStateDescription vmstate_vhost_input = { >> + .name = "vhost-user-input", >> + .unmigratable = 1, >> +}; > > ... and here ... > >> +static void vhost_input_is_busy(const Object *obj, const char *name, >> + Object *val, Error **errp) >> +{ >> + VHostUserInput *vhi = VHOST_USER_INPUT(obj); >> + >> + if (vhi->vhost) { >> + error_setg(errp, "can't use already busy vhost-user"); >> + } else { >> + qdev_prop_allow_set_link_before_realize(obj, name, val, errp); >> + } >> +} > > ... likewise ... > > So, maybe it makes sense to have a abstact base class for vhost-user > devices? And possibly move the vhost-backend code to the base class > then? The device inherits from virtio-input type. So we could somehow not expose -object vhost-user and instead have internal vhost-user object & properties aliased & duplicated on each -device vhost-user*. I would rather keep the -object solution, since it's somehow cleaner, more flexible and simpler to document that way. Or do you have a better idea? -- Marc-André Lureau