]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Initialize MAC address for virtio net properly
authorAsias He <asias.hejun@gmail.com>
Sun, 17 Jul 2011 08:57:03 +0000 (16:57 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 18 Jul 2011 10:17:20 +0000 (13:17 +0300)
- Drop static initialization

- Move the initializtion out of tap init

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/virtio/net.c

index f4ba79af001b58f62ab70261abd8f1c9def1b8e8..af9b7409f6baf9dcc1d82fa2b11b53324f058e0d 100644 (file)
@@ -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);