xen-proxy: Remove it entirely and use libvirtd instead

Suggested by danpb, as it's not up-to-date anymore and
lacks many functions that were added to libvirtd.
This commit is contained in:
Matthias Bolte 2010-11-08 17:32:02 +01:00
parent c3697a0ed5
commit e65812d479
29 changed files with 75 additions and 2374 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@
.sc-start-sc_* .sc-start-sc_*
/GNUmakefile /GNUmakefile
/libvirt-[0-9]* /libvirt-[0-9]*
/proxy/
/maint.mk /maint.mk
ABOUT-NLS ABOUT-NLS
COPYING COPYING

View File

@ -3,7 +3,7 @@
LCOV = lcov LCOV = lcov
GENHTML = genhtml GENHTML = genhtml
SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \ SUBDIRS = gnulib/lib include src daemon tools docs gnulib/tests \
python tests po examples/domain-events/events-c examples/hellolibvirt \ python tests po examples/domain-events/events-c examples/hellolibvirt \
examples/dominfo examples/domsuspend examples/python examples/apparmor \ examples/dominfo examples/domsuspend examples/python examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap examples/xml/nwfilter examples/openauth examples/systemtap

View File

@ -17,8 +17,7 @@ rm -rf coverage
./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT" \ ./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT" \
--enable-test-coverage \ --enable-test-coverage \
--enable-compile-warnings=error \ --enable-compile-warnings=error
--with-xen-proxy
# If the MAKEFLAGS envvar does not yet include a -j option, # If the MAKEFLAGS envvar does not yet include a -j option,
# add -jN where N depends on the number of processors. # add -jN where N depends on the number of processors.

1
cfg.mk
View File

@ -346,7 +346,6 @@ msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError msg_gen_function += virLibDomainError
msg_gen_function += virNetworkReportError msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError msg_gen_function += virNodeDeviceReportError
msg_gen_function += virProxyError
msg_gen_function += virRaiseError msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError msg_gen_function += virReportSystemError

View File

@ -1893,29 +1893,6 @@ if test "$enable_locking" = "yes"; then
fi fi
AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"]) AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"])
dnl Enable building the proxy?
AC_ARG_WITH([xen-proxy],
AC_HELP_STRING([--with-xen-proxy], [add XEN setuid proxy support @<:@default=auto@:>@]),[],[with_xen_proxy=auto])
AC_MSG_CHECKING([if Xen setuid proxy is needed])
if test "$with_xen_proxy" = "auto"; then
if test "$with_polkit" = "yes"; then
with_xen_proxy="no"
else
with_xen_proxy="yes"
fi
fi
if test "$with_xen" != "yes"; then
with_xen_proxy="no"
fi
AC_MSG_RESULT([$with_xen_proxy])
AM_CONDITIONAL([WITH_PROXY],[test "$with_xen_proxy" = "yes"])
if test "$with_xen_proxy" = "yes"; then
AC_DEFINE([WITH_PROXY], 1, [Whether Xen proxy is enabled])
fi
dnl Enable building libvirtd? dnl Enable building libvirtd?
AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"]) AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
@ -2258,7 +2235,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
python/Makefile python/tests/Makefile \ python/Makefile python/tests/Makefile \
daemon/Makefile \ daemon/Makefile \
tools/Makefile \ tools/Makefile \
tests/Makefile proxy/Makefile \ tests/Makefile \
tests/xml2sexprdata/Makefile \ tests/xml2sexprdata/Makefile \
tests/sexpr2xmldata/Makefile \ tests/sexpr2xmldata/Makefile \
tests/xmconfigdata/Makefile \ tests/xmconfigdata/Makefile \
@ -2281,7 +2258,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([Drivers]) AC_MSG_NOTICE([Drivers])
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Xen: $with_xen]) AC_MSG_NOTICE([ Xen: $with_xen])
AC_MSG_NOTICE([ Proxy: $with_xen_proxy])
AC_MSG_NOTICE([ QEMU: $with_qemu]) AC_MSG_NOTICE([ QEMU: $with_qemu])
AC_MSG_NOTICE([ UML: $with_uml]) AC_MSG_NOTICE([ UML: $with_uml])
AC_MSG_NOTICE([ OpenVZ: $with_openvz]) AC_MSG_NOTICE([ OpenVZ: $with_openvz])

View File

@ -302,7 +302,8 @@ connection.
</p> </p>
<p> <p>
You should consider using <a href="remote.html">libvirt remote support</a> You should consider using <a href="remote.html">libvirt remote support</a>
in future. in future. <span class="since">Since 0.8.6</span> libvirt doesn't contain
the Xen proxy anymore and you should use libvirtd instead.
</p> </p>
</body> </body>
</html> </html>

View File

