@@ -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(),
};
@@ -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