[dpdk-dev] [PATCH 1/4] vhost: prevent features to be changed while device is running
Maxime Coquelin
maxime.coquelin at redhat.com
Mon Dec 4 15:20:53 CET 2017
On 12/04/2017 03:17 PM, Ladi Prosek wrote:
> On Mon, Dec 4, 2017 at 3:08 PM, Maxime Coquelin
> <maxime.coquelin at redhat.com> 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<maxime.coquelin at redhat.com>
>> ---
>> 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
Oh right, of course.
Thanks for spotting this.
Maxime
More information about the dev
mailing list