All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
@ 2012-07-04 11:04 Fabien Chouteau
  2012-07-09 10:19 ` Fabien Chouteau
  0 siblings, 1 reply; 6+ messages in thread
From: Fabien Chouteau @ 2012-07-04 11:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, peter.maydell, aliguori, pbonzini

The goal is to make ctrl-a x to close Qemu in a clean way. The current
exit(0) skips a lot of cleanup/close functions, for example in block
drivers.

Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
---
 qemu-char.c |    2 +-
 sysemu.h    |    1 +
 vl.c        |    5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/qemu-char.c b/qemu-char.c
index c2aaaee..7732846 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -353,7 +353,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
             {
                  const char *term =  "QEMU: Terminated\n\r";
                  chr->chr_write(chr,(uint8_t *)term,strlen(term));
-                 exit(0);
+                 qemu_system_force_shutdown();
                  break;
             }
         case 's':
diff --git a/sysemu.h b/sysemu.h
index bc2c788..2b2c354 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -50,6 +50,7 @@ void qemu_register_suspend_notifier(Notifier *notifier);
 void qemu_system_wakeup_request(WakeupReason reason);
 void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
 void qemu_register_wakeup_notifier(Notifier *notifier);
+void qemu_system_force_shutdown(void);
 void qemu_system_shutdown_request(void);
 void qemu_system_powerdown_request(void);
 void qemu_system_debug_request(void);
diff --git a/vl.c b/vl.c
index 1329c30..bd27583 100644
--- a/vl.c
+++ b/vl.c
@@ -1477,6 +1477,11 @@ void qemu_system_killed(int signal, pid_t pid)
 {
     shutdown_signal = signal;
     shutdown_pid = pid;
+    qemu_system_force_shutdown();
+}
+
+void qemu_system_force_shutdown(void)
+{
     no_shutdown = 0;
     qemu_system_shutdown_request();
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
  2012-07-04 11:04 [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x Fabien Chouteau
@ 2012-07-09 10:19 ` Fabien Chouteau
  2012-07-09 10:20   ` Paolo Bonzini
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Fabien Chouteau @ 2012-07-09 10:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, peter.maydell, aliguori, pbonzini

Any comment?

On 07/04/2012 01:04 PM, Fabien Chouteau wrote:
> The goal is to make ctrl-a x to close Qemu in a clean way. The current
> exit(0) skips a lot of cleanup/close functions, for example in block
> drivers.
> 
> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
> ---
>  qemu-char.c |    2 +-
>  sysemu.h    |    1 +
>  vl.c        |    5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/qemu-char.c b/qemu-char.c
> index c2aaaee..7732846 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -353,7 +353,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
>              {
>                   const char *term =  "QEMU: Terminated\n\r";
>                   chr->chr_write(chr,(uint8_t *)term,strlen(term));
> -                 exit(0);
> +                 qemu_system_force_shutdown();
>                   break;
>              }
>          case 's':
> diff --git a/sysemu.h b/sysemu.h
> index bc2c788..2b2c354 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -50,6 +50,7 @@ void qemu_register_suspend_notifier(Notifier *notifier);
>  void qemu_system_wakeup_request(WakeupReason reason);
>  void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
>  void qemu_register_wakeup_notifier(Notifier *notifier);
> +void qemu_system_force_shutdown(void);
>  void qemu_system_shutdown_request(void);
>  void qemu_system_powerdown_request(void);
>  void qemu_system_debug_request(void);
> diff --git a/vl.c b/vl.c
> index 1329c30..bd27583 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -1477,6 +1477,11 @@ void qemu_system_killed(int signal, pid_t pid)
>  {
>      shutdown_signal = signal;
>      shutdown_pid = pid;
> +    qemu_system_force_shutdown();
> +}
> +
> +void qemu_system_force_shutdown(void)
> +{
>      no_shutdown = 0;
>      qemu_system_shutdown_request();
>  }
> 


-- 
Fabien Chouteau

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
  2012-07-09 10:19 ` Fabien Chouteau
