Commit f30dbae6 authored by Amos Kong's avatar Amos Kong Committed by Stefan Hajnoczi
Browse files

net: clean up network at qemu process termination



We don't clean up network if fails to parse "-device" parameters without
calling net_cleanup(). I touch a problem, the tap device which is
created by qemu-ifup script could not be removed by qemu-ifdown script.
Some similar problems also exist in vl.c

In this patch, if network initialization successes, a cleanup function
will be registered to be called at qemu process termination.

Signed-off-by: default avatarAmos Kong <akong@redhat.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 2c0331f4
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -3762,6 +3762,9 @@ int main(int argc, char **argv, char **envp)
    }
    configure_icount(icount_option);

    /* clean up network at qemu process termination */
    atexit(&net_cleanup);

    if (net_init_clients() < 0) {
        exit(1);
    }
@@ -4014,7 +4017,6 @@ int main(int argc, char **argv, char **envp)
    main_loop();
    bdrv_close_all();
    pause_all_vcpus();
    net_cleanup();
    res_free();

    return 0;