diff mbox series

[4/5] qga: Add shutdown/halt/reboot support for FreeBSD

Message ID 20220922132001.940334-5-alexander.ivanov@virtuozzo.com
State New
Headers show
Series [1/5] qga: Move Linux-specific commands code to separate file | expand

Commit Message

Alexander Ivanov Sept. 22, 2022, 1:20 p.m. UTC
Add appropriate shutdown command arguments in qmp_guest_shutdown()
for FreeBSD.

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 qga/commands-posix.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Marc-André Lureau Sept. 23, 2022, 8:13 a.m. UTC | #1
Hi

On Thu, Sep 22, 2022 at 3:51 PM Alexander Ivanov <
alexander.ivanov@virtuozzo.com> wrote:

> Add appropriate shutdown command arguments in qmp_guest_shutdown()
> for FreeBSD.
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
> ---
>  qga/commands-posix.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
> index 3a1055d5c3..60cc673f25 100644
> --- a/qga/commands-posix.c
> +++ b/qga/commands-posix.c
> @@ -242,6 +242,10 @@ void qmp_guest_shutdown(bool has_mode, const char
> *mode, Error **errp)
>      const char *powerdown_flag = "-i5";
>      const char *halt_flag = "-i0";
>      const char *reboot_flag = "-i6";
> +#elifdef CONFIG_BSD
>

It might be the first time I see a patch with "#elifdef" :) this is C2X, so
please use "#elif defined(..)" instead


> +    const char *powerdown_flag = "-p";
> +    const char *halt_flag = "-h";
> +    const char *reboot_flag = "-r";
>  #else
>      const char *powerdown_flag = "-P";
>      const char *halt_flag = "-H";
> @@ -272,6 +276,9 @@ void qmp_guest_shutdown(bool has_mode, const char
> *mode, Error **errp)
>  #ifdef CONFIG_SOLARIS
>          execl("/sbin/shutdown", "shutdown", shutdown_flag, "-g0", "-y",
>                "hypervisor initiated shutdown", (char *)NULL);
> +#elifdef CONFIG_BSD
> +        execl("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
> +               "hypervisor initiated shutdown", (char *)NULL);
>  #else
>          execl("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
>                 "hypervisor initiated shutdown", (char *)NULL);
> --
> 2.34.1
>
>
>
lgtm otherwise
diff mbox series

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 3a1055d5c3..60cc673f25 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -242,6 +242,10 @@  void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
     const char *powerdown_flag = "-i5";
     const char *halt_flag = "-i0";
     const char *reboot_flag = "-i6";
+#elifdef CONFIG_BSD
+    const char *powerdown_flag = "-p";
+    const char *halt_flag = "-h";
+    const char *reboot_flag = "-r";
 #else
     const char *powerdown_flag = "-P";
     const char *halt_flag = "-H";
@@ -272,6 +276,9 @@  void qmp_guest_shutdown(bool has_mode, const char *mode, Error **errp)
 #ifdef CONFIG_SOLARIS
         execl("/sbin/shutdown", "shutdown", shutdown_flag, "-g0", "-y",
               "hypervisor initiated shutdown", (char *)NULL);
+#elifdef CONFIG_BSD
+        execl("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
+               "hypervisor initiated shutdown", (char *)NULL);
 #else
         execl("/sbin/shutdown", "shutdown", "-h", shutdown_flag, "+0",
                "hypervisor initiated shutdown", (char *)NULL);