Module Name: src Committed By: jym Date: Thu Sep 22 23:02:35 UTC 2011
Modified Files: src/sys/arch/xen/conf: files.xen src/sys/arch/xen/xen: hypervisor.c src/sys/arch/xen/xenbus: xenbus_dev.c xenbus_probe.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/arch/xen/conf/files.xen cvs rdiff -u -r1.57 -r1.58 src/sys/arch/xen/xen/hypervisor.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/xen/xenbus/xenbus_dev.c cvs rdiff -u -r1.34 -r1.35 src/sys/arch/xen/xenbus/xenbus_probe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/xen/conf/files.xen diff -u src/sys/arch/xen/conf/files.xen:1.122 src/sys/arch/xen/conf/files.xen:1.123 --- src/sys/arch/xen/conf/files.xen:1.122 Wed Aug 10 11:39:45 2011 +++ src/sys/arch/xen/conf/files.xen Thu Sep 22 23:02:34 2011 @@ -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 @@ 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 Index: src/sys/arch/xen/xen/hypervisor.c diff -u src/sys/arch/xen/xen/hypervisor.c:1.57 src/sys/arch/xen/xen/hypervisor.c:1.58 --- src/sys/arch/xen/xen/hypervisor.c:1.57 Tue Sep 20 00:12:24 2011 +++ src/sys/arch/xen/xen/hypervisor.c Thu Sep 22 23:02:35 2011 @@ -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 @@ #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 @@ 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 @@ kernfs_addentry(NULL, dkt); kernxen_pkt = KERNFS_ENTOPARENTDIR(dkt); } -#endif /* DOM0OPS */ Index: src/sys/arch/xen/xenbus/xenbus_dev.c diff -u src/sys/arch/xen/xenbus/xenbus_dev.c:1.8 src/sys/arch/xen/xenbus/xenbus_dev.c:1.9 --- src/sys/arch/xen/xenbus/xenbus_dev.c:1.8 Mon Mar 16 06:17:39 2009 +++ src/sys/arch/xen/xenbus/xenbus_dev.c Thu Sep 22 23:02:35 2011 @@ -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 @@ 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 { Index: src/sys/arch/xen/xenbus/xenbus_probe.c diff -u src/sys/arch/xen/xenbus/xenbus_probe.c:1.34 src/sys/arch/xen/xenbus/xenbus_probe.c:1.35 --- src/sys/arch/xen/xenbus/xenbus_probe.c:1.34 Tue Sep 20 00:12:25 2011 +++ src/sys/arch/xen/xenbus/xenbus_probe.c Thu Sep 22 23:02:35 2011 @@ -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 @@ 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);