static int
qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
- virDomainGraphicsDefPtr graphics)
+ virDomainGraphicsDefPtr graphics,
+ bool reconnect)
{
virDomainGraphicsListenDefPtr glisten;
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
- if (!graphics->data.vnc.autoport) {
+ if (!graphics->data.vnc.autoport ||
+ reconnect) {
if (virPortAllocatorSetUsed(driver->remotePorts,
graphics->data.vnc.port,
true) < 0)
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
- if (graphics->data.spice.autoport)
+ if (graphics->data.spice.autoport && !reconnect)
return 0;
if (graphics->data.spice.port > 0) {
for (i = 0; i < vm->def->ngraphics; i++) {
graphics = vm->def->graphics[i];
- if (qemuProcessGraphicsReservePorts(driver, graphics) < 0)
+ if (qemuProcessGraphicsReservePorts(driver, graphics, false) < 0)
goto cleanup;
}
}
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)
goto error;