mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
qemuDeviceVideoGetModel: Deduplicate a check
There is the same check written twice (whether given video card is primary one and whether it supports VGA mode). Write it just once and store it in a boolean variable. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
614fb5546c
commit
44d7a77c81
@ -4200,18 +4200,22 @@ qemuDeviceVideoGetModel(virQEMUCaps *qemuCaps,
|
|||||||
const virDomainVideoDef *video)
|
const virDomainVideoDef *video)
|
||||||
{
|
{
|
||||||
const char *model = NULL;
|
const char *model = NULL;
|
||||||
|
bool primaryVga = false;
|
||||||
|
|
||||||
|
if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
|
||||||
|
primaryVga = true;
|
||||||
|
|
||||||
/* We try to chose the best model for primary video device by preferring
|
/* We try to chose the best model for primary video device by preferring
|
||||||
* model with VGA compatibility mode. For some video devices on some
|
* model with VGA compatibility mode. For some video devices on some
|
||||||
* architectures there might not be such model so fallback to one
|
* architectures there might not be such model so fallback to one
|
||||||
* without VGA compatibility mode. */
|
* without VGA compatibility mode. */
|
||||||
if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
|
if (video->backend == VIR_DOMAIN_VIDEO_BACKEND_TYPE_VHOSTUSER) {
|
||||||
if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
|
if (primaryVga)
|
||||||
model = "vhost-user-vga";
|
model = "vhost-user-vga";
|
||||||
else
|
else
|
||||||
model = "vhost-user-gpu";
|
model = "vhost-user-gpu";
|
||||||
} else {
|
} else {
|
||||||
if (video->primary && qemuDomainSupportsVideoVga(video, qemuCaps))
|
if (primaryVga)
|
||||||
model = qemuDeviceVideoTypeToString(video->type);
|
model = qemuDeviceVideoTypeToString(video->type);
|
||||||
else
|
else
|
||||||
model = qemuDeviceVideoSecondaryTypeToString(video->type);
|
model = qemuDeviceVideoSecondaryTypeToString(video->type);
|
||||||
|
Loading…
Reference in New Issue
Block a user