From patchwork Sun Jul 17 08:57:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 983042 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 p6H8xvdA023149 for ; Sun, 17 Jul 2011 08:59:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754462Ab1GQI7x (ORCPT ); Sun, 17 Jul 2011 04:59:53 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:39735 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753880Ab1GQI7x (ORCPT ); Sun, 17 Jul 2011 04:59:53 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so2303241iyb.19 for ; Sun, 17 Jul 2011 01:59:52 -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=TvOnm9wOSkIfAp6f5G5zTaz3VBzSJRr0oO4iaSqqQZA=; b=lg4gijuExLEn9a7wemDjgS+NzZpKNW9nTWK2+Iiz1825s+YZXzOVbTMqFvetncotaI 5ENj7lMzkC0MFojmUA7+7AcxkezVDE4AmsXHDVvbaAsZwlLygLNjkc3jxGG7wfIlkB6b 0ObAtfVr1mXkXz39ZhCbxuu1UlbA1wQfwT8M8= Received: by 10.42.131.196 with SMTP id a4mr5767867ict.101.1310893192625; Sun, 17 Jul 2011 01:59:52 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id us2sm3593680icb.19.2011.07.17.01.59.49 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jul 2011 01:59:52 -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 16/16] kvm tools: Initialize MAC and IP address for uip properly Date: Sun, 17 Jul 2011 16:57:04 +0800 Message-Id: <1310893024-21615-17-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:57 +0000 (UTC) - Drop static initialization - Use {host,guet}_{ip,mac} to initialize Signed-off-by: Asias He --- tools/kvm/virtio/net.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/kvm/virtio/net.c b/tools/kvm/virtio/net.c index af9b740..739f157 100644 --- a/tools/kvm/virtio/net.c +++ b/tools/kvm/virtio/net.c @@ -93,9 +93,6 @@ static struct net_dev ndev = { | 1UL << VIRTIO_NET_F_GUEST_TSO4 | 1UL << VIRTIO_NET_F_GUEST_TSO6, .info = { - .host_mac.addr = {0x00, 0x01, 0x01, 0x01, 0x01, 0x01}, - .guest_mac.addr = {0x00, 0x15, 0x15, 0x15, 0x15, 0x15}, - .host_ip = 0xc0a82101, .buf_nr = 20, } }; @@ -455,14 +452,20 @@ 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]; + for (i = 0 ; i < 6 ; i++) { + ndev.config.mac[i] = params->guest_mac[i]; + ndev.info.guest_mac.addr[i] = params->guest_mac[i]; + ndev.info.host_mac.addr[i] = params->host_mac[i]; + } ndev.mode = params->mode; if (ndev.mode == NET_MODE_TAP) { virtio_net__tap_init(params); ndev.ops = &tap_ops; } else { + ndev.info.host_ip = ntohl(inet_addr(params->host_ip)); + ndev.info.guest_ip = ntohl(inet_addr(params->guest_ip)); + ndev.info.guest_netmask = ntohl(inet_addr("255.255.255.0")); uip_init(&ndev.info); ndev.ops = &uip_ops; }