diff mbox

[3/4] hw/net/virtio-net: Move DEFINE_VIRTIO_NET_FEATURES to virtio-net

Message ID 1429272826-4145-4-git-send-email-shannon.zhao@linaro.org
State New
Headers show

Commit Message

Shannon Zhao April 17, 2015, 12:13 p.m. UTC
Move DEFINE_VIRTIO_NET_FEATURES to the backend virtio-net.
The transports just sync the host features from backend.

Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 hw/net/virtio-net.c            | 4 ++++
 hw/s390x/s390-virtio-bus.c     | 1 -
 hw/s390x/virtio-ccw.c          | 1 -
 hw/virtio/virtio-pci.c         | 1 -
 include/hw/virtio/virtio-net.h | 1 +
 5 files changed, 5 insertions(+), 3 deletions(-)

Comments

Peter Maydell April 17, 2015, 2:05 p.m. UTC | #1
On 17 April 2015 at 13:13, Shannon Zhao <shannon.zhao@linaro.org> wrote:
> Move DEFINE_VIRTIO_NET_FEATURES to the backend virtio-net.
> The transports just sync the host features from backend.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  hw/net/virtio-net.c            | 4 ++++
>  hw/s390x/s390-virtio-bus.c     | 1 -
>  hw/s390x/virtio-ccw.c          | 1 -
>  hw/virtio/virtio-pci.c         | 1 -
>  include/hw/virtio/virtio-net.h | 1 +
>  5 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 27adcc5..5d72e2d 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -446,6 +446,9 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
>      VirtIONet *n = VIRTIO_NET(vdev);
>      NetClientState *nc = qemu_get_queue(n->nic);
>
> +    /* First sync all virtio-net possible supported features */
> +    features |= n->host_features;
> +
>      virtio_add_feature(&features, VIRTIO_NET_F_MAC);
>
>      if (!peer_has_vnet_hdr(n)) {
> @@ -1714,6 +1717,7 @@ static void virtio_net_instance_init(Object *obj)
>  }
>
>  static Property virtio_net_properties[] = {
> +    DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features),
>      DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf),
>      DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer,
>                                                 TX_TIMER_INTERVAL),
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index 31fdf94..49c13e2 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -517,7 +517,6 @@ static void virtio_s390_device_plugged(DeviceState *d)
>
>  static Property s390_virtio_net_properties[] = {
>      DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
> -    DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
>      DEFINE_PROP_END_OF_LIST(),
>  };

I'm confused. This seems to be the same "breaks backwards compatibility"
implementation you suggested to me off-list and which I said
wouldn't work.

thanks
-- PMM
Shannon Zhao April 17, 2015, 2:50 p.m. UTC | #2
On Friday, 17 April 2015, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 17 April 2015 at 13:13, Shannon Zhao <shannon.zhao@linaro.org> wrote:
>> Move DEFINE_VIRTIO_NET_FEATURES to the backend virtio-net.
>> The transports just sync the host features from backend.
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  hw/net/virtio-net.c            | 4 ++++
>>  hw/s390x/s390-virtio-bus.c     | 1 -
>>  hw/s390x/virtio-ccw.c          | 1 -
>>  hw/virtio/virtio-pci.c         | 1 -
>>  include/hw/virtio/virtio-net.h | 1 +
>>  5 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
>> index 27adcc5..5d72e2d 100644
>> --- a/hw/net/virtio-net.c
>> +++ b/hw/net/virtio-net.c
>> @@ -446,6 +446,9 @@ static uint32_t virtio_net_get_features(VirtIODevice
*vdev, uint32_t features)
>>      VirtIONet *n = VIRTIO_NET(vdev);
>>      NetClientState *nc = qemu_get_queue(n->nic);
>>
>> +    /* First sync all virtio-net possible supported features */
>> +    features |= n->host_features;
>> +
>>      virtio_add_feature(&features, VIRTIO_NET_F_MAC);
>>
>>      if (!peer_has_vnet_hdr(n)) {
>> @@ -1714,6 +1717,7 @@ static void virtio_net_instance_init(Object *obj)
>>  }
>>
>>  static Property virtio_net_properties[] = {
>> +    DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features),
>>      DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf),
>>      DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer,
>>                                                 TX_TIMER_INTERVAL),
>> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
>> index 31fdf94..49c13e2 100644
>> --- a/hw/s390x/s390-virtio-bus.c
>> +++ b/hw/s390x/s390-virtio-bus.c
>> @@ -517,7 +517,6 @@ static void virtio_s390_device_plugged(DeviceState
*d)
>>
>>  static Property s390_virtio_net_properties[] = {
>>      DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
>> -    DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
>>      DEFINE_PROP_END_OF_LIST(),
>>  };
>
> I'm confused. This seems to be the same "breaks backwards compatibility"
> implementation you suggested to me off-list and which I said
> wouldn't work.
>


Hi Peter,

The backwards compatibility is that with this patch the virtio-net-pci can
still set these properties through the qemu comand line, right?

As I mentioned off list and in the cover letter, the virtio-net-pci has the
ability to access the child's(here is virtio-net) properties. So it look
like the wrapper has these properties.

> thanks
> -- PMM
>
Peter Maydell April 17, 2015, 3:03 p.m. UTC | #3
On 17 April 2015 at 15:50, Shannon Zhao <shannon.zhao@linaro.org> wrote:
> The backwards compatibility is that with this patch the virtio-net-pci can
> still set these properties through the qemu comand line, right?
>
> As I mentioned off list and in the cover letter, the virtio-net-pci has the
> ability to access the child's(here is virtio-net) properties. So it look
> like the wrapper has these properties.

Hmm, you're right -- if I test (using "-device virtio-net-pci,help"
to list properties) they're all still there. I don't see how this
works, but it does seem to :-)

-- PMM
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 27adcc5..5d72e2d 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -446,6 +446,9 @@  static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc = qemu_get_queue(n->nic);
 
+    /* First sync all virtio-net possible supported features */
+    features |= n->host_features;
+
     virtio_add_feature(&features, VIRTIO_NET_F_MAC);
 
     if (!peer_has_vnet_hdr(n)) {
@@ -1714,6 +1717,7 @@  static void virtio_net_instance_init(Object *obj)
 }
 
 static Property virtio_net_properties[] = {
+    DEFINE_VIRTIO_NET_FEATURES(VirtIONet, host_features),
     DEFINE_NIC_PROPERTIES(VirtIONet, nic_conf),
     DEFINE_PROP_UINT32("x-txtimer", VirtIONet, net_conf.txtimer,
                                                TX_TIMER_INTERVAL),
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 31fdf94..49c13e2 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -517,7 +517,6 @@  static void virtio_s390_device_plugged(DeviceState *d)
 
 static Property s390_virtio_net_properties[] = {
     DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
-    DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 30ca377..acd3844 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1409,7 +1409,6 @@  static void virtio_ccw_device_plugged(DeviceState *d)
 
 static Property virtio_ccw_net_properties[] = {
     DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
-    DEFINE_VIRTIO_NET_FEATURES(VirtioCcwDevice, host_features[0]),
     DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
                     VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
     DEFINE_PROP_END_OF_LIST(),
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c7c3f72..772244e 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1360,7 +1360,6 @@  static Property virtio_net_properties[] = {
     DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
                     VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
     DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
-    DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 4c2fe83..5bee4df 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -68,6 +68,7 @@  typedef struct VirtIONet {
     uint32_t has_vnet_hdr;
     size_t host_hdr_len;
     size_t guest_hdr_len;
+    uint32_t host_features;
     uint8_t has_ufo;
     int mergeable_rx_bufs;
     uint8_t promisc;