!graphics->data.vnc.socket && graphics->data.vnc.autoport) {
graphics->data.vnc.port = 5900;
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
- size_t j;
- bool needTLSPort = false;
- bool needPort = false;
- int defaultMode = graphics->data.spice.defaultMode;
-
- if (graphics->data.spice.autoport) {
- /* check if tlsPort or port need allocation */
- for (j = 0; j < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; j++) {
- switch (graphics->data.spice.channels[j]) {
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE:
- needTLSPort = true;
- break;
-
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE:
- needPort = true;
- break;
-
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
- switch (defaultMode) {
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE:
- needTLSPort = true;
- break;
-
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE:
- needPort = true;
- break;
-
- case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY:
- if (cfg->spiceTLS)
- needTLSPort = true;
- needPort = true;
- break;
- }
- break;
- }
- }
- }
-
- if (needPort || graphics->data.spice.port == -1)
- graphics->data.spice.port = 5901;
-
- if (needTLSPort || graphics->data.spice.tlsPort == -1)
- graphics->data.spice.tlsPort = 5902;
+ if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0)
+ goto cleanup;
}
}
return 0;
}
-static int
+int
qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
virQEMUDriverConfigPtr cfg,
- virDomainGraphicsDefPtr graphics)
+ virDomainGraphicsDefPtr graphics,
+ bool allocate)
{
unsigned short port = 0;
unsigned short tlsPort;
}
}
+ if (!allocate) {
+ if (needPort || graphics->data.spice.port == -1)
+ graphics->data.spice.port = 5901;
+
+ if (needTLSPort || graphics->data.spice.tlsPort == -1)
+ graphics->data.spice.tlsPort = 5902;
+
+ return 0;
+ }
+
if (needPort || graphics->data.spice.port == -1) {
if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
goto error;
if (qemuProcessVNCAllocatePorts(driver, graphics) < 0)
goto cleanup;
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
- if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics) < 0)
+ if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0)
goto cleanup;
}
int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp,
virDomainThreadSchedParamPtr sp);
+int qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
+ virQEMUDriverConfigPtr cfg,
+ virDomainGraphicsDefPtr graphics,
+ bool allocate);
+
#endif /* __QEMU_PROCESS_H__ */