@ -45,7 +45,7 @@ typedef enum {
VIR_FROM_XML, /* Error in the XML code */ VIR_FROM_XML, /* Error in the XML code */
VIR_FROM_DOM, /* Error when operating on a domain */ VIR_FROM_DOM, /* Error when operating on a domain */
VIR_FROM_RPC, /* Error in the XML-RPC code */ VIR_FROM_RPC, /* Error in the XML-RPC code */
VIR_FROM_PROXY, /* Error in the proxy code */ VIR_FROM_PROXY, /* Error in the proxy code */ /* unused since 0.8.6 */
VIR_FROM_CONF, /* Error in the configuration file handling */ VIR_FROM_CONF, /* Error in the configuration file handling */
VIR_FROM_QEMU, /* Error at the QEMU daemon */ VIR_FROM_QEMU, /* Error at the QEMU daemon */
VIR_FROM_NET, /* Error when operating on a network */ VIR_FROM_NET, /* Error when operating on a network */

View File

@ -31,7 +31,6 @@
# Then the hypervisor drivers that run on local host # Then the hypervisor drivers that run on local host
%define with_xen 0%{!?_without_xen:%{server_drivers}} %define with_xen 0%{!?_without_xen:%{server_drivers}}
%define with_xen_proxy 0%{!?_without_xen_proxy:%{server_drivers}}
%define with_qemu 0%{!?_without_qemu:%{server_drivers}} %define with_qemu 0%{!?_without_qemu:%{server_drivers}}
%define with_openvz 0%{!?_without_openvz:%{server_drivers}} %define with_openvz 0%{!?_without_openvz:%{server_drivers}}
%define with_lxc 0%{!?_without_lxc:%{server_drivers}} %define with_lxc 0%{!?_without_lxc:%{server_drivers}}
@ -115,11 +114,6 @@
%define with_xen 0 %define with_xen 0
%endif %endif
# If Xen isn't turned on, we shouldn't build the xen proxy either
%if ! %{with_xen}
%define with_xen_proxy 0
%endif
# Fedora doesn't have any QEMU on ppc64 - only ppc # Fedora doesn't have any QEMU on ppc64 - only ppc
%if 0%{?fedora} %if 0%{?fedora}
%ifarch ppc64 %ifarch ppc64
@ -127,11 +121,9 @@
%endif %endif
%endif %endif
# PolicyKit was introduced in Fedora 8 / RHEL-6 or newer, allowing # PolicyKit was introduced in Fedora 8 / RHEL-6 or newer
# the setuid Xen proxy to be killed off
%if 0%{?fedora} >= 8 || 0%{?rhel} >= 6 %if 0%{?fedora} >= 8 || 0%{?rhel} >= 6
%define with_polkit 0%{!?_without_polkit:1} %define with_polkit 0%{!?_without_polkit:1}
%define with_xen_proxy 0
%endif %endif
# libcapng is used to manage capabilities in Fedora 12 / RHEL-6 or newer # libcapng is used to manage capabilities in Fedora 12 / RHEL-6 or newer
@ -848,10 +840,6 @@ fi
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/ %dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/
%if %{with_xen_proxy}
%attr(4755, root, root) %{_libexecdir}/libvirt_proxy
%endif
%if %{with_lxc} %if %{with_lxc}
%attr(0755, root, root) %{_libexecdir}/libvirt_lxc %attr(0755, root, root) %{_libexecdir}/libvirt_lxc
%endif %endif

View File

@ -97,7 +97,6 @@ src/util/xml.c
src/vbox/vbox_XPCOMCGlue.c src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_driver.c src/vbox/vbox_driver.c
src/vbox/vbox_tmpl.c src/vbox/vbox_tmpl.c
src/xen/proxy_internal.c
src/xen/xen_driver.c src/xen/xen_driver.c
src/xen/xen_hypervisor.c src/xen/xen_hypervisor.c
src/xen/xen_inotify.c src/xen/xen_inotify.c

5
proxy/.gitignore vendored
View File

@ -1,5 +0,0 @@
Makefile
Makefile.in
.deps
.libs
libvirt_proxy

View File

@ -1,42 +0,0 @@
## Process this file with automake to produce Makefile.in
if WITH_PROXY
INCLUDES = -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
-I$(top_builddir)/include -I@top_srcdir@/include \
-I@top_srcdir@/proxy -I@top_srcdir@/src \
-I@top_srcdir@/src/util \
-I@top_srcdir@/src/conf \
-I@top_srcdir@/src/xen \
$(LIBXML_CFLAGS) \
-DPROXY -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(XEN_CFLAGS)
libexec_PROGRAMS = libvirt_proxy
libvirt_proxy_SOURCES = libvirt_proxy.c \
@top_srcdir@/src/util/buf.c \
@top_srcdir@/src/util/files.c \
@top_srcdir@/src/util/hash.c \
@top_srcdir@/src/util/logging.c \
@top_srcdir@/src/util/memory.c \
@top_srcdir@/src/util/network.c \
@top_srcdir@/src/util/threads.c \
@top_srcdir@/src/util/util.c \
@top_srcdir@/src/util/uuid.c \
@top_srcdir@/src/util/virterror.c \
@top_srcdir@/src/conf/capabilities.c \
@top_srcdir@/src/conf/storage_encryption_conf.c \
@top_srcdir@/src/conf/domain_conf.c \
@top_srcdir@/src/conf/cpu_conf.c \
@top_srcdir@/src/conf/nwfilter_params.c \
@top_srcdir@/src/xen/xend_internal.c \
@top_srcdir@/src/xen/xen_hypervisor.c \
@top_srcdir@/src/xen/sexpr.c \
@top_srcdir@/src/xen/xs_internal.c
libvirt_proxy_LDFLAGS = $(WARN_LDFLAGS)
libvirt_proxy_DEPENDENCIES =
libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la $(XEN_LIBS) $(LIB_PTHREAD)
install-exec-hook:
chmod u+s $(DESTDIR)$(libexecdir)/libvirt_proxy
endif

View File

@ -1,856 +0,0 @@
/*
* proxy_svr.c: root suid proxy server for Xen access to APIs with no
* side effects from unauthenticated clients.
*
* Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#include <config.h>
#include <stdio.h>
#ifdef WITH_XEN
# include <stdlib.h>
# include <unistd.h>
# include <errno.h>
# include <sys/types.h>
# include <sys/poll.h>
# include <sys/socket.h>
# include <sys/un.h>
# include <locale.h>
# include "internal.h"
# include "datatypes.h"
# include "proxy_internal.h"
# include "util.h"
# include "xen_hypervisor.h"
# include "xend_internal.h"
# include "xs_internal.h"
# include "xen_driver.h"
static int fdServer = -1;
static int debug = 0;
static int persist = 0;
static int done = 0;
# define MAX_CLIENT 64
static int nbClients = 0; /* client 0 is the unix listen socket */
static struct pollfd pollInfos[MAX_CLIENT + 1];
static virConnect conninfos;
static virConnectPtr conn = &conninfos;
static unsigned long xenVersion = 0;
/************************************************************************
* *
* Interfaces with the Xen hypervisor *
* *
************************************************************************/
/**
* proxyInitXen:
*
* Initialize the communication layer with Xen
*
* Returns 0 or -1 in case of error
*/
static int
proxyInitXen(void) {
int ret;
unsigned long xenVersion2;
xenUnifiedPrivatePtr priv;
/* Allocate per-connection private data. */
priv = malloc (sizeof *priv);
if (!priv) {
fprintf(stderr, "Failed to allocate private data\n");
return(-1);
}
conn->privateData = priv;
priv->handle = -1;
priv->xendConfigVersion = -1;
priv->xshandle = NULL;
priv->proxy = -1;
ret = xenHypervisorOpen(conn, NULL, 0);
if (ret < 0) {
fprintf(stderr, "Failed to open Xen hypervisor\n");
return(-1);
} else {
ret = xenHypervisorGetVersion(conn, &xenVersion);
if (ret != 0) {
fprintf(stderr, "Failed to get Xen hypervisor version\n");
return(-1);
}
}
ret = xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket");
if (ret < 0) {
fprintf(stderr, "Failed to connect to Xen daemon\n");
return(-1);
}
ret = xenStoreOpen(conn, NULL, VIR_CONNECT_RO);
if (ret < 0) {
fprintf(stderr, "Failed to open XenStore connection");
return (-1);
}
ret = xenDaemonGetVersion(conn, &xenVersion2);
if (ret != 0) {
fprintf(stderr, "Failed to get Xen daemon version\n");
return(-1);
}
if (debug)
fprintf(stderr, "Connected to hypervisor %lu and daemon %lu\n",
xenVersion, xenVersion2);
if (xenVersion2 > xenVersion)
xenVersion = xenVersion2;
return(0);
}
/************************************************************************
* *
* Processing of the unix socket to listen for clients *
* *
************************************************************************/
/**
* proxyCloseUnixSocket:
*
* close the unix socket
*
* Returns 0 or -1 in case of error
*/
static int
proxyCloseUnixSocket(void) {
int ret;
if (fdServer < 0)
return(0);
ret = close(fdServer);
if (debug > 0)
fprintf(stderr, "closing unix socket %d: %d\n", fdServer, ret);
fdServer = -1;
pollInfos[0].fd = -1;
return(ret);
}
/**
* proxyListenUnixSocket:
* @path: the filename for the socket
*
* create a new abstract socket based on that path and listen on it
*
* Returns the associated file descriptor or -1 in case of failure
*/
static int
proxyListenUnixSocket(const char *path) {
int fd;
struct sockaddr_un addr;
if (fdServer >= 0)
return(fdServer);
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
fprintf(stderr, "Failed to create unix socket");
return(-1);
}
/*
* Abstract socket do not hit the filesystem, way more secure and
* guaranteed to be atomic
*/
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
addr.sun_path[0] = '\0';
if (virStrcpy(&addr.sun_path[1], path, sizeof(addr.sun_path) - 1) == NULL) {
fprintf(stderr, "Path %s too long to fit into destination\n", path);
close(fd);
return -1;
}
/*
* now bind the socket to that address and listen on it
*/
if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
fprintf(stderr, "Failed to bind to socket %s\n", path);
close(fd);
return (-1);
}
if (listen(fd, 30 /* backlog */ ) < 0) {
fprintf(stderr, "Failed to listen to socket %s\n", path);
close(fd);
return (-1);
}
if (debug > 0)
fprintf(stderr, "opened and bound unix socket %d\n", fd);
fdServer = fd;
pollInfos[0].fd = fd;
pollInfos[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
return (fd);
}
/**
* proxyAcceptClientSocket:
*
* Process a request to the unix socket
*
* Returns the filedescriptor of the new client or -1 in case of error
*/
static int
proxyAcceptClientSocket(void) {
int client;
socklen_t client_addrlen;
struct sockaddr client_addr;
retry:
client_addrlen = sizeof(client_addr);
client = accept(pollInfos[0].fd, &client_addr, &client_addrlen);
if (client < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "accept connection on socket %d interrupted\n",
pollInfos[0].fd);
goto retry;
}
fprintf(stderr, "Failed to accept incoming connection on socket %d\n",
pollInfos[0].fd);
done = 1;
return(-1);
}
if (nbClients >= MAX_CLIENT) {
fprintf(stderr, "Too many client registered\n");
close(client);
return(-1);
}
nbClients++;
pollInfos[nbClients].fd = client;
pollInfos[nbClients].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
if (debug > 0)
fprintf(stderr, "accept connection on socket %d for client %d\n",
client, nbClients);
return(client);
}
/************************************************************************
* *
* Processing of client sockets *
* *
************************************************************************/
/**
* proxyCloseClientSocket:
* @nr: client number
*
* Close the socket from that client, and recompact the pollInfo array
*
* Returns 0 in case of success and -1 in case of error
*/
static int
proxyCloseClientSocket(int nr) {
int ret;
ret = close(pollInfos[nr].fd);
if (ret != 0)
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[nr].fd, nr);
else if (debug > 0)
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[nr].fd, nr);
if (nr < nbClients) {
memmove(&pollInfos[nr], &pollInfos[nr + 1],
(nbClients - nr) * sizeof(pollInfos[0]));
}
nbClients--;
return(ret);
}
/**
* proxyCloseClientSockets:
*
* Close all the sockets from the clients
*/
static void
proxyCloseClientSockets(void) {
int i, ret;
for (i = 1;i <= nbClients;i++) {
ret = close(pollInfos[i].fd);
if (ret != 0)
fprintf(stderr, "Failed to close socket %d from client %d\n",
pollInfos[i].fd, i);
else if (debug > 0)
fprintf(stderr, "Closed socket %d from client %d\n",
pollInfos[i].fd, i);
}
nbClients = 0;
}
/**
* proxyWriteClientSocket:
* @nr: the client number
* @req: pointer to the packet
*
* Send back a packet to the client. If it seems write would be blocking
* then try to disconnect from it.
*
* Return 0 in case of success and -1 in case of error.
*/
static int
proxyWriteClientSocket(int nr, virProxyPacketPtr req) {
int ret;
if ((nr <= 0) || (nr > nbClients) || (req == NULL) ||
(req->len < sizeof(virProxyPacket)) ||
(req->len > sizeof(virProxyFullPacket)) ||
(pollInfos[nr].fd < 0)) {
fprintf(stderr, "write to client %d in error", nr);
proxyCloseClientSocket(nr);
return(-1);
}
ret = safewrite(pollInfos[nr].fd, (char *) req, req->len);
if (ret < 0) {
fprintf(stderr, "write %d bytes to socket %d from client %d failed\n",
req->len, pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret != req->len) {
fprintf(stderr, "write %d of %d bytes to socket %d from client %d\n",
ret, req->len, pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (debug)
fprintf(stderr, "wrote %d bytes to client %d on socket %d\n",
ret, nr, pollInfos[nr].fd);
return(0);
}
/**
* proxyReadClientSocket:
* @nr: the client number
*
* Process a read from a client socket
*/
static int
proxyReadClientSocket(int nr) {
virDomainDefPtr def;
union {
virProxyFullPacket full_request;
virProxyPacket request;
} r;
virProxyPacketPtr req = &r.request;
int ret;
char *xml, *ostype;
retry:
ret = read(pollInfos[nr].fd, req, sizeof(virProxyPacket));
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry;
}
fprintf(stderr, "Failed to read socket %d from client %d\n",
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr, "end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
if (debug)
fprintf(stderr, "read %d bytes from client %d on socket %d\n",
ret, nr, pollInfos[nr].fd);
if ((ret != sizeof(virProxyPacket)) ||
(req->version != PROXY_PROTO_VERSION) ||
(req->len < sizeof(virProxyPacket)) ||
(req->len > sizeof(virProxyFullPacket)))
goto comm_error;
if (debug)
fprintf(stderr, "Got command %d from client %d\n", req->command, nr);
/*
* complete reading the packet.
* TODO: we should detect when blocking and abort connection if this happen
*/
if (req->len > ret) {
int total, extra;
char *base = (char *) &r;
total = ret;
while (total < req->len) {
extra = req->len - total;
retry2:
ret = read(pollInfos[nr].fd, base + total, extra);
if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr,
"read socket %d from client %d interrupted\n",
pollInfos[nr].fd, nr);
goto retry2;
}
fprintf(stderr, "Failed to read socket %d from client %d\n",
pollInfos[nr].fd, nr);
proxyCloseClientSocket(nr);
return(-1);
}
if (ret == 0) {
if (debug)
fprintf(stderr,
"end of stream from client %d on socket %d\n",
nr, pollInfos[nr].fd);
proxyCloseClientSocket(nr);
return(-1);
}
total += ret;
}
}
switch (req->command) {
case VIR_PROXY_NONE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
break;
case VIR_PROXY_VERSION:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenVersion;
break;
case VIR_PROXY_LIST: {
int maxids;
if (req->len != sizeof(virProxyPacket))
goto comm_error;
maxids = sizeof(r.full_request.extra.arg) / sizeof(int);
ret = xenHypervisorListDomains(conn, &r.full_request.extra.arg[0],
maxids);
if (ret < 0) {
req->len = sizeof(virProxyPacket);
req->data.arg = 0;
} else {
req->len = sizeof(virProxyPacket) + ret * sizeof(int);
req->data.arg = ret;
}
break;
}
case VIR_PROXY_NUM_DOMAIN:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.arg = xenHypervisorNumOfDomains(conn);
break;
case VIR_PROXY_MAX_MEMORY:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
break;
case VIR_PROXY_DOMAIN_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
memset(&r.full_request.extra.dinfo, 0, sizeof(virDomainInfo));
ret = xenHypervisorGetDomInfo(conn, req->data.arg,
&r.full_request.extra.dinfo);
if (ret < 0) {
req->data.arg = -1;
} else {
req->len += sizeof(virDomainInfo);
}
break;
case VIR_PROXY_LOOKUP_ID: {
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
int len;
if (req->len != sizeof(virProxyPacket))
goto comm_error;
if (xenDaemonDomainLookupByID(conn, req->data.arg, &name, uuid) < 0) {
req->data.arg = -1;
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len += VIR_UUID_BUFLEN + len + 1;
memcpy(&r.full_request.extra.str[0], uuid, VIR_UUID_BUFLEN);
strcpy(&r.full_request.extra.str[VIR_UUID_BUFLEN], name);
}
free(name);
break;
}
case VIR_PROXY_LOOKUP_UUID: {
char **names;
char **tmp;
int ident, len;
char *name = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len != sizeof(virProxyPacket) + VIR_UUID_BUFLEN)
goto comm_error;
/*
* Xend API forces to collect the full domain list by names, and
* then query each of them until the id is found
*/
names = xenDaemonListDomainsOld(conn);
tmp = names;
if (names != NULL) {
while (*tmp != NULL) {
ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
if (!memcmp(uuid, &r.full_request.extra.str[0], VIR_UUID_BUFLEN)) {
name = *tmp;
break;
}
tmp++;
}
}
if (name == NULL) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
len = strlen(name);
if (len > 1000) {
len = 1000;
name[1000] = 0;
}
req->len = sizeof(virProxyPacket) + len + 1;
strcpy(&r.full_request.extra.str[0], name);
req->data.arg = ident;
}
free(names);
break;
}
case VIR_PROXY_LOOKUP_NAME: {
int ident;
unsigned char uuid[VIR_UUID_BUFLEN];
if (req->len > sizeof(virProxyPacket) + 1000)
goto comm_error;
ident = xenDaemonDomainLookupByName_ids(conn,
&r.full_request.extra.str[0], &uuid[0]);
if (ident < 0) {
/* not found */
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
req->len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
memcpy(&r.full_request.extra.str[0], uuid, VIR_UUID_BUFLEN);
req->data.arg = ident;
}
break;
}
case VIR_PROXY_NODE_INFO:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
/*
* Hum, could we expect those information to be unmutable and
* cache them ? Since it's probably an unfrequent call better
* not make assumption and do the xend RPC each call.
*/
ret = xenDaemonNodeGetInfo(conn, &r.full_request.extra.ninfo);
if (ret < 0) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
req->data.arg = 0;
req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
}
break;
case VIR_PROXY_GET_CAPABILITIES:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
xml = xenHypervisorGetCapabilities (conn);
if (!xml) {
req->data.arg = -1;
req->len = sizeof (virProxyPacket);
} else {
int xmllen = strlen (xml);
if (xmllen > (int) sizeof (r.full_request.extra.str)) {
req->data.arg = -2;
req->len = sizeof (virProxyPacket);
} else {
req->data.arg = 0;
memmove (r.full_request.extra.str, xml, xmllen);
req->len = sizeof (virProxyPacket) + xmllen;
}
free (xml);
}
break;
case VIR_PROXY_DOMAIN_XML:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
/*
* Ideally we should get the CPUs used by the domain
* but that information is really node specific and it
* rather hard to get from that code path. So proxy
* users won't see CPU pinning (last NULL arg)
*/
def = xenDaemonDomainFetch(conn, r.full_request.data.arg, NULL, NULL);
if (!def) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
xml = virDomainDefFormat(def, 0);
if (!xml) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
int xmllen = strlen(xml);
if (xmllen > (int) sizeof(r.full_request.extra.str)) {
req->data.arg = -2;
req->len = sizeof(virProxyPacket);
} else {
req->data.arg = 0;
memmove(&r.full_request.extra.str[0], xml, xmllen);
req->len = sizeof(virProxyPacket) + xmllen;
}
free(xml);
}
}
virDomainDefFree(def);
break;
case VIR_PROXY_DOMAIN_OSTYPE:
if (req->len != sizeof(virProxyPacket))
goto comm_error;
ostype = xenStoreDomainGetOSTypeID(conn, r.full_request.data.arg);
if (!ostype) {
req->data.arg = -1;
req->len = sizeof(virProxyPacket);
} else {
int ostypelen = strlen(ostype);
if (ostypelen > (int) sizeof(r.full_request.extra.str)) {
req->data.arg = -2;
req->len = sizeof(virProxyPacket);
} else {
req->data.arg = 0;
memmove(&r.full_request.extra.str[0], ostype, ostypelen);
req->len = sizeof(virProxyPacket) + ostypelen;
}
free(ostype);
}
break;
default:
goto comm_error;
}
ret = proxyWriteClientSocket(nr, req);
return(ret);
comm_error:
fprintf(stderr,
"Communication error with client %d: malformed packet\n", nr);
proxyCloseClientSocket(nr);
return(-1);
}
/************************************************************************
* *
* Main loop processing *
* *
************************************************************************/
/**
* proxyProcessRequests:
*
* process requests and timers
*/
static void
proxyProcessRequests(void) {
int exit_timeout = 30;
int ret, i;
while (!done) {
/*
* wait for requests, with a one second timeout
*/
ret = poll(&pollInfos[0], nbClients + 1, 1000);
if (ret == 0) { /* timeout */
if ((nbClients == 0) && (persist == 0)) {
exit_timeout--;
if (exit_timeout == 0) {
done = 1;
if (debug > 0) {
fprintf(stderr, "Exiting after 30s without clients\n");
}
}
} else
exit_timeout = 30;
if (debug > 1)
fprintf(stderr, "poll timeout\n");
continue;
} else if (ret < 0) {
if (errno == EINTR) {
if (debug > 0)
fprintf(stderr, "poll syscall interrupted\n");
continue;
}
fprintf(stderr, "poll syscall failed\n");
break;
}
/*
* there have been I/O to process
*/
exit_timeout = 30;
if (pollInfos[0].revents != 0) {
if (pollInfos[0].revents & POLLIN) {
proxyAcceptClientSocket();
} else {
fprintf(stderr, "Got an error %d on incoming socket %d\n",
pollInfos[0].revents, pollInfos[0].fd);
break;
}
}
/*
* process the clients in reverse order since on error or disconnect
* pollInfos is compacted to remove the given client.
*/
for (i = nbClients;i > 0;i--) {
if (pollInfos[i].revents & POLLIN) {
proxyReadClientSocket(i);
} else if (pollInfos[i].revents != 0) {
fprintf(stderr, "Got an error %d on client %d socket %d\n",
pollInfos[i].revents, i, pollInfos[i].fd);
proxyCloseClientSocket(i);
}
}
}
}
/**
* proxyMainLoop:
*
* main loop for the proxy, continually try to keep the unix socket
* open, serve client requests, and process timing events.
*/
static void
proxyMainLoop(void) {
while (! done) {
if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
break;
proxyProcessRequests();
}
proxyCloseClientSockets();
}
/**
* usage:
*
* dump on stdout information about the program
*/
static void
usage(const char *progname) {
printf("Usage: %s [-v] [-v]\n", progname);
printf(" option -v increase the verbosity level for debugging\n");
printf("This is a proxy for xen services used by libvirt to offer\n");
printf("safe and fast status information on the Xen virtualization.\n");
printf("This need not be run manually it's started automatically.\n");
}
/**
* main:
*
* Check that we are running with root privileges, initialize the
* connections to the daemon and or hypervisor, and then run the main loop
*/
int main(int argc, char **argv) {
int i;
if (!setlocale(LC_ALL, "")) {
perror("setlocale");
return -1;
}
if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR)) {
perror("bindtextdomain");
return -1;
}
if (!textdomain(GETTEXT_PACKAGE)) {
perror("textdomain");
return -1;
}
for (i = 1; i < argc; i++) {
if (STREQ(argv[i], "-v")) {
debug++;
} else if (STREQ(argv[i], "-no-timeout")) {
persist = 1;
} else {
usage(argv[0]);
exit(EXIT_FAILURE);
}
}
if (geteuid() != 0) {
fprintf(stderr, "%s must be run as root or suid\n", argv[0]);
/* exit(EXIT_FAILURE); */
}
/*
* setup a connection block
*/
memset(conn, 0, sizeof(conninfos));
conn->magic = VIR_CONNECT_MAGIC;
/*
* very fist thing, use the socket as an exclusive lock, this then
* allow to do timed exits, avoiding constant CPU usage in case of
* failure.
*/
if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
exit(EXIT_SUCCESS);
if (proxyInitXen() == 0)
proxyMainLoop();
sleep(1);
proxyCloseUnixSocket();
exit(EXIT_SUCCESS);
}
#else /* WITHOUT_XEN */
int main(void) {
fprintf(stderr, "libvirt was compiled without Xen support\n");
exit(EXIT_FAILURE);
}
#endif /* WITH_XEN */

