From: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH 2 of 2] Add support to libxl to trigger power or sleep button pushes
Date: Wed, 13 Jan 2010 11:00:48 +0000 [thread overview]
Message-ID: <4B4DA7E0.6050400@eu.citrix.com> (raw)
In-Reply-To: <679f0a189c7280053cc1.1263377772@localhost.localdomain>
Paul Durrant wrote:
> # HG changeset patch
> # User Paul Durrant <paul.durrant@citrix.com>
> # Date 1263377694 0
> # Node ID 679f0a189c7280053cc172d1ed80b6312702f4d8
> # Parent cdf348c11aba31171bdc838ffe3a457acab0f7de
> Add support to libxl to trigger power or sleep button pushes
> in HVM guests.
Thanks !
Acked-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
minor comment inline (but can be applied nonetheless):
> +void button_press(char *p, char *b)
> +{
> + struct libxl_ctx ctx;
> + uint32_t domid;
> + libxl_button button;
> +
> + libxl_ctx_init(&ctx, LIBXL_VERSION);
ctx_init can fails in bad situation; it is always better to check the
return value just in case.
> + libxl_ctx_set_log(&ctx, log_callback, NULL);
> +
> + if (domain_qualifier_to_domid(&ctx, p, &domid) < 0) {
> + fprintf(stderr, "%s is an invalid domain identifier\n", p);
> + exit(2);
> + }
> +
> + if (!strcmp(b, "power")) {
> + button = POWER_BUTTON;
> + } else if (!strcmp(b, "sleep")) {
> + button = SLEEP_BUTTON;
> + } else {
> + fprintf(stderr, "%s is an invalid button identifier\n", b);
> + exit(2);
> + }
> +
> + libxl_button_press(&ctx, domid, button);
> +}
> +
and while it doesn't matter because the program is short lived, you're
suppose to call libxl_ctx_free when you're done with libxl.
--
Vincent Hanquez
next prev parent reply other threads:[~2010-01-13 11:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 10:16 [PATCH 0 of 2] Add ACPI sleep button for HVM guests and a libxl method for 'pressing' sleep or power Paul Durrant
2010-01-13 10:16 ` [PATCH 1 of 2] Add ACPI fixed sleep button for HVM Paul Durrant
2010-01-13 11:01 ` Ian Campbell
2010-01-13 10:16 ` [PATCH 2 of 2] Add support to libxl to trigger power or sleep button pushes Paul Durrant
2010-01-13 11:00 ` Vincent Hanquez [this message]
2010-01-13 10:30 ` [PATCH 0 of 2] Add ACPI sleep button for HVM guests and a libxl method for 'pressing' sleep or power Pasi Kärkkäinen
2010-01-13 10:37 ` Paul Durrant
2010-01-14 0:39 ` Kouya Shimura
2010-01-13 12:46 ` Ian Pratt
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=4B4DA7E0.6050400@eu.citrix.com \
--to=vincent.hanquez@eu.citrix.com \
--cc=paul.durrant@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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.