vhost-user: sync backend features
PATCH 1/1 vhost-user: sync backend features
Complete vhost-user negotiation by syncing the features supported by the backend.
---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.html
Currently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.
Thanks,
Marcel
hw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
hw/net/vhost_net.c +2 -1
@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features); }
hw/virtio/vhost-user.c +2 -2
@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ;
Signature · 1 line
2.1.0
Quoted 29 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 7 lines
hw/net/vhost_net.c +2
-1@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);
So you ack it twice?
Quoted 20 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-2@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ;Signature · 1 line
2.1.0
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)
Quoted 8 lines
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 6 lines
hw/net/vhost_net.c +2
-1void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);So you ack it twice?
Not really, first call to vhost_ack_features acks the net->dev.backend_features, the second one acks the guest features.
The first call replaces the previous assignment that assumes that all backend features are supported by QEMU.
Thanks,
Marcel
Quoted 21 lines
Quoted 21 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-3@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ; --2.1.0
Quoted 40 lines · Marcel Apfelbaum
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)Quoted 8 lines
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 6 lines
hw/net/vhost_net.c +2
-1void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);So you ack it twice?
Quoted 8 lines
Not really, first call to
vhost_ack_featuresacks thenet->dev.backend_features, the second one acks the guest features.The first call replaces the previous assignment that assumes that all backend features are supported by QEMU.
Thanks,
Marcel
I think it's cleaner to whitelist backend features QEMU supports. I thought we did this, will look again.
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-3@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ; --2.1.0
Quoted 44 lines · Michael S. Tsirkin
Quoted 43 lines · Marcel Apfelbaum
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)Quoted 8 lines
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 6 lines
hw/net/vhost_net.c +2
-1void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);So you ack it twice?
Not really, first call to
vhost_ack_featuresacks thenet->dev.backend_features, the second one acks the guest features.
Quoted 8 lines
Quoted 5 lines
The first call replaces the previous assignment that assumes that all backend features are supported by QEMU.
Thanks,
MarcelI think it's cleaner to whitelist backend features QEMU supports. I thought we did this, will look again.
I thought to do it the same as you started in vhost-init:
if (__virtio_has_feature(msg.u64, VHOST_USER_F_PROTOCOL_FEATURES)) {
dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;However, we should check all possible flags, no? We have about 16 now. And we'll need to manually add to white-list every new feature, seems error prone. Anyway, I am open to suggestions.
Thanks,
Marcel
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-3@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ; --2.1.0
Quoted 53 lines · Marcel Apfelbaum
Quoted 44 lines · Michael S. Tsirkin
Quoted 43 lines · Marcel Apfelbaum
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)Quoted 8 lines
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 6 lines
hw/net/vhost_net.c +2
-1void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);So you ack it twice?
Not really, first call to
vhost_ack_featuresacks thenet->dev.backend_features, the second one acks the guest features.Quoted 8 lines
Quoted 5 lines
The first call replaces the previous assignment that assumes that all backend features are supported by QEMU.
Thanks,
MarcelI think it's cleaner to whitelist backend features QEMU supports. I thought we did this, will look again.
Quoted 7 lines
I thought to do it the same as you started in vhost-init:
if (__virtio_has_feature(msg.u64, VHOST_USER_F_PROTOCOL_FEATURES)) { dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;However, we should check all possible flags, no? We have about 16 now. And we'll need to manually add to white-list every new feature, seems error prone.
But more secure :)
Quoted 4 lines
Anyway, I am open to suggestions.
Thanks,
Marcel
Can you describe the problem you are solving? Maybe write a unit test patch that'll make unit test fail?
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-3@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ; --2.1.0
Quoted 62 lines · Michael S. Tsirkin
Quoted 53 lines · Marcel Apfelbaum
Quoted 44 lines · Michael S. Tsirkin
Quoted 43 lines · Marcel Apfelbaum
Quoted 31 lines · Michael S. Tsirkin
Quoted 30 lines · Marcel Apfelbaum
Complete vhost-user negotiation by syncing the features supported by the backend.
Signed-off-by Marcel Apfelbaum <[email protected]>---
To be used on top of:
[PATCH 0/4] vhost-user: protocol updates
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg03842.htmlCurrently the vhost-user supported features are not evaluated. The way I see it, and please correct me, the best way to do this is to:
1. get the backend features on vhost init
2. Instead of simply copying them during features ack, check that that all backend features are supported by current QEMU
3. All other code should remain the same.Thanks,
Marcelhw/net/vhost_net.c | 3 ++- hw/virtio/vhost-user.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)hw/net/vhost_net.c +0
-0@@ -118,7 +118,8 @@ uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features)Quoted 8 lines
hw/net/vhost_net.c uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) · line 123
Quoted 6 lines
hw/net/vhost_net.c +2
-1void vhost_net_ack_features (struct vhost_net *net,uint64_t features) { - net->dev.acked_features = net->dev.backend_features; +vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), + net->dev.backend_features);vhost_ack_features (&net->dev,vhost_net_get_feature_bits (net), features);So you ack it twice?
Not really, first call to
vhost_ack_featuresacks thenet->dev.backend_features, the second one acks the guest features.Quoted 8 lines
Quoted 5 lines
The first call replaces the previous assignment that assumes that all backend features are supported by QEMU.
Thanks,
MarcelI think it's cleaner to whitelist backend features QEMU supports. I thought we did this, will look again.
Quoted 7 lines
I thought to do it the same as you started in vhost-init:
if (__virtio_has_feature(msg.u64, VHOST_USER_F_PROTOCOL_FEATURES)) { dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;However, we should check all possible flags, no? We have about 16 now. And we'll need to manually add to white-list every new feature, seems error prone.
Quoted 8 lines
But more secure :)
Quoted 4 lines
Anyway, I am open to suggestions.
Thanks,
MarcelCan you describe the problem you are solving?
vhost-user backend features are not enabled if are not negotiated, for example virtio 1.0 .
Quoted 1 line
Maybe write a unit test patch that'll make unit test fail?
I'll have a look to the current unit tests to see if we can load a guest virtio driver and check what features are negotiated. If we have something like that, it will not be a problem.
Thanks,
Marcel
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
hw/net/vhost_net.c +0
-0}hw/virtio/vhost-user.c +2
-3@@ -358,9 +358,9 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)return err; } -if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { - dev->backend_features |=1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ; + dev->backend_features = msg.u64; +if (__virtio_has_feature (msg.u64,VHOST_USER_F_PROTOCOL_FEATURES )) { msg.request =VHOST_USER_GET_PROTOCOL_FEATURES ; msg.flags =VHOST_USER_VERSION ; msg.size =0 ; --2.1.0