View File

@ -228,7 +228,6 @@ TEST_DRIVER_SOURCES = \
# Now the Hypervisor specific drivers # Now the Hypervisor specific drivers
XEN_DRIVER_SOURCES = \ XEN_DRIVER_SOURCES = \
xen/proxy_internal.c xen/proxy_internal.h \
xen/sexpr.c xen/sexpr.h \ xen/sexpr.c xen/sexpr.h \
xen/block_stats.c xen/block_stats.h \ xen/block_stats.c xen/block_stats.h \
xen/xen_hypervisor.c xen/xen_hypervisor.h \ xen/xen_hypervisor.c xen/xen_hypervisor.h \

View File

@ -106,7 +106,6 @@ no_memory:
} }
#ifndef PROXY
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node, virCPUDefParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
@ -298,7 +297,6 @@ error:
def = NULL; def = NULL;
goto cleanup; goto cleanup;
} }
#endif
char * char *

View File

@ -26,9 +26,7 @@
# include "util.h" # include "util.h"
# include "buf.h" # include "buf.h"
# ifndef PROXY # include "xml.h"
# include "xml.h"
# endif
enum virCPUType { enum virCPUType {
VIR_CPU_TYPE_HOST, VIR_CPU_TYPE_HOST,
@ -87,12 +85,10 @@ virCPUDefFree(virCPUDefPtr def);
virCPUDefPtr virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu); virCPUDefCopy(const virCPUDefPtr cpu);
# ifndef PROXY
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node, virCPUDefParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
enum virCPUType mode); enum virCPUType mode);
# endif
enum virCPUFormatFlags { enum virCPUFormatFlags {
VIR_CPU_FORMAT_EMBEDED = (1 << 0) /* embed into existing <cpu/> element VIR_CPU_FORMAT_EMBEDED = (1 << 0) /* embed into existing <cpu/> element

View File

@ -335,8 +335,6 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__) __FUNCTION__, __LINE__, __VA_ARGS__)
#ifndef PROXY
int virDomainObjListInit(virDomainObjListPtr doms) int virDomainObjListInit(virDomainObjListPtr doms)
{ {
doms->objs = virHashCreate(50); doms->objs = virHashCreate(50);
@ -428,8 +426,6 @@ virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
return obj; return obj;
} }
#endif /* !PROXY */
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def) void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
{ {
if (!def) if (!def)
@ -813,8 +809,6 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def); VIR_FREE(def);
} }
#ifndef PROXY
static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots); static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots);
static void virDomainObjFree(virDomainObjPtr dom) static void virDomainObjFree(virDomainObjPtr dom)
{ {
@ -990,7 +984,6 @@ int virDomainDeviceVirtioSerialAddressIsValid(
{ {
return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */ return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */
} }
#endif /* !PROXY */
int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info) int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info)
@ -1153,9 +1146,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
} }
#ifndef PROXY
static int static int
virDomainDevicePCIAddressParseXML(xmlNodePtr node, virDomainDevicePCIAddressParseXML(xmlNodePtr node,
virDomainDevicePCIAddressPtr addr) virDomainDevicePCIAddressPtr addr)
@ -4045,7 +4035,6 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
VIR_FREE(dev); VIR_FREE(dev);
return NULL; return NULL;
} }
#endif /* !PROXY */
static const char * static const char *
@ -4236,7 +4225,6 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
} }
#ifndef PROXY
static char *virDomainDefDefaultEmulator(virDomainDefPtr def, static char *virDomainDefDefaultEmulator(virDomainDefPtr def,
virCapsPtr caps) { virCapsPtr caps) {
const char *type; const char *type;
@ -5400,8 +5388,6 @@ int virDomainDefAddImplicitControllers(virDomainDefPtr def)
} }
#endif /* ! PROXY */
/************************************************************************ /************************************************************************
* * * *
* Parser and converter for the CPUset strings used in libvirt * * Parser and converter for the CPUset strings used in libvirt *
@ -6949,7 +6935,6 @@ char *virDomainDefFormat(virDomainDefPtr def,
return NULL; return NULL;
} }
#ifndef PROXY
static char *virDomainObjFormat(virCapsPtr caps, static char *virDomainObjFormat(virCapsPtr caps,
virDomainObjPtr obj, virDomainObjPtr obj,
@ -8020,5 +8005,3 @@ cleanup:
return ret; return ret;
} }
#endif /* ! PROXY */

