From patchwork Tue Jan 13 21:23:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 2216 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0DLJfAC012070 for ; Tue, 13 Jan 2009 13:19:41 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753875AbZAMVXX (ORCPT ); Tue, 13 Jan 2009 16:23:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753715AbZAMVXX (ORCPT ); Tue, 13 Jan 2009 16:23:23 -0500 Received: from g4t0015.houston.hp.com ([15.201.24.18]:7212 "EHLO g4t0015.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655AbZAMVXW (ORCPT ); Tue, 13 Jan 2009 16:23:22 -0500 Received: from g1t0039.austin.hp.com (g1t0039.austin.hp.com [16.236.32.45]) by g4t0015.houston.hp.com (Postfix) with ESMTP id DA46680E3; Tue, 13 Jan 2009 21:23:21 +0000 (UTC) Received: from ldl.fc.hp.com (ldl.fc.hp.com [15.11.146.30]) by g1t0039.austin.hp.com (Postfix) with ESMTP id C5205340EE; Tue, 13 Jan 2009 21:23:21 +0000 (UTC) Received: from localhost (ldl.fc.hp.com [127.0.0.1]) by ldl.fc.hp.com (Postfix) with ESMTP id 679A639C003; Tue, 13 Jan 2009 14:23:21 -0700 (MST) X-Virus-Scanned: Debian amavisd-new at ldl.fc.hp.com Received: from ldl.fc.hp.com ([127.0.0.1]) by localhost (ldl.fc.hp.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hli3qoZO8NWq; Tue, 13 Jan 2009 14:23:19 -0700 (MST) Received: from [192.168.1.60] (squirrel.fc.hp.com [15.11.146.57]) by ldl.fc.hp.com (Postfix) with ESMTP id 48F4D39C001; Tue, 13 Jan 2009 14:23:19 -0700 (MST) Subject: [PATCH 1/4] virtio_net: Allow setting the MAC address of the NIC From: Alex Williamson To: Rusty Russell Cc: kvm , netdev , Mark McLoughlin Organization: HP OSLO R&D Date: Tue, 13 Jan 2009 14:23:16 -0700 Message-Id: <1231881796.9095.186.camel@bling> Mime-Version: 1.0 X-Mailer: Evolution 2.24.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Alex Williamson Acked-by: Mark McLoughlin --- drivers/net/virtio_net.c | 23 +++++++++++++++++++++-- 1 files changed, 21 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 43f6523..e7700de 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -561,6 +561,22 @@ stop_queue: goto done; } +static int virtnet_set_mac_address(struct net_device *dev, void *p) +{ + struct virtnet_info *vi = netdev_priv(dev); + struct virtio_device *vdev = vi->vdev; + int ret; + + ret = eth_mac_addr(dev, p); + if (ret) + return ret; + + vdev->config->set(vdev, offsetof(struct virtio_net_config, mac), + dev->dev_addr, dev->addr_len); + + return 0; +} + #ifdef CONFIG_NET_POLL_CONTROLLER static void virtnet_netpoll(struct net_device *dev) { @@ -629,7 +645,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_stop = virtnet_close, .ndo_start_xmit = start_xmit, .ndo_validate_addr = eth_validate_addr, - .ndo_set_mac_address = eth_mac_addr, + .ndo_set_mac_address = virtnet_set_mac_address, .ndo_change_mtu = virtnet_change_mtu, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = virtnet_netpoll, @@ -677,8 +693,11 @@ static int virtnet_probe(struct virtio_device *vdev) vdev->config->get(vdev, offsetof(struct virtio_net_config, mac), dev->dev_addr, dev->addr_len); - } else + } else { random_ether_addr(dev->dev_addr); + vdev->config->set(vdev, offsetof(struct virtio_net_config, mac), + dev->dev_addr, dev->addr_len); + } /* Set up our device-specific information */ vi = netdev_priv(dev);