提交 a78a6602 编写于 作者: D Daniel P. Berrange

Move QEMU driver into main libvirt.so and use single daemon for all drivers

上级 8c90a888
Tue Jun 26 19:35:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/libvirtd.sysconf, qemud/libvirtd.init.in: Added config
to turn on/off remote support in daemon
* qemud/conf.c, qemud/conf.h, qemud/driver.c, qemud/driver.h
Finally switch over to be an internal driver.
* qemud/dispatch.c, qemud/dispatch.h: Remove obsolete files
* qemud/protocol.*: Remove all except packet header.
* src/xml.c: Don't compile virXMLError for libvirt_proxy
* src/remote_internal.c: Pick up QEMU uris too
Tue Jun 26 19:05:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* src/remote_internal.c: Fix typo in checking for read only
......
......@@ -3,5 +3,5 @@ Makefile.in
Makefile
.deps
.libs
suspend
info1
suspend
......@@ -18,24 +18,24 @@ install-data-local:
EXTRA_DIST=examples.xsl index.py examples.xml
noinst_PROGRAMS=suspend info1
suspend_SOURCES=suspend.c
suspend_LDFLAGS=
suspend_DEPENDENCIES= $(DEPS)
suspend_LDADD= $(LDADDS)
noinst_PROGRAMS=info1 suspend
info1_SOURCES=info1.c
info1_LDFLAGS=
info1_DEPENDENCIES= $(DEPS)
info1_LDADD= $(LDADDS)
suspend_SOURCES=suspend.c
suspend_LDFLAGS=
suspend_DEPENDENCIES= $(DEPS)
suspend_LDADD= $(LDADDS)
valgrind:
$(MAKE) CHECKER='valgrind' tests
tests: $(noinst_PROGRAMS)
@(echo '## examples regression tests')
@($(CHECKER) ./suspend)
@($(CHECKER) ./info1)
@($(CHECKER) ./suspend)
......@@ -124,10 +124,7 @@ fi
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/
%dir %attr(0700, root, root) %{_sysconfdir}/libvirt/qemu/networks/autostart
%{_sysconfdir}/rc.d/init.d/libvirtd
%dir %{_sysconfdir}/libvirt
%dir %{_sysconfdir}/libvirt/qemu
%dir %{_sysconfdir}/libvirt/qemu/networks
%dir %{_sysconfdir}/libvirt/qemu/networks/autostart
%config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
%dir %{_datadir}/libvirt/
%dir %{_datadir}/libvirt/networks/
%{_datadir}/libvirt/networks/default.xml
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -7,17 +7,9 @@ sbin_PROGRAMS = libvirtd
libvirtd_SOURCES = \
qemud.c internal.h \
driver.c driver.h \
dispatch.c dispatch.h \
conf.c conf.h \
bridge.c bridge.h \
iptables.c iptables.h \
uuid.c uuid.h \
../src/buf.c \
protocol.h protocol.c \
remote_protocol.h remote_protocol.c \
remote.c \
../src/virterror.c \
event.c event.h
#-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
libvirtd_CFLAGS = \
......@@ -52,14 +44,19 @@ uninstall-local: uninstall-init
# Distribute the generated files so that rpcgen isn't required on the
# target machine (although almost any Unix machine will have it).
EXTRA_DIST = libvirtd.init.in default-network.xml \
EXTRA_DIST = libvirtd.init.in libvirtd.sysconf default-network.xml \
protocol.x remote_protocol.x \
protocol.c protocol.h \
remote_protocol.c remote_protocol.h \
remote_generate_stubs.pl rpcgen_fix.pl \
remote_dispatch_prototypes.h \
remote_dispatch_localvars.h \
remote_dispatch_proc_switch.h
remote_dispatch_proc_switch.h \
driver.c driver.h \
conf.c conf.h \
iptables.c iptables.h \
bridge.c bridge.h \
uuid.c uuid.h
.x.c:
rm -f $@
......@@ -91,6 +88,8 @@ if LIBVIRT_INIT_SCRIPTS_RED_HAT
install-init: libvirtd.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) $(srcdir)/libvirtd.init $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd
mkdir -p $(DESTDIR)$(sysconfdir)/sysconfig
$(INSTALL_SCRIPT) $(srcdir)/libvirtd.sysconf $(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
uninstall-init:
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd
......
......@@ -42,11 +42,12 @@
#include <libvirt/virterror.h>
#include "internal.h"
#include "conf.h"
#include "uuid.h"
#include "../src/buf.h"
#define qemudLog(level, msg...) fprintf(stderr, msg)
void qemudReportError(virConnectPtr conn,
virDomainPtr dom,
virNetworkPtr net,
......@@ -61,7 +62,6 @@ void qemudReportError(virConnectPtr conn,
} else {
errorMessage[0] = '\0';
}
__virRaiseError(conn, dom, net, VIR_FROM_QEMU, code, VIR_ERR_ERROR,
NULL, NULL, NULL, -1, -1, errorMessage);
}
......@@ -266,7 +266,7 @@ static const char *qemudDefaultBinaryForArch(const char *arch) {
}
/* Find the fully qualified path to the binary for an architecture */
static char *qemudLocateBinaryForArch(struct qemud_driver *driver,
static char *qemudLocateBinaryForArch(struct qemud_driver *driver ATTRIBUTE_UNUSED,
int virtType, const char *arch) {
const char *name;
char *path;
......@@ -415,7 +415,7 @@ int qemudExtractVersion(struct qemud_driver *driver) {
/* Parse the XML definition for a disk */
static struct qemud_vm_disk_def *qemudParseDiskXML(struct qemud_driver *driver,
static struct qemud_vm_disk_def *qemudParseDiskXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
xmlNodePtr node) {
struct qemud_vm_disk_def *disk = calloc(1, sizeof(struct qemud_vm_disk_def));
xmlNodePtr cur;
......@@ -552,7 +552,7 @@ static void qemudRandomMAC(struct qemud_vm_net_def *net) {
/* Parse the XML definition for a network interface */
static struct qemud_vm_net_def *qemudParseInterfaceXML(struct qemud_driver *driver,
static struct qemud_vm_net_def *qemudParseInterfaceXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
xmlNodePtr node) {
struct qemud_vm_net_def *net = calloc(1, sizeof(struct qemud_vm_net_def));
xmlNodePtr cur;
......@@ -1842,7 +1842,7 @@ static int qemudParseBridgeXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
return 1;
}
static int qemudParseDhcpRangesXML(struct qemud_driver *driver,
static int qemudParseDhcpRangesXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_network_def *def,
xmlNodePtr node) {
......@@ -2494,7 +2494,7 @@ int qemudScanConfigs(struct qemud_driver *driver) {
}
/* Generate an XML document describing the guest's configuration */
char *qemudGenerateXML(struct qemud_driver *driver,
char *qemudGenerateXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_vm *vm,
struct qemud_vm_def *def,
int live) {
......@@ -2772,7 +2772,7 @@ char *qemudGenerateXML(struct qemud_driver *driver,
}
char *qemudGenerateNetworkXML(struct qemud_driver *driver,
char *qemudGenerateNetworkXML(struct qemud_driver *driver ATTRIBUTE_UNUSED,
struct qemud_network *network,
struct qemud_network_def *def) {
virBufferPtr buf = 0;
......@@ -2863,7 +2863,7 @@ char *qemudGenerateNetworkXML(struct qemud_driver *driver,
}
int qemudDeleteConfig(struct qemud_driver *driver,
int qemudDeleteConfig(struct qemud_driver *driver ATTRIBUTE_UNUSED,
const char *configFile,
const char *name) {
if (!configFile[0]) {
......
......@@ -25,6 +25,11 @@
#define __QEMUD_CONF_H
#include "../src/internal.h"
#include "bridge.h"
#include "iptables.h"
#include <netinet/in.h>
#define qemudDebug(fmt, ...) do {} while(0)
/* Different types of QEMU acceleration possible */
enum qemud_vm_virt_type {
......@@ -33,7 +38,6 @@ enum qemud_vm_virt_type {
QEMUD_VIRT_KVM,
};
/* Two types of disk backends */
enum qemud_vm_disk_type {
QEMUD_DISK_BLOCK,
......@@ -74,6 +78,11 @@ enum qemud_vm_net_type {
QEMUD_NET_BRIDGE,
};
#define QEMUD_UUID_RAW_LEN 16
#define QEMUD_MAX_NAME_LEN 50
#define QEMUD_MAX_XML_LEN 4096
#define QEMUD_MAX_ERROR_LEN 1024
/* Stores the virtual network interface configuration */
struct qemud_vm_net_def {
int type;
......
此差异已折叠。
/*
* dispatch.h: (De-)marshall wire messages to driver functions.
*
* Copyright (C) 2006, 2007 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* 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.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#ifndef QEMUD_DISPATCH_H
#define QEMUD_DISPATCH_H
#include "internal.h"
int qemudDispatch(struct qemud_server *server, struct qemud_client *client,
struct qemud_packet_client_data *in, struct qemud_packet_server_data *out);
#endif
/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/
......@@ -53,6 +53,8 @@
#include "driver.h"
#include "conf.h"
#define qemudLog(level, msg...) fprintf(stderr, msg)
static int qemudSetCloseExec(int fd) {
int flags;
if ((flags = fcntl(fd, F_GETFD)) < 0)
......@@ -81,10 +83,6 @@ static int qemudSetNonBlock(int fd) {
}
#define virEventAddHandle(fd, events, cb, opaque) virEventAddHandleImpl(fd, events, cb, opaque)
#define virEventRemoveHandle(fd) virEventRemoveHandleImpl(fd)
static void qemudDispatchVMEvent(int fd, int events, void *opaque);
int qemudStartVMDaemon(struct qemud_driver *driver,
struct qemud_vm *vm);
......@@ -1712,7 +1710,7 @@ static int qemudGetProcessInfo(unsigned long long *cpuTime, int pid) {
}
virDomainPtr qemudDomainLookupByID(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr qemudDomainLookupByID(virConnectPtr conn,
int id) {
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
struct qemud_vm *vm = qemudFindVMByID(driver, id);
......@@ -1723,19 +1721,16 @@ virDomainPtr qemudDomainLookupByID(virConnectPtr conn ATTRIBUTE_UNUSED,
return NULL;
}
dom = calloc(1, sizeof(struct _virDomain));
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (!dom) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr");
return NULL;
}
dom->conn = conn;
dom->id = vm->id;
dom->name = vm->def->name;
memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid));
return dom;
}
virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn,
const unsigned char *uuid) {
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
struct qemud_vm *vm = qemudFindVMByUUID(driver, uuid);
......@@ -1746,19 +1741,16 @@ virDomainPtr qemudDomainLookupByUUID(virConnectPtr conn ATTRIBUTE_UNUSED,
return NULL;
}
dom = calloc(1, sizeof(struct _virDomain));
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (!dom) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr");
return NULL;
}
dom->conn = conn;
dom->id = vm->id;
dom->name = vm->def->name;
memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid));
return dom;
}
virDomainPtr qemudDomainLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainPtr qemudDomainLookupByName(virConnectPtr conn,
const char *name) {
struct qemud_driver *driver = (struct qemud_driver *)conn->privateData;
struct qemud_vm *vm = qemudFindVMByName(driver, name);
......@@ -1769,16 +1761,13 @@ virDomainPtr qemudDomainLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED,
return NULL;
}
dom = calloc(1, sizeof(struct _virDomain));
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (!dom) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr");
return NULL;
}
dom->conn = conn;
dom->id = vm->id;
dom->name = vm->def->name;
memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid));
return dom;
}
......@@ -1828,17 +1817,13 @@ virDomainPtr qemudDomainCreate(virConnectPtr conn, const char *xml,
return NULL;
}
dom = calloc(1, sizeof(struct _virDomain));
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (!dom) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr");
return NULL;
}
dom->conn = conn;
dom->id = vm->id;
dom->name = vm->def->name;
memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid));
return dom;
}
......@@ -2057,16 +2042,13 @@ virDomainPtr qemudDomainDefine(virConnectPtr conn, const char *xml) {
return NULL;
}
dom = calloc(1, sizeof(struct _virDomain));
dom = virGetDomain(conn, vm->def->name, vm->def->uuid);
if (!dom) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virDomainPtr");
return NULL;
}
dom->conn = conn;
dom->id = vm->id;
dom->name = vm->def->name;
memcpy(dom->uuid, vm->def->uuid, sizeof(dom->uuid));
return dom;
}
......@@ -2170,15 +2152,11 @@ virNetworkPtr qemudNetworkLookupByUUID(virConnectPtr conn ATTRIBUTE_UNUSED,
return NULL;
}
net = calloc(1, sizeof(struct _virNetwork));
net = virGetNetwork(conn, network->def->name, network->def->uuid);
if (!net) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr");
return NULL;
}
net->conn = conn;
net->name = network->def->name;
memcpy(net->uuid, network->def->uuid, sizeof(net->uuid));
return net;
}
virNetworkPtr qemudNetworkLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED,
......@@ -2192,15 +2170,11 @@ virNetworkPtr qemudNetworkLookupByName(virConnectPtr conn ATTRIBUTE_UNUSED,
return NULL;
}
net = calloc(1, sizeof(struct _virNetwork));
net = virGetNetwork(conn, network->def->name, network->def->uuid);
if (!net) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr");
return NULL;
}
net->conn = conn;
net->name = network->def->name;
memcpy(net->uuid, network->def->uuid, sizeof(net->uuid));
return net;
}
......@@ -2292,16 +2266,11 @@ virNetworkPtr qemudNetworkCreate(virConnectPtr conn, const char *xml) {
return NULL;
}
net = calloc(1, sizeof(struct _virNetwork));
net = virGetNetwork(conn, network->def->name, network->def->uuid);
if (!net) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr");
return NULL;
}
net->conn = conn;
net->name = network->def->name;
memcpy(net->uuid, network->def->uuid, sizeof(net->uuid));
return net;
}
......@@ -2324,16 +2293,11 @@ virNetworkPtr qemudNetworkDefine(virConnectPtr conn, const char *xml) {
return NULL;
}
net = calloc(1, sizeof(struct _virNetwork));
net = virGetNetwork(conn, network->def->name, network->def->uuid);
if (!net) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "virNetworkPtr");
return NULL;
}
net->conn = conn;
net->name = network->def->name;
memcpy(net->uuid, network->def->uuid, sizeof(net->uuid));
return net;
}
......@@ -2555,6 +2519,13 @@ static virStateDriver qemuStateDriver = {
qemudActive,
};
int qemudRegister(void) {
virRegisterDriver(&qemuDriver);
virRegisterNetworkDriver(&qemuNetworkDriver);
virRegisterStateDriver(&qemuStateDriver);
return 0;
}
/*
* Local variables:
* indent-tabs-mode: nil
......
......@@ -25,14 +25,13 @@
#ifndef QEMUD_DRIVER_H
#define QEMUD_DRIVER_H
#include "internal.h"
#include "../src/internal.h"
int qemudStartup(void);
int qemudReload(void);
int qemudShutdown(void);
int qemudActive(void);
int qemudRegister(void);
virDrvOpenStatus qemudOpen(virConnectPtr conn,
const char *name,
......
......@@ -25,8 +25,6 @@
#ifndef QEMUD_INTERNAL_H__
#define QEMUD_INTERNAL_H__
#include <sys/socket.h>
#include <netinet/in.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
......
......@@ -38,6 +38,8 @@
#include "internal.h"
#define qemudLog(level, msg...) fprintf(stderr, msg)
enum {
ADD = 0,
REMOVE
......
......@@ -20,12 +20,22 @@
SERVICE=libvirtd
PROCESS=libvirtd
LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd
LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
fi
RETVAL=0
start() {
echo -n $"Starting $SERVICE daemon: "
daemon --check $SERVICE $PROCESS --system --daemon
daemon --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE
......
# Override the default config file
#LIBVIRTD_CONFIG=/etc/libvirt/libvirtd.conf
# Listen for TCP/IP connections
# NB. must setup TLS/SSL keys prior to using this
#LIBVIRTD_ARGS="--listen"
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -49,10 +49,6 @@
#include "internal.h"
#include "../src/internal.h"
#include "dispatch.h"
#include "driver.h"
#include "conf.h"
#include "iptables.h"
#define DEBUG 0
......
......@@ -34,6 +34,8 @@
#include "internal.h"
#define qemudLog(level, msg...) fprintf(stderr, msg)
static int
virUUIDGenerateRandomBytes(unsigned char *buf,
int buflen)
......
......@@ -16,7 +16,8 @@ DEPS = libvirt.la
LDADDS = @STATIC_BINARIES@ libvirt.la
VIRSH_LIBS = @VIRSH_LIBS@
EXTRA_DIST = libvirt_sym.version
EXTRA_DIST = libvirt_sym.version \
qemu_internal.c qemu_internal.h
lib_LTLIBRARIES = libvirt.la
libvirt_la_LIBADD = @LIBXML_LIBS@
......@@ -42,10 +43,14 @@ CLIENT_SOURCES = \
proxy_internal.c proxy_internal.h \
conf.c conf.h \
xm_internal.c xm_internal.h \
qemu_internal.c qemu_internal.h \
remote_internal.c remote_internal.h
SERVER_SOURCES = \
../qemud/bridge.c ../qemud/bridge.h \
../qemud/iptables.c ../qemud/iptables.h \
../qemud/uuid.c ../qemud/uuid.h \
../qemud/driver.c ../qemud/driver.h \
../qemud/qemu_conf.c ../qemud/conf.h \
../qemud/protocol.h ../qemud/protocol.c \
../qemud/remote_protocol.c ../qemud/remote_protocol.h
......@@ -59,6 +64,9 @@ virsh_DEPENDENCIES = $(DEPS)
virsh_LDADD = $(LDADDS) $(VIRSH_LIBS)
virsh_CFLAGS = $(COVERAGE_CFLAGS)
../qemud/qemu_conf.c:
ln -s conf.c $@
#
# target to ease building test programs
#
......
......@@ -27,8 +27,8 @@
#include "xml.h"
#include "test.h"
#include "xen_unified.h"
#include "qemu_internal.h"
#include "remote_internal.h"
#include "../qemud/driver.h"
/*
* TODO:
......@@ -71,7 +71,7 @@ virInitialize(void)
if (testRegister() == -1) return -1;
#endif
#ifdef WITH_QEMU
if (qemuRegister() == -1) return -1;
if (qemudRegister() == -1) return -1;
#endif
#ifdef WITH_XEN
if (xenUnifiedRegister () == -1) return -1;
......@@ -273,6 +273,9 @@ virRegisterStateDriver(virStateDriverPtr driver)
int __virStateInitialize(void) {
int i, ret = 0;
if (virInitialize() < 0)
return -1;
if (virInitialize() < 0)
return -1;
......@@ -470,9 +473,9 @@ virConnectClose(virConnectPtr conn)
if (!VIR_IS_CONNECT(conn))
return (-1);
conn->driver->close (conn);
if (conn->networkDriver)
conn->networkDriver->close (conn);
conn->driver->close (conn);
if (virFreeConnect(conn) < 0)
return (-1);
......
......@@ -34,6 +34,7 @@
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <pwd.h>
#include <rpc/xdr.h>
#include <gnutls/gnutls.h>
......@@ -118,8 +119,6 @@ remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
return VIR_DRV_OPEN_DECLINED; /* Decline - not a URL. */
char *transport_str = get_transport_from_scheme (uri->scheme);
if (!uri->server && !transport_str)
return VIR_DRV_OPEN_DECLINED; /* Decline - not a remote URL. */
/* What transport? */
enum {
......@@ -147,6 +146,12 @@ remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
return VIR_DRV_OPEN_ERROR;
}
if (!strcmp(uri_str, "qemu:///system") ||
!strcmp(uri_str, "qemu:///session"))
transport = trans_unix;
else if (!uri->server && !transport_str)
return VIR_DRV_OPEN_DECLINED; /* Decline - not a remote URL. */
/* Local variables which we will initialise. These can
* get freed in the failed: path.
*/
......@@ -350,10 +355,27 @@ remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
case trans_unix: {
if (!sockname) {
if (flags & VIR_DRV_OPEN_RO)
sockname = strdup (LIBVIRTD_UNIX_SOCKET_RO);
else
sockname = strdup (LIBVIRTD_UNIX_SOCKET);
if (!strcmp(uri->scheme, "qemu") &&
uri->path &&
!strcmp(uri->path, "/session")) {
struct passwd *pw;
uid_t uid = getuid();
if (!(pw = getpwuid(uid))) {
error (NULL, VIR_ERR_SYSTEM_ERROR, strerror (errno));
goto failed;
}
if (asprintf (&sockname, "@%s" LIBVIRTD_USER_UNIX_SOCKET, pw->pw_dir) < 0) {
error (NULL, VIR_ERR_SYSTEM_ERROR, strerror (errno));
goto failed;
}
} else {
if (flags & VIR_DRV_OPEN_RO)
sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET_RO);
else
sockname = strdup (LIBVIRTD_PRIV_UNIX_SOCKET);
}
}
#ifndef UNIX_PATH_MAX
......@@ -363,6 +385,8 @@ remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
memset (&addr, 0, sizeof addr);
addr.sun_family = AF_UNIX;
strncpy (addr.sun_path, sockname, UNIX_PATH_MAX (addr));
if (addr.sun_path[0] == '@')
addr.sun_path[0] = '\0';
priv.sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (priv.sock == -1) {
......@@ -396,7 +420,7 @@ remoteOpen (virConnectPtr conn, const char *uri_str, int flags)
cmd_argv[j++] = strdup (server);
cmd_argv[j++] = strdup (netcat ? netcat : "nc");
cmd_argv[j++] = strdup ("-U");
cmd_argv[j++] = strdup (sockname ? sockname : LIBVIRTD_UNIX_SOCKET);
cmd_argv[j++] = strdup (sockname ? sockname : LIBVIRTD_PRIV_UNIX_SOCKET);
cmd_argv[j++] = 0;
assert (j == nr_args);
}
......
......@@ -34,8 +34,9 @@ int remoteRegister (void);
#define LIBVIRTD_TLS_PORT "16514"
#define LIBVIRTD_TCP_PORT "16509"
#define LIBVIRTD_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock"
#define LIBVIRTD_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro"
#define LIBVIRTD_PRIV_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock"
#define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro"
#define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock"
#define LIBVIRTD_CONFIGURATION_FILE SYSCONF_DIR "/libvirtd.conf"
/* Defaults for PKI directory. */
......
......@@ -25,6 +25,7 @@
#include "buf.h"
#include "xs_internal.h" /* for xenStoreDomainGetNetworkID */
#ifndef PROXY
/**
* virXMLError:
* @conn: a connection if any
......@@ -47,7 +48,6 @@ virXMLError(virConnectPtr conn, virErrorNumber error, const char *info, int valu
errmsg, info, NULL, value, 0, errmsg, info, value);
}
#ifndef PROXY
/**
* virXPathString:
* @xpath: the XPath string to evaluate
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册