mirror of https://gitee.com/openkylin/libvirt.git
Xen: xenconfig: remove XEND_CONFIG_VERSION in common code
Remove use of XEND_CONFIG_VERSION_* from xenconfig/xen_common.c Signed-off-by: Jim Fehlig <jfehlig@suse.com>
This commit is contained in:
parent
9e6d721985
commit
4796d7b34b
|
@ -323,8 +323,7 @@ xenParseMem(virConfPtr conf, virDomainDefPtr def)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def,
|
xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def)
|
||||||
int xendConfigVersion)
|
|
||||||
{
|
{
|
||||||
int vmlocaltime;
|
int vmlocaltime;
|
||||||
|
|
||||||
|
@ -332,24 +331,15 @@ xenParseTimeOffset(virConfPtr conf, virDomainDefPtr def,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||||
/* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset */
|
unsigned long rtc_timeoffset;
|
||||||
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
|
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
|
||||||
if (vmlocaltime)
|
if (xenConfigGetULong(conf, "rtc_timeoffset", &rtc_timeoffset, 0) < 0)
|
||||||
def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
|
return -1;
|
||||||
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;
|
|
||||||
|
|
||||||
def->clock.data.variable.adjustment = (int)rtc_timeoffset;
|
def->clock.data.variable.adjustment = (int)rtc_timeoffset;
|
||||||
def->clock.data.variable.basis = vmlocaltime ?
|
def->clock.data.variable.basis = vmlocaltime ?
|
||||||
VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
|
VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
|
||||||
VIR_DOMAIN_CLOCK_BASIS_UTC;
|
VIR_DOMAIN_CLOCK_BASIS_UTC;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* PV domains do not have an emulated RTC and the offset is fixed. */
|
/* PV domains do not have an emulated RTC and the offset is fixed. */
|
||||||
def->clock.offset = vmlocaltime ?
|
def->clock.offset = vmlocaltime ?
|
||||||
|
@ -573,7 +563,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
|
||||||
#define MAX_VFB 1024
|
#define MAX_VFB 1024
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
xenParseVfb(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
char *listenAddr = NULL;
|
char *listenAddr = NULL;
|
||||||
|
@ -581,7 +571,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
||||||
virConfValuePtr list;
|
virConfValuePtr list;
|
||||||
virDomainGraphicsDefPtr graphics = NULL;
|
virDomainGraphicsDefPtr graphics = NULL;
|
||||||
|
|
||||||
if (hvm || xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
|
if (hvm) {
|
||||||
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
|
if (xenConfigGetBool(conf, "vnc", &val, 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (val) {
|
if (val) {
|
||||||
|
@ -1028,7 +1018,7 @@ int
|
||||||
xenParseConfigCommon(virConfPtr conf,
|
xenParseConfigCommon(virConfPtr conf,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
virCapsPtr caps,
|
virCapsPtr caps,
|
||||||
int xendConfigVersion)
|
int xendConfigVersion ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (xenParseGeneralMeta(conf, def, caps) < 0)
|
if (xenParseGeneralMeta(conf, def, caps) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1042,7 +1032,7 @@ xenParseConfigCommon(virConfPtr conf,
|
||||||
if (xenParseCPUFeatures(conf, def) < 0)
|
if (xenParseCPUFeatures(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenParseTimeOffset(conf, def, xendConfigVersion) < 0)
|
if (xenParseTimeOffset(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
|
if (xenConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
|
||||||
|
@ -1057,7 +1047,7 @@ xenParseConfigCommon(virConfPtr conf,
|
||||||
if (xenParseEmulatedDevices(conf, def) < 0)
|
if (xenParseEmulatedDevices(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenParseVfb(conf, def, xendConfigVersion) < 0)
|
if (xenParseVfb(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenParseCharDev(conf, def) < 0)
|
if (xenParseCharDev(conf, def) < 0)
|
||||||
|
@ -1109,7 +1099,7 @@ static int
|
||||||
xenFormatNet(virConnectPtr conn,
|
xenFormatNet(virConnectPtr conn,
|
||||||
virConfValuePtr list,
|
virConfValuePtr list,
|
||||||
virDomainNetDefPtr net,
|
virDomainNetDefPtr net,
|
||||||
int hvm, int xendConfigVersion)
|
int hvm)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
virConfValuePtr val, tmp;
|
virConfValuePtr val, tmp;
|
||||||
|
@ -1185,13 +1175,6 @@ xenFormatNet(virConnectPtr conn,
|
||||||
} else {
|
} else {
|
||||||
if (net->model != NULL)
|
if (net->model != NULL)
|
||||||
virBufferAsprintf(&buf, ",model=%s", net->model);
|
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,12 +1305,47 @@ xenFormatMem(virConfPtr conf, virDomainDefPtr def)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
int vmlocaltime;
|
int vmlocaltime;
|
||||||
|
|
||||||
if (xendConfigVersion < XEND_CONFIG_VERSION_3_1_0) {
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||||
/* <3.1: UTC and LOCALTIME */
|
/* >=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 {
|
||||||
|
/* PV: UTC and LOCALTIME */
|
||||||
switch (def->clock.offset) {
|
switch (def->clock.offset) {
|
||||||
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
|
case VIR_DOMAIN_CLOCK_OFFSET_UTC:
|
||||||
vmlocaltime = 0;
|
vmlocaltime = 0;
|
||||||
|
@ -1341,61 +1359,7 @@ xenFormatTimeOffset(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
||||||
virDomainClockOffsetTypeToString(def->clock.offset));
|
virDomainClockOffsetTypeToString(def->clock.offset));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} /* !hvm */
|
||||||
} 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 */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (xenConfigSetInt(conf, "localtime", vmlocaltime) < 0)
|
if (xenConfigSetInt(conf, "localtime", vmlocaltime) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1559,7 +1523,7 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr def)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
@ -1579,17 +1543,15 @@ xenFormatCPUFeatures(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion
|
||||||
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xendConfigVersion >= XEND_CONFIG_VERSION_3_0_4) {
|
if (xenConfigSetInt(conf, "hap",
|
||||||
if (xenConfigSetInt(conf, "hap",
|
(def->features[VIR_DOMAIN_FEATURE_HAP] ==
|
||||||
(def->features[VIR_DOMAIN_FEATURE_HAP] ==
|
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
||||||
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (xenConfigSetInt(conf, "viridian",
|
if (xenConfigSetInt(conf, "viridian",
|
||||||
(def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] ==
|
(def->features[VIR_DOMAIN_FEATURE_VIRIDIAN] ==
|
||||||
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
VIR_TRISTATE_SWITCH_ON) ? 1 : 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < def->clock.ntimers; i++) {
|
for (i = 0; i < def->clock.ntimers; i++) {
|
||||||
if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET &&
|
if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET &&
|
||||||
|
@ -1615,38 +1577,13 @@ xenFormatEmulator(virConfPtr conf, virDomainDefPtr def)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
xenFormatCDROM(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion)
|
xenFormatVfb(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0;
|
int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM ? 1 : 0;
|
||||||
|
|
||||||
if (def->ngraphics == 1 &&
|
if (def->ngraphics == 1 &&
|
||||||
def->graphics[0]->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
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 (def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
|
||||||
if (xenConfigSetInt(conf, "sdl", 1) < 0)
|
if (xenConfigSetInt(conf, "sdl", 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1785,8 +1722,7 @@ xenFormatSound(virConfPtr conf, virDomainDefPtr def)
|
||||||
static int
|
static int
|
||||||
xenFormatVif(virConfPtr conf,
|
xenFormatVif(virConfPtr conf,
|
||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def)
|
||||||
int xendConfigVersion)
|
|
||||||
{
|
{
|
||||||
virConfValuePtr netVal = NULL;
|
virConfValuePtr netVal = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
@ -1799,7 +1735,7 @@ xenFormatVif(virConfPtr conf,
|
||||||
|
|
||||||
for (i = 0; i < def->nnets; i++) {
|
for (i = 0; i < def->nnets; i++) {
|
||||||
if (xenFormatNet(conn, netVal, def->nets[i],
|
if (xenFormatNet(conn, netVal, def->nets[i],
|
||||||
hvm, xendConfigVersion) < 0)
|
hvm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1826,7 +1762,7 @@ int
|
||||||
xenFormatConfigCommon(virConfPtr conf,
|
xenFormatConfigCommon(virConfPtr conf,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
virConnectPtr conn,
|
virConnectPtr conn,
|
||||||
int xendConfigVersion)
|
int xendConfigVersion ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
if (xenFormatGeneralMeta(conf, def) < 0)
|
if (xenFormatGeneralMeta(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1837,13 +1773,10 @@ xenFormatConfigCommon(virConfPtr conf,
|
||||||
if (xenFormatCPUAllocation(conf, def) < 0)
|
if (xenFormatCPUAllocation(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatCPUFeatures(conf, def, xendConfigVersion) < 0)
|
if (xenFormatCPUFeatures(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatCDROM(conf, def, xendConfigVersion) < 0)
|
if (xenFormatTimeOffset(conf, def) < 0)
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (xenFormatTimeOffset(conf, def, xendConfigVersion) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatEventActions(conf, def) < 0)
|
if (xenFormatEventActions(conf, def) < 0)
|
||||||
|
@ -1852,10 +1785,10 @@ xenFormatConfigCommon(virConfPtr conf,
|
||||||
if (xenFormatEmulator(conf, def) < 0)
|
if (xenFormatEmulator(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatVfb(conf, def, xendConfigVersion) < 0)
|
if (xenFormatVfb(conf, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatVif(conf, conn, def, xendConfigVersion) < 0)
|
if (xenFormatVif(conf, conn, def) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (xenFormatPCI(conf, def) < 0)
|
if (xenFormatPCI(conf, def) < 0)
|
||||||
|
|
Loading…
Reference in New Issue