提交 4796d7b3 编写于 作者: J Jim Fehlig

Xen: xenconfig: remove XEND_CONFIG_VERSION in common code

Remove use of XEND_CONFIG_VERSION_* from xenconfig/xen_common.c
Signed-off-by: NJim Fehlig <jfehlig@suse.com>
上级 9e6d7219
......@@ -323,8 +323,7 @@ xenParseMem(virConfPtr conf, virDomainDefPtr def)
static int
xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def,
int xendConfigVersion)
xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def)
{
int vmlocaltime;
......@@ -332,24 +331,15 @@ xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def,
return -1;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
/* 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 {
unsigned long rtc_timeoffset;
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
if (xenConfigGetULong(conf, "rtc_timeoffset", &rtc_timeoffset, 0) < 0)
return -1;
unsigned long rtc_timeoffset;
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
if (xenConfigGetULong(conf, "rtc_timeoffset", &rtc_timeoffset, 0) < 0)
return -1;
def->clock.data.variable.adjustment = (int)rtc_timeoffset;
def->clock.data.variable.basis = vmlocaltime ?
VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
VIR_DOMAIN_CLOCK_BASIS_UTC;
}
def->clock.data.variable.adjustment = (int)rtc_timeoffset;
def->clock.data.variable.basis = vmlocaltime ?
VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
VIR_DOMAIN_CLOCK_BASIS_UTC;
} else {
/* PV domains do not have an emulated RTC and the offset is fixed. */
def->clock.offset = vmlocaltime ?
......@@ -573,7 +563,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
#define MAX_VFB 1024
static int
xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
xenParseVfb(virConfPtr conf, virDomainDefPtr def)
{
int val;
char *listenAddr = NULL;
......@@ -581,7 +571,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
virConfValuePtr list;
virDomainGraphicsDefPtr graphics = NULL;
if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
if (hvm) {
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
goto cleanup;
if (val) {
......@@ -1028,7 +1018,7 @@ int
xenParseConfigCommon(virConfPtr conf,
virDomainDefPtr def,
virCapsPtr caps,
int xendConfigVersion)
int xendConfigVersion ATTRIBUTE_UNUSED)
{
if (xenParseGeneralMeta(conf, def, caps) < 0)
return -1;
......@@ -1042,7 +1032,7 @@ xenParseConfigCommon(virConfPtr conf,
if (xenParseCPUFeatures(conf, def) < 0)
return -1;
if (xenParseTimeOffset(conf, def, xendConfigVersion) < 0)
if (xenParseTimeOffset(conf, def) < 0)
return -1;
if (xenConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
......@@ -1057,7 +1047,7 @@ xenParseConfigCommon(virConfPtr conf,
if (xenParseEmulatedDevices(conf, def) < 0)
return -1;
if (xenParseVfb(conf, def, xendConfigVersion) < 0)
if (xenParseVfb(conf, def) < 0)
return -1;
if (xenParseCharDev(conf, def) < 0)
......@@ -1109,7 +1099,7 @@ static int
xenFormatNet(virConnectPtr conn,
virConfValuePtr list,
virDomainNetDefPtr net,
int hvm, int xendConfigVersion)
int hvm)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
virConfValuePtr val, tmp;
......@@ -1185,13 +1175,6 @@ xenFormatNet(virConnectPtr conn,
} else {
if (net->model != NULL)
virBufferAsprintf(&buf, ",model=%s", net->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");
}
}
......@@ -1322,18 +1305,36 @@ xenFormatMem(virConfPtr conf, virDomainDefPtr def)
static int
xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def)
{
int vmlocaltime;
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
/* <3.1: UTC and LOCALTIME */
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
/* >=3.1 HV: VARIABLE */
int rtc_timeoffset;
switch (def->clock.offset) {
case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
vmlocaltime = (int)def->clock.data.variable.basis;
rtc_timeoffset = def->clock.data.variable.adjustment;
break;
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
if (def->clock.data.utc_reset) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
return -1;
}
vmlocaltime = 0;
rtc_timeoffset = 0;
break;
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
if (def->clock.data.utc_reset) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
return -1;
}
vmlocaltime = 1;
rtc_timeoffset = 0;
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
......@@ -1341,61 +1342,24 @@ xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
virDomainClockOffsetTypeToString(def->clock.offset));
return -1;
}
if (xenConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0)
return -1;
} else {
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
/* >=3.1 HV: VARIABLE */
int rtc_timeoffset;
switch (def->clock.offset) {
case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
vmlocaltime = (int)def->clock.data.variable.basis;
rtc_timeoffset = def->clock.data.variable.adjustment;
break;
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
if (def->clock.data.utc_reset) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
return -1;
}
vmlocaltime = 0;
rtc_timeoffset = 0;
break;
case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
if (def->clock.data.utc_reset) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unsupported clock adjustment='reset'"));
return -1;
}
vmlocaltime = 1;
rtc_timeoffset = 0;
break;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported clock offset='%s'"),
virDomainClockOffsetTypeToString(def->clock.offset));
return -1;
}
if (xenConfigSetInt(conf, "rtc_timeoffset", rtc_timeoffset) < 0)
return -1;
} else {
/* >=3.1 PV: 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));
return -1;
}
} /* !hvm */
}
/* PV: 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));
return -1;
}
} /* !hvm */
if (xenConfigSetInt(conf, "localtime", vmlocaltime) < 0)
return -1;
......@@ -1559,7 +1523,7 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr def)
static int
xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def)
{
size_t i;
......@@ -1579,17 +1543,15 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
return -1;
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) {
if (xenConfigSetInt(conf, "hap",
(def->features[VIR_DOMAIN_FEATURE_HAP] ==
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
return -1;
if (xenConfigSetInt(conf, "hap",
(def->features[VIR_DOMAIN_FEATURE_HAP] ==
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
return -1;
if (xenConfigSetInt(conf, "viridian",
(def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] ==
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
return -1;
}
if (xenConfigSetInt(conf, "viridian",
(def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] ==
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
return -1;
for (i = 0; i < def->clock.ntimers; i++) {
if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET &&
......@@ -1615,38 +1577,13 @@ xenFormatEmulator(virConfPtr conf, virDomainDefPtr def)
static int
xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
{
size_t i;
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
def->disks[i]->dst &&
STREQ(def->disks[i]->dst, "hdc") &&
virDomainDiskGetSource(def->disks[i])) {
if (xenConfigSetString(conf, "cdrom",
virDomainDiskGetSource(def->disks[i])) < 0)
return -1;
break;
}
}
}
}
return 0;
}
static int
xenFormatVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
{
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0;
if (def->ngraphics == 1 &&
def->graphics[0]->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
if (hvm || (xendConfigVersion < XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
if (hvm) {
if (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
if (xenConfigSetInt(conf, "sdl", 1) < 0)
return -1;
......@@ -1785,8 +1722,7 @@ xenFormatSound(virConfPtr conf, virDomainDefPtr def)
static int
xenFormatVif(virConfPtr conf,
virConnectPtr conn,
virDomainDefPtr def,
int xendConfigVersion)
virDomainDefPtr def)
{
virConfValuePtr netVal = NULL;
size_t i;
......@@ -1799,7 +1735,7 @@ xenFormatVif(virConfPtr conf,
for (i = 0; i < def->nnets; i++) {
if (xenFormatNet(conn, netVal, def->nets[i],
hvm, xendConfigVersion) < 0)
hvm) < 0)
goto cleanup;
}
......@@ -1826,7 +1762,7 @@ int
xenFormatConfigCommon(virConfPtr conf,
virDomainDefPtr def,
virConnectPtr conn,
int xendConfigVersion)
int xendConfigVersion ATTRIBUTE_UNUSED)
{
if (xenFormatGeneralMeta(conf, def) < 0)
return -1;
......@@ -1837,13 +1773,10 @@ xenFormatConfigCommon(virConfPtr conf,
if (xenFormatCPUAllocation(conf, def) < 0)
return -1;
if (xenFormatCPUFeatures(conf, def, xendConfigVersion) < 0)
return -1;
if (xenFormatCDROM(conf, def, xendConfigVersion) < 0)
if (xenFormatCPUFeatures(conf, def) < 0)
return -1;
if (xenFormatTimeOffset(conf, def, xendConfigVersion) < 0)
if (xenFormatTimeOffset(conf, def) < 0)
return -1;
if (xenFormatEventActions(conf, def) < 0)
......@@ -1852,10 +1785,10 @@ xenFormatConfigCommon(virConfPtr conf,
if (xenFormatEmulator(conf, def) < 0)
return -1;
if (xenFormatVfb(conf, def, xendConfigVersion) < 0)
if (xenFormatVfb(conf, def) < 0)
return -1;
if (xenFormatVif(conf, conn, def, xendConfigVersion) < 0)
if (xenFormatVif(conf, conn, def) < 0)
return -1;
if (xenFormatPCI(conf, def) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册