qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV
       [not found] <op.w53t8fe2cb68cn@whitewind-arch>
@ 2013-11-06  9:20 ` Michael Tokarev
  2013-11-07  2:45   ` whitearchey
  2013-11-13 12:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2013-11-06  9:20 UTC (permalink / raw)
  To: whitearchey; +Cc: qemu-trivial, qemu-devel

06.11.2013 05:54, whitearchey wrote:
> For now guest agent uses following command to shutdown system:
> shutdown -P +0 "blabla"
> but this syntax works only with shutdown command from systemd or upstart,
> because SysV shutdown requires -h switch.
>
> Following patch changes the command so it works with systemd, upstart and SysV

While the patch is one-liner indeed, it is a bit more than trivial.
Because it changes things in a non-obvious way, especially when
multiple systems are concerned.  Cc'ing qemu-devel@ due to this.

> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> -        execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
> +        execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",

Note that shutdown command is not in POSIX, despite the fact
that this is put into commands-posix.c

Note also that even shutdown from sysvinit on linux has another
option, -P, which mean poweroff, while -h means "halt OR poweroff"
(the latter is a bit unclear).

Does the same work on other *nixes?  *BSD?  Solaris?

Thanks,

/mjt

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

* Re: [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV
  2013-11-06  9:20 ` [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV Michael Tokarev
@ 2013-11-07  2:45   ` whitearchey
  2013-11-12  9:01     ` whitearchey
  0 siblings, 1 reply; 4+ messages in thread
From: whitearchey @ 2013-11-07  2:45 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial@nongnu.org, qemu-devel

On Wed, 06 Nov 2013 18:20:36 +0900, Michael Tokarev <mjt@tls.msk.ru> wrote:

> 06.11.2013 05:54, whitearchey wrote:
>> For now guest agent uses following command to shutdown system:
>> shutdown -P +0 "blabla"
>> but this syntax works only with shutdown command from systemd or upstart,
>> because SysV shutdown requires -h switch.
>>
>> Following patch changes the command so it works with systemd, upstart and SysV
>
> While the patch is one-liner indeed, it is a bit more than trivial.
> Because it changes things in a non-obvious way, especially when
> multiple systems are concerned.  Cc'ing qemu-devel@ due to this.
>
>> --- a/qga/commands-posix.c
>> +++ b/qga/commands-posix.c
>> -        execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
>> +        execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
>
> Note that shutdown command is not in POSIX, despite the fact
> that this is put into commands-posix.c
>
> Note also that even shutdown from sysvinit on linux has another
> option, -P, which mean poweroff, while -h means "halt OR poweroff"
> (the latter is a bit unclear).
With upstart/systemd qga use one of thee commands, depending on 'mode' parameter:
   shutdown -P +0 "..."
   shutdown -H +0 "..."
   shutdown -r +0 "..."
SysV equivalents for these are:
   shutdown -h -P +0 "..."
   shutdown -h -H +0 "..."
   shutdown -h -r +0 "..."
and these retain their meaning with upstart/systemd.

>
> Does the same work on other *nixes?  *BSD?  Solaris?
>
No, it doesn't. But existing code also does not work.
According to FreeBSD manpages, shutdown does not accept -P and -H options. Commands should be:
   shutdown -p +0 "..."
   shutdown -h +0 "..."
   shutdown -r +0 "..."

shutdown in Solaris does not accept any of -hHpPr and does not accept time in "+0" format

> Thanks,
>
> /mjt

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

* Re: [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV
  2013-11-07  2:45   ` whitearchey
@ 2013-11-12  9:01     ` whitearchey
  0 siblings, 0 replies; 4+ messages in thread
From: whitearchey @ 2013-11-12  9:01 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: qemu-trivial@nongnu.org, qemu-devel

What about patch? Will it be applied? Or should it be rewritten?

On Thu, 07 Nov 2013 11:45:25 +0900, whitearchey <whitearchey@gmail.com> wrote:

> On Wed, 06 Nov 2013 18:20:36 +0900, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
>> 06.11.2013 05:54, whitearchey wrote:
>>> For now guest agent uses following command to shutdown system:
>>> shutdown -P +0 "blabla"
>>> but this syntax works only with shutdown command from systemd or upstart,
>>> because SysV shutdown requires -h switch.
>>>
>>> Following patch changes the command so it works with systemd, upstart and SysV
>>
>> While the patch is one-liner indeed, it is a bit more than trivial.
>> Because it changes things in a non-obvious way, especially when
>> multiple systems are concerned.  Cc'ing qemu-devel@ due to this.
>>
>>> --- a/qga/commands-posix.c
>>> +++ b/qga/commands-posix.c
>>> -        execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
>>> +        execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
>>
>> Note that shutdown command is not in POSIX, despite the fact
>> that this is put into commands-posix.c
>>
>> Note also that even shutdown from sysvinit on linux has another
>> option, -P, which mean poweroff, while -h means "halt OR poweroff"
>> (the latter is a bit unclear).
> With upstart/systemd qga use one of thee commands, depending on 'mode' parameter:
>    shutdown -P +0 "..."
>    shutdown -H +0 "..."
>    shutdown -r +0 "..."
> SysV equivalents for these are:
>    shutdown -h -P +0 "..."
>    shutdown -h -H +0 "..."
>    shutdown -h -r +0 "..."
> and these retain their meaning with upstart/systemd.
>
>>
>> Does the same work on other *nixes?  *BSD?  Solaris?
>>
> No, it doesn't. But existing code also does not work.
> According to FreeBSD manpages, shutdown does not accept -P and -H options. Commands should be:
>    shutdown -p +0 "..."
>    shutdown -h +0 "..."
>    shutdown -r +0 "..."
>
> shutdown in Solaris does not accept any of -hHpPr and does not accept time in "+0" format
>
>> Thanks,
>>
>> /mjt


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] qga: Fix shutdown command of guest agent to work with SysV
       [not found] <op.w53t8fe2cb68cn@whitewind-arch>
  2013-11-06  9:20 ` [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV Michael Tokarev
@ 2013-11-13 12:02 ` Michael Tokarev
  1 sibling, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2013-11-13 12:02 UTC (permalink / raw)
  To: whitearchey; +Cc: qemu-trivial, qemu-devel

06.11.2013 05:54, whitearchey wrote:
> For now guest agent uses following command to shutdown system:
> shutdown -P +0 "blabla"
> but this syntax works only with shutdown command from systemd or upstart,
> because SysV shutdown requires -h switch.
> 
> Following patch changes the command so it works with systemd, upstart and SysV
> 
> Signed-off-by: Michael Avdienko <whitearchey@gmail.com>
> ---
>  qga/commands-posix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index f453132..10682f5 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -99,7 +99,7 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
>          reopen_fd_to_null(1);
>          reopen_fd_to_null(2);
> 
> -        execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
> +        execle("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
>                 "hypervisor initiated shutdown", (char*)NULL, environ);
>          _exit(EXIT_FAILURE);
>      } else if (pid < 0) {

Applied to the trivial-patches queue, with additional comments from your
next email explaining which commands/flags are used by which shutdown command.

I guess we'll need some #ifdef SOLARIS..#ifdef *BSD here later, but for
now it should be fine as-is, since apparently both variants (before and after
your change) are linux-only anyway.

Thanks,

/mjt

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

end of thread, other threads:[~2013-11-13 12:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <op.w53t8fe2cb68cn@whitewind-arch>
2013-11-06  9:20 ` [Qemu-devel] [PATCH] qga: Fix shutdown command of guest agent to work with SysV Michael Tokarev
2013-11-07  2:45   ` whitearchey
2013-11-12  9:01     ` whitearchey
2013-11-13 12:02 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).