qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC 13/29] vhost+postcopy: Transmit 'listen' to client


From: Maxime Coquelin
Subject: Re: [Qemu-devel] [RFC 13/29] vhost+postcopy: Transmit 'listen' to client
Date: Mon, 24 Jul 2017 16:36:11 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0



On 06/28/2017 09:00 PM, Dr. David Alan Gilbert (git) wrote:
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index b98fbe4834..1f70f5760f 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -67,6 +67,7 @@ typedef enum VhostUserRequest {
      VHOST_USER_SET_SLAVE_REQ_FD = 21,
      VHOST_USER_IOTLB_MSG = 22,
      VHOST_USER_POSTCOPY_ADVISE  = 23,
+    VHOST_USER_POSTCOPY_LISTEN  = 24,
      VHOST_USER_MAX
  } VhostUserRequest;
@@ -771,6 +772,25 @@ static int vhost_user_postcopy_advise(struct vhost_dev *dev, Error **errp)
      return 0;
  }
+/*
+ * Called at the switch to postcopy on reception of the 'listen' command.
+ */
+static int vhost_user_postcopy_listen(struct vhost_dev *dev, Error **errp)
+{
+    VhostUserMsg msg = {
+        .request = VHOST_USER_POSTCOPY_LISTEN,
+        .flags = VHOST_USER_VERSION,
+    };

I think it should use REPLY_ACK feature when available for two reasons:
1. The backend could reply nack if nregions is already set.
2. When leaving vhost_user_postcopy_listen(), the message might likely
   not have been handled yet by the backend.

+    trace_vhost_user_postcopy_listen();
+    if (vhost_user_write(dev, &msg, NULL, 0) < 0) {
+        error_setg(errp, "Failed to send postcopy_listen to vhost");
+        return -1;
+    }
+
+    return 0;
+}
+
  static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier,
                                          void *opaque)
  {
@@ -793,6 +813,9 @@ static int vhost_user_postcopy_notifier(NotifierWithReturn 
*notifier,
      case POSTCOPY_NOTIFY_INBOUND_ADVISE:
          return vhost_user_postcopy_advise(dev, pnd->errp);
+ case POSTCOPY_NOTIFY_INBOUND_LISTEN:
+        return vhost_user_postcopy_listen(dev, pnd->errp);
+
      default:
          /* We ignore notifications we don't know */
          break;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]