Split network driver out into separate files

This commit is contained in:
Daniel P. Berrange 2008-10-10 13:57:13 +00:00
parent 0107578c5e
commit 1564711a27
9 changed files with 1246 additions and 977 deletions

View File

@ -1,3 +1,13 @@
Fri Oct 10 14:56:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* configure.in: option to enable/disable network driver
* src/Makefile.am: Add network_driver.c/.h files
* src/libvirt.c: Import network_driver.h file
* src/qemu_conf.c, src/qemu-conf.h, src/qemu_driver.c: Remove
all network driver support
* src/network_driver.c, src/network_driver.h: Add standalone
network driver
Fri Oct 10 13:30:00 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/xml.c, src/xen_internal.c: Cast some args to unsigned

View File

@ -643,6 +643,17 @@ AC_SUBST([WITH_XEN])
AC_SUBST([LIBVIRT_FEATURES])
AC_ARG_WITH([network],
[ --with-network with virtual network driver (on)],[],[with_network=yes])
if test "$with_libvirtd" = "no" ; then
with_network=no
fi
if test "$with_network" = "yes" ; then
AC_DEFINE_UNQUOTED([WITH_NETWORK], 1, [whether network driver is enabled])
fi
AM_CONDITIONAL([WITH_NETWORK], [test "$with_network" = "yes"])
dnl
dnl Storage driver checks
dnl
@ -1070,6 +1081,7 @@ AC_MSG_NOTICE([ OpenVZ: $with_openvz])
AC_MSG_NOTICE([ LXC: $with_lxc])
AC_MSG_NOTICE([ Test: $with_test])
AC_MSG_NOTICE([ Remote: $with_remote])
AC_MSG_NOTICE([ Network: $with_network])
AC_MSG_NOTICE([Libvirtd: $with_libvirtd])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Storage Drivers])

View File

@ -104,11 +104,12 @@ OPENVZ_DRIVER_SOURCES = \
openvz_conf.c openvz_conf.h \
openvz_driver.c openvz_driver.h
# XXX network driver should be split out of this
QEMU_DRIVER_SOURCES = \
qemu_conf.c qemu_conf.h \
qemu_driver.c qemu_driver.h
NETWORK_DRIVER_SOURCES = \
network_driver.h network_driver.c
# And finally storage backend specific impls
STORAGE_DRIVER_SOURCES = \
@ -165,9 +166,11 @@ if WITH_OPENVZ
libvirt_la_SOURCES += $(OPENVZ_DRIVER_SOURCES)
endif
# Drivers usable inside daemon context
if WITH_LIBVIRTD
if WITH_NETWORK
libvirt_la_SOURCES += $(NETWORK_DRIVER_SOURCES)
endif
libvirt_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
libvirt_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
@ -200,6 +203,7 @@ EXTRA_DIST += \
$(QEMU_DRIVER_SOURCES) \
$(LXC_DRIVER_SOURCES) \
$(OPENVZ_DRIVER_SOURCES) \
$(NETWORK_DRIVER_SOURCES) \
$(STORAGE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_FS_SOURCES) \
$(STORAGE_DRIVER_LVM_SOURCES) \

View File

@ -57,6 +57,9 @@
#include "lxc_driver.h"
#endif
#include "storage_driver.h"
#ifdef WITH_NETWORK
#include "network_driver.h"
#endif
/*
* TODO:
@ -292,6 +295,9 @@ virInitialize(void)
#endif
#ifdef WITH_LXC
if (lxcRegister() == -1) return -1;
#endif
#ifdef WITH_NETWORK
if (networkRegister() == -1) return -1;
#endif
if (storageRegister() == -1) return -1;
#ifdef WITH_REMOTE

1168
src/network_driver.c Normal file

File diff suppressed because it is too large Load Diff

34
src/network_driver.h Normal file
View File

@ -0,0 +1,34 @@
/*
* network_driver.h: core driver methods for managing networks
*
* 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 __VIR_NETWORK__DRIVER_H
#define __VIR_NETWORK__DRIVER_H
#include <config.h>
#include "internal.h"
int networkRegister(void);
#endif /* __VIR_NETWORK__DRIVER_H */

View File

@ -516,7 +516,6 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
virDomainNetDefPtr net,
int vlan)
{
virNetworkObjPtr network = NULL;
char *brname;
char tapfdstr[4+3+32+7];
char *retval = NULL;
@ -524,18 +523,24 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
int tapfd = -1;
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
if (!(network = virNetworkFindByName(driver->networks, net->data.network.name))) {
virNetworkPtr network = virNetworkLookupByName(conn,
net->data.network.name);
if (!network) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Network '%s' not found"),
net->data.network.name);
goto error;
} else if (network->def->bridge == NULL) {
}
brname = virNetworkGetBridgeName(network);
virNetworkFree(network);
if (brname == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Network '%s' not active"),
_("Network '%s' is not active"),
net->data.network.name);
goto error;
}
brname = network->def->bridge;
} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
brname = net->data.bridge.brname;
} else {

View File

@ -27,7 +27,6 @@
#include <config.h>
#include "internal.h"
#include "iptables.h"
#include "bridge.h"
#include "capabilities.h"
#include "network_conf.h"
@ -53,14 +52,10 @@ struct qemud_driver {
int nextvmid;
virDomainObjPtr domains;
virNetworkObjPtr networks;
brControl *brctl;
iptablesContext *iptables;
char *configDir;
char *autostartDir;
char *networkConfigDir;
char *networkAutostartDir;
char *logDir;
unsigned int vncTLS : 1;
unsigned int vncTLSx509verify : 1;

File diff suppressed because it is too large Load Diff