Moved SEXPR parsing functions to xenxs

This commit is contained in:
Markus Groß 2011-02-21 14:40:08 +01:00 committed by Eric Blake
parent c71328b9aa
commit 07129039cc
10 changed files with 1514 additions and 1326 deletions

View File

@ -119,6 +119,7 @@ src/xen/xm_internal.c
src/xen/xs_internal.c
src/xenapi/xenapi_driver.c
src/xenapi/xenapi_utils.c
src/xenxs/xen_sxpr.c
tools/console.c
tools/libvirt-guests.init.sh
tools/virsh.c

View File

@ -423,6 +423,10 @@ CPU_SOURCES = \
VMX_SOURCES = \
vmx/vmx.c vmx/vmx.h
XENXS_SOURCES = \
xenxs/xenxs_private.h \
xenxs/xen_sxpr.c xenxs/xen_sxpr.h
pkgdata_DATA = cpu/cpu_map.xml
EXTRA_DIST += $(pkgdata_DATA)
@ -464,6 +468,14 @@ libvirt_vmx_la_CFLAGS = \
libvirt_vmx_la_SOURCES = $(VMX_SOURCES)
endif
if WITH_XEN
noinst_LTLIBRARIES += libvirt_xenxs.la
libvirt_la_BUILT_LIBADD += libvirt_xenxs.la
libvirt_xenxs_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_xenxs_la_SOURCES = $(XENXS_SOURCES)
endif
noinst_LTLIBRARIES += libvirt_driver.la
libvirt_la_BUILT_LIBADD += libvirt_driver.la
@ -583,6 +595,7 @@ endif
libvirt_driver_xen_la_CFLAGS = \
$(XEN_CFLAGS) \
-I@top_srcdir@/src/conf \
-I@top_srcdir@/src/xenxs \
$(AM_CFLAGS)
libvirt_driver_xen_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_xen_la_LIBADD = $(XEN_LIBS)
@ -995,7 +1008,8 @@ EXTRA_DIST += \
$(SECURITY_DRIVER_APPARMOR_SOURCES) \
$(SECRET_DRIVER_SOURCES) \
$(VBOX_DRIVER_EXTRA_DIST) \
$(VMWARE_DRIVER_SOURCES)
$(VMWARE_DRIVER_SOURCES) \
$(XENXS_SOURCES)
check-local: augeas-check

View File

