diff mbox

[5/5] hostmem: init/finalize hostmem listener

Message ID 1364804434-7980-6-git-send-email-qemulist@gmail.com
State New
Headers show

Commit Message

pingfan liu April 1, 2013, 8:20 a.m. UTC
From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 vl.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Paolo Bonzini April 11, 2013, 10:02 a.m. UTC | #1
Il 01/04/2013 10:20, Liu Ping Fan ha scritto:
> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> 
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
>  vl.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 7643f16..46a25cf 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4157,6 +4157,7 @@ int main(int argc, char **argv, char **envp)
>      }
>  
>      os_set_line_buffering();
> +    hostmem_init();
>  
>      qemu_init_cpu_loop();
>      qemu_mutex_lock_iothread();
> @@ -4174,6 +4175,7 @@ int main(int argc, char **argv, char **envp)
>  
>      /* clean up network at qemu process termination */
>      atexit(&net_cleanup);
> +    atexit(&hostmem_finalize);

This should be in hostmem_init.

Paolo

>  
>      if (net_init_clients() < 0) {
>          exit(1);
>
pingfan liu April 11, 2013, 12:08 p.m. UTC | #2
On Thu, Apr 11, 2013 at 6:02 PM, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 01/04/2013 10:20, Liu Ping Fan ha scritto:
>> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>>
>> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>> ---
>>  vl.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 7643f16..46a25cf 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -4157,6 +4157,7 @@ int main(int argc, char **argv, char **envp)
>>      }
>>
>>      os_set_line_buffering();
>> +    hostmem_init();
>>
>>      qemu_init_cpu_loop();
>>      qemu_mutex_lock_iothread();
>> @@ -4174,6 +4175,7 @@ int main(int argc, char **argv, char **envp)
>>
>>      /* clean up network at qemu process termination */
>>      atexit(&net_cleanup);
>> +    atexit(&hostmem_finalize);
>
> This should be in hostmem_init.
>
Ok, thanks. And extra, for the hostmem_init, what about something like
#define block_init(function) module_init(function, MODULE_INIT_BLOCK)

Regards,
Pingfan
> Paolo
>
>>
>>      if (net_init_clients() < 0) {
>>          exit(1);
>>
>
Paolo Bonzini April 11, 2013, 1:14 p.m. UTC | #3
Il 11/04/2013 14:08, liu ping fan ha scritto:
>>> >>      /* clean up network at qemu process termination */
>>> >>      atexit(&net_cleanup);
>>> >> +    atexit(&hostmem_finalize);
>> >
>> > This should be in hostmem_init.
>> >
> Ok, thanks. And extra, for the hostmem_init, what about something like
> #define block_init(function) module_init(function, MODULE_INIT_BLOCK)

Actually, I would prefer that you do not use a global, so the above
comment doesn't really apply unless someone overrides me and tell you to
use a global.

Paolo
Amos Kong June 13, 2013, 4:38 a.m. UTC | #4
On Mon, Apr 01, 2013 at 04:20:34PM +0800, Liu Ping Fan wrote:
> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> 
> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
> ---
>  vl.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/vl.c b/vl.c
> index 7643f16..46a25cf 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -4157,6 +4157,7 @@ int main(int argc, char **argv, char **envp)
>      }
>  
>      os_set_line_buffering();
> +    hostmem_init();
>  
>      qemu_init_cpu_loop();
>      qemu_mutex_lock_iothread();
> @@ -4174,6 +4175,7 @@ int main(int argc, char **argv, char **envp)
>  
>      /* clean up network at qemu process termination */
>      atexit(&net_cleanup);
> +    atexit(&hostmem_finalize);


The func registered by atexit() can only be called at normal termination.
If qemu process is abort() or killed by 'kill -9', the func won't be
called.

A known issue: at the abnormal termination, downscript could not be
executed to cleanup tap device. Can we suggest user to clean network
manually in this condition?


>  
>      if (net_init_clients() < 0) {
>          exit(1);
> --
pingfan liu June 13, 2013, 8:51 a.m. UTC | #5
On Thu, Jun 13, 2013 at 12:38 PM, Amos Kong <akong@redhat.com> wrote:
> On Mon, Apr 01, 2013 at 04:20:34PM +0800, Liu Ping Fan wrote:
>> From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>>
>> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>> ---
>>  vl.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/vl.c b/vl.c
>> index 7643f16..46a25cf 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -4157,6 +4157,7 @@ int main(int argc, char **argv, char **envp)
>>      }
>>
>>      os_set_line_buffering();
>> +    hostmem_init();
>>
>>      qemu_init_cpu_loop();
>>      qemu_mutex_lock_iothread();
>> @@ -4174,6 +4175,7 @@ int main(int argc, char **argv, char **envp)
>>
>>      /* clean up network at qemu process termination */
>>      atexit(&net_cleanup);
>> +    atexit(&hostmem_finalize);
>
>
> The func registered by atexit() can only be called at normal termination.
> If qemu process is abort() or killed by 'kill -9', the func won't be
> called.
>
> A known issue: at the abnormal termination, downscript could not be
> executed to cleanup tap device. Can we suggest user to clean network
> manually in this condition?
>
SIG_KILL leaves no opportunity for us to do extra things, so I think
your suggestion is the only way out.
>
>>
>>      if (net_init_clients() < 0) {
>>          exit(1);
>> --
>
> --
>                         Amos.
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 7643f16..46a25cf 100644
--- a/vl.c
+++ b/vl.c
@@ -4157,6 +4157,7 @@  int main(int argc, char **argv, char **envp)
     }
 
     os_set_line_buffering();
+    hostmem_init();
 
     qemu_init_cpu_loop();
     qemu_mutex_lock_iothread();
@@ -4174,6 +4175,7 @@  int main(int argc, char **argv, char **envp)
 
     /* clean up network at qemu process termination */
     atexit(&net_cleanup);
+    atexit(&hostmem_finalize);
 
     if (net_init_clients() < 0) {
         exit(1);