From: Simon <qemu.bugs@whitewinterwolf.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Bug 1217339] [PATCH v2] Unix signal to send ACPI-shutdown to Guest
Date: Tue, 21 Mar 2017 13:30:56 +0100 [thread overview]
Message-ID: <2dc320e84befdfb8d96f7ec764a1c8e2@whitewinterwolf.com> (raw)
In-Reply-To: <20170320095533.GB3792@redhat.com>
Daniel P. Berrange:
> On Sat, Mar 18, 2017 at 02:41:16PM +0100, Simon wrote:
>> Hi,
>>
>> The patch below adds the new command-line option `-powerdown' which
>> changes the behavior for both SIGHUP and SIGINT signals to cause a
>> clean
>> power down of the guest using an ACPI shutdown request.
>
> If you need to add command line arguments IMHO this feature becomes
> much less interesting - just use the QEMU monitor instead of inventing
> an adhoc way to achieve something the monitor already does. The value
> of
> using a signal handler comes from the fact that it would be
> unconditionally
> available no matter what command line args were added.
Hi Daniel,
Thank you for taking the time to answer me.
I am currently using the monitor to achieve this functionality, and this
boils down into doing something similar to this:
--------- 8< ----------------
if ! type 'socat' >/dev/null 2>&1
then
echo "You must install 'socat'." >&2
exit 1
fi
files=$( ps -e -o args | awk '$1 ~ /qemu-system-/' \
| sed 's/.* -monitor unix:\([^,]*\).*/\1/;t;s/.*//' )
IFS='
'
for f in $files
do
echo 'system_powerdown' | socat "UNIX-CONNECT:${f}" -
done
--------- 8< ----------------
In other words I check that required software is properly installed,
parse `ps' output to extract the path to the monitor socket file when it
is available, and pipe the `system_powerdown' command into it to
cleanly shut the VM down.
As a matter of comparison, here the same functionality implemented using
Unix signals instead of the monitor socket files:
--------- 8< ----------------
pkill -HUP qemu-system-
--------- 8< ----------------
Maybe it is just my own opinion, but I find the second approach cleaner
and more reliable.
Regarding the fact that it would require a specific parameter to be
enabled, I already use several parameters on a systematic basis with
Qemu (enable KVM, the USB tablet, set the keyboard layout, etc.).
I don't see the fact of adding a supplementary one to this set as an
annoyance.
On the contrary, I love Qemu's versatility and all these parameters are
here just to let users personalize Qemu behavior to best suit the way
they use it.
Regards,
Simon.
prev parent reply other threads:[~2017-03-21 12:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 13:45 [Qemu-devel] [Bug 1217339] [PATCH] Unix signal to send ACPI-shutdown to Guest Simon
2017-03-15 14:41 ` Daniel P. Berrange
2017-03-15 17:46 ` Simon
2017-03-15 18:00 ` Peter Maydell
2017-03-15 18:08 ` Daniel P. Berrange
2017-03-15 18:45 ` Peter Maydell
2017-03-16 10:25 ` Simon
2017-03-16 10:26 ` Daniel P. Berrange
2017-03-18 13:41 ` [Qemu-devel] [Bug 1217339] [PATCH v2] " Simon
2017-03-20 9:55 ` Daniel P. Berrange
2017-03-21 12:30 ` Simon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2dc320e84befdfb8d96f7ec764a1c8e2@whitewinterwolf.com \
--to=qemu.bugs@whitewinterwolf.com \
--cc=berrange@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.