View File

@ -1057,7 +1057,6 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
void virDomainRemoveInactive(virDomainObjListPtr doms, void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom); virDomainObjPtr dom);
# ifndef PROXY
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps, virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
const virDomainDefPtr def, const virDomainDefPtr def,
const char *xmlStr, const char *xmlStr,
@ -1081,7 +1080,6 @@ virDomainObjPtr virDomainObjParseNode(virCapsPtr caps,
int virDomainDefAddImplicitControllers(virDomainDefPtr def); int virDomainDefAddImplicitControllers(virDomainDefPtr def);
# endif
char *virDomainDefFormat(virDomainDefPtr def, char *virDomainDefFormat(virDomainDefPtr def,
int flags); int flags);

View File

@ -202,8 +202,6 @@ err_exit:
} }
#ifndef PROXY
static bool static bool
isValidVarName(const char *var) isValidVarName(const char *var)
{ {
@ -258,7 +256,6 @@ skip_entry:
} }
return table; return table;
} }
#endif
struct formatterParam { struct formatterParam {

View File

@ -68,8 +68,6 @@ virStorageEncryptionFree(virStorageEncryptionPtr enc)
VIR_FREE(enc); VIR_FREE(enc);
} }
#ifndef PROXY
static virStorageEncryptionSecretPtr static virStorageEncryptionSecretPtr
virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
xmlNodePtr node) xmlNodePtr node)
@ -211,7 +209,6 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)
xmlXPathFreeContext(ctxt); xmlXPathFreeContext(ctxt);
return enc; return enc;
} }
#endif /* ! PROXY */
static int static int

View File

@ -195,8 +195,6 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
# endif /* HAVE_MMAP */ # endif /* HAVE_MMAP */
#endif /* HAVE_POSIX_FALLOCATE */ #endif /* HAVE_POSIX_FALLOCATE */
#ifndef PROXY
int virFileStripSuffix(char *str, int virFileStripSuffix(char *str,
const char *suffix) const char *suffix)
{ {
@ -241,14 +239,14 @@ virArgvToString(const char *const *argv)
} }
int virSetNonBlock(int fd) { int virSetNonBlock(int fd) {
# ifndef WIN32 #ifndef WIN32
int flags; int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0) if ((flags = fcntl(fd, F_GETFL)) < 0)
return -1; return -1;
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
if ((fcntl(fd, F_SETFL, flags)) < 0) if ((fcntl(fd, F_SETFL, flags)) < 0)
return -1; return -1;
# else #else
unsigned long flag = 1; unsigned long flag = 1;
/* This is actually Gnulib's replacement rpl_ioctl function. /* This is actually Gnulib's replacement rpl_ioctl function.
@ -256,12 +254,12 @@ int virSetNonBlock(int fd) {
*/ */
if (ioctl (fd, FIONBIO, (void *) &flag) == -1) if (ioctl (fd, FIONBIO, (void *) &flag) == -1)
return -1; return -1;
# endif #endif
return 0; return 0;
} }
# ifndef WIN32 #ifndef WIN32
int virSetCloseExec(int fd) { int virSetCloseExec(int fd) {
int flags; int flags;
@ -274,7 +272,7 @@ int virSetCloseExec(int fd) {
} }
# if HAVE_CAPNG # if HAVE_CAPNG
static int virClearCapabilities(void) static int virClearCapabilities(void)
{ {
int ret; int ret;
@ -289,13 +287,13 @@ static int virClearCapabilities(void)
return 0; return 0;
} }
# else # else
static int virClearCapabilities(void) static int virClearCapabilities(void)
{ {
// VIR_WARN0("libcap-ng support not compiled in, unable to clear capabilities"); // VIR_WARN0("libcap-ng support not compiled in, unable to clear capabilities");
return 0; return 0;
} }
# endif # endif
/* virFork() - fork a new process while avoiding various race/deadlock conditions /* virFork() - fork a new process while avoiding various race/deadlock conditions
@ -314,9 +312,9 @@ static int virClearCapabilities(void)
*/ */
int virFork(pid_t *pid) { int virFork(pid_t *pid) {
# ifdef HAVE_PTHREAD_SIGMASK # ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, newmask; sigset_t oldmask, newmask;
# endif # endif
struct sigaction sig_action; struct sigaction sig_action;
int saved_errno, ret = -1; int saved_errno, ret = -1;
@ -326,7 +324,7 @@ int virFork(pid_t *pid) {
* Need to block signals now, so that child process can safely * Need to block signals now, so that child process can safely
* kill off caller's signal handlers without a race. * kill off caller's signal handlers without a race.
*/ */
# ifdef HAVE_PTHREAD_SIGMASK # ifdef HAVE_PTHREAD_SIGMASK
sigfillset(&newmask); sigfillset(&newmask);
if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) { if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
saved_errno = errno; saved_errno = errno;
@ -334,7 +332,7 @@ int virFork(pid_t *pid) {
"%s", _("cannot block signals")); "%s", _("cannot block signals"));
goto cleanup; goto cleanup;
} }
# endif # endif
/* Ensure we hold the logging lock, to protect child processes /* Ensure we hold the logging lock, to protect child processes
* from deadlocking on another thread's inherited mutex state */ * from deadlocking on another thread's inherited mutex state */
@ -347,11 +345,11 @@ int virFork(pid_t *pid) {
virLogUnlock(); virLogUnlock();
if (*pid < 0) { if (*pid < 0) {
# ifdef HAVE_PTHREAD_SIGMASK # ifdef HAVE_PTHREAD_SIGMASK
/* attempt to restore signal mask, but ignore failure, to /* attempt to restore signal mask, but ignore failure, to
avoid obscuring the fork failure */ avoid obscuring the fork failure */
ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL)); ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
# endif # endif
virReportSystemError(saved_errno, virReportSystemError(saved_errno,
"%s", _("cannot fork child process")); "%s", _("cannot fork child process"));
goto cleanup; goto cleanup;
@ -361,7 +359,7 @@ int virFork(pid_t *pid) {
/* parent process */ /* parent process */
# ifdef HAVE_PTHREAD_SIGMASK # ifdef HAVE_PTHREAD_SIGMASK
/* Restore our original signal mask now that the child is /* Restore our original signal mask now that the child is
safely running */ safely running */
if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) { if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) {
@ -369,7 +367,7 @@ int virFork(pid_t *pid) {
virReportSystemError(errno, "%s", _("cannot unblock signals")); virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup; goto cleanup;
} }
# endif # endif
ret = 0; ret = 0;
} else { } else {
@ -405,7 +403,7 @@ int virFork(pid_t *pid) {
sigaction(i, &sig_action, NULL); sigaction(i, &sig_action, NULL);
} }
# ifdef HAVE_PTHREAD_SIGMASK # ifdef HAVE_PTHREAD_SIGMASK
/* Unmask all signals in child, since we've no idea /* Unmask all signals in child, since we've no idea
what the caller's done with their signal mask what the caller's done with their signal mask
and don't want to propagate that to children */ and don't want to propagate that to children */
@ -415,7 +413,7 @@ int virFork(pid_t *pid) {
virReportSystemError(errno, "%s", _("cannot unblock signals")); virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup; goto cleanup;
} }
# endif # endif
ret = 0; ret = 0;
} }
@ -873,7 +871,7 @@ virRunWithHook(const char *const*argv,
return ret; return ret;
} }
# else /* WIN32 */ #else /* WIN32 */
int virSetCloseExec(int fd ATTRIBUTE_UNUSED) int virSetCloseExec(int fd ATTRIBUTE_UNUSED)
{ {
@ -937,7 +935,7 @@ virFork(pid_t *pid)
return -1; return -1;
} }
# endif /* WIN32 */ #endif /* WIN32 */
int int
virPipeReadUntilEOF(int outfd, int errfd, virPipeReadUntilEOF(int outfd, int errfd,
@ -1173,7 +1171,7 @@ int virFileHasSuffix(const char *str,
return STRCASEEQ(str + len - suffixlen, suffix); return STRCASEEQ(str + len - suffixlen, suffix);
} }
# define SAME_INODE(Stat_buf_1, Stat_buf_2) \ #define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \ ((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev) && (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
@ -1279,7 +1277,7 @@ int virFileExists(const char *path)
return(0); return(0);
} }
# ifndef WIN32 #ifndef WIN32
/* return -errno on failure, or 0 on success */ /* return -errno on failure, or 0 on success */
static int virFileOperationNoFork(const char *path, int openflags, mode_t mode, static int virFileOperationNoFork(const char *path, int openflags, mode_t mode,
uid_t uid, gid_t gid, uid_t uid, gid_t gid,
@ -1591,7 +1589,7 @@ childerror:
_exit(ret); _exit(ret);
} }
# else /* WIN32 */ #else /* WIN32 */
/* return -errno on failure, or 0 on success */ /* return -errno on failure, or 0 on success */
int virFileOperation(const char *path ATTRIBUTE_UNUSED, int virFileOperation(const char *path ATTRIBUTE_UNUSED,
@ -1620,7 +1618,7 @@ int virDirCreate(const char *path ATTRIBUTE_UNUSED,
return -1; return -1;
} }
# endif /* WIN32 */ #endif /* WIN32 */
static int virFileMakePathHelper(char *path) { static int virFileMakePathHelper(char *path) {
struct stat st; struct stat st;
@ -1714,7 +1712,7 @@ int virFileOpenTty(int *ttymaster,
rawmode); rawmode);
} }
# ifdef __linux__ #ifdef __linux__
int virFileOpenTtyAt(const char *ptmx, int virFileOpenTtyAt(const char *ptmx,
int *ttymaster, int *ttymaster,
char **ttyName, char **ttyName,
@ -1764,7 +1762,7 @@ cleanup:
return rc; return rc;
} }
# else #else
int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED, int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
int *ttymaster ATTRIBUTE_UNUSED, int *ttymaster ATTRIBUTE_UNUSED,
char **ttyName ATTRIBUTE_UNUSED, char **ttyName ATTRIBUTE_UNUSED,
@ -1772,7 +1770,7 @@ int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
{ {
return -1; return -1;
} }
# endif #endif
char* virFilePid(const char *dir, const char* name) char* virFilePid(const char *dir, const char* name)
{ {
@ -1911,7 +1909,6 @@ cleanup:
return rc; return rc;
} }
#endif /* PROXY */
/* /*
* Creates an absolute path for a potentialy realtive path. * Creates an absolute path for a potentialy realtive path.
@ -2861,15 +2858,14 @@ virFileFindMountPoint(const char *type ATTRIBUTE_UNUSED)
#endif /* defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R */ #endif /* defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R */
#ifndef PROXY #if defined(UDEVADM) || defined(UDEVSETTLE)
# if defined(UDEVADM) || defined(UDEVSETTLE)
void virFileWaitForDevices(void) void virFileWaitForDevices(void)
{ {
# ifdef UDEVADM # ifdef UDEVADM
const char *const settleprog[] = { UDEVADM, "settle", NULL }; const char *const settleprog[] = { UDEVADM, "settle", NULL };
# else # else
const char *const settleprog[] = { UDEVSETTLE, NULL }; const char *const settleprog[] = { UDEVSETTLE, NULL };
# endif # endif
int exitstatus; int exitstatus;
if (access(settleprog[0], X_OK) != 0) if (access(settleprog[0], X_OK) != 0)
@ -2884,9 +2880,8 @@ void virFileWaitForDevices(void)
if (virRun(settleprog, &exitstatus) < 0) if (virRun(settleprog, &exitstatus) < 0)
{} {}
} }
# else #else
void virFileWaitForDevices(void) {} void virFileWaitForDevices(void) {}
# endif
#endif #endif
int virBuildPathInternal(char **path, ...) int virBuildPathInternal(char **path, ...)

