Remove use of xendConfigVersion in the s-expresion config formatter/parser
in src/xenconfig/. Adjust callers in the xen and libxl drivers accordingly.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_driver.c | 1 -
src/xen/xen_driver.c | 6 +++---
src/xen/xend_internal.c | 20 ++++++++----------
src/xen/xm_internal.c | 2 +-
src/xenconfig/xen_sxpr.c | 48 +++++++++++--------------------------------
src/xenconfig/xen_sxpr.h | 21 ++++++-------------
src/xenconfig/xenxs_private.h | 8 --------
tests/sexpr2xmltest.c | 5 ++---
tests/xmconfigtest.c | 2 --
tests/xml2sexprtest.c | 2 +-
10 files changed, 33 insertions(+), 82 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index fd92fac..02ef4f5 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2608,7 +2608,6 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
} else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_SEXPR)) {
/* only support latest xend config format */
if (!(def = xenParseSxprString(nativeConfig,
- XEND_CONFIG_VERSION_3_1_0,
NULL,
-1,
cfg->caps,
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 27da520..6f25625 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1568,13 +1568,13 @@ xenUnifiedConnectDomainXMLFromNative(virConnectPtr conn,
def = xenParseXM(conf, priv->caps, priv->xmlopt);
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
- if (xenGetDomIdFromSxprString(config, priv->xendConfigVersion, &id) <
0)
+ if (xenGetDomIdFromSxprString(config, &id) < 0)
goto cleanup;
xenUnifiedLock(priv);
tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(priv);
- def = xenParseSxprString(config, priv->xendConfigVersion, tty,
+ def = xenParseSxprString(config, tty,
vncport, priv->caps, priv->xmlopt);
}
if (!def)
@@ -1632,7 +1632,7 @@ xenUnifiedConnectDomainXMLToNative(virConnectPtr conn,
goto cleanup;
}
} else if (STREQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
- ret = xenFormatSxpr(conn, def, priv->xendConfigVersion);
+ ret = xenFormatSxpr(conn, def);
}
cleanup:
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 72a1259..cd783a1 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1569,7 +1569,7 @@ xenDaemonDomainFetch(virConnectPtr conn, int domid, const char
*name,
if (root == NULL)
return NULL;
- if (xenGetDomIdFromSxpr(root, priv->xendConfigVersion, &id) < 0)
+ if (xenGetDomIdFromSxpr(root, &id) < 0)
goto cleanup;
xenUnifiedLock(priv);
if (sexpr_lookup(root, "domain/image/hvm"))
@@ -1579,7 +1579,6 @@ xenDaemonDomainFetch(virConnectPtr conn, int domid, const char
*name,
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(priv);
if (!(def = xenParseSxpr(root,
- priv->xendConfigVersion,
cpus,
tty,
vncport)))
@@ -2056,7 +2055,6 @@ xenDaemonCreateXML(virConnectPtr conn, virDomainDefPtr def)
char *sexpr;
const char *tmp;
struct sexpr *root;
- xenUnifiedPrivatePtr priv = conn->privateData;
if (def->id != -1) {
virReportError(VIR_ERR_OPERATION_INVALID,
@@ -2065,7 +2063,7 @@ xenDaemonCreateXML(virConnectPtr conn, virDomainDefPtr def)
return -1;
}
- if (!(sexpr = xenFormatSxpr(conn, def, priv->xendConfigVersion)))
+ if (!(sexpr = xenFormatSxpr(conn, def)))
return -1;
ret = xenDaemonDomainCreateXML(conn, sexpr);
@@ -2167,7 +2165,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
if (xenFormatSxprDisk(dev->data.disk,
&buf,
def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
- priv->xendConfigVersion, 1) < 0)
+ 1) < 0)
goto cleanup;
if (dev->data.disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM &&
@@ -2180,7 +2178,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr conn,
dev->data.net,
&buf,
def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
- priv->xendConfigVersion, 1) < 0)
+ 1) < 0)
goto cleanup;
char macStr[VIR_MAC_STRING_BUFLEN];
@@ -2303,7 +2301,7 @@ xenDaemonUpdateDeviceFlags(virConnectPtr conn,
if (xenFormatSxprDisk(dev->data.disk,
&buf,
def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0,
- priv->xendConfigVersion, 1) < 0)
+ 1) < 0)
goto cleanup;
break;
@@ -2691,9 +2689,8 @@ xenDaemonDomainDefineXML(virConnectPtr conn, virDomainDefPtr def)
{
int ret = -1;
char *sexpr;
- xenUnifiedPrivatePtr priv = conn->privateData;
- if (!(sexpr = xenFormatSxpr(conn, def, priv->xendConfigVersion))) {
+ if (!(sexpr = xenFormatSxpr(conn, def))) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("failed to build sexpr"));
goto cleanup;
@@ -3107,15 +3104,14 @@ xenDaemonDomainBlockPeek(virConnectPtr conn,
return -1;
}
- if (xenGetDomIdFromSxpr(root, priv->xendConfigVersion, &id) < 0)
+ if (xenGetDomIdFromSxpr(root, &id) < 0)
goto cleanup;
xenUnifiedLock(priv);
tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(priv);
- if (!(def = xenParseSxpr(root, priv->xendConfigVersion, NULL, tty,
- vncport)))
+ if (!(def = xenParseSxpr(root, NULL, tty, vncport)))
goto cleanup;
if (!(actual = virDomainDiskPathByName(def, path))) {
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 085b24a..a0d6f74 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -920,7 +920,7 @@ xenXMDomainCreate(virConnectPtr conn,
if (!(entry = virHashLookup(priv->configCache, filename)))
goto error;
- if (!(sexpr = xenFormatSxpr(conn, entry->def, priv->xendConfigVersion)))
+ if (!(sexpr = xenFormatSxpr(conn, entry->def)))
goto error;
ret = xenDaemonDomainCreateXML(conn, sexpr);
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index defff23..d99bac0 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -42,7 +42,7 @@
VIR_LOG_INIT("xenconfig.xen_sxpr");
/* Get a domain id from a S-expression string */
-int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion, int *id)
+int xenGetDomIdFromSxprString(const char *sexpr, int *id)
{
struct sexpr *root = string2sexpr(sexpr);
int ret;
@@ -52,15 +52,13 @@ int xenGetDomIdFromSxprString(const char *sexpr, int
xendConfigVersion, int *id)
if (!root)
return -1;
- ret = xenGetDomIdFromSxpr(root, xendConfigVersion, id);
+ ret = xenGetDomIdFromSxpr(root, id);
sexpr_free(root);
return ret;
}
/* Get a domain id from a S-expression */
-int xenGetDomIdFromSxpr(const struct sexpr *root,
- int xendConfigVersion ATTRIBUTE_UNUSED,
- int *id)
+int xenGetDomIdFromSxpr(const struct sexpr *root, int *id)
{
const char * tmp = sexpr_node(root, "domain/domid");
@@ -322,7 +320,6 @@ xenParseSxprChar(const char *value,
* @def: the domain config
* @root: root S-expression
* @hvm: true or 1 if node contains HVM S-Expression
- * @xendConfigVersion: version of xend
*
* This parses out block devices from the domain S-expression
*
@@ -331,8 +328,7 @@ xenParseSxprChar(const char *value,
static int
xenParseSxprDisks(virDomainDefPtr def,
const struct sexpr *root,
- int hvm,
- int xendConfigVersion ATTRIBUTE_UNUSED)
+ int hvm)
{
const struct sexpr *cur, *node;
virDomainDiskDefPtr disk = NULL;
@@ -754,7 +750,6 @@ xenParseSxprUSB(virDomainDefPtr def,
* @def: the domain config
* @root: root S-expression
* @hvm: true or 1 if root contains HVM S-Expression
- * @xendConfigVersion: version of xend
* @vncport: VNC port number
*
* This parses out VNC devices from the domain S-expression
@@ -765,7 +760,6 @@ static int
xenParseSxprGraphicsOld(virDomainDefPtr def,
const struct sexpr *root,
int hvm,
- int xendConfigVersion ATTRIBUTE_UNUSED,
int vncport)
{
const char *tmp;
@@ -1059,7 +1053,6 @@ xenParseSxprPCI(virDomainDefPtr def,
/**
* xenParseSxpr:
* @root: the root of the parsed S-Expression
- * @xendConfigVersion: version of xend
* @cpus: set of cpus the domain may be pinned to
* @tty: the console pty path
* @vncport: VNC port number
@@ -1072,7 +1065,6 @@ xenParseSxprPCI(virDomainDefPtr def,
*/
virDomainDefPtr
xenParseSxpr(const struct sexpr *root,
- int xendConfigVersion,
const char *cpus, char *tty, int vncport)
{
const char *tmp;
@@ -1271,7 +1263,7 @@ xenParseSxpr(const struct sexpr *root,
goto error;
/* append block devices */
- if (xenParseSxprDisks(def, root, hvm, xendConfigVersion) < 0)
+ if (xenParseSxprDisks(def, root, hvm) < 0)
goto error;
if (xenParseSxprNets(def, root) < 0)
@@ -1286,8 +1278,7 @@ xenParseSxpr(const struct sexpr *root,
/* Graphics device (HVM <= 3.0.4, or PV <= 3.0.3) vnc config */
if ((def->ngraphics == 0) &&
- xenParseSxprGraphicsOld(def, root, hvm, xendConfigVersion,
- vncport) < 0)
+ xenParseSxprGraphicsOld(def, root, hvm, vncport) < 0)
goto error;
/* in case of HVM we have USB device emulation */
@@ -1392,7 +1383,6 @@ xenParseSxpr(const struct sexpr *root,
/**
* xenParseSxprString:
* @sexpr: the root of the parsed S-Expression
- * @xendConfigVersion: version of xend
* @tty: the console pty path
* @vncport: VNC port number
*
@@ -1404,7 +1394,6 @@ xenParseSxpr(const struct sexpr *root,
*/
virDomainDefPtr
xenParseSxprString(const char *sexpr,
- int xendConfigVersion,
char *tty,
int vncport,
virCapsPtr caps,
@@ -1416,7 +1405,7 @@ xenParseSxprString(const char *sexpr,
if (!root)
return NULL;
- if (!(def = xenParseSxpr(root, xendConfigVersion, NULL, tty, vncport)))
+ if (!(def = xenParseSxpr(root, NULL, tty, vncport)))
goto cleanup;
if (virDomainDefPostParse(def, caps, VIR_DOMAIN_DEF_PARSE_ABI_UPDATE,
@@ -1499,7 +1488,6 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def,
* xenFormatSxprGraphicsOld:
* @def: the domain config
* @buf: a buffer for the result S-expression
- * @xendConfigVersion: version of xend
*
* Convert the graphics part of the domain description into a S-expression
* in buf. (HVM <= 3.0.4 or PV <= 3.0.3)
@@ -1507,9 +1495,7 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def,
* Returns 0 in case of success, -1 in case of error
*/
static int
-xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
- virBufferPtr buf,
- int xendConfigVersion ATTRIBUTE_UNUSED)
+xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf)
{
const char *listenAddr;
@@ -1639,7 +1625,6 @@ xenFormatSxprChr(virDomainChrDefPtr def,
* @node: node containing the disk description
* @buf: a buffer for the result S-expression
* @hvm: true or 1 if domain is HVM
- * @xendConfigVersion: xend configuration file format
* @isAttach: create expression for device attach (1).
*
* Convert the disk device part of the domain config into a S-expresssion in buf.
@@ -1650,7 +1635,6 @@ int
xenFormatSxprDisk(virDomainDiskDefPtr def,
virBufferPtr buf,
int hvm,
- int xendConfigVersion ATTRIBUTE_UNUSED,
int isAttach)
{
const char *src = virDomainDiskGetSource(def);
@@ -1758,7 +1742,6 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
* @def: the domain config
* @buf: a buffer for the result S-expression
* @hvm: true or 1 if domain is HVM
- * @xendConfigVersion: xend configuration file format
* @isAttach: create expression for device attach (1).
*
* Convert the interface description of the domain config into a S-expression in buf.
@@ -1773,7 +1756,6 @@ xenFormatSxprNet(virConnectPtr conn,
virDomainNetDefPtr def,
virBufferPtr buf,
int hvm,
- int xendConfigVersion ATTRIBUTE_UNUSED,
int isAttach)
{
const char *script = DEFAULT_VIF_SCRIPT;
@@ -2093,7 +2075,6 @@ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
* xenFormatSxpr:
* @conn: pointer to the hypervisor connection
* @def: domain config definition
- * @xendConfigVersion: xend configuration file format
*
* Generate an S-expression representing the domain configuration.
*
@@ -2101,9 +2082,7 @@ verify(MAX_VIRT_CPUS <= sizeof(1UL) * CHAR_BIT);
* the caller must free() the returned value.
*/
char *
-xenFormatSxpr(virConnectPtr conn,
- virDomainDefPtr def,
- int xendConfigVersion)
+xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -2324,8 +2303,7 @@ xenFormatSxpr(virConnectPtr conn,
/* PV graphics for xen <= 3.0.4, or HVM graphics */
if (hvm) {
if ((def->ngraphics == 1) &&
- xenFormatSxprGraphicsOld(def->graphics[0],
- &buf, xendConfigVersion) < 0)
+ xenFormatSxprGraphicsOld(def->graphics[0], &buf) < 0)
goto error;
}
} else {
@@ -2405,13 +2383,11 @@ xenFormatSxpr(virConnectPtr conn,
for (i = 0; i < def->ndisks; i++)
- if (xenFormatSxprDisk(def->disks[i],
- &buf, hvm, xendConfigVersion, 0) < 0)
+ if (xenFormatSxprDisk(def->disks[i], &buf, hvm, 0) < 0)
goto error;
for (i = 0; i < def->nnets; i++)
- if (xenFormatSxprNet(conn, def->nets[i],
- &buf, hvm, xendConfigVersion, 0) < 0)
+ if (xenFormatSxprNet(conn, def->nets[i], &buf, hvm, 0) < 0)
goto error;
if (xenFormatSxprAllPCI(def, &buf) < 0)
diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h
index e42a931..a4f4c44 100644
--- a/src/xenconfig/xen_sxpr.h
+++ b/src/xenconfig/xen_sxpr.h
@@ -32,25 +32,17 @@
# include "domain_conf.h"
# include "virsexpr.h"
-typedef enum {
- XEND_CONFIG_VERSION_3_0_2 = 1,
- XEND_CONFIG_VERSION_3_0_3 = 2,
- XEND_CONFIG_VERSION_3_0_4 = 3,
- XEND_CONFIG_VERSION_3_1_0 = 4,
-} xenConfigVersionEnum;
-
/* helper functions to get the dom id from a sexpr */
-int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion, int *id);
-int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion, int *id);
+int xenGetDomIdFromSxprString(const char *sexpr, int *id);
+int xenGetDomIdFromSxpr(const struct sexpr *root, int *id);
virDomainDefPtr xenParseSxprString(const char *sexpr,
- int xendConfigVersion,
char *tty,
int vncport,
virCapsPtr caps,
virDomainXMLOptionPtr xmlopt);
-virDomainDefPtr xenParseSxpr(const struct sexpr *root, int xendConfigVersion,
+virDomainDefPtr xenParseSxpr(const struct sexpr *root,
const char *cpus, char *tty, int vncport);
int xenParseSxprSound(virDomainDefPtr def, const char *str);
@@ -58,11 +50,11 @@ int xenParseSxprSound(virDomainDefPtr def, const char *str);
virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty);
int xenFormatSxprDisk(virDomainDiskDefPtr def, virBufferPtr buf, int hvm,
- int xendConfigVersion, int isAttach);
+ int isAttach);
int xenFormatSxprNet(virConnectPtr conn,
virDomainNetDefPtr def, virBufferPtr buf, int hvm,
- int xendConfigVersion, int isAttach);
+ int isAttach);
int xenFormatSxprOnePCI(virDomainHostdevDefPtr def, virBufferPtr buf,
int detach);
@@ -70,7 +62,6 @@ int xenFormatSxprOnePCI(virDomainHostdevDefPtr def, virBufferPtr buf,
int xenFormatSxprChr(virDomainChrDefPtr def, virBufferPtr buf);
int xenFormatSxprSound(virDomainDefPtr def, virBufferPtr buf);
-char * xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def,
- int xendConfigVersion);
+char * xenFormatSxpr(virConnectPtr conn, virDomainDefPtr def);
#endif /* __VIR_XEN_SXPR_H__ */
diff --git a/src/xenconfig/xenxs_private.h b/src/xenconfig/xenxs_private.h
index 293e986..4f529d6 100644
--- a/src/xenconfig/xenxs_private.h
+++ b/src/xenconfig/xenxs_private.h
@@ -38,14 +38,6 @@
# define MAX_VIRT_CPUS XEN_LEGACY_MAX_VCPUS
# endif
-# ifdef WITH_RHEL5_API
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_3
-# else
-# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU XEND_CONFIG_VERSION_3_0_4
-# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF XEND_CONFIG_VERSION_3_0_4
-# endif
-
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
# ifdef __sun
diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c
index 1b42a18..26fadaa 100644
--- a/tests/sexpr2xmltest.c
+++ b/tests/sexpr2xmltest.c
@@ -41,20 +41,19 @@ testCompareFiles(const char *xml, const char *sexpr)
memset(&priv, 0, sizeof(priv));
/* Many puppies died to bring you this code. */
- priv.xendConfigVersion = 4;
priv.caps = caps;
conn->privateData = &priv;
if (virMutexInit(&priv.lock) < 0)
goto fail;
- if (xenGetDomIdFromSxprString(sexprData, 4, &id) < 0)
+ if (xenGetDomIdFromSxprString(sexprData, &id) < 0)
goto fail;
xenUnifiedLock(&priv);
tty = xenStoreDomainGetConsolePath(conn, id);
vncport = xenStoreDomainGetVNCPort(conn, id);
xenUnifiedUnlock(&priv);
- if (!(def = xenParseSxprString(sexprData, 4,
+ if (!(def = xenParseSxprString(sexprData,
tty, vncport, caps, xmlopt)))
goto fail;
diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c
index 43a6775..c2084c2 100644
--- a/tests/xmconfigtest.c
+++ b/tests/xmconfigtest.c
@@ -60,7 +60,6 @@ testCompareParseXML(const char *xmcfg, const char *xml)
if (!conn) goto fail;
/* Many puppies died to bring you this code. */
- priv.xendConfigVersion = 4;
priv.caps = caps;
conn->privateData = &priv;
@@ -113,7 +112,6 @@ testCompareFormatXML(const char *xmcfg, const char *xml)
goto fail;
/* Many puppies died to bring you this code. */
- priv.xendConfigVersion = 4;
priv.caps = caps;
conn->privateData = &priv;
diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c
index 246fae0..b1b0cde 100644
--- a/tests/xml2sexprtest.c
+++ b/tests/xml2sexprtest.c
@@ -36,7 +36,7 @@ testCompareFiles(const char *xml, const char *sexpr)
goto fail;
}
- if (!(gotsexpr = xenFormatSxpr(NULL, def, 4)))
+ if (!(gotsexpr = xenFormatSxpr(NULL, def)))
goto fail;
if (virtTestCompareToFile(gotsexpr, sexpr) < 0)
--
2.1.4