@ -33,6 +33,7 @@
#include "datatypes.h"
#include "xen_driver.h"
#include "xen_sxpr.h"
#include "xen_hypervisor.h"
#include "xend_internal.h"
#include "xs_internal.h"
@ -1198,6 +1199,9 @@ xenUnifiedDomainXMLFromNative(virConnectPtr conn,
virDomainDefPtr def = NULL;
char *ret = NULL;
virConfPtr conf = NULL;
int id;
char * tty;
int vncport;
GET_PRIVATE(conn);
if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
@ -1214,7 +1218,13 @@ xenUnifiedDomainXMLFromNative(virConnectPtr conn,
def = xenXMDomainConfigParse(conn, conf);
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
def = xenDaemonParseSxprString(conn, config, priv->xendConfigVersion);
id = xenGetDomIdFromSxprString(config, priv->xendConfigVersion);
xenUnifiedLock(priv);
tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(priv);
def = xenDaemonParseSxprString(config, priv->xendConfigVersion, tty,
vncport);
}
if (!def)
goto cleanup;

File diff suppressed because it is too large Load Diff

View File

@ -27,12 +27,6 @@
# include "driver.h"
# include "buf.h"
# ifdef __sun
# define DEFAULT_VIF_SCRIPT "vif-vnic"
# else
# define DEFAULT_VIF_SCRIPT "vif-bridge"
# endif
int
xenDaemonOpen_unix(virConnectPtr conn, const char *path);
@ -96,18 +90,6 @@ xenDaemonDomainFetch(virConnectPtr xend,
const char *name,
const char *cpus);
virDomainDefPtr
xenDaemonParseSxprString(virConnectPtr conn,
const char *sexpr,
int xendConfigVersion);
int
xenDaemonParseSxprSound(virDomainDefPtr def,
const char *str);
virDomainChrDefPtr
xenDaemonParseSxprChar(const char *value,
const char *tty);
int
xenDaemonFormatSxprChr(virDomainChrDefPtr def,

View File

@ -40,6 +40,7 @@
#include "xm_internal.h"
#include "xen_driver.h"
#include "xend_internal.h"
#include "xen_sxpr.h"
#include "hash.h"
#include "buf.h"
#include "uuid.h"

1351
src/xenxs/xen_sxpr.c Normal file

File diff suppressed because it is too large Load Diff

62
src/xenxs/xen_sxpr.h Normal file
View File

@ -0,0 +1,62 @@
/*
* xen_sxpr.h: Xen SEXPR parsing functions
*
* Copyright (C) 2011 Univention GmbH
* Copyright (C) 2006-2008, 2010 Red Hat, Inc.
* Copyright (C) 2005,2006
*
* 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: Anthony Liguori <aliguori@us.ibm.com>
* Author: Daniel Veillard <veillard@redhat.com>
* Author: Markus Groß <gross@univention.de>
*/
#ifndef __VIR_XEN_SXPR_H__
# define __VIR_XEN_SXPR_H__
# include "internal.h"
# include "conf.h"
# include "domain_conf.h"
# include "sexpr.h"
# ifdef __sun
# define DEFAULT_VIF_SCRIPT "vif-vnic"
# else
# define DEFAULT_VIF_SCRIPT "vif-bridge"
# endif
/* helper functions to get the dom id from a sexpr */
int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion);
int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion);
virDomainDefPtr
xenDaemonParseSxprString(const char *sexpr,
int xendConfigVersion, char *tty, int vncport);
virDomainDefPtr
xenDaemonParseSxpr(const struct sexpr *root,
int xendConfigVersion,
const char *cpus, char *tty, int vncport);
int
xenDaemonParseSxprSound(virDomainDefPtr def,
const char *str);
virDomainChrDefPtr
xenDaemonParseSxprChar(const char *value,
const char *tty);
#endif /* __VIR_XEN_SXPR_H__ */

37
src/xenxs/xenxs_private.h Normal file
View File

@ -0,0 +1,37 @@
/*
* xenxs_private.h: Private definitions for Xen parsing
*
* Copyright (C) 2011 Univention GmbH
* Copyright (C) 2007, 2010 Red Hat, Inc.
*
* 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: Richard W.M. Jones <rjones@redhat.com>
* Author: Markus Groß <gross@univention.de>
*/
#ifndef __VIR_XENXS_PRIVATE_H__
# define __VIR_XENXS_PRIVATE_H__
# include "internal.h"
# define VIR_FROM_THIS VIR_FROM_NONE
# define XENXS_ERROR(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, __FUNCTION__, \
__LINE__, __VA_ARGS__)
#endif /* __VIR_XENXS_PRIVATE_H__ */

View File

@ -9,6 +9,7 @@
#include "datatypes.h"
#include "xen/xen_driver.h"
#include "xen/xend_internal.h"
#include "xenxs/xen_sxpr.h"
#include "testutils.h"
#include "testutilsxen.h"
@ -25,6 +26,9 @@ static int testCompareFiles(const char *xml, const char *sexpr,
char *gotxml = NULL;
char *xmlPtr = &(xmlData[0]);
char *sexprPtr = &(sexprData[0]);
int id;
char * tty;
int vncport;
int ret = -1;
virDomainDefPtr def = NULL;
virConnectPtr conn;
@ -48,7 +52,14 @@ static int testCompareFiles(const char *xml, const char *sexpr,
if (virMutexInit(&priv.lock) < 0)
goto fail;
if (!(def = xenDaemonParseSxprString(conn, sexprData, xendConfigVersion)))
id = xenGetDomIdFromSxprString(sexprData, xendConfigVersion);
xenUnifiedLock(&priv);
tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(&priv);
if (!(def = xenDaemonParseSxprString(sexprData, xendConfigVersion, tty,
vncport)))
goto fail;
if (!(gotxml = virDomainDefFormat(def, 0)))