qemu: Mark graphics ports used on reconnect

I don't want to mask the real problem, but one can advocate
that we should be marking graphics ports as already in use on
qemuProcessReconnect anyway, because we already know that they
are taken.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2017-09-18 15:39:58 +02:00
parent cdd6eb99c2
commit 8406769642
1 changed files with 13 additions and 4 deletions

View File

@ -4035,7 +4035,8 @@ qemuProcessStartHook(virQEMUDriverPtr driver,
static int static int
qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics) virDomainGraphicsDefPtr graphics,
bool reconnect)
{ {
virDomainGraphicsListenDefPtr glisten; virDomainGraphicsListenDefPtr glisten;
@ -4050,7 +4051,8 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
switch (graphics->type) { switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC: case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (!graphics->data.vnc.autoport) { if (!graphics->data.vnc.autoport ||
reconnect) {
if (virPortAllocatorSetUsed(driver->remotePorts, if (virPortAllocatorSetUsed(driver->remotePorts,
graphics->data.vnc.port, graphics->data.vnc.port,
true) < 0) true) < 0)
@ -4065,7 +4067,7 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
break; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (graphics->data.spice.autoport) if (graphics->data.spice.autoport && !reconnect)
return 0; return 0;
if (graphics->data.spice.port > 0) { if (graphics->data.spice.port > 0) {
@ -4269,7 +4271,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ngraphics; i++) { for (i = 0; i < vm->def->ngraphics; i++) {
graphics = vm->def->graphics[i]; graphics = vm->def->graphics[i];
if (qemuProcessGraphicsReservePorts(driver, graphics) < 0) if (qemuProcessGraphicsReservePorts(driver, graphics, false) < 0)
goto cleanup; goto cleanup;
} }
} }
@ -6881,6 +6883,13 @@ qemuProcessReconnect(void *opaque)
goto error; goto error;
} }
for (i = 0; i < obj->def->ngraphics; i++) {
if (qemuProcessGraphicsReservePorts(driver,
obj->def->graphics[i],
true) < 0)
goto error;
}
if (qemuProcessUpdateState(driver, obj) < 0) if (qemuProcessUpdateState(driver, obj) < 0)
goto error; goto error;