mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
qemu: Refactor qemuProcessGraphicsReservePorts
Use switch for enums rather than if/else conditions.
This commit is contained in:
parent
db34168a7f
commit
b07cfd724f
@ -4096,16 +4096,21 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
|
|||||||
glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)
|
glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
|
switch (graphics->type) {
|
||||||
!graphics->data.vnc.autoport) {
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||||
|
if (!graphics->data.vnc.autoport) {
|
||||||
if (virPortAllocatorSetUsed(driver->remotePorts,
|
if (virPortAllocatorSetUsed(driver->remotePorts,
|
||||||
graphics->data.vnc.port,
|
graphics->data.vnc.port,
|
||||||
true) < 0)
|
true) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
graphics->data.vnc.portReserved = true;
|
graphics->data.vnc.portReserved = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||||
|
if (graphics->data.spice.autoport)
|
||||||
|
return 0;
|
||||||
|
|
||||||
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
|
|
||||||
!graphics->data.spice.autoport) {
|
|
||||||
if (graphics->data.spice.port > 0) {
|
if (graphics->data.spice.port > 0) {
|
||||||
if (virPortAllocatorSetUsed(driver->remotePorts,
|
if (virPortAllocatorSetUsed(driver->remotePorts,
|
||||||
graphics->data.spice.port,
|
graphics->data.spice.port,
|
||||||
@ -4121,6 +4126,13 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
|
|||||||
return -1;
|
return -1;
|
||||||
graphics->data.spice.tlsPortReserved = true;
|
graphics->data.spice.tlsPortReserved = true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user