File diff suppressed because it is too large Load Diff

View File

@ -1,100 +0,0 @@
/*
* proxy.h: common definitions for proxy usage
*
* Copyright (C) 2006 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#ifndef __LIBVIR_PROXY_H__
# define __LIBVIR_PROXY_H__
# include "internal.h"
# define PROXY_SOCKET_PATH "/tmp/livirt_proxy_conn"
# define PROXY_PROTO_VERSION 1
/*
* the command allowed though the proxy
*/
typedef enum {
VIR_PROXY_NONE = 0,
VIR_PROXY_VERSION = 1,
VIR_PROXY_NODE_INFO = 2,
VIR_PROXY_LIST = 3,
VIR_PROXY_NUM_DOMAIN = 4,
VIR_PROXY_LOOKUP_ID = 5,
VIR_PROXY_LOOKUP_UUID = 6,
VIR_PROXY_LOOKUP_NAME = 7,
VIR_PROXY_MAX_MEMORY = 8,
VIR_PROXY_DOMAIN_INFO = 9,
VIR_PROXY_DOMAIN_XML = 10,
VIR_PROXY_DOMAIN_OSTYPE = 11,
VIR_PROXY_GET_CAPABILITIES = 12
} virProxyCommand;
/*
* structure used by the client to make a request to the proxy
* and by the proxy when answering the client.
* the size may not be fixed, it's passed as len.
*/
struct _virProxyPacket {
unsigned short version; /* version of the proxy protocol */
unsigned short command; /* command number a virProxyCommand */
unsigned short serial; /* command serial number */
unsigned short len; /* the length of the request */
union {
char string[8]; /* string data */
int arg; /* or int argument */
long larg; /* or long argument */
} data;
};
typedef struct _virProxyPacket virProxyPacket;
typedef virProxyPacket *virProxyPacketPtr;
/*
* If there is extra data sent from the proxy to the client,
* they are appended after the packet.
* the size may not be fixed, it's passed as len and includes the
* extra data.
*/
struct _virProxyFullPacket {
unsigned short version; /* version of the proxy protocol */
unsigned short command; /* command number a virProxyCommand */
unsigned short serial; /* command serial number */
unsigned short len; /* the length of the request */
union {
char string[8]; /* string data */
int arg; /* or int argument */
long larg; /* or long argument */
} data;
/* that should be aligned on a 16bytes boundary */
union {
char str[4080]; /* extra char array */
int arg[1020]; /* extra int array */
virDomainInfo dinfo; /* domain information */
virNodeInfo ninfo; /* node information */
} extra;
};
typedef struct _virProxyFullPacket virProxyFullPacket;
typedef virProxyFullPacket *virProxyFullPacketPtr;
/* xen_unified makes direct calls or indirect calls through here. */
extern struct xenUnifiedDriver xenProxyDriver;
extern int xenProxyInit (void);
extern virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id);
extern virDomainPtr xenProxyLookupByUUID(virConnectPtr conn,
const unsigned char *uuid);
extern virDomainPtr xenProxyLookupByName(virConnectPtr conn,
const char *domname);
extern char * xenProxyDomainDumpXML(virDomainPtr domain,
int flags);
extern int xenProxyListDomains(virConnectPtr conn, int *ids,
int maxids);
extern int xenProxyNumOfDomains(virConnectPtr conn);
#endif /* __LIBVIR_PROXY_H__ */

View File

