Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/conf/device_conf.h | 4 ++--
src/conf/domain_conf.c | 26 ++++++++++++++++----------
src/qemu/qemu_command.c | 3 ++-
src/qemu/qemu_hotplug.c | 2 +-
4 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
index a51bdf10ee..289af1153a 100644
--- a/src/conf/device_conf.h
+++ b/src/conf/device_conf.h
@@ -153,8 +153,8 @@ struct _virDomainDeviceInfo {
} master;
/* rombar and romfile are only used for pci hostdev and network
* devices. */
- int romenabled; /* enum virTristateBool */
- int rombar; /* enum virTristateSwitch */
+ virTristateBool romenabled;
+ virTristateSwitch rombar;
char *romfile;
/* bootIndex is only used for disk, network interface, hostdev
* and redirdev devices */
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 27eb98d93c..43789fa2c7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6681,17 +6681,23 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt,
if ((flags & VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) &&
(rom = virXPathNode("./rom", ctxt))) {
- if ((romenabled = virXPathString("string(./rom/@enabled)", ctxt))
&&
- ((info->romenabled = virTristateBoolTypeFromString(romenabled)) <= 0))
{
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown rom enabled value '%s'"),
romenabled);
- goto cleanup;
+ if ((romenabled = virXPathString("string(./rom/@enabled)", ctxt))) {
+ int value;
+ if ((value = virTristateBoolTypeFromString(romenabled)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown rom enabled value '%s'"),
romenabled);
+ goto cleanup;
+ }
+ info->romenabled = value;
}
- if ((rombar = virXPathString("string(./rom/@bar)", ctxt)) &&
- ((info->rombar = virTristateSwitchTypeFromString(rombar)) <= 0)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown rom bar value '%s'"), rombar);
- goto cleanup;
+ if ((rombar = virXPathString("string(./rom/@bar)", ctxt))) {
+ int value;
+ if ((value = virTristateSwitchTypeFromString(rombar)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown rom bar value '%s'"),
rombar);
+ goto cleanup;
+ }
+ info->rombar = value;
}
info->romfile = virXMLPropString(rom, "file");
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5717f7b98d..73c28ed7a0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -660,7 +660,8 @@ qemuBuildRomStr(virBufferPtr buf,
case VIR_TRISTATE_SWITCH_ON:
virBufferAddLit(buf, ",rombar=1");
break;
- default:
+ case VIR_TRISTATE_SWITCH_ABSENT:
+ case VIR_TRISTATE_SWITCH_LAST:
break;
}
if (info->romfile) {
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a66354426d..cc49f10198 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3665,7 +3665,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
/* device alias is checked already in virDomainDefCompatibleDevice */
- if (newdev->info.rombar == VIR_TRISTATE_BOOL_ABSENT)
+ if (newdev->info.rombar == VIR_TRISTATE_SWITCH_ABSENT)
newdev->info.rombar = olddev->info.rombar;
if (olddev->info.rombar != newdev->info.rombar) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
--
2.26.2