Expose Xen kernfs entries inside a domU. Patch originally from sborrill@,
slightly modified by me to profit from runtime checks for dom0 privileges instead of using compile time macros (DOM0OPS). It should now be possible to use pkgsrc's sysutils/xentools inside a domU to query XenStore entries (or even modify part of it if the domain has enough rights).
This commit is contained in:
parent
12de7c048b
commit
afeabb041e
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.xen,v 1.122 2011/08/10 11:39:45 cherry Exp $
|
||||
# $NetBSD: files.xen,v 1.123 2011/09/22 23:02:34 jym Exp $
|
||||
# NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp
|
||||
# NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp
|
||||
|
||||
|
@ -176,7 +176,7 @@ device xenbus {[id = -1]}
|
|||
attach xenbus at xendevbus
|
||||
file arch/xen/xenbus/xenbus_client.c xenbus needs-flag
|
||||
file arch/xen/xenbus/xenbus_comms.c xenbus needs-flag
|
||||
file arch/xen/xenbus/xenbus_dev.c xenbus & dom0ops needs-flag
|
||||
file arch/xen/xenbus/xenbus_dev.c xenbus needs-flag
|
||||
file arch/xen/xenbus/xenbus_probe.c xenbus needs-flag
|
||||
file arch/xen/xenbus/xenbus_xs.c xenbus needs-flag
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: hypervisor.c,v 1.57 2011/09/20 00:12:24 jym Exp $ */
|
||||
/* $NetBSD: hypervisor.c,v 1.58 2011/09/22 23:02:35 jym Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005 Manuel Bouyer.
|
||||
|
@ -53,7 +53,7 @@
|
|||
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.57 2011/09/20 00:12:24 jym Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: hypervisor.c,v 1.58 2011/09/22 23:02:35 jym Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -210,11 +210,8 @@ hypervisor_attach(device_t parent, device_t self, void *aux)
|
|||
#endif /* NPCI */
|
||||
union hypervisor_attach_cookie hac;
|
||||
|
||||
#ifdef DOM0OPS
|
||||
if (xendomain_is_privileged()) {
|
||||
xenkernfs_init();
|
||||
}
|
||||
#endif
|
||||
xenkernfs_init();
|
||||
|
||||
xen_version = HYPERVISOR_xen_version(XENVER_version, NULL);
|
||||
aprint_normal(": Xen version %d.%d\n", (xen_version & 0xffff0000) >> 16,
|
||||
xen_version & 0x0000ffff);
|
||||
|
@ -367,8 +364,6 @@ hypervisor_print(void *aux, const char *parent)
|
|||
return (UNCONF);
|
||||
}
|
||||
|
||||
#if defined(DOM0OPS)
|
||||
|
||||
#define DIR_MODE (S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
|
||||
|
||||
kernfs_parentdir_t *kernxen_pkt;
|
||||
|
@ -383,4 +378,3 @@ xenkernfs_init(void)
|
|||
kernfs_addentry(NULL, dkt);
|
||||
kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt);
|
||||
}
|
||||
#endif /* DOM0OPS */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xenbus_dev.c,v 1.8 2009/03/16 06:17:39 cegger Exp $ */
|
||||
/* $NetBSD: xenbus_dev.c,v 1.9 2011/09/22 23:02:35 jym Exp $ */
|
||||
/*
|
||||
* xenbus_dev.c
|
||||
*
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.8 2009/03/16 06:17:39 cegger Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_dev.c,v 1.9 2011/09/22 23:02:35 jym Exp $");
|
||||
|
||||
#include "opt_xen.h"
|
||||
|
||||
|
@ -92,10 +92,13 @@ xenbus_kernfs_init(void)
|
|||
PRIVCMD_MODE);
|
||||
kernfs_addentry(kernxen_pkt, dkt);
|
||||
|
||||
kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
|
||||
KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
|
||||
KERNFS_INITENTRY(dkt, DT_REG, "xsd_port", NULL, kfst, VREG, XSD_MODE);
|
||||
kernfs_addentry(kernxen_pkt, dkt);
|
||||
if (xendomain_is_dom0()) {
|
||||
kfst = KERNFS_ALLOCTYPE(xsd_port_fileops);
|
||||
KERNFS_ALLOCENTRY(dkt, M_TEMP, M_WAITOK);
|
||||
KERNFS_INITENTRY(dkt, DT_REG, "xsd_port", NULL,
|
||||
kfst, VREG, XSD_MODE);
|
||||
kernfs_addentry(kernxen_pkt, dkt);
|
||||
}
|
||||
}
|
||||
|
||||
struct xenbus_dev_data {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: xenbus_probe.c,v 1.34 2011/09/20 00:12:25 jym Exp $ */
|
||||
/* $NetBSD: xenbus_probe.c,v 1.35 2011/09/22 23:02:35 jym Exp $ */
|
||||
/******************************************************************************
|
||||
* Talks to Xen Store to figure out what devices we have.
|
||||
*
|
||||
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.34 2011/09/20 00:12:25 jym Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: xenbus_probe.c,v 1.35 2011/09/22 23:02:35 jym Exp $");
|
||||
|
||||
#if 0
|
||||
#define DPRINTK(fmt, args...) \
|
||||
|
@ -627,15 +627,15 @@ xenbus_probe_init(void *unused)
|
|||
|
||||
xen_start_info.store_evtchn = op.u.alloc_unbound.port;
|
||||
|
||||
/* And finally publish the above info in /kern/xen */
|
||||
xenbus_kernfs_init();
|
||||
|
||||
DELAY(1000);
|
||||
#else /* DOM0OPS */
|
||||
kthread_exit(0); /* can't get a working xenstore in this case */
|
||||
#endif /* DOM0OPS */
|
||||
}
|
||||
|
||||
/* Publish xenbus and Xenstore info in /kern/xen */
|
||||
xenbus_kernfs_init();
|
||||
|
||||
/* register event handler */
|
||||
xb_init_comms(xenbus_dev);
|
||||
|
||||
|
|
Loading…
Reference in New Issue