1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: mark user defined websocket as used

We need extra state variable to distinguish between autogenerated
and user defined cases after auto generation is done.
This commit is contained in:
Nikolay Shirokovskiy 2016-11-22 14:09:32 +03:00 committed by John Ferlan
parent b07cfd724f
commit 1215965a4c
2 changed files with 17 additions and 2 deletions

View File

@ -1487,6 +1487,7 @@ struct _virDomainGraphicsDef {
int port;
bool portReserved;
int websocket;
bool websocketGenerated;
bool autoport;
char *keymap;
virDomainGraphicsAuthDef auth;

View File

@ -3614,6 +3614,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
if (virPortAllocatorAcquire(driver->webSocketPorts, &port) < 0)
return -1;
graphics->data.vnc.websocket = port;
graphics->data.vnc.websocketGenerated = true;
}
return 0;
@ -4105,6 +4106,11 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
return -1;
graphics->data.vnc.portReserved = true;
}
if (graphics->data.vnc.websocket > 0 &&
virPortAllocatorSetUsed(driver->remotePorts,
graphics->data.vnc.websocket,
true) < 0)
return -1;
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
@ -6212,8 +6218,16 @@ void qemuProcessStop(virQEMUDriverPtr driver,
false);
graphics->data.vnc.portReserved = false;
}
if (graphics->data.vnc.websocketGenerated) {
virPortAllocatorRelease(driver->webSocketPorts,
graphics->data.vnc.websocket);
graphics->data.vnc.websocketGenerated = false;
graphics->data.vnc.websocket = -1;
} else if (graphics->data.vnc.websocket) {
virPortAllocatorSetUsed(driver->remotePorts,
graphics->data.vnc.websocket,
false);
}
}
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
if (graphics->data.spice.autoport) {