From patchwork Sun Jul 17 08:57:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 983032 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6H8xrer023138 for ; Sun, 17 Jul 2011 08:59:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754443Ab1GQI7u (ORCPT ); Sun, 17 Jul 2011 04:59:50 -0400 Received: from mail-iw0-f174.google.com ([209.85.214.174]:63499 "EHLO mail-iw0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754379Ab1GQI7t (ORCPT ); Sun, 17 Jul 2011 04:59:49 -0400 Received: by mail-iw0-f174.google.com with SMTP id 6so2294615iwn.19 for ; Sun, 17 Jul 2011 01:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=EYrwtv6gVGaPsWzT3lXpy/iLCO9586FrI5wdrjWixzw=; b=PaJQ6G1Tzb7tEGk0WtKjvjIeuk8fpNwXuYEVmQq7NvwSduiVjz+ufPF7awJCHkSh40 1y236Y5iDEswcYU7xLJSYZniuL69bFpWdgyKid2fEITbwn6ZRp+Yb7ZkfWvFEUGxzr6g RTqRJvlGAjEE/TO0nadMEgWrmKqDN2wT8u1VY= Received: by 10.42.168.74 with SMTP id v10mr5908800icy.165.1310893189345; Sun, 17 Jul 2011 01:59:49 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id us2sm3593680icb.19.2011.07.17.01.59.46 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jul 2011 01:59:48 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH 15/16] kvm tools: Initialize MAC address for virtio net properly Date: Sun, 17 Jul 2011 16:57:03 +0800 Message-Id: <1310893024-21615-16-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> References: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 17 Jul 2011 08:59:54 +0000 (UTC) - Drop static initialization - Move the initializtion out of tap init Signed-off-by: Asias He --- tools/kvm/virtio/net.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index f4ba79a..af9b740 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -82,7 +82,6 @@ static struct net_dev ndev = { .mutex = PTHREAD_MUTEX_INITIALIZER, .config = { - .mac = {0x00, 0x15, 0x15, 0x15, 0x15, 0x15}, .status = VIRTIO_NET_S_LINK_UP, }, .host_features = 1UL << VIRTIO_NET_F_MAC @@ -318,13 +317,10 @@ static struct ioport_operations virtio_net_io_ops = { static bool virtio_net__tap_init(const struct virtio_net_parameters *params) { int sock = socket(AF_INET, SOCK_STREAM, 0); - int i, pid, status, offload, hdr_len; + int pid, status, offload, hdr_len; struct sockaddr_in sin = {0}; struct ifreq ifr; - for (i = 0 ; i < 6 ; i++) - ndev.config.mac[i] = params->guest_mac[i]; - ndev.tap_fd = open("/dev/net/tun", O_RDWR); if (ndev.tap_fd < 0) { pr_warning("Unable to open /dev/net/tun"); @@ -459,6 +455,9 @@ void virtio_net__init(const struct virtio_net_parameters *params) ndev.base_addr = net_base_addr; pci__register(&pci_header, dev); + for (i = 0 ; i < 6 ; i++) + ndev.config.mac[i] = params->guest_mac[i]; + ndev.mode = params->mode; if (ndev.mode == NET_MODE_TAP) { virtio_net__tap_init(params);