Make virtio_net report carrier status ON.

Message ID
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

Pantelis Koukousoulas March 14, 2009, 10:40 a.m.
The current versions of virtio hardware do not have a way to
turn the link "OFF", so in practice, the status is always ON.

Reporting that via ethtool instead of claiming
"I have no idea", allows NetworkManager to configure the
card automatically as preferred and gives users e.g.,
testing a new livecd in existing qemu/kvm the experience
they expect.

Note that for the next versions of the kernel and virtual
hardware, there is a patch that adds proper link detection
to the driver (since it will now be possible to turn it off).
But even in the light of this, my patch is still valid
because the "default ON" behavior will still be needed for
current qemu / virtio versions that don't support this feature

Signed-off-by: Pantelis Koukousoulas <>
 drivers/net/virtio_net.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index c688083..e67d16c 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -612,6 +612,7 @@  static struct ethtool_ops virtnet_ethtool_ops = {
 	.set_tx_csum = virtnet_set_tx_csum,
 	.set_sg = ethtool_op_set_sg,
 	.set_tso = ethtool_op_set_tso,
+	.get_link = ethtool_op_get_link,
 #define MIN_MTU 68
@@ -739,6 +740,8 @@  static int virtnet_probe(struct virtio_device *vdev)
 		goto unregister;
+	netif_carrier_on(dev);
 	pr_debug("virtnet: registered device %s\n", dev->name);
 	return 0;