- Drop static initialization

- Move the initializtion out of tap init

Signed-off-by: Asias He <[email protected]>
---
 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);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to