mirror of https://gitee.com/openkylin/libvirt.git
virDomainWatchdogDef: Convert 'model' field to proper enum type
Convert the field and adjust the XML parsers to use virXMLPropEnum(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b691d249d1
commit
a6eadf00d2
|
@ -12065,21 +12065,14 @@ virDomainWatchdogDefParseXML(virDomainXMLOption *xmlopt,
|
|||
unsigned int flags)
|
||||
{
|
||||
virDomainWatchdogDef *def;
|
||||
g_autofree char *model = NULL;
|
||||
g_autofree char *action = NULL;
|
||||
|
||||
def = g_new0(virDomainWatchdogDef, 1);
|
||||
|
||||
model = virXMLPropString(node, "model");
|
||||
if (model == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("watchdog must contain model name"));
|
||||
goto error;
|
||||
}
|
||||
def->model = virDomainWatchdogModelTypeFromString(model);
|
||||
if (def->model < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown watchdog model '%1$s'"), model);
|
||||
if (virXMLPropEnum(node, "model",
|
||||
virDomainWatchdogModelTypeFromString,
|
||||
VIR_XML_PROP_REQUIRED,
|
||||
&def->model) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
@ -1759,7 +1759,7 @@ typedef enum {
|
|||
} virDomainWatchdogAction;
|
||||
|
||||
struct _virDomainWatchdogDef {
|
||||
int model;
|
||||
virDomainWatchdogModel model;
|
||||
int action;
|
||||
virDomainDeviceInfo info;
|
||||
};
|
||||
|
|
|
@ -927,7 +927,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
|||
|
||||
case VIR_DOMAIN_DEVICE_WATCHDOG:
|
||||
/* only one model connects using PCI */
|
||||
switch ((virDomainWatchdogModel) dev->data.watchdog->model) {
|
||||
switch (dev->data.watchdog->model) {
|
||||
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
|
||||
return pciFlags;
|
||||
|
||||
|
|
|
@ -2251,7 +2251,7 @@ qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
|
|||
return -1;
|
||||
}
|
||||
|
||||
switch ((virDomainWatchdogModel) dev->model) {
|
||||
switch (dev->model) {
|
||||
case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
|
||||
if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||
dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
||||
|
|
Loading…
Reference in New Issue