提交 675f9bde 编写于 作者: P Pavel Hrdina

qemu_process: graphics: extract port allocation into function

Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
上级 eaa20e68
...@@ -4047,6 +4047,44 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, ...@@ -4047,6 +4047,44 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
} }
static int
qemuProcessGraphicsAllocatePorts(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics,
bool allocate)
{
virDomainGraphicsListenDefPtr glisten;
if (graphics->nListens <= 0)
return 0;
glisten = &graphics->listens[0];
if (glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS &&
glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)
return 0;
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
return -1;
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (qemuProcessSPICEAllocatePorts(driver, graphics, allocate) < 0)
return -1;
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;
}
static int static int
qemuProcessGraphicsSetupNetworkAddress(virDomainGraphicsListenDefPtr glisten, qemuProcessGraphicsSetupNetworkAddress(virDomainGraphicsListenDefPtr glisten,
const char *listenAddr) const char *listenAddr)
...@@ -4176,27 +4214,8 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, ...@@ -4176,27 +4214,8 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ngraphics; ++i) { for (i = 0; i < vm->def->ngraphics; ++i) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
if (graphics->nListens > 0 && if (qemuProcessGraphicsAllocatePorts(driver, graphics, allocate) < 0)
(graphics->listens[0].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
graphics->listens[0].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) {
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0)
goto cleanup;
break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
if (qemuProcessSPICEAllocatePorts(driver, graphics, allocate) < 0)
goto cleanup; goto cleanup;
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;
}
}
if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0) if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0)
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册