Skip to content

Instantly share code, notes, and snippets.

@JohnGarbutt
Last active December 14, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohnGarbutt/5108563 to your computer and use it in GitHub Desktop.
Save JohnGarbutt/5108563 to your computer and use it in GitHub Desktop.
XAPI wil permisions issues
xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|mscgen] xapi=>xenops [label="HOST.get_total_memory_mib"];
xenopsd: [debug|john-centos|13|read_localhost_info|xenops] HOST.get_total_memory_mib
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] read_one_line for /root/testfile
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] opened /root/testfile
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] closed /root/testfile
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] got file content asdfasdf
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] XXXXX about to open file XXXXX /sys/devices/system/xen_memory/xen_memory0/info/current_kb
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|xenops] read_one_line for /sys/devices/system/xen_memory/xen_memory0/info/current_kb
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|backtrace] Raised at pervasives.ml:289.20-46 -> balloon.ml:33.14-26 -> balloon.ml:59.13-47 -> list.ml:57.20-23 -> create_misc.ml:71.12-45 -> dbsync_slave.ml:225.13-47 -> dbsync.ml:62.7-53 -> server_helpers.ml:75.11-23
[debug|john-centos|0 thread_zero|dbsync (update_env) D:de0894b753b1|dispatcher] Server_helpers.exec exception_handler: Got exception INTERNAL_ERROR: [ Sys_error("/sys/devices/system/xen_memory/xen_memory0/info/current_kb: Permission denied") ]
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] read_one_line for /root/testfile", 135, MSG_NOSIGNAL, NULL, 0) = 135
lstat("/root/testfile", {st_dev=makedev(253, 0), st_ino=264551, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=9, st_atime=2013/03/02-20:44:31, st_mtime=2013/03/02-20:44:13, st_ctime=2013/03/02-20:44:23}) = 0
open("/root/testfile", O_RDONLY) = 13
fcntl(13, F_SETFD, FD_CLOEXEC) = 0
lseek(13, 0, SEEK_CUR) = 0
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] opened /root/testfile", 124, MSG_NOSIGNAL, NULL, 0) = 124
read(13, "asdfasdf\n", 65536) = 9
close(13) = 0
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] closed /root/testfile", 124, MSG_NOSIGNAL, NULL, 0) = 124
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] got file content asdfasdf", 128, MSG_NOSIGNAL, NULL, 0) = 128
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] XXXXX about to open file XXXXX /sys/devices/system/xen_memory/xen_memory0/info/current_kb", 192, MSG_NOSIGNAL, NULL, 0) = 192
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|xenops] read_one_line for /sys/devices/system/xen_memory/xen_memory0/info/current_kb", 179, MSG_NOSIGNAL, NULL, 0) = 179
lstat("/sys/devices/system/xen_memory/xen_memory0/info/current_kb", {st_dev=makedev(0, 16), st_ino=3878, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2013/03/02-19:50:22, st_mtime=2013/03/02-19:50:22, st_ctime=2013/03/02-19:53:54}) = 0
stat("/sys/devices/system/xen_memory/xen_memory0/info/current_kb", {st_dev=makedev(0, 16), st_ino=3878, st_mode=S_IFREG|0444, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=0, st_size=4096, st_atime=2013/03/02-19:50:22, st_mtime=2013/03/02-19:50:22, st_ctime=2013/03/02-19:53:54}) = 0
access("/sys/devices/system/xen_memory/xen_memory0/info/current_kb", W_OK) = 0
open("/sys/devices/system/xen_memory/xen_memory0/info/current_kb", O_RDWR) = -1 EACCES (Permission denied)
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|backtrace] Raised at pervasives.ml:289.20-46 -> balloon.ml:33.14-26 -> balloon.ml:59.13-47 -> list.ml:57.20-23 -> create_misc.ml:71.12-45 -> dbsync_slave.m"..., 312, MSG_NOSIGNAL, NULL, 0) = 312
sendto(4, "<175>Mar 2 22:39:09 xapi: [debug|john-centos|0 thread_zero|dbsync (update_env) D:0992c2cf8bd6|dispatcher] Server_helpers.exec exception_handler: Got exception INTERNAL_ERROR: [ Sys_error(\"/sys/devices/system/xen_memory/xen_memory0/info/current_kb: P"..., 270, MSG_NOSIGNAL, NULL, 0) = 270
(*
* Copyright (C) 2006-2009 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
open Stringext
open Printf
open Xenstore
module D = Debug.Debugger(struct let name = "xenops" end)
open D
let sysfs_stem = "/sys/devices/system/xen_memory/xen_memory0/"
let _current_allocation = "info/current_kb"
let _requested_target = "target_kb"
let _low_mem_balloon = "info/low_kb"
let _high_mem_balloon = "info/high_kb"
(** Indicates whether or not we're running with XIU (Xen-In Userspace) *)
let on_xiu () = Xenctrl.is_fake ()
let read_one_line file =
debug "read_one_line for %s" file;
let inchan = open_in file in
try
debug "opened %s" file;
let result = input_line inchan in
close_in inchan;
debug "closed %s" file;
result
with exn -> close_in inchan; raise exn;;
(** Reads /proc/xen/balloon into a string * int64 option association list *)
let parse_proc_xen_balloon () =
if on_xiu () then
[ _current_allocation, Some 100L;
_requested_target, Some 100L;
_low_mem_balloon, Some 100L;
_high_mem_balloon, Some 100L;]
else
let keys = [
_current_allocation;
_requested_target;
_low_mem_balloon;
_high_mem_balloon] in
List.map (fun key ->
let test = (read_one_line "/root/testfile") in
debug "got file content %s" test;
debug "XXXXX about to open file XXXXX %s" (sysfs_stem ^ key);
let s = (read_one_line (sysfs_stem ^ key)) in
let stripped = Stringext.String.strip Stringext.String.isspace s in
(key, Some (Int64.of_string stripped))) keys
(** (key, Some 1048576L)) keys **)
@JohnGarbutt
Copy link
Author

Similar with:
/sys/class/net/eth0/address

Accessed inside netdev.ml

@djs55
Copy link

djs55 commented Mar 11, 2013

This

access("/sys/devices/system/xen_memory/xen_memory0/info/current_kb", W_OK) = 0

is odd -- according to access(2) this means that the calling process has write permission (which it shouldn't have!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment