qemu: Use virTristateBool instead of virTristateSwitch in a few places

Both @accel2d and @accel3d are parsed as virTristateBool, but in
a few places (qemuDeviceVideoGetModel() and
qemuValidateDomainDeviceDefVideo()) they are compared to
virTristateSwitch enum either directly or via a variable of that
type. Clear this confusion by using the correct enum.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2022-01-20 14:14:31 +01:00
parent 2ab0a346bf
commit 5a33dd25c1
2 changed files with 6 additions and 6 deletions

View File

@ -695,7 +695,7 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
{ {
const char *model = NULL; const char *model = NULL;
bool primaryVga = false; bool primaryVga = false;
virTristateSwitch accel3d = VIR_TRISTATE_SWITCH_ABSENT; virTristateBool accel3d = VIR_TRISTATE_BOOL_ABSENT;
*virtio = false; *virtio = false;
*virtioBusSuffix = false; *virtioBusSuffix = false;
@ -735,7 +735,7 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
break; break;
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) && if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_VGA_GL) &&
accel3d == VIR_TRISTATE_SWITCH_ON) accel3d == VIR_TRISTATE_BOOL_YES)
model = "virtio-vga-gl"; model = "virtio-vga-gl";
else else
model = "virtio-vga"; model = "virtio-vga";
@ -765,7 +765,7 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
break; break;
case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: case VIR_DOMAIN_VIDEO_TYPE_VIRTIO:
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) && if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) &&
accel3d == VIR_TRISTATE_SWITCH_ON) accel3d == VIR_TRISTATE_BOOL_YES)
model = "virtio-gpu-gl"; model = "virtio-gpu-gl";
else else
model = "virtio-gpu"; model = "virtio-gpu";
@ -4816,7 +4816,7 @@ qemuBuildDeviceVideoCmd(virCommand *cmd,
virQEMUCaps *qemuCaps) virQEMUCaps *qemuCaps)
{ {
const char *model = NULL; const char *model = NULL;
virTristateSwitch virgl = VIR_TRISTATE_SWITCH_ABSENT; virTristateBool virgl = VIR_TRISTATE_BOOL_ABSENT;
bool virtio = false; bool virtio = false;
bool virtioBusSuffix = false; bool virtioBusSuffix = false;
g_autoptr(virJSONValue) props = NULL; g_autoptr(virJSONValue) props = NULL;

View File

@ -2489,7 +2489,7 @@ qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
} }
} }
if (video->accel && video->accel->accel2d == VIR_TRISTATE_SWITCH_ON) { if (video->accel && video->accel->accel2d == VIR_TRISTATE_BOOL_YES) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("qemu does not support the accel2d setting")); _("qemu does not support the accel2d setting"));
return -1; return -1;
@ -2553,7 +2553,7 @@ qemuValidateDomainDeviceDefVideo(const virDomainVideoDef *video,
return -1; return -1;
} }
} else if (video->accel) { } else if (video->accel) {
if (video->accel->accel3d == VIR_TRISTATE_SWITCH_ON && if (video->accel->accel3d == VIR_TRISTATE_BOOL_YES &&
(video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO || (video->type != VIR_DOMAIN_VIDEO_TYPE_VIRTIO ||
!(virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL) || !(virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_VIRGL) ||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) || virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_GPU_GL_PCI) ||