mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu_process: graphics: ref driver config only in function where it is used
Signed-off-by: Pavel Hrdina <phrdina@redhat.com
This commit is contained in:
parent
3edcf83433
commit
eaa20e68b3
@ -3547,14 +3547,15 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
||||||
virQEMUDriverConfigPtr cfg,
|
|
||||||
virDomainGraphicsDefPtr graphics,
|
virDomainGraphicsDefPtr graphics,
|
||||||
bool allocate)
|
bool allocate)
|
||||||
{
|
{
|
||||||
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
unsigned short tlsPort;
|
unsigned short tlsPort;
|
||||||
size_t i;
|
size_t i;
|
||||||
int defaultMode = graphics->data.spice.defaultMode;
|
int defaultMode = graphics->data.spice.defaultMode;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
bool needTLSPort = false;
|
bool needTLSPort = false;
|
||||||
bool needPort = false;
|
bool needPort = false;
|
||||||
@ -3600,12 +3601,13 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
|||||||
if (needTLSPort || graphics->data.spice.tlsPort == -1)
|
if (needTLSPort || graphics->data.spice.tlsPort == -1)
|
||||||
graphics->data.spice.tlsPort = 5902;
|
graphics->data.spice.tlsPort = 5902;
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needPort || graphics->data.spice.port == -1) {
|
if (needPort || graphics->data.spice.port == -1) {
|
||||||
if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
|
if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
|
||||||
goto error;
|
goto cleanup;
|
||||||
|
|
||||||
graphics->data.spice.port = port;
|
graphics->data.spice.port = port;
|
||||||
|
|
||||||
@ -3618,11 +3620,11 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
|||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Auto allocation of spice TLS port requested "
|
_("Auto allocation of spice TLS port requested "
|
||||||
"but spice TLS is disabled in qemu.conf"));
|
"but spice TLS is disabled in qemu.conf"));
|
||||||
goto error;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0)
|
if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0)
|
||||||
goto error;
|
goto cleanup;
|
||||||
|
|
||||||
graphics->data.spice.tlsPort = tlsPort;
|
graphics->data.spice.tlsPort = tlsPort;
|
||||||
|
|
||||||
@ -3630,11 +3632,12 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
|
|||||||
graphics->data.spice.tlsPortReserved = true;
|
graphics->data.spice.tlsPortReserved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
|
||||||
error:
|
cleanup:
|
||||||
virPortAllocatorRelease(driver->remotePorts, port);
|
virPortAllocatorRelease(driver->remotePorts, port);
|
||||||
return -1;
|
virObjectUnref(cfg);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4072,15 +4075,17 @@ qemuProcessGraphicsSetupNetworkAddress(virDomainGraphicsListenDefPtr glisten,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
|
||||||
virDomainGraphicsDefPtr graphics,
|
virDomainGraphicsDefPtr graphics,
|
||||||
virDomainObjPtr vm)
|
virDomainObjPtr vm)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
const char *type = virDomainGraphicsTypeToString(graphics->type);
|
const char *type = virDomainGraphicsTypeToString(graphics->type);
|
||||||
char *listenAddr = NULL;
|
char *listenAddr = NULL;
|
||||||
bool useSocket = false;
|
bool useSocket = false;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
switch (graphics->type) {
|
switch (graphics->type) {
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||||
@ -4113,12 +4118,12 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
|||||||
memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
|
memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
|
||||||
if (virAsprintf(&glisten->socket, "%s/%s.sock",
|
if (virAsprintf(&glisten->socket, "%s/%s.sock",
|
||||||
priv->libDir, type) < 0)
|
priv->libDir, type) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
glisten->fromConfig = true;
|
glisten->fromConfig = true;
|
||||||
glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
|
glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
|
||||||
} else if (listenAddr) {
|
} else if (listenAddr) {
|
||||||
if (VIR_STRDUP(glisten->address, listenAddr) < 0)
|
if (VIR_STRDUP(glisten->address, listenAddr) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
glisten->fromConfig = true;
|
glisten->fromConfig = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4130,14 +4135,14 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
|||||||
|
|
||||||
if (qemuProcessGraphicsSetupNetworkAddress(glisten,
|
if (qemuProcessGraphicsSetupNetworkAddress(glisten,
|
||||||
listenAddr) < 0)
|
listenAddr) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
|
||||||
if (!glisten->socket) {
|
if (!glisten->socket) {
|
||||||
if (virAsprintf(&glisten->socket, "%s/%s.sock",
|
if (virAsprintf(&glisten->socket, "%s/%s.sock",
|
||||||
priv->libDir, type) < 0)
|
priv->libDir, type) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
glisten->autoGenerated = true;
|
glisten->autoGenerated = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4148,7 +4153,11 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virObjectUnref(cfg);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4157,7 +4166,6 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
|
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -4178,8 +4186,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||||
if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics,
|
if (qemuProcessSPICEAllocatePorts(driver, graphics, allocate) < 0)
|
||||||
allocate) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -4191,14 +4198,13 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuProcessGraphicsSetupListen(cfg, graphics, vm) < 0)
|
if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virObjectUnref(cfg);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user