* [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len
@ 2013-04-25 7:26 Jason Wang
2013-04-25 7:42 ` Michael S. Tsirkin
2013-05-02 15:55 ` Anthony Liguori
0 siblings, 2 replies; 3+ messages in thread
From: Jason Wang @ 2013-04-25 7:26 UTC (permalink / raw)
To: aliguori, qemu-devel; +Cc: Jason Wang, Jesse Larrew, mst
Commit 14f9b664 (hw/virtio-net.c: set config size using host features) tries to
calculate config size based on the host features. But it forgets the
VIRTIO_NET_F_MAC were always set for qemu later. This will lead a zero config
len for virtio-net device when both VIRTIO_NET_F_STATUS and VIRTIO_NET_F_MQ were
disabled form command line. Then qemu will crash when user tries to read the
config of virtio-net.
Fix this by counting VIRTIO_NET_F_MAC and make sure the config at least contains
the mac address.
Cc: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
Changes from V1:
- Set VIRTIO_NET_F_MAC bit in host_features instead of initializing config_size
---
hw/net/virtio-net.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1662f46..d4533d5 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1266,6 +1266,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features)
{
int i, config_size = 0;
+ host_features |= (1 << VIRTIO_NET_F_MAC);
for (i = 0; feature_sizes[i].flags != 0; i++) {
if (host_features & feature_sizes[i].flags) {
config_size = MAX(feature_sizes[i].end, config_size);
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len
2013-04-25 7:26 [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len Jason Wang
@ 2013-04-25 7:42 ` Michael S. Tsirkin
2013-05-02 15:55 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2013-04-25 7:42 UTC (permalink / raw)
To: Jason Wang; +Cc: aliguori, qemu-devel, Jesse Larrew
On Thu, Apr 25, 2013 at 03:26:54PM +0800, Jason Wang wrote:
> Commit 14f9b664 (hw/virtio-net.c: set config size using host features) tries to
> calculate config size based on the host features. But it forgets the
> VIRTIO_NET_F_MAC were always set for qemu later. This will lead a zero config
> len for virtio-net device when both VIRTIO_NET_F_STATUS and VIRTIO_NET_F_MQ were
> disabled form command line. Then qemu will crash when user tries to read the
> config of virtio-net.
>
> Fix this by counting VIRTIO_NET_F_MAC and make sure the config at least contains
> the mac address.
>
> Cc: Jesse Larrew <jlarrew@linux.vnet.ibm.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Not sure which tag is needed anymore ...
Anthony, pick this up for 1.5?
> ---
> Changes from V1:
> - Set VIRTIO_NET_F_MAC bit in host_features instead of initializing config_size
> ---
> hw/net/virtio-net.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 1662f46..d4533d5 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1266,6 +1266,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx,
> void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features)
> {
> int i, config_size = 0;
> + host_features |= (1 << VIRTIO_NET_F_MAC);
> for (i = 0; feature_sizes[i].flags != 0; i++) {
> if (host_features & feature_sizes[i].flags) {
> config_size = MAX(feature_sizes[i].end, config_size);
> --
> 1.7.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len
2013-04-25 7:26 [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len Jason Wang
2013-04-25 7:42 ` Michael S. Tsirkin
@ 2013-05-02 15:55 ` Anthony Liguori
1 sibling, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2013-05-02 15:55 UTC (permalink / raw)
To: Jason Wang, aliguori, qemu-devel; +Cc: Jesse Larrew, mst
Applied. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-02 15:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25 7:26 [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len Jason Wang
2013-04-25 7:42 ` Michael S. Tsirkin
2013-05-02 15:55 ` Anthony Liguori
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.