On 04/04/2016 09:20 AM, Pavel Hrdina wrote: > Move generation of vnc unix socket to qemuProcessPrepareDomain which is > the correct place to do those things. Now we can also test it. > > Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> > --- > src/qemu/qemu_command.c | 20 ++++--------- > src/qemu/qemu_command.h | 3 +- > src/qemu/qemu_process.c | 20 +++++++++++-- > ...qemuxml2argv-graphics-vnc-auto-unix-socket.args | 22 ++++++++++++++ > .../qemuxml2argv-graphics-vnc-auto-unix-socket.xml | 34 ++++++++++++++++++++++ > tests/qemuxml2argvtest.c | 4 +++ > 6 files changed, 84 insertions(+), 19 deletions(-) > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args > create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml > > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index 9335f63..67d3336 100644 > --- a/src/qemu/qemu_command.c > +++ b/src/qemu/qemu_command.c > @@ -7219,8 +7219,7 @@ static int > qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, > virCommandPtr cmd, > virQEMUCapsPtr qemuCaps, > - virDomainGraphicsDefPtr graphics, > - const char *domainLibDir) > + virDomainGraphicsDefPtr graphics) > { > virBuffer opt = VIR_BUFFER_INITIALIZER; > virDomainGraphicsListenDefPtr listen = NULL; > @@ -7235,14 +7234,8 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, > goto error; > } > > - if (graphics->data.vnc.socket || cfg->vncAutoUnixSocket) { > - if (!graphics->data.vnc.socket && > - virAsprintf(&graphics->data.vnc.socket, > - "%s/vnc.sock", domainLibDir) == -1) > - goto error; > - > + if (graphics->data.vnc.socket) { > virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); > - > } else { > if (!graphics->data.vnc.autoport && > (graphics->data.vnc.port < 5900 || > @@ -7613,8 +7606,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg, > virCommandPtr cmd, > virDomainDefPtr def, > virQEMUCapsPtr qemuCaps, > - virDomainGraphicsDefPtr graphics, > - const char *domainLibDir) > + virDomainGraphicsDefPtr graphics) > { > switch ((virDomainGraphicsType) graphics->type) { > case VIR_DOMAIN_GRAPHICS_TYPE_SDL: > @@ -7646,8 +7638,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); > @@ -9199,7 +9190,6 @@ qemuBuildCommandLine(virConnectPtr conn, > virBitmapPtr nodeset, > size_t *nnicindexes, > int **nicindexes, > - const char *domainLibDir, > const char *domainChannelTargetDir) > { > size_t i; > @@ -9360,7 +9350,7 @@ qemuBuildCommandLine(virConnectPtr conn, > > for (i = 0; i < def->ngraphics; ++i) { > if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps, > - def->graphics[i], domainLibDir) < 0) > + def->graphics[i]) < 0) > goto error; > } > > diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h > index 7c13d45..677fc05 100644 > --- a/src/qemu/qemu_command.h > +++ b/src/qemu/qemu_command.h > @@ -74,10 +74,9 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn, > virBitmapPtr nodeset, > size_t *nnicindexes, > int **nicindexes, > - const char *domainLibDir, > const char *domainChannelTargetDir) > ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(11) > - ATTRIBUTE_NONNULL(17) ATTRIBUTE_NONNULL(18); > + ATTRIBUTE_NONNULL(17); > > /* Generate '-device' string for chardev device */ > int > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c > index 6a4fb8c..cfd8a90 100644 > --- a/src/qemu/qemu_process.c > +++ b/src/qemu/qemu_process.c > @@ -4957,6 +4957,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, > size_t i; > char *nodeset = NULL; > qemuDomainObjPrivatePtr priv = vm->privateData; > + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); > virCapsPtr caps; > > if (!(caps = virQEMUDriverGetCapabilities(driver, false))) > @@ -4996,6 +4997,22 @@ qemuProcessPrepareDomain(virConnectPtr conn, > if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) > goto cleanup; > > + /* Generate socket paths for graphics */ > + for (i = 0; i < vm->def->ngraphics; i++) { > + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; > + > + switch (graphics->type) { > + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: > + if (cfg->vncAutoUnixSocket && !graphics->data.vnc.socket) { > + if (virAsprintf(&graphics->data.vnc.socket, > + "%s/vnc.sock", priv->libDir) < 0) > + goto cleanup; > + > + continue; > + } > + } > + } A pre-existing bug, but we shouldn't be forcing usage of socket= here if the user already specified a listen address. So, check nListens == 0 first. But that's for a separate patch - Cole -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list