qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Sameeh Jubran <sameeh@daynix.com>
To: qemu-devel@nongnu.org, Jason Wang <jasowang@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
	Yan Vugenfirer <yan@daynix.com>,
	Eduardo Habkost <ehabkost@redhat.com>
Subject: [Qemu-devel] [RFC 2/2] virtio-net: Implement VIRTIO_NET_F_STANDBY feature
Date: Thu, 25 Oct 2018 17:06:31 +0300	[thread overview]
Message-ID: <20181025140631.634922-3-sameeh@daynix.com> (raw)
In-Reply-To: <20181025140631.634922-1-sameeh@daynix.com>

From: Sameeh Jubran <sjubran@redhat.com>

Signed-off-by: Sameeh Jubran <sjubran@redhat.com>
---
 hw/net/virtio-net.c            | 25 +++++++++++++++++++++++++
 include/hw/virtio/virtio-net.h |  5 +++++
 2 files changed, 30 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f154756e85..f478445cbd 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -686,6 +686,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
 {
     VirtIONet *n = VIRTIO_NET(vdev);
     int i;
+    Error *err;
 
     if (n->mtu_bypass_backend &&
             !virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_MTU)) {
@@ -721,6 +722,10 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
     } else {
         memset(n->vlans, 0xff, MAX_VLAN >> 3);
     }
+
+    if (virtio_has_feature(features, VIRTIO_NET_F_STANDBY)) {
+        qdev_unhide(n->net_conf.primary_id_str, n->primary_parent_bus, &err);
+    }
 }
 
 static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
@@ -1946,6 +1951,20 @@ void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
     n->netclient_type = g_strdup(type);
 }
 
+static void virtio_net_primary_should_be_hidden(DeviceListener *listener,const char *dev_id, BusState *bus, bool *res)
+{
+   VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
+    if (!strcmp(n->net_conf.primary_id_str ,dev_id) && bus)
+    {
+        printf("net_confnet_confnet_confnet_confnet_conf\n");
+        n->host_features |= (1ULL << VIRTIO_NET_F_STANDBY);
+        n->primary_parent_bus = bus;
+        *res = true;
+        return;
+    }
+    *res = false;
+}
+
 static void virtio_net_device_realize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
@@ -1976,6 +1995,11 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
         n->host_features |= (1ULL << VIRTIO_NET_F_SPEED_DUPLEX);
     }
 
+    if (n->net_conf.primary_id_str) {
+        n->primary_listener.should_be_hidden = virtio_net_primary_should_be_hidden;
+        device_listener_register(&n->primary_listener);
+    }
+
     virtio_net_set_config_size(n, n->host_features);
     virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size);
 
@@ -2198,6 +2222,7 @@ static Property virtio_net_properties[] = {
                      true),
     DEFINE_PROP_INT32("speed", VirtIONet, net_conf.speed, SPEED_UNKNOWN),
     DEFINE_PROP_STRING("duplex", VirtIONet, net_conf.duplex_str),
+    DEFINE_PROP_STRING("primary", VirtIONet, net_conf.primary_id_str),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 4d7f3c82ca..6aca93e461 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -42,6 +42,7 @@ typedef struct virtio_net_conf
     int32_t speed;
     char *duplex_str;
     uint8_t duplex;
+    char *primary_id_str;
 } virtio_net_conf;
 
 /* Maximum packet size we can receive from tap device: header + 64k */
@@ -103,9 +104,13 @@ typedef struct VirtIONet {
     int announce_counter;
     bool needs_vnet_hdr_swap;
     bool mtu_bypass_backend;
+    BusState *primary_parent_bus;
+    DeviceListener primary_listener;
 } VirtIONet;
 
 void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
                                    const char *type);
+void virtio_net_register_primary_device(DeviceState *vdev, DeviceState *pdev);
+
 
 #endif
-- 
2.17.0

  parent reply	other threads:[~2018-10-25 14:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 14:06 [Qemu-devel] [RFC 0/2] Attempt to implement the standby feature for assigned network devices Sameeh Jubran
2018-10-25 14:06 ` [Qemu-devel] [RFC 1/2] qdev/qbus: Add hidden device support Sameeh Jubran
2018-10-25 14:06 ` Sameeh Jubran [this message]
2018-10-25 18:01 ` [Qemu-devel] [RFC 0/2] Attempt to implement the standby feature for assigned network devices Sameeh Jubran
2018-12-05 16:18   ` Michael Roth
2018-12-05 17:09     ` [Qemu-devel] [libvirt] " Peter Krempa
2018-12-05 17:22       ` Michael S. Tsirkin
2018-12-05 17:26         ` Daniel P. Berrangé
2018-12-05 17:43       ` Daniel P. Berrangé
2018-10-25 22:17 ` [Qemu-devel] " Michael S. Tsirkin
2018-12-05 17:18 ` Daniel P. Berrangé
2018-12-05 17:26   ` Michael S. Tsirkin
2018-12-05 20:24   ` Michael Roth
2018-12-05 20:44     ` Michael Roth
2018-12-05 20:58       ` Michael S. Tsirkin
2018-12-05 20:57     ` Michael S. Tsirkin
2018-12-06 10:01       ` Daniel P. Berrangé
2018-12-06 10:06     ` Daniel P. Berrangé
2018-12-07 16:36       ` Eduardo Habkost
2018-12-07 16:46         ` Daniel P. Berrangé
2018-12-07 18:26           ` Michael S. Tsirkin
2018-12-07 17:50       ` Roman Kagan
2018-12-07 18:20       ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181025140631.634922-3-sameeh@daynix.com \
    --to=sameeh@daynix.com \
    --cc=ehabkost@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yan@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).