Hi On Fri, Apr 26, 2019 at 9:12 AM Gerd Hoffmann <kra...@redhat.com> wrote: > > > +static void vhost_input_get_config(VirtIODevice *vdev, uint8_t > > *config_data) > > +{ > > + VirtIOInput *vinput = VIRTIO_INPUT(vdev); > > + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); > > + int ret; > > + > > + memset(config_data, 0, vinput->cfg_size); > > + > > + ret = vhost_dev_get_config(&vhi->vhost->dev, config_data, > > vinput->cfg_size); > > + if (ret) { > > + error_report("vhost-user-input: get device config space failed"); > > + return; > > + } > > +} > > + > > +static void vhost_input_set_config(VirtIODevice *vdev, > > + const uint8_t *config_data) > > +{ > > + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); > > + int ret; > > + > > + ret = vhost_dev_set_config(&vhi->vhost->dev, config_data, > > + 0, sizeof(virtio_input_config), > > + VHOST_SET_CONFIG_TYPE_MASTER); > > + if (ret) { > > + error_report("vhost-user-input: set device config space failed"); > > + return; > > + } > > + > > + virtio_notify_config(vdev); > > +} > > These two look rather generic, the only virtio-input specific thing is > the config space size. Can we store the size somewhere, then move the > functions to common vhost-user code?
vhost-user-input is simple, vhost-user-gpu is fiddling with the config on qemu side. virtio-input set_config() calls virtio_notify_config(), while virtio-gpu does not (vhost-user versions copy that). There isn't much code to share at this point. -- Marc-André Lureau