@ -13,7 +13,7 @@
/* Note: /* Note:
* *
* This driver provides a unified interface to the five * This driver provides a unified interface to the five
* separate underlying Xen drivers (xen_internal, proxy_internal, * separate underlying Xen drivers (xen_internal,
* xend_internal, xs_internal and xm_internal). Historically * xend_internal, xs_internal and xm_internal). Historically
* the body of libvirt.c handled the five Xen drivers, * the body of libvirt.c handled the five Xen drivers,
* and contained Xen-specific code. * and contained Xen-specific code.
@ -33,7 +33,6 @@
#include "xen_driver.h" #include "xen_driver.h"
#include "xen_hypervisor.h" #include "xen_hypervisor.h"
#include "proxy_internal.h"
#include "xend_internal.h" #include "xend_internal.h"
#include "xs_internal.h" #include "xs_internal.h"
#include "xm_internal.h" #include "xm_internal.h"
@ -61,7 +60,6 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
/* The five Xen drivers below us. */ /* The five Xen drivers below us. */
static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = {
[XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver, [XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver,
[XEN_UNIFIED_PROXY_OFFSET] = &xenProxyDriver,
[XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver, [XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver,
[XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver, [XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver,
[XEN_UNIFIED_XM_OFFSET] = &xenXMDriver, [XEN_UNIFIED_XM_OFFSET] = &xenXMDriver,
@ -318,7 +316,6 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
priv->handle = -1; priv->handle = -1;
priv->xendConfigVersion = -1; priv->xendConfigVersion = -1;
priv->xshandle = NULL; priv->xshandle = NULL;
priv->proxy = -1;
/* Hypervisor is only run with privilege & required to succeed */ /* Hypervisor is only run with privilege & required to succeed */
@ -331,9 +328,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
} }
} }
/* XenD is required to succeed if privileged. /* XenD is required to succeed if privileged */
* If it fails as non-root, then the proxy driver may take over
*/
DEBUG0("Trying XenD sub-driver"); DEBUG0("Trying XenD sub-driver");
if (drivers[XEN_UNIFIED_XEND_OFFSET]->open(conn, auth, flags) == if (drivers[XEN_UNIFIED_XEND_OFFSET]->open(conn, auth, flags) ==
VIR_DRV_OPEN_SUCCESS) { VIR_DRV_OPEN_SUCCESS) {
@ -363,20 +358,9 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
if (xenHavePrivilege()) { if (xenHavePrivilege()) {
goto fail; /* XenD is mandatory when privileged */ goto fail; /* XenD is mandatory when privileged */
} else { } else {
#if WITH_PROXY
DEBUG0("Trying proxy sub-driver");
if (drivers[XEN_UNIFIED_PROXY_OFFSET]->open(conn, auth, flags) ==
VIR_DRV_OPEN_SUCCESS) {
DEBUG0("Activated proxy sub-driver");
priv->opened[XEN_UNIFIED_PROXY_OFFSET] = 1;
} else {
goto fail; /* Proxy is mandatory if XenD failed */
}
#else
DEBUG0("Handing off for remote driver"); DEBUG0("Handing off for remote driver");
ret = VIR_DRV_OPEN_DECLINED; /* Let remote_driver try instead */ ret = VIR_DRV_OPEN_DECLINED; /* Let remote_driver try instead */
goto clean; goto clean;
#endif
} }
} }
@ -402,9 +386,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
fail: fail:
ret = VIR_DRV_OPEN_ERROR; ret = VIR_DRV_OPEN_ERROR;
#ifndef WITH_PROXY
clean: clean:
#endif
DEBUG0("Failed to activate a mandatory sub-driver"); DEBUG0("Failed to activate a mandatory sub-driver");
for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++) for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++)
if (priv->opened[i]) drivers[i]->close(conn); if (priv->opened[i]) drivers[i]->close(conn);
@ -579,11 +561,6 @@ xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids)
if (ret >= 0) return ret; if (ret >= 0) return ret;
} }
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyListDomains (conn, ids, maxids);
if (ret >= 0) return ret;
}
return -1; return -1;
} }
@ -611,12 +588,6 @@ xenUnifiedNumOfDomains (virConnectPtr conn)
if (ret >= 0) return ret; if (ret >= 0) return ret;
} }
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyNumOfDomains (conn);
if (ret >= 0) return ret;
}
return -1; return -1;
} }
@ -659,13 +630,6 @@ xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
return ret; return ret;
} }
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByID (conn, id);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try xend. */ /* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) { if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByID (conn, id); ret = xenDaemonLookupByID (conn, id);
@ -697,13 +661,6 @@ xenUnifiedDomainLookupByUUID (virConnectPtr conn,
return ret; return ret;
} }
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByUUID (conn, uuid);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try xend. */ /* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) { if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByUUID (conn, uuid); ret = xenDaemonLookupByUUID (conn, uuid);
@ -735,13 +692,6 @@ xenUnifiedDomainLookupByName (virConnectPtr conn,
*/ */
virConnResetLastError (conn); virConnResetLastError (conn);
/* Try proxy. */
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
ret = xenProxyLookupByName (conn, name);
if (ret || conn->err.code != VIR_ERR_OK)
return ret;
}
/* Try xend. */ /* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) { if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByName (conn, name); ret = xenDaemonLookupByName (conn, name);
@ -1223,8 +1173,6 @@ xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
VIR_FREE(cpus); VIR_FREE(cpus);
return(res); return(res);
} }
if (priv->opened[XEN_UNIFIED_PROXY_OFFSET])
return xenProxyDomainDumpXML(dom, flags);
} }
xenUnifiedError(VIR_ERR_NO_SUPPORT, __FUNCTION__); xenUnifiedError(VIR_ERR_NO_SUPPORT, __FUNCTION__);

View File

@ -42,16 +42,15 @@
extern int xenRegister (void); extern int xenRegister (void);
# define XEN_UNIFIED_HYPERVISOR_OFFSET 0 # define XEN_UNIFIED_HYPERVISOR_OFFSET 0
# define XEN_UNIFIED_PROXY_OFFSET 1 # define XEN_UNIFIED_XEND_OFFSET 1
# define XEN_UNIFIED_XEND_OFFSET 2 # define XEN_UNIFIED_XS_OFFSET 2
# define XEN_UNIFIED_XS_OFFSET 3 # define XEN_UNIFIED_XM_OFFSET 3
# define XEN_UNIFIED_XM_OFFSET 4
# if WITH_XEN_INOTIFY # if WITH_XEN_INOTIFY
# define XEN_UNIFIED_INOTIFY_OFFSET 5 # define XEN_UNIFIED_INOTIFY_OFFSET 4
# define XEN_UNIFIED_NR_DRIVERS 6
# else
# define XEN_UNIFIED_NR_DRIVERS 5 # define XEN_UNIFIED_NR_DRIVERS 5
# else
# define XEN_UNIFIED_NR_DRIVERS 4
# endif # endif
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */ # define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
@ -175,8 +174,6 @@ struct _xenUnifiedPrivate {
struct xs_handle *xshandle; /* handle to talk to the xenstore */ struct xs_handle *xshandle; /* handle to talk to the xenstore */
int proxy; /* fd of proxy. */
/* A list of xenstore watches */ /* A list of xenstore watches */
xenStoreWatchListPtr xsWatchList; xenStoreWatchListPtr xsWatchList;
@ -230,12 +227,7 @@ void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
unsigned long xenUnifiedVersion(void); unsigned long xenUnifiedVersion(void);
int xenUnifiedGetMaxVcpus(virConnectPtr conn, const char *type); int xenUnifiedGetMaxVcpus(virConnectPtr conn, const char *type);
# ifndef PROXY
void xenUnifiedLock(xenUnifiedPrivatePtr priv); void xenUnifiedLock(xenUnifiedPrivatePtr priv);
void xenUnifiedUnlock(xenUnifiedPrivatePtr priv); void xenUnifiedUnlock(xenUnifiedPrivatePtr priv);
# else
# define xenUnifiedLock(p) do {} while(0)
# define xenUnifiedUnlock(p) do {} while(0)
# endif
#endif /* __VIR_XEN_UNIFIED_H__ */ #endif /* __VIR_XEN_UNIFIED_H__ */

View File

@ -748,11 +748,8 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
# error "unsupported platform" # error "unsupported platform"
#endif #endif
#ifndef PROXY
static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain); static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain);
#endif
#ifndef PROXY
struct xenUnifiedDriver xenHypervisorDriver = { struct xenUnifiedDriver xenHypervisorDriver = {
xenHypervisorOpen, /* open */ xenHypervisorOpen, /* open */
xenHypervisorClose, /* close */ xenHypervisorClose, /* close */
@ -792,15 +789,12 @@ struct xenUnifiedDriver xenHypervisorDriver = {
xenHypervisorGetSchedulerParameters, /* domainGetSchedulerParameters */ xenHypervisorGetSchedulerParameters, /* domainGetSchedulerParameters */
xenHypervisorSetSchedulerParameters, /* domainSetSchedulerParameters */ xenHypervisorSetSchedulerParameters, /* domainSetSchedulerParameters */
}; };
#endif /* !PROXY */
#define virXenError(code, ...) \ #define virXenError(code, ...) \
if (in_init == 0) \ if (in_init == 0) \
virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__) __FUNCTION__, __LINE__, __VA_ARGS__)
#ifndef PROXY
/** /**
* virXenErrorFunc: * virXenErrorFunc:
* @error: the error number * @error: the error number
@ -835,8 +829,6 @@ virXenErrorFunc(virErrorNumber error, const char *func, const char *info,
} }
} }
#endif /* PROXY */
/** /**
* xenHypervisorDoV0Op: * xenHypervisorDoV0Op:
* @handle: the handle to the Xen hypervisor * @handle: the handle to the Xen hypervisor
@ -1103,7 +1095,6 @@ virXen_getdomaininfo(int handle, int first_domain,
} }
#ifndef PROXY
/** /**
* xenHypervisorGetSchedulerType: * xenHypervisorGetSchedulerType:
* @domain: pointer to the Xen Hypervisor block * @domain: pointer to the Xen Hypervisor block
@ -1419,7 +1410,7 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
const char *path, const char *path,
struct _virDomainBlockStats *stats) struct _virDomainBlockStats *stats)
{ {
# ifdef __linux__ #ifdef __linux__
xenUnifiedPrivatePtr priv; xenUnifiedPrivatePtr priv;
int ret; int ret;
@ -1429,12 +1420,12 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
ret = xenLinuxDomainBlockStats (priv, dom, path, stats); ret = xenLinuxDomainBlockStats (priv, dom, path, stats);
xenUnifiedUnlock(priv); xenUnifiedUnlock(priv);
return ret; return ret;
# else #else
virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__, virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
"block statistics not supported on this platform", "block statistics not supported on this platform",
dom->id); dom->id);
return -1; return -1;
# endif #endif
} }
/* Paths have the form vif<domid>.<n> (this interface checks that /* Paths have the form vif<domid>.<n> (this interface checks that
@ -1449,7 +1440,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
const char *path, const char *path,
struct _virDomainInterfaceStats *stats) struct _virDomainInterfaceStats *stats)
{ {
# ifdef __linux__ #ifdef __linux__
int rqdomid, device; int rqdomid, device;
/* Verify that the vif requested is one belonging to the current /* Verify that the vif requested is one belonging to the current
@ -1467,11 +1458,11 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
} }
return linuxDomainInterfaceStats(path, stats); return linuxDomainInterfaceStats(path, stats);
# else #else
virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__, virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
"/proc/net/dev: Interface not found", 0); "/proc/net/dev: Interface not found", 0);
return -1; return -1;
# endif #endif
} }
/** /**
@ -1777,7 +1768,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
} }
return(ret); return(ret);
} }
#endif /* !PROXY*/
/** /**
* virXen_getvcpusinfo: * virXen_getvcpusinfo:
@ -2810,7 +2801,6 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
} }
#ifndef PROXY
char * char *
xenHypervisorDomainGetOSType (virDomainPtr dom) xenHypervisorDomainGetOSType (virDomainPtr dom)
{ {
@ -2982,7 +2972,6 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
VIR_FREE(name); VIR_FREE(name);
return ret; return ret;
} }
#endif
/** /**
* xenHypervisorGetMaxVcpus: * xenHypervisorGetMaxVcpus:
@ -3044,7 +3033,6 @@ xenHypervisorGetDomMaxMemory(virConnectPtr conn, int id)
return((unsigned long) XEN_GETDOMAININFO_MAX_PAGES(dominfo) * kb_per_pages); return((unsigned long) XEN_GETDOMAININFO_MAX_PAGES(dominfo) * kb_per_pages);
} }
#ifndef PROXY
/** /**
* xenHypervisorGetMaxMemory: * xenHypervisorGetMaxMemory:
* @domain: a domain object or NULL * @domain: a domain object or NULL
@ -3069,7 +3057,6 @@ xenHypervisorGetMaxMemory(virDomainPtr domain)
return(xenHypervisorGetDomMaxMemory(domain->conn, domain->id)); return(xenHypervisorGetDomMaxMemory(domain->conn, domain->id));
} }
#endif
/** /**
* xenHypervisorGetDomInfo: * xenHypervisorGetDomInfo:
@ -3181,7 +3168,6 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
} }
#ifndef PROXY
/** /**
* xenHypervisorNodeGetCellsFreeMemory: * xenHypervisorNodeGetCellsFreeMemory:
* @conn: pointer to the hypervisor connection * @conn: pointer to the hypervisor connection
@ -3371,9 +3357,8 @@ xenHypervisorSetMaxMemory(virDomainPtr domain, unsigned long memory)
return (-1); return (-1);
return (0); return (0);
} }
#endif /* PROXY */
#ifndef PROXY
/** /**
* xenHypervisorSetVcpus: * xenHypervisorSetVcpus:
* @domain: pointer to domain object * @domain: pointer to domain object
@ -3436,7 +3421,6 @@ xenHypervisorPinVcpu(virDomainPtr domain, unsigned int vcpu,
return (-1); return (-1);
return (0); return (0);
} }
#endif
/** /**
* virDomainGetVcpus: * virDomainGetVcpus:
@ -3457,7 +3441,6 @@ xenHypervisorPinVcpu(virDomainPtr domain, unsigned int vcpu,
* *
* Returns the number of info filled in case of success, -1 in case of failure. * Returns the number of info filled in case of success, -1 in case of failure.
*/ */
#ifndef PROXY
int int
xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo, xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen) unsigned char *cpumaps, int maplen)
@ -3523,7 +3506,6 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
} }
return nbinfo; return nbinfo;
} }
#endif /* PROXY */
/** /**
* xenHypervisorGetVcpuMax: * xenHypervisorGetVcpuMax:

View File

@ -22,7 +22,6 @@ int xenHypervisorInit (void);
virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn); virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn);
/* The following calls are made directly by the Xen proxy: */
int int
xenHypervisorHasDomain(virConnectPtr conn, xenHypervisorHasDomain(virConnectPtr conn,
int id); int id);

