diff -r e73ea74cba30 config/NetBSD.mk --- a/config/NetBSD.mk Mon Sep 24 13:45:57 2007 +0100 +++ b/config/NetBSD.mk Mon Sep 24 15:55:04 2007 +0000 @@ -1,1 +1,4 @@ include $(XEN_ROOT)/config/StdGNU.mk include $(XEN_ROOT)/config/StdGNU.mk + +# Override settings for this OS +CURSES_LIBS = -lcurses diff -r e73ea74cba30 tools/xenstat/libxenstat/Makefile --- a/tools/xenstat/libxenstat/Makefile Mon Sep 24 13:45:57 2007 +0100 +++ b/tools/xenstat/libxenstat/Makefile Mon Sep 24 15:55:04 2007 +0000 @@ -31,6 +31,7 @@ OBJECTS-y=src/xenstat.o OBJECTS-y=src/xenstat.o OBJECTS-$(CONFIG_Linux) += src/xenstat_linux.o OBJECTS-$(CONFIG_SunOS) += src/xenstat_solaris.o +OBJECTS-$(CONFIG_NetBSD) += src/xenstat_netbsd.o SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR) WARN_FLAGS=-Wall -Werror diff -r e73ea74cba30 tools/xenstat/libxenstat/src/xenstat_netbsd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstat/libxenstat/src/xenstat_netbsd.c Mon Sep 24 15:55:04 2007 +0000 @@ -0,0 +1,97 @@ +/* libxenstat: statistics-collection library for Xen + * Copyright (C) International Business Machines Corp., 2005 + * Authors: Josh Triplett + * Judy Fischbach + * David Hendricks + * + * This library 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; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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. + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xenstat_priv.h" + +#define SYSFS_VBD_PATH "/sys/devices/xen-backend/" + +struct priv_data { + FILE *procnetdev; + DIR *sysfsvbd; +}; + +static struct priv_data * +get_priv_data(xenstat_handle *handle) +{ + if (handle->priv != NULL) + return handle->priv; + + handle->priv = malloc(sizeof(struct priv_data)); + if (handle->priv == NULL) + return (NULL); + + ((struct priv_data *)handle->priv)->procnetdev = NULL; + ((struct priv_data *)handle->priv)->sysfsvbd = NULL; + + return handle->priv; +} + +/* Expected format of /proc/net/dev */ +static const char PROCNETDEV_HEADER[] = + "Inter-| Receive |" + " Transmit\n" + " face |bytes packets errs drop fifo frame compressed multicast|" + "bytes packets errs drop fifo colls carrier compressed\n"; + +/* Collect information about networks */ +int xenstat_collect_networks(xenstat_node * node) +{ + /* XXX fixme: implement code to get stats from libkvm ! */ + return 1; +} + +/* Free network information in handle */ +void xenstat_uninit_networks(xenstat_handle * handle) +{ + struct priv_data *priv = get_priv_data(handle); + if (priv != NULL && priv->procnetdev != NULL) + fclose(priv->procnetdev); +} + +static int read_attributes_vbd(const char *vbd_directory, const char *what, char *ret, int cap) +{ + /* XXX implement */ + return 0; +} + +/* Collect information about VBDs */ +int xenstat_collect_vbds(xenstat_node * node) +{ + return 1; +} + +/* Free VBD information in handle */ +void xenstat_uninit_vbds(xenstat_handle * handle) +{ + struct priv_data *priv = get_priv_data(handle); + if (priv != NULL && priv->sysfsvbd != NULL) + closedir(priv->sysfsvbd); +} diff -r e73ea74cba30 tools/xenstat/xentop/xentop.c --- a/tools/xenstat/xentop/xentop.c Mon Sep 24 13:45:57 2007 +0100 +++ b/tools/xenstat/xentop/xentop.c Mon Sep 24 15:55:04 2007 +0000 @@ -28,7 +28,9 @@ #include #include #include +#if defined(__linux__) || defined(__Linux__) #include +#endif #include @@ -938,7 +940,7 @@ void do_vbd(xenstat_domain *domain) vbd = xenstat_domain_vbd(domain,i); -#ifdef __sun__ +#if defined(__sun__) || defined(__NetBSD__) || defined(__OpenBSD__) details[0] = '\0'; #else snprintf(details, 20, "[%2x:%2x] ", MAJOR(xenstat_vbd_dev(vbd)), diff -r e73ea74cba30 tools/xenstore/Makefile --- a/tools/xenstore/Makefile Mon Sep 24 13:45:57 2007 +0100 +++ b/tools/xenstore/Makefile Mon Sep 24 15:55:04 2007 +0000 @@ -25,6 +25,7 @@ XENSTORED_OBJS = xenstored_core.o xensto XENSTORED_OBJS_$(CONFIG_Linux) = xenstored_linux.o XENSTORED_OBJS_$(CONFIG_SunOS) = xenstored_solaris.o +XENSTORED_OBJS_$(CONFIG_NetBSD) = xenstored_netbsd.o XENSTORED_OBJS += $(XENSTORED_OBJS_y) diff -r e73ea74cba30 tools/xenstore/xenstored_netbsd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/xenstore/xenstored_netbsd.c Mon Sep 24 15:55:04 2007 +0000 @@ -0,0 +1,73 @@ +/****************************************************************************** + * + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + * + * Copyright (C) 2005 Rusty Russell IBM Corporation + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, version 2 of the + * License. + */ + +#include +#include +#include +#include + +#include "xenstored_core.h" + +#define XENSTORED_PROC_KVA "/dev/xsd_kva" +#define XENSTORED_PROC_PORT "/kern/xen/xsd_port" + +evtchn_port_t xenbus_evtchn(void) +{ + int fd; + int rc; + evtchn_port_t port; + char str[20]; + + fd = open(XENSTORED_PROC_PORT, O_RDONLY); + if (fd == -1) + return -1; + + rc = read(fd, str, sizeof(str)); + if (rc == -1) + { + int err = errno; + close(fd); + errno = err; + return -1; + } + + str[rc] = '\0'; + port = strtoul(str, NULL, 0); + + close(fd); + return port; +} + +void *xenbus_map(void) +{ + int fd; + void *addr; + + fd = open(XENSTORED_PROC_KVA, O_RDWR); + if (fd == -1) + return NULL; + + addr = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, + MAP_SHARED, fd, 0); + + if (addr == MAP_FAILED) + addr = NULL; + + close(fd); + + return addr; +} + +void xenbus_notify_running(void) +{ +}