Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen Expose Xen kernfs entries inside a domU. Patch ...



details:   https://anonhg.NetBSD.org/src/rev/6490901f4c33
branches:  trunk
changeset: 769776:6490901f4c33
user:      jym <jym%NetBSD.org@localhost>
date:      Thu Sep 22 23:02:34 2011 +0000

description:
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).

diffstat:

 sys/arch/xen/conf/files.xen        |   4 ++--
 sys/arch/xen/xen/hypervisor.c      |  14 ++++----------
 sys/arch/xen/xenbus/xenbus_dev.c   |  15 +++++++++------
 sys/arch/xen/xenbus/xenbus_probe.c |  10 +++++-----
 4 files changed, 20 insertions(+), 23 deletions(-)

diffs (137 lines):

diff -r 05ec2643315d -r 6490901f4c33 sys/arch/xen/conf/files.xen
--- a/sys/arch/xen/conf/files.xen       Thu Sep 22 22:00:52 2011 +0000
+++ b/sys/arch/xen/conf/files.xen       Thu Sep 22 23:02:34 2011 +0000
@@ -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
 
diff -r 05ec2643315d -r 6490901f4c33 sys/arch/xen/xen/hypervisor.c
--- a/sys/arch/xen/xen/hypervisor.c     Thu Sep 22 22:00:52 2011 +0000
+++ b/sys/arch/xen/xen/hypervisor.c     Thu Sep 22 23:02:34 2011 +0000
@@ -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 */
diff -r 05ec2643315d -r 6490901f4c33 sys/arch/xen/xenbus/xenbus_dev.c
--- a/sys/arch/xen/xenbus/xenbus_dev.c  Thu Sep 22 22:00:52 2011 +0000
+++ b/sys/arch/xen/xenbus/xenbus_dev.c  Thu Sep 22 23:02:34 2011 +0000
@@ -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 {
diff -r 05ec2643315d -r 6490901f4c33 sys/arch/xen/xenbus/xenbus_probe.c
--- a/sys/arch/xen/xenbus/xenbus_probe.c        Thu Sep 22 22:00:52 2011 +0000
+++ b/sys/arch/xen/xenbus/xenbus_probe.c        Thu Sep 22 23:02:34 2011 +0000
@@ -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);
 



Home | Main Index | Thread Index | Old Index