mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
Xen: xenconfig: remove use of XEND_CONFIG_VERSION in xen_sxpr
Remove use of XEND_CONFIG_VERSION_* in s-expression parser/formatter. Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
f2b4a65728
commit
5ff2e370af
@ -58,17 +58,14 @@ int xenGetDomIdFromSxprString(const char *sexpr, int xendConfigVersion, int *id)
|
||||
}
|
||||
|
||||
/* Get a domain id from a S-expression */
|
||||
int xenGetDomIdFromSxpr(const struct sexpr *root, int xendConfigVersion, int *id)
|
||||
int xenGetDomIdFromSxpr(const struct sexpr *root,
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED,
|
||||
int *id)
|
||||
{
|
||||
const char * tmp = sexpr_node(root, "domain/domid");
|
||||
if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("domain information incomplete, missing id"));
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
*id = tmp ? sexpr_int(root, "domain/domid") : -1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
@ -335,7 +332,7 @@ static int
|
||||
xenParseSxprDisks(virDomainDefPtr def,
|
||||
const struct sexpr *root,
|
||||
int hvm,
|
||||
int xendConfigVersion)
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED)
|
||||
{
|
||||
const struct sexpr *cur, *node;
|
||||
virDomainDiskDefPtr disk = NULL;
|
||||
@ -466,8 +463,6 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||
dst += 6;
|
||||
|
||||
disk->device = VIR_DOMAIN_DISK_DEVICE_DISK;
|
||||
/* New style disk config from Xen >= 3.0.3 */
|
||||
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
|
||||
offset = strrchr(dst, ':');
|
||||
if (offset) {
|
||||
if (STREQ(offset, ":cdrom")) {
|
||||
@ -479,7 +474,6 @@ xenParseSxprDisks(virDomainDefPtr def,
|
||||
}
|
||||
offset[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (VIR_STRDUP(disk->dst, dst) < 0)
|
||||
goto error;
|
||||
@ -771,7 +765,8 @@ static int
|
||||
xenParseSxprGraphicsOld(virDomainDefPtr def,
|
||||
const struct sexpr *root,
|
||||
int hvm,
|
||||
int xendConfigVersion, int vncport)
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED,
|
||||
int vncport)
|
||||
{
|
||||
const char *tmp;
|
||||
virDomainGraphicsDefPtr graphics = NULL;
|
||||
@ -791,15 +786,6 @@ xenParseSxprGraphicsOld(virDomainDefPtr def,
|
||||
goto error;
|
||||
|
||||
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
|
||||
/* For Xen >= 3.0.3, don't generate a fixed port mapping
|
||||
* because it will almost certainly be wrong ! Just leave
|
||||
* it as -1 which lets caller see that the VNC server isn't
|
||||
* present yet. Subsequent dumps of the XML will eventually
|
||||
* find the port in XenStore once VNC server has started
|
||||
*/
|
||||
if (port == -1 && xendConfigVersion < XEND_CONFIG_VERSION_3_0_3)
|
||||
port = 5900 + def->id;
|
||||
|
||||
if ((unused && STREQ(unused, "1")) || port == -1)
|
||||
graphics->data.vnc.autoport = true;
|
||||
graphics->data.vnc.port = port;
|
||||
@ -1098,11 +1084,6 @@ xenParseSxpr(const struct sexpr *root,
|
||||
goto error;
|
||||
|
||||
tmp = sexpr_node(root, "domain/domid");
|
||||
if (tmp == NULL && xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) { /* domid was mandatory */
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("domain information incomplete, missing id"));
|
||||
goto error;
|
||||
}
|
||||
def->virtType = VIR_DOMAIN_VIRT_XEN;
|
||||
if (tmp)
|
||||
def->id = sexpr_int(root, "domain/domid");
|
||||
@ -1234,6 +1215,8 @@ xenParseSxpr(const struct sexpr *root,
|
||||
vmlocaltime = sexpr_int(root, "domain/localtime");
|
||||
if (hvm) {
|
||||
const char *value = sexpr_node(root, "domain/image/hvm/localtime");
|
||||
int rtc_offset;
|
||||
|
||||
if (value) {
|
||||
if (virStrToLong_i(value, NULL, 0, &vmlocaltime) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
@ -1241,22 +1224,12 @@ xenParseSxpr(const struct sexpr *root,
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
/* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
|
||||
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
|
||||
if (vmlocaltime)
|
||||
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
|
||||
else
|
||||
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
|
||||
def->clock.data.utc_reset = true;
|
||||
} else {
|
||||
int rtc_offset;
|
||||
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
|
||||
rtc_offset = sexpr_int(root, "domain/image/hvm/rtc_timeoffset");
|
||||
def->clock.data.variable.adjustment = rtc_offset;
|
||||
def->clock.data.variable.basis = vmlocaltime ?
|
||||
VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
|
||||
VIR_DOMAIN_CLOCK_BASIS_UTC;
|
||||
}
|
||||
|
||||
if (sexpr_lookup(root, "domain/image/hvm/hpet")) {
|
||||
virDomainTimerDefPtr timer;
|
||||
@ -1536,7 +1509,7 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def,
|
||||
static int
|
||||
xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
|
||||
virBufferPtr buf,
|
||||
int xendConfigVersion)
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED)
|
||||
{
|
||||
const char *listenAddr;
|
||||
|
||||
@ -1556,7 +1529,6 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
|
||||
virBufferAsprintf(buf, "(xauthority '%s')", def->data.sdl.xauth);
|
||||
} else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
||||
virBufferAddLit(buf, "(vnc 1)");
|
||||
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_3) {
|
||||
if (def->data.vnc.autoport) {
|
||||
virBufferAddLit(buf, "(vncunused 1)");
|
||||
} else {
|
||||
@ -1571,8 +1543,6 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def,
|
||||
virBufferAsprintf(buf, "(vncpasswd '%s')", def->data.vnc.auth.passwd);
|
||||
if (def->data.vnc.keymap)
|
||||
virBufferAsprintf(buf, "(keymap '%s')", def->data.vnc.keymap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1680,7 +1650,7 @@ int
|
||||
xenFormatSxprDisk(virDomainDiskDefPtr def,
|
||||
virBufferPtr buf,
|
||||
int hvm,
|
||||
int xendConfigVersion,
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED,
|
||||
int isAttach)
|
||||
{
|
||||
const char *src = virDomainDiskGetSource(def);
|
||||
@ -1699,18 +1669,6 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Xend <= 3.0.2 doesn't include cdrom config here */
|
||||
if (hvm &&
|
||||
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
|
||||
xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
|
||||
if (isAttach) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("Cannot directly attach CDROM %s"), src);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!isAttach)
|
||||
virBufferAddLit(buf, "(device ");
|
||||
|
||||
@ -1726,16 +1684,10 @@ xenFormatSxprDisk(virDomainDiskDefPtr def,
|
||||
}
|
||||
|
||||
if (hvm) {
|
||||
/* Xend <= 3.0.2 wants a ioemu: prefix on devices for HVM */
|
||||
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
|
||||
virBufferEscapeSexpr(buf, "(dev 'ioemu:%s')", def->dst);
|
||||
} else {
|
||||
/* But newer does not */
|
||||
virBufferEscapeSexpr(buf, "(dev '%s:", def->dst);
|
||||
virBufferAsprintf(buf, "%s')",
|
||||
def->device == VIR_DOMAIN_DISK_DEVICE_CDROM ?
|
||||
"cdrom" : "disk");
|
||||
}
|
||||
} else if (def->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
||||
virBufferEscapeSexpr(buf, "(dev '%s:cdrom')", def->dst);
|
||||
} else {
|
||||
@ -1821,7 +1773,7 @@ xenFormatSxprNet(virConnectPtr conn,
|
||||
virDomainNetDefPtr def,
|
||||
virBufferPtr buf,
|
||||
int hvm,
|
||||
int xendConfigVersion,
|
||||
int xendConfigVersion ATTRIBUTE_UNUSED,
|
||||
int isAttach)
|
||||
{
|
||||
const char *script = DEFAULT_VIF_SCRIPT;
|
||||
@ -1935,12 +1887,6 @@ xenFormatSxprNet(virConnectPtr conn,
|
||||
} else {
|
||||
if (def->model != NULL)
|
||||
virBufferEscapeSexpr(buf, "(model '%s')", def->model);
|
||||
/*
|
||||
* apparently (type ioemu) breaks paravirt drivers on HVM so skip
|
||||
* this from XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU
|
||||
*/
|
||||
if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU)
|
||||
virBufferAddLit(buf, "(type ioemu)");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2362,7 +2308,7 @@ xenFormatSxpr(virConnectPtr conn,
|
||||
} /* hvm */
|
||||
|
||||
/* get the device emulation model */
|
||||
if (def->emulator && (hvm || xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4))
|
||||
if (def->emulator && hvm)
|
||||
virBufferEscapeSexpr(&buf, "(device_model '%s')", def->emulator);
|
||||
|
||||
/* look for HPET in order to override the hypervisor/xend default */
|
||||
@ -2376,7 +2322,7 @@ xenFormatSxpr(virConnectPtr conn,
|
||||
}
|
||||
|
||||
/* PV graphics for xen <= 3.0.4, or HVM graphics */
|
||||
if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
|
||||
if (hvm) {
|
||||
if ((def->ngraphics == 1) &&
|
||||
xenFormatSxprGraphicsOld(def->graphics[0],
|
||||
&buf, xendConfigVersion) < 0)
|
||||
@ -2390,23 +2336,6 @@ xenFormatSxpr(virConnectPtr conn,
|
||||
}
|
||||
} /* os.bootloader */
|
||||
|
||||
|
||||
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
|
||||
/* <3.1: UTC and LOCALTIME */
|
||||
switch (def->clock.offset) {
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
|
||||
vmlocaltime = 0;
|
||||
break;
|
||||
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
|
||||
vmlocaltime = 1;
|
||||
break;
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unsupported clock offset='%s'"),
|
||||
virDomainClockOffsetTypeToString(def->clock.offset));
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (!in_image) {
|
||||
if (hvm)
|
||||
virBufferAddLit(&buf, "(image (hvm ");
|
||||
@ -2465,7 +2394,7 @@ xenFormatSxpr(virConnectPtr conn,
|
||||
} /* !hvm */
|
||||
/* default post-XenD-3.1 location: */
|
||||
virBufferAsprintf(&buf, "(localtime %d)", vmlocaltime);
|
||||
}
|
||||
|
||||
if (in_image) {
|
||||
/* closes (image(hvm|linux */
|
||||
virBufferAddLit(&buf, "))");
|
||||
@ -2489,7 +2418,7 @@ xenFormatSxpr(virConnectPtr conn,
|
||||
goto error;
|
||||
|
||||
/* New style PV graphics config xen >= 3.0.4 */
|
||||
if (!hvm && (xendConfigVersion >= XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
|
||||
if (!hvm) {
|
||||
if ((def->ngraphics == 1) &&
|
||||
xenFormatSxprGraphicsNew(def->graphics[0], &buf) < 0)
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user