On 2017年01月18日 06:22, John Fastabend wrote:
+static int virtnet_reset(struct virtnet_info *vi)
+{
+       struct virtio_device *dev = vi->vdev;
+       int ret;
+
+       virtio_config_disable(dev);
+       dev->failed = dev->config->get_status(dev) & VIRTIO_CONFIG_S_FAILED;
+       virtnet_freeze_down(dev);
+       _remove_vq_common(vi);
+
+       dev->config->reset(dev);
+       virtio_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
+       virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
+
+       ret = virtio_finalize_features(dev);
+       if (ret)
+               goto err;
+
+       ret = virtnet_restore_up(dev);
+       if (ret)
+               goto err;
+       ret = _virtnet_set_queues(vi, vi->curr_queue_pairs);
+       if (ret)
+               goto err;
+
+       virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
+       virtio_config_enable(dev);
+       return 0;
+err:
+       virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
+       return ret;
+}
+

Hi John:

I still prefer not open code (part of) virtio_device_freeze() and virtio_device_restore() here. How about:

1) introduce __virtio_device_freeze/__virtio_device_restore which accepts a function pointer of free/restore 2) for virtio_device_freeze/virtio_device_restore just pass drv->freeze/drv->restore (locked version)
3) for virtnet_reset(), we can pass unlocked version of freeze and restore

Just my preference, if both Michael and you stick to this, I'm also fine.

Thanks

Reply via email to