All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xenproject.org, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: Re: [PATCH] libxl: create control/sysrq xenstore node
Date: Tue, 04 Sep 2018 19:27:31 +0200	[thread overview]
Message-ID: <87k1o118cc.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <20180904165158.x3am5qhrluxj2bzn@zion.uk.xensource.com> (Wei Liu's message of "Tue, 4 Sep 2018 17:51:58 +0100")

Wei Liu <wei.liu2@citrix.com> writes:

> On Tue, Sep 04, 2018 at 01:39:29PM +0200, Vitaly Kuznetsov wrote:
>> 'xl sysrq' command doesn't work with modern Linux guests with the following
>> message in guest's log:
>> 
>>  xen:manage: sysrq_handler: Error -13 writing sysrq in control/sysrq
>> 
>> xenstore trace confirms:
>> 
>>  IN 0x24bd9a0 20180904 04:36:32 WRITE (control/sysrq )
>>  OUT 0x24bd9a0 20180904 04:36:32 ERROR (EACCES )
>> 
>> The problem seems to be in the fact that we don't pre-create control/sysrq
>> xenstore node and libxl_send_sysrq() doing libxl__xs_printf() creates it as
>> read-only. As we want to allow guests to clean 'control/sysrq' after the
>> requested action is performed, we need to make this node writable.
>> 
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> Hmm... this node isn't documented.
>

But libxl already writes it, see libxl_send_sysrq().

> Can you point me to the code in Linux?
>

Sure,

drivers/xen/manage.c:

static void sysrq_handler(struct xenbus_watch *watch, const char *path,
			  const char *token)
{
	char sysrq_key = '\0';
	struct xenbus_transaction xbt;
	int err;

 again:
	err = xenbus_transaction_start(&xbt);
	if (err)
		return;
	err = xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key);
	if (err < 0) {
		/*
		 * The Xenstore watch fires directly after registering it and
		 * after a suspend/resume cycle. So ENOENT is no error but
		 * might happen in those cases.
		 */
		if (err != -ENOENT)
			pr_err("Error %d reading sysrq code in control/sysrq\n",
			       err);
		xenbus_transaction_end(xbt, 1);
		return;
	}

	if (sysrq_key != '\0') {
		err = xenbus_printf(xbt, "control", "sysrq", "%c", '\0');
		if (err) {
			pr_err("%s: Error %d writing sysrq in control/sysrq\n",
			       __func__, err);
			xenbus_transaction_end(xbt, 1);
			return;
		}
	}

	err = xenbus_transaction_end(xbt, 0);
	if (err == -EAGAIN)
		goto again;

	if (sysrq_key != '\0')
		handle_sysrq(sysrq_key);
}

static struct xenbus_watch sysrq_watch = {
	.node = "control/sysrq",
	.callback = sysrq_handler
};


-- 
  Vitaly

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-09-04 17:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-04 11:39 [PATCH] libxl: create control/sysrq xenstore node Vitaly Kuznetsov
2018-09-04 16:51 ` Wei Liu
2018-09-04 17:27   ` Vitaly Kuznetsov [this message]
2018-09-05  8:22     ` Wei Liu
2018-09-05 10:12       ` Roger Pau Monné
2018-09-05 10:15       ` Vitaly Kuznetsov
2018-09-05  8:22 ` Wei Liu

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=87k1o118cc.fsf@vitty.brq.redhat.com \
    --to=vkuznets@redhat.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.