mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
xenconfig: Add support for 'passthrough' hypervisor feature
Add support for xl.cfg(5) 'passthrough' option in the domXML-to-xenconfig configuration converter. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9cb8bc6ff1
commit
b523e22521
@ -649,6 +649,8 @@ virDomainWatchdogActionTypeToString;
|
|||||||
virDomainWatchdogDefFree;
|
virDomainWatchdogDefFree;
|
||||||
virDomainWatchdogModelTypeFromString;
|
virDomainWatchdogModelTypeFromString;
|
||||||
virDomainWatchdogModelTypeToString;
|
virDomainWatchdogModelTypeToString;
|
||||||
|
virDomainXenPassthroughModeTypeFromString;
|
||||||
|
virDomainXenPassthroughModeTypeToString;
|
||||||
virDomainXMLOptionGetNamespace;
|
virDomainXMLOptionGetNamespace;
|
||||||
virDomainXMLOptionGetSaveCookie;
|
virDomainXMLOptionGetSaveCookie;
|
||||||
virDomainXMLOptionNew;
|
virDomainXMLOptionNew;
|
||||||
|
@ -530,14 +530,14 @@ xenParseCPU(virConfPtr conf,
|
|||||||
static int
|
static int
|
||||||
xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
||||||
{
|
{
|
||||||
g_autofree char *tsc_mode = NULL;
|
g_autofree char *strval = NULL;
|
||||||
virDomainTimerDefPtr timer;
|
virDomainTimerDefPtr timer;
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
if (xenConfigGetString(conf, "tsc_mode", &tsc_mode, NULL) < 0)
|
if (xenConfigGetString(conf, "tsc_mode", &strval, NULL) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (tsc_mode) {
|
if (strval) {
|
||||||
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
|
if (VIR_EXPAND_N(def->clock.timers, def->clock.ntimers, 1) < 0 ||
|
||||||
VIR_ALLOC(timer) < 0)
|
VIR_ALLOC(timer) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -547,16 +547,40 @@ xenParseHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
|||||||
timer->tickpolicy = -1;
|
timer->tickpolicy = -1;
|
||||||
timer->mode = VIR_DOMAIN_TIMER_MODE_AUTO;
|
timer->mode = VIR_DOMAIN_TIMER_MODE_AUTO;
|
||||||
timer->track = -1;
|
timer->track = -1;
|
||||||
if (STREQ_NULLABLE(tsc_mode, "always_emulate"))
|
if (STREQ_NULLABLE(strval, "always_emulate"))
|
||||||
timer->mode = VIR_DOMAIN_TIMER_MODE_EMULATE;
|
timer->mode = VIR_DOMAIN_TIMER_MODE_EMULATE;
|
||||||
else if (STREQ_NULLABLE(tsc_mode, "native"))
|
else if (STREQ_NULLABLE(strval, "native"))
|
||||||
timer->mode = VIR_DOMAIN_TIMER_MODE_NATIVE;
|
timer->mode = VIR_DOMAIN_TIMER_MODE_NATIVE;
|
||||||
else if (STREQ_NULLABLE(tsc_mode, "native_paravirt"))
|
else if (STREQ_NULLABLE(strval, "native_paravirt"))
|
||||||
timer->mode = VIR_DOMAIN_TIMER_MODE_PARAVIRT;
|
timer->mode = VIR_DOMAIN_TIMER_MODE_PARAVIRT;
|
||||||
|
|
||||||
def->clock.timers[def->clock.ntimers - 1] = timer;
|
def->clock.timers[def->clock.ntimers - 1] = timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (xenConfigGetString(conf, "passthrough", &strval, NULL) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (strval) {
|
||||||
|
if (STREQ(strval, "disabled")) {
|
||||||
|
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_OFF;
|
||||||
|
def->xen_features[VIR_DOMAIN_XEN_PASSTHROUGH] = VIR_TRISTATE_SWITCH_OFF;
|
||||||
|
} else if (STREQ(strval, "enabled")) {
|
||||||
|
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
def->xen_features[VIR_DOMAIN_XEN_PASSTHROUGH] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
} else if (STREQ(strval, "sync_pt")) {
|
||||||
|
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
def->xen_features[VIR_DOMAIN_XEN_PASSTHROUGH] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
def->xen_passthrough_mode = VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT;
|
||||||
|
} else if (STREQ(strval, "share_pt")) {
|
||||||
|
def->features[VIR_DOMAIN_FEATURE_XEN] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
def->xen_features[VIR_DOMAIN_XEN_PASSTHROUGH] = VIR_TRISTATE_SWITCH_ON;
|
||||||
|
def->xen_passthrough_mode = VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT;
|
||||||
|
} else {
|
||||||
|
virReportError(VIR_ERR_CONF_SYNTAX,
|
||||||
|
_("Invalid passthrough mode %s"), strval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
|
||||||
if (xenConfigGetBool(conf, "pae", &val, 1) < 0)
|
if (xenConfigGetBool(conf, "pae", &val, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2163,6 +2187,20 @@ xenFormatHypervisorFeatures(virConfPtr conf, virDomainDefPtr def)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (def->features[VIR_DOMAIN_FEATURE_XEN] == VIR_TRISTATE_SWITCH_ON) {
|
||||||
|
if (def->xen_features[VIR_DOMAIN_XEN_PASSTHROUGH] == VIR_TRISTATE_SWITCH_ON) {
|
||||||
|
if (def->xen_passthrough_mode == VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SYNC_PT ||
|
||||||
|
def->xen_passthrough_mode == VIR_DOMAIN_XEN_PASSTHROUGH_MODE_SHARE_PT) {
|
||||||
|
if (xenConfigSetString(conf, "passthrough",
|
||||||
|
virDomainXenPassthroughModeTypeToString(def->xen_passthrough_mode)) < 0)
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
if (xenConfigSetString(conf, "passthrough", "enabled") < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->clock.ntimers; i++) {
|
for (i = 0; i < def->clock.ntimers; i++) {
|
||||||
switch ((virDomainTimerNameType)def->clock.timers[i]->name) {
|
switch ((virDomainTimerNameType)def->clock.timers[i]->name) {
|
||||||
case VIR_DOMAIN_TIMER_NAME_TSC:
|
case VIR_DOMAIN_TIMER_NAME_TSC:
|
||||||
|
Loading…
Reference in New Issue
Block a user