@ 2012-07-09 10:20   ` Paolo Bonzini
  2012-07-09 10:27   ` Kevin Wolf
  2012-07-09 12:18   ` Andreas Färber
  2 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2012-07-09 10:20 UTC (permalink / raw)
  To: Fabien Chouteau, qemu-devel, Blue Swirl; +Cc: kwolf, peter.maydell, aliguori

Il 09/07/2012 12:19, Fabien Chouteau ha scritto:
> Any comment?

Looks good to me.  Blue, can you apply it while Anthony is on holiday?

Paolo

> On 07/04/2012 01:04 PM, Fabien Chouteau wrote:
>> The goal is to make ctrl-a x to close Qemu in a clean way. The current
>> exit(0) skips a lot of cleanup/close functions, for example in block
>> drivers.
>>
>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>> ---
>>  qemu-char.c |    2 +-
>>  sysemu.h    |    1 +
>>  vl.c        |    5 +++++
>>  3 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/qemu-char.c b/qemu-char.c
>> index c2aaaee..7732846 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -353,7 +353,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
>>              {
>>                   const char *term =  "QEMU: Terminated\n\r";
>>                   chr->chr_write(chr,(uint8_t *)term,strlen(term));
>> -                 exit(0);
>> +                 qemu_system_force_shutdown();
>>                   break;
>>              }
>>          case 's':
>> diff --git a/sysemu.h b/sysemu.h
>> index bc2c788..2b2c354 100644
>> --- a/sysemu.h
>> +++ b/sysemu.h
>> @@ -50,6 +50,7 @@ void qemu_register_suspend_notifier(Notifier *notifier);
>>  void qemu_system_wakeup_request(WakeupReason reason);
>>  void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
>>  void qemu_register_wakeup_notifier(Notifier *notifier);
>> +void qemu_system_force_shutdown(void);
>>  void qemu_system_shutdown_request(void);
>>  void qemu_system_powerdown_request(void);
>>  void qemu_system_debug_request(void);
>> diff --git a/vl.c b/vl.c
>> index 1329c30..bd27583 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -1477,6 +1477,11 @@ void qemu_system_killed(int signal, pid_t pid)
>>  {
>>      shutdown_signal = signal;
>>      shutdown_pid = pid;
>> +    qemu_system_force_shutdown();
>> +}
>> +
>> +void qemu_system_force_shutdown(void)
>> +{
>>      no_shutdown = 0;
>>      qemu_system_shutdown_request();
>>  }
>>
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
  2012-07-09 10:19 ` Fabien Chouteau
  2012-07-09 10:20   ` Paolo Bonzini
@ 2012-07-09 10:27   ` Kevin Wolf
  2012-07-09 12:18   ` Andreas Färber
  2 siblings, 0 replies; 6+ messages in thread
From: Kevin Wolf @ 2012-07-09 10:27 UTC (permalink / raw)
  To: Fabien Chouteau; +Cc: peter.maydell, aliguori, qemu-devel, pbonzini

Am 09.07.2012 12:19, schrieb Fabien Chouteau:
> Any comment?
> 
> On 07/04/2012 01:04 PM, Fabien Chouteau wrote:
>> The goal is to make ctrl-a x to close Qemu in a clean way. The current
>> exit(0) skips a lot of cleanup/close functions, for example in block
>> drivers.
>>
>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>

Reviewed-by: Kevin Wolf <kwolf@redhat.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
  2012-07-09 10:19 ` Fabien Chouteau
  2012-07-09 10:20   ` Paolo Bonzini
  2012-07-09 10:27   ` Kevin Wolf
@ 2012-07-09 12:18   ` Andreas Färber
  2012-07-10 10:16     ` Fabien Chouteau
  2 siblings, 1 reply; 6+ messages in thread
From: Andreas Färber @ 2012-07-09 12:18 UTC (permalink / raw)
  To: Fabien Chouteau
  Cc: kwolf, peter.maydell, aliguori, qemu-devel,
	Hervé Poussineau, pbonzini

Am 09.07.2012 12:19, schrieb Fabien Chouteau:
> Any comment?
> 
> On 07/04/2012 01:04 PM, Fabien Chouteau wrote:
>> The goal is to make ctrl-a x to close Qemu in a clean way. The current
>> exit(0) skips a lot of cleanup/close functions, for example in block
>> drivers.
>>
>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>> ---
>>  qemu-char.c |    2 +-
>>  sysemu.h    |    1 +
>>  vl.c        |    5 +++++
>>  3 files changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/qemu-char.c b/qemu-char.c
>> index c2aaaee..7732846 100644
>> --- a/qemu-char.c
>> +++ b/qemu-char.c
>> @@ -353,7 +353,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
>>              {
>>                   const char *term =  "QEMU: Terminated\n\r";
>>                   chr->chr_write(chr,(uint8_t *)term,strlen(term));
>> -                 exit(0);
>> +                 qemu_system_force_shutdown();
>>                   break;
>>              }
>>          case 's':

FWIW there was a recent patch by Hervé that exposed further occurrences
of exit(), probably all would need to be reviewed and fixed.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x
  2012-07-09 12:18   ` Andreas Färber
@ 2012-07-10 10:16     ` Fabien Chouteau
  0 siblings, 0 replies; 6+ messages in thread
From: Fabien Chouteau @ 2012-07-10 10:16 UTC (permalink / raw)
  To: Andreas Färber
  Cc: kwolf, peter.maydell, aliguori, qemu-devel,
	Hervé Poussineau, pbonzini

On 07/09/2012 02:18 PM, Andreas Färber wrote:
> Am 09.07.2012 12:19, schrieb Fabien Chouteau:
>> Any comment?
>>
>> On 07/04/2012 01:04 PM, Fabien Chouteau wrote:
>>> The goal is to make ctrl-a x to close Qemu in a clean way. The current
>>> exit(0) skips a lot of cleanup/close functions, for example in block
>>> drivers.
>>>
>>> Signed-off-by: Fabien Chouteau <chouteau@adacore.com>
>>> ---
>>>  qemu-char.c |    2 +-
>>>  sysemu.h    |    1 +
>>>  vl.c        |    5 +++++
>>>  3 files changed, 7 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qemu-char.c b/qemu-char.c
>>> index c2aaaee..7732846 100644
>>> --- a/qemu-char.c
>>> +++ b/qemu-char.c
>>> @@ -353,7 +353,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
>>>              {
>>>                   const char *term =  "QEMU: Terminated\n\r";
>>>                   chr->chr_write(chr,(uint8_t *)term,strlen(term));
>>> -                 exit(0);
>>> +                 qemu_system_force_shutdown();
>>>                   break;
>>>              }
>>>          case 's':
> 
> FWIW there was a recent patch by Hervé that exposed further occurrences
> of exit(), probably all would need to be reviewed and fixed.
> 

There's a lot of exit() in Qemu (~660 with a quick grep), but it doesn't
always make sense to change them all.

In my opinion this one is a clean user request to shutdown the system,
as opposed to an error state that requires exit().


-- 
Fabien Chouteau

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-07-10 10:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-04 11:04 [Qemu-devel] [PATCH V2] Use clean shutdown request for ctrl-a x Fabien Chouteau
2012-07-09 10:19 ` Fabien Chouteau
2012-07-09 10:20   ` Paolo Bonzini
2012-07-09 10:27   ` Kevin Wolf
2012-07-09 12:18   ` Andreas Färber
2012-07-10 10:16     ` Fabien Chouteau

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.