mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
qemu: Use switch instead of ifs in qemuBuildGraphicsCommandLine
Switch the function from a bunch of ifs to a switch statement with correct type and reflow some code. Also fix comment in enum describing possible graphics types
This commit is contained in:
parent
66135c7208
commit
bd15ee89a7
@ -1230,7 +1230,7 @@ struct _virDomainVideoDef {
|
|||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 3 possible graphics console modes */
|
/* graphics console modes */
|
||||||
enum virDomainGraphicsType {
|
enum virDomainGraphicsType {
|
||||||
VIR_DOMAIN_GRAPHICS_TYPE_SDL,
|
VIR_DOMAIN_GRAPHICS_TYPE_SDL,
|
||||||
VIR_DOMAIN_GRAPHICS_TYPE_VNC,
|
VIR_DOMAIN_GRAPHICS_TYPE_VNC,
|
||||||
|
@ -5804,24 +5804,19 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
virDomainGraphicsDefPtr graphics)
|
virDomainGraphicsDefPtr graphics)
|
||||||
{
|
{
|
||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
|
switch ((enum virDomainGraphicsType) graphics->type) {
|
||||||
if (qemuBuildGraphicsVNCCommandLine(cfg, cmd, def, qemuCaps, graphics) < 0)
|
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||||
goto error;
|
|
||||||
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_0_10) &&
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_0_10) &&
|
||||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL)) {
|
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("sdl not supported by '%s'"),
|
_("sdl not supported by '%s'"), def->emulator);
|
||||||
def->emulator);
|
return -1;
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graphics->data.sdl.xauth)
|
if (graphics->data.sdl.xauth)
|
||||||
virCommandAddEnvPair(cmd, "XAUTHORITY",
|
virCommandAddEnvPair(cmd, "XAUTHORITY", graphics->data.sdl.xauth);
|
||||||
graphics->data.sdl.xauth);
|
|
||||||
if (graphics->data.sdl.display)
|
if (graphics->data.sdl.display)
|
||||||
virCommandAddEnvPair(cmd, "DISPLAY",
|
virCommandAddEnvPair(cmd, "DISPLAY", graphics->data.sdl.display);
|
||||||
graphics->data.sdl.display);
|
|
||||||
if (graphics->data.sdl.fullscreen)
|
if (graphics->data.sdl.fullscreen)
|
||||||
virCommandAddArg(cmd, "-full-screen");
|
virCommandAddArg(cmd, "-full-screen");
|
||||||
|
|
||||||
@ -5838,20 +5833,24 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL))
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SDL))
|
||||||
virCommandAddArg(cmd, "-sdl");
|
virCommandAddArg(cmd, "-sdl");
|
||||||
|
|
||||||
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
break;
|
||||||
if (qemuBuildGraphicsSPICECommandLine(cfg, cmd, qemuCaps, graphics) < 0)
|
|
||||||
goto error;
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||||
} else {
|
return qemuBuildGraphicsVNCCommandLine(cfg, cmd, def, qemuCaps, graphics);
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||||
|
return qemuBuildGraphicsSPICECommandLine(cfg, cmd, qemuCaps, graphics);
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported graphics type '%s'"),
|
_("unsupported graphics type '%s'"),
|
||||||
virDomainGraphicsTypeToString(graphics->type));
|
virDomainGraphicsTypeToString(graphics->type));
|
||||||
goto error;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user