[libvirt] [PATCH v6 07/10] spice: add support for listen type socket
Ján Tomko
jtomko at redhat.com
Thu Jun 9 11:37:23 UTC 2016
On Wed, Jun 08, 2016 at 05:25:45PM +0200, Pavel Hrdina wrote:
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1335832
>
> Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
> ---
> docs/formatdomain.html.in | 2 +-
> src/conf/domain_conf.c | 31 ++++++++----
> src/qemu/qemu_command.c | 56 ++++++++++++++++------
> src/qemu/qemu_migration.c | 47 +++++++++++++-----
> .../qemuxml2argv-graphics-spice-auto-socket.args | 20 ++++++++
> .../qemuxml2argv-graphics-spice-auto-socket.xml | 30 ++++++++++++
> .../qemuxml2argv-graphics-spice-socket.args | 20 ++++++++
> .../qemuxml2argv-graphics-spice-socket.xml | 30 ++++++++++++
> tests/qemuxml2argvtest.c | 6 +++
> .../qemuxml2xmlout-graphics-spice-auto-socket.xml | 35 ++++++++++++++
> .../qemuxml2xmlout-graphics-spice-socket.xml | 35 ++++++++++++++
> tests/qemuxml2xmltest.c | 2 +
> 12 files changed, 277 insertions(+), 37 deletions(-)
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args
> create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml
> create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml
> create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml
>
> @@ -21924,18 +21925,28 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
> break;
>
> case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
> - if (def->data.spice.port)
> - virBufferAsprintf(buf, " port='%d'",
> - def->data.spice.port);
> + switch (glisten->type) {
This could be typecasted.
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
> + if (def->data.spice.port)
> + virBufferAsprintf(buf, " port='%d'",
> + def->data.spice.port);
>
> - if (def->data.spice.tlsPort)
> - virBufferAsprintf(buf, " tlsPort='%d'",
> - def->data.spice.tlsPort);
> + if (def->data.spice.tlsPort)
> + virBufferAsprintf(buf, " tlsPort='%d'",
> + def->data.spice.tlsPort);
>
> - virBufferAsprintf(buf, " autoport='%s'",
> - def->data.spice.autoport ? "yes" : "no");
> + virBufferAsprintf(buf, " autoport='%s'",
> + def->data.spice.autoport ? "yes" : "no");
>
> - virDomainGraphicsListenDefFormatAddr(buf, glisten, flags);
> + virDomainGraphicsListenDefFormatAddr(buf, glisten, flags);
> + break;
> +
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
> + break;
> + }
>
> if (def->data.spice.keymap)
> virBufferEscapeString(buf, " keymap='%s'",
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 1d25655..1b46012 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7347,27 +7347,53 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
> goto error;
> }
>
> - glisten = virDomainGraphicsGetListen(graphics, 0);
> -
> - if (port > 0) {
> - virBufferAsprintf(&opt, "port=%u,", port);
> - hasInsecure = true;
> + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("missing listen element"));
> + goto error;
> }
>
> - if (tlsPort > 0) {
> - if (!cfg->spiceTLS) {
> + switch (glisten->type) {
Same here.
Separating the change to using switch from adding the _SOCKET case would
have made the diff nicer, but luckily we have -b.
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
> + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_UNIX)) {
> virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> - _("spice TLS port set in XML configuration,"
> - " but TLS is disabled in qemu.conf"));
> + _("unix socket for spice graphics are not supported "
> + "with this QEMU"));
> + if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
> + virDomainGraphicsListenDefPtr glisten =
> + virDomainGraphicsGetListen(dom->def->graphics[i], 0);
> +
> + if (!glisten) {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("missing listen element"));
> + return -1;
> + }
> +
> + switch (glisten->type) {
This can also be typecasted.
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
> + /* Seamless migration is supported only for listen types
> + * 'address and 'network'. */
> + if (!(mig->graphics =
> + qemuMigrationCookieGraphicsSpiceAlloc(driver,
> + dom->def->graphics[i],
> + glisten)))
> + return -1;
> + mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
> + break;
> +
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
> + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
> + break;
> + }
ACK
Jan
More information about the libvir-list
mailing list