View File

@ -51,15 +51,11 @@
#define VIR_FROM_THIS VIR_FROM_XEND #define VIR_FROM_THIS VIR_FROM_XEND
#ifndef PROXY
/* /*
* The number of Xen scheduler parameters * The number of Xen scheduler parameters
*/ */
# define XEN_SCHED_SEDF_NPARAM 6 #define XEN_SCHED_SEDF_NPARAM 6
# define XEN_SCHED_CRED_NPARAM 2 #define XEN_SCHED_CRED_NPARAM 2
#endif /* PROXY */
#ifdef WITH_RHEL5_API #ifdef WITH_RHEL5_API
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0 # define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
@ -71,7 +67,6 @@
#define XEND_RCV_BUF_MAX_LEN 65536 #define XEND_RCV_BUF_MAX_LEN 65536
#ifndef PROXY
static int static int
xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED, xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskDefPtr def, virDomainDiskDefPtr def,
@ -97,7 +92,6 @@ virDomainXMLDevID(virDomainPtr domain,
char *class, char *class,
char *ref, char *ref,
int ref_len); int ref_len);
#endif
#define virXendError(code, ...) \ #define virXendError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_XEND, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_XEND, code, __FILE__, \
@ -399,7 +393,6 @@ xend_get(virConnectPtr xend, const char *path,
return ret; return ret;
} }
#ifndef PROXY
/** /**
* xend_post: * xend_post:
* @xend: pointer to the Xen Daemon structure * @xend: pointer to the Xen Daemon structure
@ -460,7 +453,6 @@ xend_post(virConnectPtr xend, const char *path, const char *ops)
VIR_FREE(err_buf); VIR_FREE(err_buf);
return ret; return ret;
} }
#endif /* ! PROXY */
/** /**
@ -495,7 +487,6 @@ http2unix(int ret)
return -1; return -1;
} }
#ifndef PROXY
/** /**
* xend_op_ext: * xend_op_ext:
* @xend: pointer to the Xen Daemon structure * @xend: pointer to the Xen Daemon structure
@ -570,7 +561,6 @@ xend_op(virConnectPtr xend, const char *name, const char *key, ...)
return ret; return ret;
} }
#endif /* ! PROXY */
/** /**
* sexpr_get: * sexpr_get:
@ -698,7 +688,6 @@ sexpr_uuid(unsigned char *ptr, const struct sexpr *node, const char *path)
} }
#ifndef PROXY
/** /**
* urlencode: * urlencode:
* @string: the input URL * @string: the input URL
@ -737,7 +726,6 @@ urlencode(const char *string)
return buffer; return buffer;
} }
#endif /* ! PROXY */
/* PUBLIC FUNCTIONS */ /* PUBLIC FUNCTIONS */
@ -779,7 +767,7 @@ xenDaemonOpen_unix(virConnectPtr conn, const char *path)
return (0); return (0);
} }
#ifndef PROXY
/** /**
* xenDaemonOpen_tcp: * xenDaemonOpen_tcp:
* @conn: an existing virtual connection block * @conn: an existing virtual connection block
@ -879,9 +867,6 @@ xend_wait_for_devices(virConnectPtr xend, const char *name)
} }
#endif /* PROXY */
/** /**
* xenDaemonListDomainsOld: * xenDaemonListDomainsOld:
* @xend: pointer to the Xen Daemon block * @xend: pointer to the Xen Daemon block
@ -946,7 +931,7 @@ xenDaemonListDomainsOld(virConnectPtr xend)
return ret; return ret;
} }
#ifndef PROXY
/** /**
* xenDaemonDomainCreateXML: * xenDaemonDomainCreateXML:
* @xend: A xend instance * @xend: A xend instance
@ -983,7 +968,7 @@ xenDaemonDomainCreateXML(virConnectPtr xend, const char *sexpr)
return ret; return ret;
} }
#endif /* ! PROXY */
/** /**
* xenDaemonDomainLookupByName_ids: * xenDaemonDomainLookupByName_ids:
@ -1090,7 +1075,6 @@ error:
} }
#ifndef PROXY
static int static int
xend_detect_config_version(virConnectPtr conn) { xend_detect_config_version(virConnectPtr conn) {
struct sexpr *root; struct sexpr *root;
@ -1121,7 +1105,6 @@ xend_detect_config_version(virConnectPtr conn) {
return (0); return (0);
} }
#endif /* PROXY */
/***************************************************************** /*****************************************************************
****** ******
@ -1767,9 +1750,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn,
int hvm, int hvm,
int xendConfigVersion) int xendConfigVersion)
{ {
#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
#endif
const char *tmp; const char *tmp;
virDomainGraphicsDefPtr graphics = NULL; virDomainGraphicsDefPtr graphics = NULL;
@ -1858,9 +1839,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
virDomainDefPtr def, virDomainDefPtr def,
const struct sexpr *root) const struct sexpr *root)
{ {
#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
#endif
virDomainGraphicsDefPtr graphics = NULL; virDomainGraphicsDefPtr graphics = NULL;
const struct sexpr *cur, *node; const struct sexpr *cur, *node;
const char *tmp; const char *tmp;
@ -2099,9 +2078,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
int xendConfigVersion, int xendConfigVersion,
const char *cpus) const char *cpus)
{ {
#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
#endif
const char *tmp; const char *tmp;
virDomainDefPtr def; virDomainDefPtr def;
int hvm = 0; int hvm = 0;
@ -2624,7 +2601,6 @@ sexpr_to_xend_topology(const struct sexpr *root,
} }
#ifndef PROXY
/** /**
* sexpr_to_domain: * sexpr_to_domain:
* @conn: an existing virtual connection block * @conn: an existing virtual connection block
@ -2678,7 +2654,7 @@ error:
virUnrefDomain(ret); virUnrefDomain(ret);
return(NULL); return(NULL);
} }
#endif /* !PROXY */
/***************************************************************** /*****************************************************************
****** ******
@ -2691,7 +2667,6 @@ error:
****** ******
****** ******
*****************************************************************/ *****************************************************************/
#ifndef PROXY
/** /**
* xenDaemonOpen: * xenDaemonOpen:
* @conn: an existing virtual connection block * @conn: an existing virtual connection block
@ -3053,7 +3028,7 @@ xenDaemonDomainRestore(virConnectPtr conn, const char *filename)
} }
return xend_op(conn, "", "op", "restore", "file", filename, NULL); return xend_op(conn, "", "op", "restore", "file", filename, NULL);
} }
#endif /* !PROXY */
/** /**
* xenDaemonDomainGetMaxMemory: * xenDaemonDomainGetMaxMemory:
@ -3091,7 +3066,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
return(ret); return(ret);
} }
#ifndef PROXY
/** /**
* xenDaemonDomainSetMaxMemory: * xenDaemonDomainSetMaxMemory:
* @domain: pointer to the Domain block * @domain: pointer to the Domain block
@ -3161,7 +3136,6 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
"target", buf, NULL); "target", buf, NULL);
} }
#endif /* ! PROXY */
virDomainDefPtr virDomainDefPtr
xenDaemonDomainFetch(virConnectPtr conn, xenDaemonDomainFetch(virConnectPtr conn,
@ -3199,7 +3173,6 @@ cleanup:
} }
#ifndef PROXY
/** /**
* xenDaemonDomainDumpXML: * xenDaemonDomainDumpXML:
* @domain: a domain object * @domain: a domain object
@ -3241,7 +3214,7 @@ xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus)
return xml; return xml;
} }
#endif /* !PROXY */
/** /**
* xenDaemonDomainGetInfo: * xenDaemonDomainGetInfo:
@ -3280,7 +3253,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
return (ret); return (ret);
} }
#ifndef PROXY
/** /**
* xenDaemonLookupByName: * xenDaemonLookupByName:
* @conn: A xend instance * @conn: A xend instance
@ -3313,7 +3286,7 @@ error:
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }
#endif /* ! PROXY */
/** /**
* xenDaemonNodeGetInfo: * xenDaemonNodeGetInfo:
@ -3420,7 +3393,7 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer)
return(0); return(0);
} }
#ifndef PROXY
/** /**
* xenDaemonListDomains: * xenDaemonListDomains:
* @conn: pointer to the hypervisor connection * @conn: pointer to the hypervisor connection
@ -3500,9 +3473,8 @@ error:
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }
#endif /* ! PROXY */
#ifndef PROXY
/** /**
* xenDaemonLookupByID: * xenDaemonLookupByID:
* @conn: pointer to the hypervisor connection * @conn: pointer to the hypervisor connection
@ -6130,5 +6102,3 @@ virDomainXMLDevID(virDomainPtr domain,
return 0; return 0;
} }
#endif /* ! PROXY */

