From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua0-f196.google.com (mail-ua0-f196.google.com [209.85.217.196]) by dpdk.org (Postfix) with ESMTP id 04FCB2A5D for ; Mon, 4 Dec 2017 15:17:44 +0100 (CET) Received: by mail-ua0-f196.google.com with SMTP id v20so12519298uaj.0 for ; Mon, 04 Dec 2017 06:17:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=xT3kY/YMrhVZNEYsQSHGxjT+JOvkL5fbnbQMmbH4qgI=; b=ECo9fW6Xq7VCduvgpWlfGzvL55EucG56ETb9OJtGnKmyrhgaIre0qYE1sUWWacTVn+ zJkXV6p2v9Dfy8JTk6Oe9s/hLm9vHk/qWEQ1XJqU9pbEUQc5c4GRcicLTfWdOQ7ooYTo ROo/0ZGHrpraXRieKnQ9rc/mfNp57wxJYRcUXvzpL401IsSDupkRH8JUm8IDWlcA4oo4 mNTfpiHUNR6XHbvj542CqPy/tM+fugEpQandd+Rf70hfyZH5qtDNS+DGQLuN9qcaKg97 xyOB8SVIwUHoVcnYtF+rGAovG4f4/0Jb6tJjk8Uj3OMmt/foIC1+Uv6cHc/Fx1+kG/xk Un6w== X-Gm-Message-State: AJaThX6HQKih10VFgTybx6+s1ZAuYnIhy72B6/Is2Fikuuw+raNMRJEI N7aij8UA9mP8d9iGote5Dc1sLtdaLBRl8lxtPLvnOA== X-Google-Smtp-Source: AGs4zMZTH5WCNwunkunSJ9+IEXe5NSXj9QvGCGJEcD1c2PeybiahlNXBhYRLfSyGIrDmvIV1nB5AwB99dkrlg52OUP0= X-Received: by 10.176.3.50 with SMTP id 47mr12060267uat.193.1512397064210; Mon, 04 Dec 2017 06:17:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.52.199 with HTTP; Mon, 4 Dec 2017 06:17:43 -0800 (PST) In-Reply-To: <20171204140900.7906-2-maxime.coquelin@redhat.com> References: <20171204140900.7906-1-maxime.coquelin@redhat.com> <20171204140900.7906-2-maxime.coquelin@redhat.com> From: Ladi Prosek Date: Mon, 4 Dec 2017 15:17:43 +0100 Message-ID: To: Maxime Coquelin Cc: dev@dpdk.org, yliu@fridaylinux.org, tiwei.bie@intel.com, jianfeng.tan@intel.com, Laszlo Ersek Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 1/4] vhost: prevent features to be changed while device is running X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Dec 2017 14:17:45 -0000 On Mon, Dec 4, 2017 at 3:08 PM, Maxime Coquelin wrote: > As section 2.2 of the Virtio spec states about features > negotiation: > "During device initialization, the driver reads this and tells > the device the subset that it accepts. The only way to > renegotiate is to reset the device." > > This patch implements a check to prevent illegal features change > while the device is running. > > One exception is the VHOST_F_LOG_ALL feature bit, which is enabled > when live-migration is initiated. But this feature is not negotiated > with the Virtio driver, but directly with the Vhost master. > > Signed-off-by: Maxime Coquelin > --- > lib/librte_vhost/vhost_user.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c > index f4c7ce462..f51055ab2 100644 > --- a/lib/librte_vhost/vhost_user.c > +++ b/lib/librte_vhost/vhost_user.c > @@ -183,7 +183,22 @@ vhost_user_set_features(struct virtio_net *dev, uint64_t features) > return -1; > } > > - if ((dev->flags & VIRTIO_DEV_RUNNING) && dev->features != features) { > + if (dev->features == features) > + return 0; > + > + if (dev->flags & VIRTIO_DEV_RUNNING) { > + /* > + * Error out if master tries to change features while device is > + * in running state. The exception being VHOST_F_LOG_ALL, which > + * is enabled when the live-migration starts. > + */ > + if ((dev->features ^ features) & ~(1ULL >> VHOST_F_LOG_ALL)) { The 1 should be shifted to the left: 1ULL << VHOST_F_LOG_ALL > + RTE_LOG(ERR, VHOST_CONFIG, > + "(%d) features changed while device is running.\n", > + dev->vid); > + return -1; > + } > + > if (dev->notify_ops->features_changed) > dev->notify_ops->features_changed(dev->vid, features); > } > -- > 2.14.3 >