1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

virDomainTimerDef: Convert 'mode' field to proper enum type

Adjust the parser and switch statements to go with it.

Note that the XEN/libxl drivers had a 'default:' case for few of the
swtich statements so this patch blindly expands it to what it would be
in those cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-10-24 15:20:10 +02:00
parent 83e1368d95
commit 51e6ae319d
4 changed files with 14 additions and 12 deletions

View File

@ -10546,7 +10546,6 @@ virDomainTimerDefParseXML(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
xmlNodePtr catchup;
int ret;
g_autofree char *mode = NULL;
ctxt->node = node;
@ -10577,14 +10576,9 @@ virDomainTimerDefParseXML(xmlNodePtr node,
return NULL;
}
mode = virXMLPropString(node, "mode");
if (mode != NULL) {
if ((def->mode = virDomainTimerModeTypeFromString(mode)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown timer mode '%s'"), mode);
return NULL;
}
}
if (virXMLPropEnum(node, "mode", virDomainTimerModeTypeFromString,
VIR_XML_PROP_NONZERO, &def->mode) < 0)
return NULL;
catchup = virXPathNode("./catchup", ctxt);
if (catchup != NULL) {

View File

@ -2483,7 +2483,7 @@ struct _virDomainTimerDef {
/* frequency & mode are only valid for name='tsc' */
unsigned long long frequency; /* in Hz, unspecified = 0 */
int mode; /* enum virDomainTimerModeType */
virDomainTimerModeType mode;
};
typedef enum {

View File

@ -409,8 +409,12 @@ libxlMakeDomBuildInfo(virDomainDef *def,
case VIR_DOMAIN_TIMER_MODE_EMULATE:
b_info->tsc_mode = LIBXL_TSC_MODE_ALWAYS_EMULATE;
break;
default:
case VIR_DOMAIN_TIMER_MODE_NONE:
case VIR_DOMAIN_TIMER_MODE_AUTO:
case VIR_DOMAIN_TIMER_MODE_SMPSAFE:
b_info->tsc_mode = LIBXL_TSC_MODE_DEFAULT;
case VIR_DOMAIN_TIMER_MODE_LAST:
break;
}
break;

View File

@ -2102,9 +2102,13 @@ xenFormatHypervisorFeatures(virConf *conf, virDomainDef *def)
if (xenConfigSetString(conf, "tsc_mode", "always_emulate") < 0)
return -1;
break;
default:
case VIR_DOMAIN_TIMER_MODE_NONE:
case VIR_DOMAIN_TIMER_MODE_AUTO:
case VIR_DOMAIN_TIMER_MODE_SMPSAFE:
if (xenConfigSetString(conf, "tsc_mode", "default") < 0)
return -1;
case VIR_DOMAIN_TIMER_MODE_LAST:
break;
}
break;