View File

@ -38,7 +38,6 @@
#define VIR_FROM_THIS VIR_FROM_XEN #define VIR_FROM_THIS VIR_FROM_XEN
#ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain); static char *xenStoreDomainGetOSType(virDomainPtr domain);
static void xenStoreWatchEvent(int watch, int fd, int events, void *data); static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
static void xenStoreWatchListFree(xenStoreWatchListPtr list); static void xenStoreWatchListFree(xenStoreWatchListPtr list);
@ -83,8 +82,6 @@ struct xenUnifiedDriver xenStoreDriver = {
NULL, /* domainSetSchedulerParameters */ NULL, /* domainSetSchedulerParameters */
}; };
#endif /* ! PROXY */
#define virXenStoreError(code, ...) \ #define virXenStoreError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \ virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__) __FUNCTION__, __LINE__, __VA_ARGS__)
@ -94,7 +91,6 @@ struct xenUnifiedDriver xenStoreDriver = {
* Helper internal APIs * * Helper internal APIs *
* * * *
************************************************************************/ ************************************************************************/
#ifndef PROXY
/** /**
* virConnectDoStoreList: * virConnectDoStoreList:
* @conn: pointer to the hypervisor connection * @conn: pointer to the hypervisor connection
@ -120,7 +116,6 @@ virConnectDoStoreList(virConnectPtr conn, const char *path,
return xs_directory (priv->xshandle, 0, path, nb); return xs_directory (priv->xshandle, 0, path, nb);
} }
#endif /* ! PROXY */
/** /**
* virDomainDoStoreQuery: * virDomainDoStoreQuery:
@ -152,7 +147,6 @@ virDomainDoStoreQuery(virConnectPtr conn, int domid, const char *path)
return xs_read(priv->xshandle, 0, &s[0], &len); return xs_read(priv->xshandle, 0, &s[0], &len);
} }
#ifndef PROXY
/** /**
* virDomainDoStoreWrite: * virDomainDoStoreWrite:
* @domain: a domain object * @domain: a domain object
@ -254,7 +248,6 @@ virDomainGetVMInfo(virDomainPtr domain, const char *vm, const char *name)
return (ret); return (ret);
} }
#endif /* ! PROXY */
/************************************************************************ /************************************************************************
* * * *
@ -278,14 +271,10 @@ xenStoreOpen(virConnectPtr conn,
{ {
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData; xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
#ifdef PROXY
priv->xshandle = xs_daemon_open_readonly();
#else
if (flags & VIR_CONNECT_RO) if (flags & VIR_CONNECT_RO)
priv->xshandle = xs_daemon_open_readonly(); priv->xshandle = xs_daemon_open_readonly();
else else
priv->xshandle = xs_daemon_open(); priv->xshandle = xs_daemon_open();
#endif /* ! PROXY */
if (priv->xshandle == NULL) { if (priv->xshandle == NULL) {
/* /*
@ -300,7 +289,6 @@ xenStoreOpen(virConnectPtr conn,
return (-1); return (-1);
} }
#ifndef PROXY
/* Init activeDomainList */ /* Init activeDomainList */
if (VIR_ALLOC(priv->activeDomainList) < 0) { if (VIR_ALLOC(priv->activeDomainList) < 0) {
virReportOOMError(); virReportOOMError();
@ -341,7 +329,6 @@ xenStoreOpen(virConnectPtr conn,
NULL)) < 0) NULL)) < 0)
DEBUG0("Failed to add event handle, disabling events"); DEBUG0("Failed to add event handle, disabling events");
#endif //PROXY
return 0; return 0;
} }
@ -365,7 +352,6 @@ xenStoreClose(virConnectPtr conn)
priv = (xenUnifiedPrivatePtr) conn->privateData; priv = (xenUnifiedPrivatePtr) conn->privateData;
#ifndef PROXY
if (xenStoreRemoveWatch(conn, "@introduceDomain", "introduceDomain") < 0) { if (xenStoreRemoveWatch(conn, "@introduceDomain", "introduceDomain") < 0) {
DEBUG0("Warning, could not remove @introduceDomain watch"); DEBUG0("Warning, could not remove @introduceDomain watch");
/* not fatal */ /* not fatal */
@ -380,21 +366,19 @@ xenStoreClose(virConnectPtr conn)
priv->xsWatchList = NULL; priv->xsWatchList = NULL;
xenUnifiedDomainInfoListFree(priv->activeDomainList); xenUnifiedDomainInfoListFree(priv->activeDomainList);
priv->activeDomainList = NULL; priv->activeDomainList = NULL;
#endif
if (priv->xshandle == NULL) if (priv->xshandle == NULL)
return(-1); return(-1);
#ifndef PROXY
if (priv->xsWatch != -1) if (priv->xsWatch != -1)
virEventRemoveHandle(priv->xsWatch); virEventRemoveHandle(priv->xsWatch);
#endif
xs_daemon_close(priv->xshandle); xs_daemon_close(priv->xshandle);
priv->xshandle = NULL; priv->xshandle = NULL;
return (0); return (0);
} }
#ifndef PROXY
/** /**
* xenStoreGetDomainInfo: * xenStoreGetDomainInfo:
* @domain: pointer to the domain block * @domain: pointer to the domain block
@ -444,7 +428,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
info->memory = 0; info->memory = 0;
info->maxMem = 0; info->maxMem = 0;
} }
# if 0 #if 0
/* doesn't seems to work */ /* doesn't seems to work */
tmp = virDomainDoStoreQuery(domain->conn, domain->id, "cpu_time"); tmp = virDomainDoStoreQuery(domain->conn, domain->id, "cpu_time");
if (tmp != NULL) { if (tmp != NULL) {
@ -453,7 +437,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
} else { } else {
info->cpuTime = 0; info->cpuTime = 0;
} }
# endif #endif
snprintf(request, 199, "/local/domain/%d/cpu", domain->id); snprintf(request, 199, "/local/domain/%d/cpu", domain->id);
request[199] = 0; request[199] = 0;
tmp2 = virConnectDoStoreList(domain->conn, request, &nb_vcpus); tmp2 = virConnectDoStoreList(domain->conn, request, &nb_vcpus);
@ -685,10 +669,10 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
if ((endptr == idlist[i]) || (*endptr != 0)) { if ((endptr == idlist[i]) || (*endptr != 0)) {
goto done; goto done;
} }
# if 0 #if 0
if (virConnectCheckStoreID(conn, (int) id) < 0) if (virConnectCheckStoreID(conn, (int) id) < 0)
continue; continue;
# endif #endif
snprintf(prop, 199, "/local/domain/%s/name", idlist[i]); snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
prop[199] = 0; prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len); tmp = xs_read(priv->xshandle, 0, prop, &len);
@ -811,7 +795,6 @@ xenStoreDomainGetOSType(virDomainPtr domain) {
return (str); return (str);
} }
#endif /* ! PROXY */
/** /**
* xenStoreDomainGetVNCPort: * xenStoreDomainGetVNCPort:
@ -860,52 +843,6 @@ char * xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
return virDomainDoStoreQuery(conn, domid, "console/tty"); return virDomainDoStoreQuery(conn, domid, "console/tty");
} }
#ifdef PROXY
/*
* xenStoreDomainGetOSTypeID:
* @conn: pointer to the connection.
* @id: the domain id
*
* Get the type of domain operation system.
*
* The caller must hold the lock on the privateData
* associated with the 'conn' parameter.
*
* Returns the new string or NULL in case of error, the string must be
* freed by the caller.
*/
char *
xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) {
char *vm, *str = NULL;
char query[200];
unsigned int len;
xenUnifiedPrivatePtr priv;
if (id < 0)
return(NULL);
priv = (xenUnifiedPrivatePtr) conn->privateData;
if (priv->xshandle == NULL)
return (NULL);
snprintf(query, 199, "/local/domain/%d/vm", id);
query[199] = 0;
vm = xs_read(priv->xshandle, 0, &query[0], &len);
if (vm) {
snprintf(query, 199, "%s/image/ostype", vm);
str = xs_read(priv->xshandle, 0, &query[0], &len);
VIR_FREE(vm);
}
if (str == NULL)
str = strdup("linux");
if (str == NULL)
virReportOOMError();
return (str);
}
#endif /* PROXY */
/* /*
* xenStoreDomainGetNetworkID: * xenStoreDomainGetNetworkID:
@ -1122,7 +1059,6 @@ char *xenStoreDomainGetName(virConnectPtr conn,
return xs_read(priv->xshandle, 0, prop, &len); return xs_read(priv->xshandle, 0, prop, &len);
} }
#ifndef PROXY
/* /*
* The caller must hold the lock on the privateData * The caller must hold the lock on the privateData
* associated with the 'conn' parameter. * associated with the 'conn' parameter.
@ -1496,5 +1432,3 @@ retry:
} }
return 0; return 0;
} }
#endif //PROXY

View File

@ -37,13 +37,10 @@ int xenStoreDomainShutdown (virDomainPtr domain);
int xenStoreDomainReboot (virDomainPtr domain, int xenStoreDomainReboot (virDomainPtr domain,
unsigned int flags); unsigned int flags);
/* those are entry point for the proxy */
int xenStoreDomainGetVNCPort(virConnectPtr conn, int xenStoreDomainGetVNCPort(virConnectPtr conn,
int domid); int domid);
char * xenStoreDomainGetConsolePath(virConnectPtr conn, char * xenStoreDomainGetConsolePath(virConnectPtr conn,
int domid); int domid);
char * xenStoreDomainGetOSTypeID(virConnectPtr conn,
int id);
char * xenStoreDomainGetNetworkID(virConnectPtr conn, char * xenStoreDomainGetNetworkID(virConnectPtr conn,
int id, int id,
const char *mac); const char *mac);