|
List Info
Thread: XEN3 handles xm shutdown?
|
|
| XEN3 handles xm shutdown? |

|
2006-07-08 22:37:44 |
Hello,
Just started testing Xen 3.0.2 before I upgrade from my
existing Xen
2.0.7. I have just compiled a NetBSD Dom-U kernel from
-current
sources (with today's date) and I have powerd running but
it looks
like the guest is not yet handling the xm shutdown from the
Dom-0.
Have I missed something or is this functionality not
available yet?
Regards
Chris
|
|
| XEN3 handles xm shutdown? |

|
2006-07-19 21:01:35 |
On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> Hello,
>
> Just started testing Xen 3.0.2 before I upgrade from my
existing Xen
> 2.0.7. I have just compiled a NetBSD Dom-U kernel from
-current
> sources (with today's date) and I have powerd running
but it looks
> like the guest is not yet handling the xm shutdown from
the Dom-0.
> Have I missed something or is this functionality not
available yet?
It's not available yet. I don't even have an idea how Xen3
tools pass this
information to a domU.
--
Manuel Bouyer <bouyer antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la
difference
--
|
|
| XEN3 handles xm shutdown? |

|
2006-07-19 21:01:35 |
On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> Hello,
>
> Just started testing Xen 3.0.2 before I upgrade from my
existing Xen
> 2.0.7. I have just compiled a NetBSD Dom-U kernel from
-current
> sources (with today's date) and I have powerd running
but it looks
> like the guest is not yet handling the xm shutdown from
the Dom-0.
> Have I missed something or is this functionality not
available yet?
It's not available yet. I don't even have an idea how Xen3
tools pass this
information to a domU.
--
Manuel Bouyer <bouyer antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la
difference
--
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
| XEN3 handles xm shutdown? |

|
2006-07-21 10:02:42 |
> On Sat, Jul 08, 2006 at 05:37:44PM -0500, Chris Brookes
wrote:
> > Hello,
> >
> > Just started testing Xen 3.0.2 before I upgrade
from my existing Xen
> > 2.0.7. I have just compiled a NetBSD Dom-U kernel
from -current
> > sources (with today's date) and I have powerd
running but it looks
> > like the guest is not yet handling the xm shutdown
from the Dom-0.
> > Have I missed something or is this functionality
not available yet?
>
> It's not available yet. I don't even have an idea how
Xen3 tools pass this
> information to a domU.
via "control/shutdown" in xenstore. patch
attached.
a question: why xenbus_watch::node is not const?
YAMAMOTO Takashi
Index: xenbus/xenbus_probe.c
============================================================
=======
--- xenbus/xenbus_probe.c (revision 1699)
+++ xenbus/xenbus_probe.c (working copy)
 -52,6
+52,7  __KERNEL_RCSID(0, "$NetBSD: xenbus_probe
#include <machine/hypervisor.h>
#include <machine/xenbus.h>
#include <machine/evtchn.h>
+#include <machine/shutdown_xenbus.h>
#include "xenbus_comms.h"
 -504,6
+505,7  xenbus_probe(void *unused)
strcpy(be_watch.node, "backend");
be_watch.xbw_callback = backend_changed;
register_xenbus_watch(&be_watch);
+ shutdown_xenbus_setup();
/* Notify others that xenstore is up */
//notifier_call_chain(&xenstore_chain, 0, NULL);
Index: conf/files.xen
============================================================
=======
--- conf/files.xen (revision 1728)
+++ conf/files.xen (working copy)
 -125,6
+125,7  file arch/xen/i386/mainbus.c mainbus
device hypervisor { }: isabus, pcibus, sysmon_power,
xendevbus, acpibus
attach hypervisor at hypervisorbus
file arch/xen/xen/hypervisor.c hypervisor needs-flag
+file arch/xen/xen/shutdown_xenbus.c hypervisor & xen3
# Xenbus (xen3 only)
device xenbus {[id = -1]}
Index: xen/hypervisor.c
============================================================
=======
--- xen/hypervisor.c (revision 1742)
+++ xen/hypervisor.c (working copy)
 -69,7
+69,10  __KERNEL_RCSID(0, "$NetBSD: hypervisor.c
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
+
+#ifndef XEN3
#include <dev/sysmon/sysmonvar.h>
+#endif
#include "xenbus.h"
#include "xencons.h"
 -191,7
+194,6  struct x86_isa_chipset x86_isa_chipset;
/* shutdown/reboot message stuff */
#ifndef XEN3
static void hypervisor_shutdown_handler(ctrl_msg_t *,
unsigned long);
-#endif
static struct sysmon_pswitch hysw_shutdown = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "hypervisor",
 -200,6
+202,7  static struct sysmon_pswitch hysw_reboot
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "hypervisor",
};
+#endif
/*
* Probe for the hypervisor; always succeeds.
 -361,12
+364,12  hypervisor_attach(parent, self, aux)
#endif
}
#endif
+#ifndef XEN3
if (sysmon_pswitch_register(&hysw_reboot) != 0 ||
sysmon_pswitch_register(&hysw_shutdown) != 0)
printf("%s: unable to register with
sysmon\n",
self->dv_xname);
-#ifndef XEN3
- else
+ else
ctrl_if_register_receiver(CMSG_SHUTDOWN,
hypervisor_shutdown_handler,
CALLBACK_IN_BLOCKING_CONTEXT);
#endif
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 2005 Manuel Bouyer.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
* 3. All advertising materials mentioning features or use
of this software
* must display the following acknowledgement:
* This product includes software developed by Manuel
Bouyer.
* 4. The name of the author may not be used to endorse or
promote products
* derived from this software without specific prior
written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
*
*/
/*
* watch "control/shutdown" and generate sysmon
events.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD$");
#include <sys/param.h>
#include <sys/malloc.h>
#include <dev/sysmon/sysmonvar.h>
#include <machine/xenbus.h>
#include <machine/shutdown_xenbus.h>
#define SHUTDOWN_PATH "control"
#define SHUTDOWN_NAME "shutdown"
static struct sysmon_pswitch xenbus_power = {
.smpsw_type = PSWITCH_TYPE_POWER,
.smpsw_name = "xenbus",
};
static struct sysmon_pswitch xenbus_reset = {
.smpsw_type = PSWITCH_TYPE_RESET,
.smpsw_name = "xenbus",
};
static void
xenbus_shutdown_handler(struct xenbus_watch *watch, const
char **vec,
unsigned int len)
{
struct xenbus_transaction *xbt;
int error;
char *reqstr;
unsigned int reqstrlen;
again:
xbt = xenbus_transaction_start();
if (xbt == NULL) {
return;
}
error = xenbus_read(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME,
&reqstrlen, &reqstr);
if (error) {
if (error != ENOENT) {
printf("%s: xenbus_read %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 1);
if (error != 0) {
printf("%s: xenbus_transaction_end 1 %d\n",
__func__, error);
}
return;
}
KASSERT(strlen(reqstr) == reqstrlen);
error = xenbus_rm(xbt, SHUTDOWN_PATH, SHUTDOWN_NAME);
if (error) {
printf("%s: xenbus_rm %d\n", __func__,
error);
}
error = xenbus_transaction_end(xbt, 0);
if (error == EAGAIN) {
free(reqstr, M_DEVBUF);
goto again;
}
if (error != 0) {
printf("%s: xenbus_transaction_end 2 %d\n",
__func__, error);
}
if (strcmp(reqstr, "poweroff") == 0) {
sysmon_pswitch_event(&xenbus_power,
PSWITCH_EVENT_PRESSED);
} else if (strcmp(reqstr, "reboot") == 0) {
sysmon_pswitch_event(&xenbus_reset,
PSWITCH_EVENT_PRESSED);
} else {
/* XXX halt, suspend */
printf("ignore shutdown request: %s\n",
reqstr);
}
free(reqstr, M_DEVBUF);
}
static struct xenbus_watch xenbus_shutdown_watch = {
.node = __UNCONST(SHUTDOWN_PATH "/"
SHUTDOWN_NAME), /* XXX */
.xbw_callback = xenbus_shutdown_handler,
};
void
shutdown_xenbus_setup(void)
{
if (sysmon_pswitch_register(&xenbus_power) != 0 ||
sysmon_pswitch_register(&xenbus_reset) != 0) {
printf("%s: unable to register with
sysmon\n", __func__);
return;
}
if (register_xenbus_watch(&xenbus_shutdown_watch)) {
printf("%s: unable to watch
control/shutdown\n", __func__);
}
}
/* $Id$ */
/*-
* Copyright (c)2006 YAMAMOTO Takashi,
* All rights reserved.
*
* Redistribution and use in source and binary forms, with
or without
* modification, are permitted provided that the following
conditions
* are met:
* 1. Redistributions of source code must retain the above
copyright
* notice, this list of conditions and the following
disclaimer.
* 2. Redistributions in binary form must reproduce the
above copyright
* notice, this list of conditions and the following
disclaimer in the
* documentation and/or other materials provided with the
distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _XEN_SHUTDOWN_XENBUS_H_
#define _XEN_SHUTDOWN_XENBUS_H_
void shutdown_xenbus_setup(void);
#endif /* _XEN_SHUTDOWN_XENBUS_H_ */
|
|
|
|