mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
vnc: move generation of socket path to qemuProcessGraphicsSetupListen
This moves the socket generation if "vnc_auto_unix_socket" is set. It also fixes a bug with this config option that we should auto-generate socket path only if listen type is address and there is no address specified. Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
17271d04e7
commit
c5caecab7b
@ -15,9 +15,9 @@
|
||||
# unix socket. This prevents unprivileged access from users on the
|
||||
# host machine, though most VNC clients do not support it.
|
||||
#
|
||||
# This will only be enabled for VNC configurations that do not have
|
||||
# a hardcoded 'listen' or 'socket' value. This setting takes preference
|
||||
# over vnc_listen.
|
||||
# This will only be enabled for VNC configurations that have listen
|
||||
# type=address but without any address specified. This setting takes
|
||||
# preference over vnc_listen.
|
||||
#
|
||||
#vnc_auto_unix_socket = 1
|
||||
|
||||
|
@ -7212,8 +7212,7 @@ static int
|
||||
qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
|
||||
virCommandPtr cmd,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
const char *domainLibDir)
|
||||
virDomainGraphicsDefPtr graphics)
|
||||
{
|
||||
virBuffer opt = VIR_BUFFER_INITIALIZER;
|
||||
virDomainGraphicsListenDefPtr glisten = NULL;
|
||||
@ -7227,15 +7226,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
|
||||
|
||||
glisten = virDomainGraphicsGetListen(graphics, 0);
|
||||
|
||||
if (graphics->data.vnc.socket || cfg->vncAutoUnixSocket) {
|
||||
if (!graphics->data.vnc.socket) {
|
||||
if (virAsprintf(&graphics->data.vnc.socket,
|
||||
"%s/vnc.sock", domainLibDir) < 0)
|
||||
goto error;
|
||||
|
||||
graphics->data.vnc.socketFromConfig = true;
|
||||
}
|
||||
|
||||
if (graphics->data.vnc.socket) {
|
||||
virBufferAddLit(&opt, "unix:");
|
||||
qemuBufferEscapeComma(&opt, graphics->data.vnc.socket);
|
||||
|
||||
@ -7537,8 +7528,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
|
||||
virCommandPtr cmd,
|
||||
virDomainDefPtr def,
|
||||
virQEMUCapsPtr qemuCaps,
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
const char *domainLibDir)
|
||||
virDomainGraphicsDefPtr graphics)
|
||||
{
|
||||
switch (graphics->type) {
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||
@ -7570,8 +7560,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||
return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps,
|
||||
graphics, domainLibDir);
|
||||
return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps, graphics);
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||
return qemuBuildGraphicsSPICECommandLine(cfg, cmd, qemuCaps, graphics);
|
||||
@ -9232,7 +9221,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
|
||||
|
||||
for (i = 0; i < def->ngraphics; ++i) {
|
||||
if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps,
|
||||
def->graphics[i], domainLibDir) < 0)
|
||||
def->graphics[i]) < 0)
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -4022,13 +4022,18 @@ qemuProcessGraphicsSetupNetworkAddress(virDomainGraphicsListenDefPtr glisten,
|
||||
|
||||
static int
|
||||
qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
||||
virDomainGraphicsDefPtr graphics)
|
||||
virDomainGraphicsDefPtr graphics,
|
||||
virDomainObjPtr vm)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
const char *type = virDomainGraphicsTypeToString(graphics->type);
|
||||
char *listenAddr = NULL;
|
||||
bool useSocket = false;
|
||||
size_t i;
|
||||
|
||||
switch (graphics->type) {
|
||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||
useSocket = cfg->vncAutoUnixSocket;
|
||||
listenAddr = cfg->vncListen;
|
||||
break;
|
||||
|
||||
@ -4048,13 +4053,22 @@ qemuProcessGraphicsSetupListen(virQEMUDriverConfigPtr cfg,
|
||||
|
||||
switch (glisten->type) {
|
||||
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
|
||||
if (glisten->address || !listenAddr)
|
||||
continue;
|
||||
|
||||
if (VIR_STRDUP(glisten->address, listenAddr) < 0)
|
||||
return -1;
|
||||
|
||||
glisten->fromConfig = true;
|
||||
if (!glisten->address) {
|
||||
/* If there is no address specified and qemu.conf has
|
||||
* *_auto_unix_socket set we should use unix socket as
|
||||
* default instead of tcp listen. */
|
||||
if (useSocket) {
|
||||
VIR_DELETE_ELEMENT(graphics->listens, i, graphics->nListens);
|
||||
if (virAsprintf(&graphics->data.vnc.socket, "%s/%s.sock",
|
||||
priv->libDir, type) < 0)
|
||||
return -1;
|
||||
graphics->data.vnc.socketFromConfig = true;
|
||||
} else if (listenAddr) {
|
||||
if (VIR_STRDUP(glisten->address, listenAddr) < 0)
|
||||
return -1;
|
||||
glisten->fromConfig = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
|
||||
@ -4110,7 +4124,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
|
||||
break;
|
||||
}
|
||||
|
||||
if (qemuProcessGraphicsSetupListen(cfg, graphics) < 0)
|
||||
if (qemuProcessGraphicsSetupListen(cfg, graphics, vm) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user