[libvirt] [PATCH 00/17] improve graphics listen configuration

This patch series improves the way how different listen types can be specified and also introduce a new listen types for graphics devices. First improvement is to move ports auto of graphics element into listen element with type address or network. This is a first step to make the code listen-driven. Second step is to create a new listen type socket to improve the current vnc configuration and to print only socket path witout any other listen types. With the new socket type now we can add support also to spice graphics. The last improvement is to introduce new listen type none for spice graphics to specify that the spice graphics shouldn't listen anywhere by default. In case of spice graphics the new listen types socket or none are required to start a guest with OpenGL support. Pavel Hrdina (17): graphics: use enums instead of int qemu_process: move listen code out of qemuProcessSetupGraphics qemu_process: handle port allocation for VNC the same way as for Spice graphics: generate fake ports also for tests qemu_hotplug: cleanup qemuDomainChangeGraphics genericxml2xml: add several graphics tests qemu_hotplug: fix checking graphics ports graphics: don't parse listens if socket attribute is present domain_conf: parse listen attr from graphics while parsing listen elements graphics: make address attribute for listen type='address' optional domain_conf: cleanup virDomainGraphicsListenDefParseXML graphics: move port definition to listen element qemu.conf: remove vnc_auto_unix_socket vnc: use listen type=socket instead of socket attribute qemu_capabilites: add QEMU_CAPS_SPICE_UNIX spice: add support for listen type socket spice: introduce listen type none docs/formatdomain.html.in | 138 +++-- docs/schemas/domaincommon.rng | 63 ++- src/conf/domain_conf.c | 604 ++++++++++++++------- src/conf/domain_conf.h | 45 +- src/libvirt_private.syms | 1 + src/libxl/libxl_conf.c | 61 ++- src/libxl/libxl_domain.c | 17 +- src/qemu/libvirtd_qemu.aug | 1 - src/qemu/qemu.conf | 10 - src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 239 ++++---- src/qemu/qemu_conf.c | 1 - src/qemu/qemu_conf.h | 1 - src/qemu/qemu_domain.c | 19 +- src/qemu/qemu_driver.c | 12 - src/qemu/qemu_hotplug.c | 76 +-- src/qemu/qemu_migration.c | 41 +- src/qemu/qemu_parse_command.c | 41 +- src/qemu/qemu_process.c | 386 ++++++++----- src/qemu/qemu_process.h | 3 + src/qemu/test_libvirtd_qemu.aug.in | 1 - src/security/virt-aa-helper.c | 15 +- src/vbox/vbox_common.c | 30 +- src/vbox/vbox_tmpl.c | 34 +- src/vbox/vbox_uniformed_api.h | 4 +- src/vmx/vmx.c | 54 +- src/vz/vz_sdk.c | 30 +- src/xenconfig/xen_common.c | 74 +-- src/xenconfig/xen_sxpr.c | 71 +-- src/xenconfig/xen_xl.c | 45 +- .../generic-graphics-listen-back-compat-ports.xml | 30 + .../generic-graphics-vnc-listen-attr-only.xml | 28 + ...generic-graphics-vnc-listen-element-minimal.xml | 30 + ...aphics-vnc-listen-element-with-address-port.xml | 30 + ...ic-graphics-vnc-listen-element-with-address.xml | 30 + .../generic-graphics-vnc-manual-port.xml | 28 + .../generic-graphics-vnc-minimal.xml | 28 + .../generic-graphics-vnc-socket-listen.xml | 30 + .../generic-graphics-vnc-socket.xml | 28 + .../generic-graphics-listen-back-compat-ports.xml | 30 + .../generic-graphics-listen-back-compat.xml | 2 +- .../generic-graphics-vnc-listen-attr-only.xml | 30 + ...generic-graphics-vnc-listen-element-minimal.xml | 30 + ...aphics-vnc-listen-element-with-address-port.xml | 30 + ...ic-graphics-vnc-listen-element-with-address.xml | 30 + .../generic-graphics-vnc-manual-port.xml | 30 + .../generic-graphics-vnc-minimal.xml | 30 + .../generic-graphics-vnc-socket-listen.xml | 30 + .../generic-graphics-vnc-socket.xml | 30 + tests/genericxml2xmltest.c | 10 + .../qemuargv2xml-graphics-vnc-policy.xml | 2 +- .../qemuargv2xml-graphics-vnc-sasl.xml | 2 +- .../qemuargv2xml-graphics-vnc-socket.xml | 4 +- .../qemuargv2xml-graphics-vnc-tls.xml | 2 +- .../qemuargv2xml-graphics-vnc-websocket.xml | 2 +- .../qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml | 2 +- ...qemuhotplug-console-compat-2+console-virtio.xml | 2 +- .../qemuhotplug-graphics-spice-listen-network.xml | 2 +- .../qemuxml2argv-console-compat-2.xml | 2 +- .../qemuxml2argv-controller-order.args | 2 +- ...muxml2argv-graphics-spice-auto-unix-socket.args | 21 + ...emuxml2argv-graphics-spice-auto-unix-socket.xml | 30 + .../qemuxml2argv-graphics-spice-unix-socket.args | 20 + .../qemuxml2argv-graphics-spice-unix-socket.xml | 30 + ...qemuxml2argv-graphics-vnc-auto-unix-socket.args | 20 + .../qemuxml2argv-graphics-vnc-auto-unix-socket.xml | 30 + .../qemuxml2argv-graphics-vnc-autosocket.args | 22 - .../qemuxml2argv-graphics-vnc-autosocket.xml | 34 -- .../qemuxml2argv-graphics-vnc-unix-socket.args | 20 + .../qemuxml2argv-graphics-vnc-unix-socket.xml | 30 + .../qemuxml2argv-hugepages-numa.args | 2 +- .../qemuxml2argv-video-device-pciaddr-default.args | 2 +- .../qemuxml2argv-video-virtio-gpu-spice-gl.args | 2 +- tests/qemuxml2argvtest.c | 8 + .../qemuxml2xmlout-graphics-listen-network.xml | 2 +- .../qemuxml2xmlout-graphics-listen-network2.xml | 4 +- ...uxml2xmlout-graphics-spice-auto-unix-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-spice-compression.xml | 2 +- .../qemuxml2xmlout-graphics-spice-qxl-vga.xml | 2 +- .../qemuxml2xmlout-graphics-spice-timeout.xml | 4 +- .../qemuxml2xmlout-graphics-spice-unix-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-spice.xml | 2 +- ...emuxml2xmlout-graphics-vnc-auto-unix-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 39 -- .../qemuxml2xmlout-graphics-vnc-no-listen-attr.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-sasl.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-tls.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-unix-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-vnc-websocket.xml | 2 +- .../qemuxml2xmlout-graphics-vnc.xml | 2 +- .../qemuxml2xmlout-interface-server.xml | 4 +- .../qemuxml2xmlout-net-bandwidth.xml | 4 +- .../qemuxml2xmlout-net-bandwidth2.xml | 4 +- .../qemuxml2xmlout-pci-bridge.xml | 2 +- ...emuxml2xmlout-seclabel-dynamic-none-relabel.xml | 2 +- .../qemuxml2xmlout-serial-spiceport.xml | 2 +- .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 3 +- tests/qemuxml2xmltest.c | 11 +- tests/sexpr2xmldata/sexpr2xml-curmem.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 4 +- .../sexpr2xml-fv-serial-dev-2-ports.xml | 4 +- .../sexpr2xml-fv-serial-dev-2nd-port.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 4 +- .../sexpr2xml-fv-serial-tcp-telnet.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-fv.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 4 +- .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +- .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 4 +- tests/sexpr2xmldata/sexpr2xml-vif-rate.xml | 4 +- tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 4 +- .../test-disk-positional-parms-full.xml | 2 +- .../test-disk-positional-parms-partial.xml | 2 +- ...est-fullvirt-direct-kernel-boot-bogus-extra.xml | 2 +- .../test-fullvirt-direct-kernel-boot-extra.xml | 2 +- .../test-fullvirt-direct-kernel-boot.xml | 2 +- tests/xlconfigdata/test-fullvirt-multiusb.xml | 2 +- tests/xlconfigdata/test-fullvirt-nohap.xml | 2 +- tests/xlconfigdata/test-new-disk.xml | 2 +- tests/xlconfigdata/test-rbd-multihost-noauth.xml | 2 +- tests/xlconfigdata/test-spice-features.xml | 2 +- tests/xlconfigdata/test-spice.xml | 2 +- tests/xlconfigdata/test-vif-rate.xml | 2 +- tests/xmconfigdata/test-escape-paths.xml | 2 +- .../xmconfigdata/test-fullvirt-default-feature.xml | 2 +- tests/xmconfigdata/test-fullvirt-force-hpet.xml | 2 +- tests/xmconfigdata/test-fullvirt-force-nohpet.xml | 2 +- tests/xmconfigdata/test-fullvirt-localtime.xml | 2 +- tests/xmconfigdata/test-fullvirt-net-netfront.xml | 2 +- tests/xmconfigdata/test-fullvirt-new-cdrom.xml | 2 +- tests/xmconfigdata/test-fullvirt-nohap.xml | 2 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.xml | 2 +- .../test-fullvirt-serial-dev-2-ports.xml | 2 +- .../test-fullvirt-serial-dev-2nd-port.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +- .../test-fullvirt-serial-tcp-telnet.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +- tests/xmconfigdata/test-fullvirt-sound.xml | 2 +- tests/xmconfigdata/test-fullvirt-usbmouse.xml | 2 +- tests/xmconfigdata/test-fullvirt-usbtablet.xml | 2 +- tests/xmconfigdata/test-fullvirt-utc.xml | 2 +- tests/xmconfigdata/test-no-source-cdrom.xml | 4 +- tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +- .../test-paravirt-new-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +- tests/xmconfigdata/test-pci-devs.xml | 4 +- 173 files changed, 2392 insertions(+), 1014 deletions(-) create mode 100644 tests/genericxml2xmlindata/generic-graphics-listen-back-compat-ports.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-attr-only.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address-port.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-manual-port.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-minimal.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-socket-listen.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-socket.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-listen-back-compat-ports.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address-port.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.args delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-unix-socket.xml delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-unix-socket.xml -- 2.8.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 2 ++ src/conf/domain_conf.h | 14 +++++++------- src/libxl/libxl_conf.c | 8 ++++++++ src/qemu/qemu_command.c | 14 +++++++++++++- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2c97bc1..73f8620 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21519,6 +21519,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, virDomainGraphicsAuthDefFormatAttr(buf, &def->data.spice.auth, flags); break; + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; } for (i = 0; i < def->nListens; i++) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b7b099c..b825477 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1552,7 +1552,7 @@ typedef enum { typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef; typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr; struct _virDomainGraphicsListenDef { - int type; /* enum virDomainGraphicsListenType */ + virDomainGraphicsListenType type; char *address; char *network; bool fromConfig; /* true if the @address is config file originated */ @@ -1564,7 +1564,7 @@ struct _virDomainGraphicsDef { * Value 0 means port wasn't specified in XML at all. * Positive value is actual port number given in XML. */ - int type; + virDomainGraphicsType type; union { struct { int port; @@ -1597,20 +1597,20 @@ struct _virDomainGraphicsDef { int tlsPort; bool portReserved; bool tlsPortReserved; - int mousemode; + virDomainGraphicsSpiceMouseMode mousemode; char *keymap; virDomainGraphicsAuthDef auth; bool autoport; int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST]; - int defaultMode; /* enum virDomainGraphicsSpiceChannelMode */ + virDomainGraphicsSpiceChannelMode defaultMode; int image; int jpeg; int zlib; int playback; int streaming; - int copypaste; /* enum virTristateBool */ - int filetransfer; /* enum virTristateBool */ - int gl; /* enum virTristateBool */ + virTristateBool copypaste; + virTristateBool filetransfer; + virTristateBool gl; } spice; } data; /* nListens, listens, and *port are only useful if type is vnc, diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 30f2ce9..d927b37 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1463,6 +1463,12 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, if (VIR_STRDUP(x_vfb->keymap, l_vfb->data.vnc.keymap) < 0) return -1; break; + + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; } return 0; @@ -1579,6 +1585,8 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_SERVER: libxl_defbool_set(&b_info->u.hvm.spice.agent_mouse, false); break; + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST: + break; } #ifdef LIBXL_HAVE_SPICE_VDAGENT diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 08c6c61..8ec550e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7381,6 +7381,10 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, if (VIR_STRDUP(gListen->address, netAddr) < 0) goto error; break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } } @@ -7538,6 +7542,10 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, if (VIR_STRDUP(gListen->address, listenAddr) < 0) goto error; break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } } @@ -7663,7 +7671,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, } } - if (graphics->data.spice.gl == VIR_TRISTATE_SWITCH_ON) { + if (graphics->data.spice.gl == VIR_TRISTATE_BOOL_YES) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("This QEMU doesn't support spice OpenGL")); @@ -9256,6 +9264,10 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver, case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: ++spice; break; + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; } } -- 2.8.2

On Thu, May 05, 2016 at 18:20:20 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 2 ++ src/conf/domain_conf.h | 14 +++++++------- src/libxl/libxl_conf.c | 8 ++++++++ src/qemu/qemu_command.c | 14 +++++++++++++- 4 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b7b099c..b825477 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1552,7 +1552,7 @@ typedef enum { typedef struct _virDomainGraphicsListenDef virDomainGraphicsListenDef; typedef virDomainGraphicsListenDef *virDomainGraphicsListenDefPtr; struct _virDomainGraphicsListenDef { - int type; /* enum virDomainGraphicsListenType */ + virDomainGraphicsListenType type;
Same as below. Assigned in virDomainGraphicsListenDefParseXML.
char *address; char *network; bool fromConfig; /* true if the @address is config file originated */ @@ -1564,7 +1564,7 @@ struct _virDomainGraphicsDef { * Value 0 means port wasn't specified in XML at all. * Positive value is actual port number given in XML. */ - int type; + virDomainGraphicsType type;
In virDomainGraphicsDefParseXML this struct member is directly assigned without a temp variable so virDomainGraphicsTypeFromString won't be able to return error as enum types are unsigned .
union { struct { int port;
ACK with a temp variable added. Peter

Move adding the config listen type=address if there is none in qemuProcessPrepareDomain and move check for multiple listens to qemuProcessStartValidate. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 348b392..17fd566 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4386,26 +4386,6 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0) goto cleanup; } - - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC || - graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (graphics->nListens == 0) { - const char *listenAddr - = graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ? - cfg->vncListen : cfg->spiceListen; - - if (virDomainGraphicsListenAppendAddress(graphics, - listenAddr) < 0) - goto cleanup; - - graphics->listens[0].fromConfig = true; - } else if (graphics->nListens > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("QEMU does not support multiple listen " - "addresses for one graphics device.")); - goto cleanup; - } - } } ret = 0; @@ -4630,6 +4610,8 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, bool snapshot, unsigned int flags) { + size_t i; + if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); @@ -4660,6 +4642,28 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, qemuProcessStartWarnShmem(vm); + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (graphics->nListens > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU does not support multiple listens for " + "one graphics device.")); + 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; } @@ -5086,6 +5090,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))) @@ -5138,6 +5143,35 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) goto cleanup; + /* Fill in run-time values for graphics devices. */ + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + char *listenAddr = NULL; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + listenAddr = cfg->vncListen; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (!listenAddr) + listenAddr = cfg->spiceListen; + + if (graphics->nListens == 0) { + if (virDomainGraphicsListenAppendAddress(graphics, + listenAddr) < 0) + goto cleanup; + + graphics->listens[0].fromConfig = true; + } + 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; + } + } + /* "volume" type disk's source must be translated before * cgroup and security setting. */ @@ -5162,6 +5196,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, cleanup: VIR_FREE(nodeset); virObjectUnref(caps); + virObjectUnref(cfg); return ret; } -- 2.8.2

On Thu, May 05, 2016 at 18:20:21 +0200, Pavel Hrdina wrote:
Move adding the config listen type=address if there is none in qemuProcessPrepareDomain and move check for multiple listens to qemuProcessStartValidate.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 348b392..17fd566 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c
@@ -5138,6 +5143,35 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) goto cleanup;
+ /* Fill in run-time values for graphics devices. */ + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + char *listenAddr = NULL; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + listenAddr = cfg->vncListen; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (!listenAddr)
This fallthrough case with checking whether this was set is weird. Looking at the caps code it looks like its guaranteed that both vncListen and spiceListen are always allocated, but still it looks like both types should either have individual calls to virDomainGraphicsListenAppendAddress or the call should happen after the switch so that we don't obscure it using the fallthrough case.
+ listenAddr = cfg->spiceListen; + + if (graphics->nListens == 0) { + if (virDomainGraphicsListenAppendAddress(graphics, + listenAddr) < 0) + goto cleanup; + + graphics->listens[0].fromConfig = true; + } + 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; + } + } + /* "volume" type disk's source must be translated before * cgroup and security setting. */

On Fri, May 06, 2016 at 02:10:10PM +0200, Peter Krempa wrote:
On Thu, May 05, 2016 at 18:20:21 +0200, Pavel Hrdina wrote:
Move adding the config listen type=address if there is none in qemuProcessPrepareDomain and move check for multiple listens to qemuProcessStartValidate.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 348b392..17fd566 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c
@@ -5138,6 +5143,35 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) goto cleanup;
+ /* Fill in run-time values for graphics devices. */ + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + char *listenAddr = NULL; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + listenAddr = cfg->vncListen; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (!listenAddr)
This fallthrough case with checking whether this was set is weird. Looking at the caps code it looks like its guaranteed that both vncListen and spiceListen are always allocated, but still it looks like both types should either have individual calls to virDomainGraphicsListenAppendAddress or the call should happen after the switch so that we don't obscure it using the fallthrough case.
Right, it can be easily updated that the listenAddr is set only for vnc or spice and the virDomainGraphicsListenAppendAddress could be moved out of the switch with this condition: if (graphics->nListens == 0 && listeAddr). Do you require v2 for this?
+ listenAddr = cfg->spiceListen; + + if (graphics->nListens == 0) { + if (virDomainGraphicsListenAppendAddress(graphics, + listenAddr) < 0) + goto cleanup; + + graphics->listens[0].fromConfig = true; + } + 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; + } + } + /* "volume" type disk's source must be translated before * cgroup and security setting. */

On Fri, May 06, 2016 at 14:52:02 +0200, Pavel Hrdina wrote:
On Fri, May 06, 2016 at 02:10:10PM +0200, Peter Krempa wrote:
On Thu, May 05, 2016 at 18:20:21 +0200, Pavel Hrdina wrote:
Move adding the config listen type=address if there is none in qemuProcessPrepareDomain and move check for multiple listens to qemuProcessStartValidate.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 75 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 20 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 348b392..17fd566 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c
@@ -5138,6 +5143,35 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) goto cleanup;
+ /* Fill in run-time values for graphics devices. */ + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + char *listenAddr = NULL; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + listenAddr = cfg->vncListen; + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (!listenAddr)
This fallthrough case with checking whether this was set is weird. Looking at the caps code it looks like its guaranteed that both vncListen and spiceListen are always allocated, but still it looks like both types should either have individual calls to virDomainGraphicsListenAppendAddress or the call should happen after the switch so that we don't obscure it using the fallthrough case.
Right, it can be easily updated that the listenAddr is set only for vnc or spice and the virDomainGraphicsListenAppendAddress could be moved out of the switch with this condition: if (graphics->nListens == 0 && listeAddr). Do you require v2 for this?
Not really. This is what I'd do. ACK using that approach

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_driver.c | 6 +++--- src/qemu/qemu_process.c | 29 ++++++++++++++++++++++++----- src/qemu/qemu_process.h | 3 +++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3d0c7c8..396e64c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7063,9 +7063,9 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, /* do fake auto-alloc of graphics ports, if such config is used */ for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - !graphics->data.vnc.socket && graphics->data.vnc.autoport) { - graphics->data.vnc.port = 5900; + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + if (qemuProcessVNCAllocatePorts(driver, graphics, false) < 0) + goto cleanup; } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 17fd566..e2f22de 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3856,15 +3856,23 @@ qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver) virDomainObjListForEach(driver->domains, qemuProcessReconnectHelper, &data); } -static int +int qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, - virDomainGraphicsDefPtr graphics) + virDomainGraphicsDefPtr graphics, + bool allocate) { unsigned short port; if (graphics->data.vnc.socket) return 0; + if (!allocate) { + if (graphics->data.vnc.autoport) + graphics->data.vnc.port = 5900; + + return 0; + } + if (graphics->data.vnc.autoport) { if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) return -1; @@ -4379,12 +4387,23 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (qemuProcessVNCAllocatePorts(driver, graphics) < 0) + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + if (qemuProcessVNCAllocatePorts(driver, graphics, true) < 0) goto cleanup; - } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0) 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; } } diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index b7262a7..9e2e036 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -175,6 +175,9 @@ bool qemuProcessAutoDestroyActive(virQEMUDriverPtr driver, int qemuProcessSetSchedParams(int id, pid_t pid, size_t nsp, virDomainThreadSchedParamPtr sp); +int qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, + virDomainGraphicsDefPtr graphics, + bool allocate); int qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, virQEMUDriverConfigPtr cfg, virDomainGraphicsDefPtr graphics, -- 2.8.2

On Thu, May 05, 2016 at 18:20:22 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_driver.c | 6 +++--- src/qemu/qemu_process.c | 29 ++++++++++++++++++++++++----- src/qemu/qemu_process.h | 3 +++ 3 files changed, 30 insertions(+), 8 deletions(-)
ACK

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_driver.c | 12 ------------ src/qemu/qemu_process.c | 13 +++++++++++++ tests/qemuxml2argvdata/qemuxml2argv-controller-order.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args | 2 +- .../qemuxml2argv-video-device-pciaddr-default.args | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 396e64c..d4d3d5b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7060,18 +7060,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn, net->mac = mac; } - /* do fake auto-alloc of graphics ports, if such config is used */ - for (i = 0; i < vm->def->ngraphics; ++i) { - virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (qemuProcessVNCAllocatePorts(driver, graphics, false) < 0) - goto cleanup; - } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0) - goto cleanup; - } - } - if (!(cmd = qemuProcessCreatePretendCmd(conn, driver, vm, NULL, qemuCheckFips(), true, VIR_QEMU_PROCESS_START_COLD))) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e2f22de..86b13bd 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5144,6 +5144,19 @@ qemuProcessPrepareDomain(virConnectPtr conn, priv->autoNodeset))) goto cleanup; } + } else { + /* If we are pretending to create only QEMU command line or for tests + * do fake allocation of graphics ports. */ + for (i = 0; i < vm->def->ngraphics; ++i) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + if (qemuProcessVNCAllocatePorts(driver, graphics, false) < 0) + goto cleanup; + } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, false) < 0) + goto cleanup; + } + } } /* diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args index b47193a..b46685f 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args @@ -37,7 +37,7 @@ media=cdrom,id=drive-ide0-1-0 \ -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\ id=channel0,name=com.redhat.spice.0 \ -device usb-tablet,id=input0 \ --spice port=0 \ +-spice port=5901,tls-port=5902,addr=0.0.0.0,x509-dir=/etc/pki/libvirt-spice \ -vga cirrus \ -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \ -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args index 56956a3..ae8ef71 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args @@ -47,7 +47,7 @@ id=channel0,name=org.qemu.guest_agent.0 \ -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\ id=channel1,name=com.redhat.spice.0 \ -device usb-tablet,id=input0 \ --spice port=0 \ +-spice port=5901,tls-port=5902,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \ -vga qxl \ -global qxl-vga.ram_size=67108864 \ -global qxl-vga.vram_size=67108864 \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args index c85c550..40937b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-device-pciaddr-default.args @@ -19,7 +19,7 @@ QEMU_AUDIO_DRV=none \ -drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\ id=drive-ide0-0-0,cache=none \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --vnc 127.0.0.1:-5900 \ +-vnc 127.0.0.1:0 \ -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\ addr=0x3 \ -device qxl,id=video1,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x4 \ -- 2.8.2

On Thu, May 05, 2016 at 18:20:23 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_driver.c | 12 ------------ src/qemu/qemu_process.c | 13 +++++++++++++ tests/qemuxml2argvdata/qemuxml2argv-controller-order.args | 2 +- tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args | 2 +- .../qemuxml2argv-video-device-pciaddr-default.args | 2 +- 5 files changed, 16 insertions(+), 15 deletions(-)
While I'm okay by this change itself I don't really see a reason why qemuProcessSPICEAllocatePorts and qemuProcessVNCAllocatePorts should be called in two distinct places. With the new helpers I think we have the facility to select the @alloc parameter according to the VIR_QEMU_PROCESS_START_PRETEND flag and call it just once.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 03e5309..97f4152 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2607,9 +2607,10 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, virDomainGraphicsDefPtr dev) { virDomainGraphicsDefPtr olddev = qemuDomainFindGraphics(vm, dev); - int ret = -1; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + const char *type = virDomainGraphicsTypeToString(dev->type); size_t i; + int ret = -1; if (!olddev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2618,8 +2619,9 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, } if (dev->nListens != olddev->nListens) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change the number of listen addresses")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change the number of listen addresses " + "on '%s' graphics"), type); goto cleanup; } @@ -2628,30 +2630,30 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, virDomainGraphicsListenDefPtr oldlisten = &olddev->listens[i]; if (newlisten->type != oldlisten->type) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change the type of listen address")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change the type of listen address " + "on '%s' graphics"), type); goto cleanup; } switch ((virDomainGraphicsListenType) newlisten->type) { case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: if (STRNEQ_NULLABLE(newlisten->address, oldlisten->address)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ? - _("cannot change listen address setting on vnc graphics") : - _("cannot change listen address setting on spice graphics")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen address setting " + "on '%s' graphics"), type); goto cleanup; } - break; + break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: if (STRNEQ_NULLABLE(newlisten->network, oldlisten->network)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ? - _("cannot change listen network setting on vnc graphics") : - _("cannot change listen network setting on spice graphics")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen address setting " + "on '%s' graphics"), type); goto cleanup; } + break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: @@ -2761,8 +2763,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, default: virReportError(VIR_ERR_INTERNAL_ERROR, - _("unable to change config on '%s' graphics type"), - virDomainGraphicsTypeToString(dev->type)); + _("unable to change config on '%s' graphics type"), type); break; } -- 2.8.2

On Thu, May 05, 2016 at 18:20:24 +0200, Pavel Hrdina wrote: In subject: This mostly improves error messages, so cleanup is not really a spot-on description of this patch.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 03e5309..97f4152 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c
@@ -2618,8 +2619,9 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, }
if (dev->nListens != olddev->nListens) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change the number of listen addresses")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change the number of listen addresses " + "on '%s' graphics"), type);
I'm not quite sure whether the 'on' preposition is correct in this context, but I don't have a better suggestion.
goto cleanup; }
@@ -2628,30 +2630,30 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, virDomainGraphicsListenDefPtr oldlisten = &olddev->listens[i];
if (newlisten->type != oldlisten->type) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change the type of listen address")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change the type of listen address " + "on '%s' graphics"), type); goto cleanup; }
switch ((virDomainGraphicsListenType) newlisten->type) { case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: if (STRNEQ_NULLABLE(newlisten->address, oldlisten->address)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ? - _("cannot change listen address setting on vnc graphics") : - _("cannot change listen address setting on spice graphics")); + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen address setting " + "on '%s' graphics"), type); goto cleanup; } - break;
+ break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
I prefer the empty line before the next 'case' statement.
if (STRNEQ_NULLABLE(newlisten->network, oldlisten->network)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - dev->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ? - _("cannot change listen network setting on vnc graphics") : - _("cannot change listen network setting on spice graphics"));
... ah so it was pre-existing. I don't care about it then :)
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen address setting " + "on '%s' graphics"), type); goto cleanup; } + break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
ACK

On Fri, May 06, 2016 at 02:30:35PM +0200, Peter Krempa wrote:
On Thu, May 05, 2016 at 18:20:24 +0200, Pavel Hrdina wrote:
In subject: This mostly improves error messages, so cleanup is not really a spot-on description of this patch.
Not exactly, the error messages are the same, but to make the subject better I'll change it to "cleanup error messages in qemuDomainChangeGraphics". Thanks

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- .../generic-graphics-vnc-listen-attr-only.xml | 28 ++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-listen-attr-only.xml | 30 ++++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ tests/genericxml2xmltest.c | 7 +++++ 15 files changed, 413 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-attr-only.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-manual-port.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-minimal.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-socket-listen.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-socket.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-attr-only.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-attr-only.xml new file mode 100644 index 0000000..f27eaa2 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-attr-only.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' listen='127.0.0.1'/> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml new file mode 100644 index 0000000..8bbf5df --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address.xml new file mode 100644 index 0000000..8bbf5df --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-manual-port.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-manual-port.xml new file mode 100644 index 0000000..580c27d --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-manual-port.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='5900' autoport='yes'/> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-minimal.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-minimal.xml new file mode 100644 index 0000000..4ffba85 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-minimal.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'/> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-socket-listen.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-socket-listen.xml new file mode 100644 index 0000000..5f82abc --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-socket-listen.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-socket.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-socket.xml new file mode 100644 index 0000000..cc26a33 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-socket.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml new file mode 100644 index 0000000..ee4909b --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml new file mode 100644 index 0000000..ee4909b --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml new file mode 100644 index 0000000..ee4909b --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml new file mode 100644 index 0000000..ac8c279 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'/> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml new file mode 100644 index 0000000..ac8c279 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'/> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml new file mode 100644 index 0000000..a3b82fe --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'> + <listen type='address' address='127.0.0.1'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml new file mode 100644 index 0000000..d8742c6 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml @@ -0,0 +1,28 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 70a5203..70ecd2d 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -77,9 +77,16 @@ mymain(void) DO_TEST_DIFFERENT("disk-virtio"); + DO_TEST_DIFFERENT("graphics-vnc-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-manual-port"); + DO_TEST_DIFFERENT("graphics-vnc-socket"); + DO_TEST_DIFFERENT("graphics-vnc-socket-listen"); DO_TEST_DIFFERENT("graphics-listen-back-compat"); DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address"); DO_TEST_FULL("name-slash-parse", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); -- 2.8.2

On Thu, May 05, 2016 at 18:20:25 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> ---
[...]
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 70a5203..70ecd2d 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -77,9 +77,16 @@ mymain(void)
DO_TEST_DIFFERENT("disk-virtio");
+ DO_TEST_DIFFERENT("graphics-vnc-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-manual-port"); + DO_TEST_DIFFERENT("graphics-vnc-socket"); + DO_TEST_DIFFERENT("graphics-vnc-socket-listen"); DO_TEST_DIFFERENT("graphics-listen-back-compat"); DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address");
I guess the test case names are self explanatory enough to require a commit message describing the tests. ACK

On Fri, May 06, 2016 at 02:33:03PM +0200, Peter Krempa wrote:
On Thu, May 05, 2016 at 18:20:25 +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> ---
[...]
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 70a5203..70ecd2d 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -77,9 +77,16 @@ mymain(void)
DO_TEST_DIFFERENT("disk-virtio");
+ DO_TEST_DIFFERENT("graphics-vnc-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-manual-port"); + DO_TEST_DIFFERENT("graphics-vnc-socket"); + DO_TEST_DIFFERENT("graphics-vnc-socket-listen"); DO_TEST_DIFFERENT("graphics-listen-back-compat"); DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address");
I guess the test case names are self explanatory enough to require a commit message describing the tests.
ACK
Thanks, I've pushed patches 1-6 except patch 4. Pavel

On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- .../generic-graphics-vnc-listen-attr-only.xml | 28 ++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-listen-attr-only.xml | 30 ++++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ tests/genericxml2xmltest.c | 7 +++++
The generic XML parser doesn't have any restriction on duplicate <graphics type='vnc'/>, so these could be combined to possibly one XML file. I know there really isn't much precedent for that at the moment, but given the massive size of our test suite and the fact that much of the time is spent on redundant parsing and XML formatting, personally I'd like to see things move in that direction. - Cole

On Fri, May 06, 2016 at 08:43:25AM -0400, Cole Robinson wrote:
On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- .../generic-graphics-vnc-listen-attr-only.xml | 28 ++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-listen-attr-only.xml | 30 ++++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ tests/genericxml2xmltest.c | 7 +++++
The generic XML parser doesn't have any restriction on duplicate <graphics type='vnc'/>, so these could be combined to possibly one XML file.
I know there really isn't much precedent for that at the moment, but given the massive size of our test suite and the fact that much of the time is spent on redundant parsing and XML formatting, personally I'd like to see things move in that direction.
The idea itself isn't bad, but I think that it's better to have vnc and spice in separate XML to make it clear which test failed so you know that it's vnc graphics or spice graphics directly only from the test name. I've tried this command on my desktop: "time ./run tests/.libs/qemuxml2xmltest" and considering that there are 837 test cases the output of time is: real 0m0.821s user 0m0.746s sys 0m0.034s So we don't spent that much time while parsing and formatting XML. Pavel

On 05/06/2016 09:21 AM, Pavel Hrdina wrote:
On Fri, May 06, 2016 at 08:43:25AM -0400, Cole Robinson wrote:
On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- .../generic-graphics-vnc-listen-attr-only.xml | 28 ++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-listen-attr-only.xml | 30 ++++++++++++++++++++++ ...generic-graphics-vnc-listen-element-minimal.xml | 30 ++++++++++++++++++++++ ...ic-graphics-vnc-listen-element-with-address.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-manual-port.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-minimal.xml | 28 ++++++++++++++++++++ .../generic-graphics-vnc-socket-listen.xml | 30 ++++++++++++++++++++++ .../generic-graphics-vnc-socket.xml | 28 ++++++++++++++++++++ tests/genericxml2xmltest.c | 7 +++++
The generic XML parser doesn't have any restriction on duplicate <graphics type='vnc'/>, so these could be combined to possibly one XML file.
I know there really isn't much precedent for that at the moment, but given the massive size of our test suite and the fact that much of the time is spent on redundant parsing and XML formatting, personally I'd like to see things move in that direction.
The idea itself isn't bad, but I think that it's better to have vnc and spice in separate XML to make it clear which test failed so you know that it's vnc graphics or spice graphics directly only from the test name.
Yes, agreed with splitting on VNC vs spice at least.
I've tried this command on my desktop:
"time ./run tests/.libs/qemuxml2xmltest"
and considering that there are 837 test cases the output of time is:
real 0m0.821s user 0m0.746s sys 0m0.034s
So we don't spent that much time while parsing and formatting XML.
Fair enough, but truly the big time sink is domainschematest... - Cole

We cannot change ports for running domain and we should error out if autoport is enabled. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_hotplug.c | 13 +++++-------- .../qemuhotplug-graphics-spice-listen-network.xml | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 97f4152..ca95004 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2665,9 +2665,8 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, switch (dev->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if ((olddev->data.vnc.autoport != dev->data.vnc.autoport) || - (!dev->data.vnc.autoport && - (olddev->data.vnc.port != dev->data.vnc.port))) { + if (olddev->data.vnc.autoport != dev->data.vnc.autoport || + olddev->data.vnc.port != dev->data.vnc.port) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot change port settings on vnc graphics")); goto cleanup; @@ -2709,11 +2708,9 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if ((olddev->data.spice.autoport != dev->data.spice.autoport) || - (!dev->data.spice.autoport && - (olddev->data.spice.port != dev->data.spice.port)) || - (!dev->data.spice.autoport && - (olddev->data.spice.tlsPort != dev->data.spice.tlsPort))) { + if (olddev->data.spice.autoport != dev->data.spice.autoport || + olddev->data.spice.port != dev->data.spice.port || + olddev->data.spice.tlsPort != dev->data.spice.tlsPort) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot change port settings on spice graphics")); goto cleanup; diff --git a/tests/qemuhotplugtestdata/qemuhotplug-graphics-spice-listen-network.xml b/tests/qemuhotplugtestdata/qemuhotplug-graphics-spice-listen-network.xml index 426a14d..f2a6aeb 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-graphics-spice-listen-network.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-graphics-spice-listen-network.xml @@ -1,4 +1,4 @@ - <graphics autoport='yes' connected='disconnect' keymap='en-us' passwd='password2' passwdValidTo='2013-06-20T01:34:37' port='5900' tlsPort='5901' type='spice'> + <graphics autoport='yes' connected='disconnect' keymap='en-us' passwd='password2' passwdValidTo='2013-06-20T01:34:37' type='spice'> <listen address='10.65.210.231' network='vdsm-rhevm' type='network'/> <channel mode='secure' name='main'/> <channel mode='secure' name='display'/> -- 2.8.2

If socket attribute is present we start VNC that listens only on that unix socket. This makes the parser behave the same way as we actually use the socket attribute. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 8 ++++++++ .../genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 73f8620..329b911 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10720,11 +10720,18 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, xmlNodePtr save = ctxt->node; virDomainGraphicsListenDefPtr address = NULL; char *listenAddr = NULL; + char *socketPath = NULL; int nListens; int ret = -1; ctxt->node = node; + if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && + (socketPath = virXMLPropString(node, "socket"))) { + ret = 0; + goto error; + } + /* parse the <listen> subelements for graphics types that support it */ nListens = virXPathNodeSet("./listen", ctxt, &listenNodes); if (nListens < 0) @@ -10777,6 +10784,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, error: VIR_FREE(listenNodes); VIR_FREE(listenAddr); + VIR_FREE(socketPath); ctxt->node = save; return ret; } diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml index a3b82fe..d8742c6 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml @@ -19,9 +19,7 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'> - <listen type='address' address='127.0.0.1'/> - </graphics> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> -- 2.8.2

Move the compatibility code out of virDomainGraphicsListensParseXML() into virDomainGraphicsListenDefParseXML(). This also fixes a small inconsistency between the code and error message itself. Before this patch we would search first listen element that is type='address' to validate listen and address attributes. After this patch we always take the first listen element regardless of the type. This shouldn't break anything since all drivers supports only one listen. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 85 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 329b911..2e19f06 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10640,18 +10640,36 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, return 0; } + +/** + * virDomainGraphicsListenDefParseXML: + * @def: listen def pointer to be filled + * @node: xml node of <listen/> element + * @parent: xml node of <graphics/> element + * @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_* + * + * Parses current <listen/> element from @node to @def. For backward + * compatibility the @parent element should contain node of <graphics/> element + * for the first <listen/> element in order to validate attributes from both + * elements. + */ static int virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, xmlNodePtr node, + xmlNodePtr parent, unsigned int flags) { int ret = -1; - char *type = virXMLPropString(node, "type"); - char *address = virXMLPropString(node, "address"); - char *network = virXMLPropString(node, "network"); + char *type = virXMLPropString(node, "type"); + char *address = virXMLPropString(node, "address"); + char *network = virXMLPropString(node, "network"); char *fromConfig = virXMLPropString(node, "fromConfig"); + char *addressCompat = NULL; int tmp; + if (parent) + addressCompat = virXMLPropString(parent, "listen"); + if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", _("graphics listen type must be specified")); @@ -10664,9 +10682,21 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, goto error; } - /* address is recognized if either type='address', or if - * type='network' and we're looking at live XML (i.e. *not* - * inactive). It is otherwise ignored. */ + if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { + if (address && addressCompat && STRNEQ(address, addressCompat)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("graphics 'listen' attribute '%s' must match " + "'address' attribute of first listen element " + "(found '%s')"), addressCompat, address); + goto error; + } + + if (!address) { + address = addressCompat; + addressCompat = NULL; + } + } + if (address && address[0] && (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && @@ -10706,6 +10736,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, VIR_FREE(address); VIR_FREE(network); VIR_FREE(fromConfig); + VIR_FREE(addressCompat); return ret; } @@ -10718,8 +10749,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, { xmlNodePtr *listenNodes = NULL; xmlNodePtr save = ctxt->node; - virDomainGraphicsListenDefPtr address = NULL; - char *listenAddr = NULL; + virDomainGraphicsListenDef newListen = {0}; char *socketPath = NULL; int nListens; int ret = -1; @@ -10746,44 +10776,31 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, for (i = 0; i < nListens; i++) { if (virDomainGraphicsListenDefParseXML(&def->listens[i], listenNodes[i], + i == 0 ? node : NULL, flags) < 0) goto error; - if (!address && - def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) - address = &def->listens[i]; - def->nListens++; } VIR_FREE(listenNodes); - } - - /* listen attribute of <graphics> is also supported by these, - * but must match the 'address' attribute of the first listen - * that is type='address' (if present) */ - listenAddr = virXMLPropString(node, "listen"); - if (STREQ_NULLABLE(listenAddr, "")) - VIR_FREE(listenAddr); + } else { + /* If not <listen/> element was found in XML for backward compatibility + * we should try to parse 'listen' attribute from <graphics/> element. */ + newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; + newListen.address = virXMLPropString(node, "listen"); + if (STREQ_NULLABLE(newListen.address, "")) + VIR_FREE(newListen.address); - if (address && listenAddr && - STRNEQ_NULLABLE(address->address, listenAddr)) { - virReportError(VIR_ERR_XML_ERROR, - _("graphics listen attribute %s must match address " - "attribute of first listen element (found %s)"), - listenAddr, address->address); - goto error; + if (newListen.address && + VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) + goto error; } - /* There were no <listen> elements, so we can just - * directly set listenAddr as listens[0]->address */ - if (listenAddr && def->nListens == 0 && - virDomainGraphicsListenAppendAddress(def, listenAddr) < 0) - goto error; - ret = 0; error: + if (ret < 0) + virDomainGraphicsListenDefClear(&newListen); VIR_FREE(listenNodes); - VIR_FREE(listenAddr); VIR_FREE(socketPath); ctxt->node = save; return ret; -- 2.8.2

We support omitting listen attribute of graphics element so we should also support omitting address attribute of listen element. This patch also updates libvirt to always add a listen element into domain XML except for VNC graphics if socket attribute is specified. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 32 +++++++++++++--------- docs/schemas/domaincommon.rng | 8 ++++-- src/conf/domain_conf.c | 3 +- src/qemu/qemu_process.c | 15 ++++++---- src/vbox/vbox_common.c | 6 ++-- src/vmx/vmx.c | 8 ++---- src/xenconfig/xen_common.c | 11 +++++--- src/xenconfig/xen_sxpr.c | 6 ++-- src/xenconfig/xen_xl.c | 3 +- .../generic-graphics-vnc-manual-port.xml | 4 ++- .../generic-graphics-vnc-minimal.xml | 4 ++- .../qemuxml2xmlout-graphics-spice-timeout.xml | 4 ++- .../qemuxml2xmlout-interface-server.xml | 4 ++- .../qemuxml2xmlout-net-bandwidth.xml | 4 ++- .../qemuxml2xmlout-net-bandwidth2.xml | 4 ++- .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 1 + tests/sexpr2xmldata/sexpr2xml-curmem.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 4 ++- .../sexpr2xml-fv-serial-dev-2-ports.xml | 4 ++- .../sexpr2xml-fv-serial-dev-2nd-port.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 4 ++- .../sexpr2xml-fv-serial-tcp-telnet.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-fv.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 4 ++- .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 4 ++- tests/sexpr2xmldata/sexpr2xml-vif-rate.xml | 4 ++- tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 4 ++- tests/xmconfigdata/test-no-source-cdrom.xml | 4 ++- tests/xmconfigdata/test-pci-devs.xml | 4 ++- 48 files changed, 167 insertions(+), 78 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 97794b7..1350519 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5114,11 +5114,10 @@ qemu-kvm -net nic,model=? /dev/null the TCP port number (with -1 as legacy syntax indicating that it should be auto-allocated). The <code>autoport</code> attribute is the new preferred syntax for indicating auto-allocation of the TCP - port to use. The <code>listen</code> attribute is an IP address - for the server to listen on. The <code>passwd</code> attribute - provides a VNC password in clear text. The <code>keymap</code> - attribute specifies the keymap to use. It is possible to set - a limit on the validity of the password by giving an timestamp + port to use. The <code>passwd</code> attribute provides a VNC + password in clear text. The <code>keymap</code> attribute specifies + the keymap to use. It is possible to set a limit on the validity of + the password by giving an timestamp <code>passwdValidTo='2010-04-09T15:51:00'</code> assumed to be in UTC. The <code>connected</code> attribute allows control of connected client during password changes. VNC accepts @@ -5156,14 +5155,12 @@ qemu-kvm -net nic,model=? /dev/null should be auto-allocated), while <code>tlsPort</code> gives an alternative secure port number. The <code>autoport</code> attribute is the new preferred syntax for indicating - auto-allocation of needed port numbers. The <code>listen</code> - attribute is an IP address for the server to listen on. - The <code>passwd</code> attribute provides a SPICE password in - clear text. The <code>keymap</code> attribute specifies the keymap - to use. It is possible to set a limit on the validity of - the password by giving an timestamp - <code>passwdValidTo='2010-04-09T15:51:00'</code> assumed to be in - UTC. + auto-allocation of needed port numbers. The <code>passwd</code> + attribute provides a SPICE password in clear text. The + <code>keymap</code> attribute specifies the keymap to use. It is + possible to set a limit on the validity of the password by giving + an timestamp <code>passwdValidTo='2010-04-09T15:51:00'</code> + assumed to be in UTC. </p> <p> The <code>connected</code> attribute allows control of connected @@ -5300,6 +5297,15 @@ qemu-kvm -net nic,model=? /dev/null or hostname (which will be resolved to an IP address via a DNS query) to listen on. </p> + <p> + It is possible to omit the <code>address</code> attribute in order to + use an address from config files <span class="since">Since 1.3.5</span>. + </p> + <p> + The <code>address</code> attribute is duplicated as <code>listen</code> + attribute in <code>graphics</code> element for backward compatibility. + If both are provided they must be equal. + </p> </dd> <dt><code>network</code></dt> <dd> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 273715c..ffeafd2 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2955,9 +2955,11 @@ <attribute name="type"> <value>address</value> </attribute> - <attribute name="address"> - <ref name="addrIPorName"/> - </attribute> + <optional> + <attribute name="address"> + <ref name="addrIPorName"/> + </attribute> + </optional> </group> <group> <attribute name="type"> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e19f06..9dae85d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10791,8 +10791,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, if (STREQ_NULLABLE(newListen.address, "")) VIR_FREE(newListen.address); - if (newListen.address && - VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) + if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) goto error; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 86b13bd..c3dfc3f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5179,6 +5179,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, for (i = 0; i < vm->def->ngraphics; i++) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; char *listenAddr = NULL; + size_t j; switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: @@ -5187,12 +5188,16 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (!listenAddr) listenAddr = cfg->spiceListen; - if (graphics->nListens == 0) { - if (virDomainGraphicsListenAppendAddress(graphics, - listenAddr) < 0) - goto cleanup; + for (j = 0; j < graphics->nListens; j++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; + + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + !glisten->address) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto cleanup; - graphics->listens[0].fromConfig = true; + glisten->fromConfig = true; + } } break; diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index ed22724..13c3fec 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -3385,8 +3385,10 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) VBOX_UTF16_FREE(netAddressUtf16); } - if (STRNEQ_NULLABLE(netAddressUtf8, "") && - virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0) + if (netAddressUtf8 && STREQ(netAddressUtf8, "")) + VBOX_UTF8_FREE(netAddressUtf8); + + if (virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0) goto cleanup; gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5e57c39..6505dd7 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1875,11 +1875,9 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) goto failure; } - if (listenAddr) { - if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0) - goto failure; - VIR_FREE(listenAddr); - } + if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0) + goto failure; + VIR_FREE(listenAddr); if (port < 0) { VIR_WARN("VNC is enabled but VMX entry 'RemoteDisplay.vnc.port' " diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index c6aee69..629fbf5 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -594,8 +594,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (xenConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) goto cleanup; - if (listenAddr && - virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) goto cleanup; VIR_FREE(listenAddr); @@ -664,8 +663,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (STREQ(key + 10, "1")) graphics->data.vnc.autoport = true; } else if (STRPREFIX(key, "vnclisten=")) { - if (virDomainGraphicsListenAppendAddress(graphics, - key+10) < 0) + if (VIR_STRDUP(listenAddr, key+10) < 0) goto cleanup; } else if (STRPREFIX(key, "vncpasswd=")) { if (VIR_STRDUP(graphics->data.vnc.auth.passwd, key + 10) < 0) @@ -699,6 +697,11 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) nextkey++; key = nextkey; } + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + if (virDomainGraphicsListenAppendAddress(graphics, + listenAddr) < 0) + goto cleanup; + } if (VIR_ALLOC_N(def->graphics, 1) < 0) goto cleanup; def->graphics[0] = graphics; diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index dc47b4d..381dbdc 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -867,8 +867,7 @@ xenParseSxprGraphicsOld(virDomainDefPtr def, graphics->data.vnc.autoport = true; graphics->data.vnc.port = port; - if (listenAddr && - virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) goto error; if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0) @@ -986,8 +985,7 @@ xenParseSxprGraphicsNew(virDomainDefPtr def, port += 5900; graphics->data.vnc.port = port; - if (listenAddr && - virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) goto error; if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 889dd40..7d41e05 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -186,8 +186,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE; if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0) goto cleanup; - if (listenAddr && - virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) goto cleanup; VIR_FREE(listenAddr); diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml index ac8c279..7301057 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml @@ -19,7 +19,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml index ac8c279..7301057 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml @@ -19,7 +19,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index 33b5465..912b542 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -77,7 +77,9 @@ <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'/> + <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'> + <listen type='address'/> + </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </sound> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml index 9bc610b..95b6e2d 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml @@ -119,7 +119,9 @@ </channel> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml index b9c9015..1fb740b 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml @@ -63,7 +63,9 @@ <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </sound> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml index 411b409..6464890 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml @@ -52,7 +52,9 @@ <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </sound> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml index 4b06e48..a6dddab 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml @@ -30,6 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' autoport='no'> + <listen type='address'/> <gl enable='yes'/> </graphics> <video> diff --git a/tests/sexpr2xmldata/sexpr2xml-curmem.xml b/tests/sexpr2xmldata/sexpr2xml-curmem.xml index a2668d1..ab23c66 100644 --- a/tests/sexpr2xmldata/sexpr2xml-curmem.xml +++ b/tests/sexpr2xmldata/sexpr2xml-curmem.xml @@ -33,7 +33,9 @@ </console> <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='xen' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml index c4b22f6..799e3ff 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml @@ -49,7 +49,9 @@ <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='5925' autoport='yes' keymap='en-us'/> + <graphics type='vnc' port='5925' autoport='yes' keymap='en-us'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml index 17d4016..adc6b89 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml index 20a0d76..836f7e3 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml @@ -45,7 +45,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml index 13fb299..9c17ce4 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml @@ -45,7 +45,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml index 1380426..8d6a6a9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml index 64111fe..4f4f16a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml @@ -43,7 +43,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml index f362aee..e9a60af 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml @@ -47,7 +47,9 @@ </parallel> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml index 4d3bdde..ed53287 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml @@ -54,7 +54,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml index d3eaf82..d22719d 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml @@ -50,7 +50,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml index 0f209d6..ea82206 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml @@ -50,7 +50,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml index b157f63..ac248b9 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml @@ -48,7 +48,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml index d9cd840..4942800 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml @@ -50,7 +50,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml index 2cffa65..358e544 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml @@ -48,7 +48,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml index 6e473d4..5bded20 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml @@ -48,7 +48,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml index f03bd29..b4447e2 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml @@ -52,7 +52,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml index 2e9c629..798117e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml @@ -52,7 +52,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml index 3f3f676..941457e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml @@ -52,7 +52,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml index 4f28511..7ae7f01 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml @@ -50,7 +50,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml index f934a85..efbded1 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <sound model='sb16'/> <sound model='es1370'/> <video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml index f934a85..efbded1 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <sound model='sb16'/> <sound model='es1370'/> <video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml index 8b5887e..f53d00e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml @@ -43,7 +43,9 @@ <input type='mouse' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml index 3e4b366..9b41231 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml @@ -43,7 +43,9 @@ <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml index 9c2b9e3..8eba88f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml index 9c2b9e3..8eba88f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv.xml b/tests/sexpr2xmldata/sexpr2xml-fv.xml index 9c2b9e3..8eba88f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv.xml @@ -42,7 +42,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml index 97d9482..89dd87f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml @@ -47,7 +47,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml index c1acba1..e8b1cd5 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml @@ -31,7 +31,9 @@ </console> <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='xen' heads='1' primary='yes'/> </video> diff --git a/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml b/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml index 45887e5..1e9d60b 100644 --- a/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml +++ b/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml @@ -46,7 +46,9 @@ </interface> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' keymap='ja'/> + <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml index 8501907..3c57579 100644 --- a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml +++ b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml @@ -11,7 +11,9 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <graphics type='vnc' port='5903' autoport='no' keymap='de' passwd='password'/> + <graphics type='vnc' port='5903' autoport='no' keymap='de' passwd='password'> + <listen type='address'/> + </graphics> <video> <model type='vmvga' vram='4096' primary='yes'/> </video> diff --git a/tests/xmconfigdata/test-no-source-cdrom.xml b/tests/xmconfigdata/test-no-source-cdrom.xml index d4c2fd6..61cfb75 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.xml +++ b/tests/xmconfigdata/test-no-source-cdrom.xml @@ -47,7 +47,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> diff --git a/tests/xmconfigdata/test-pci-devs.xml b/tests/xmconfigdata/test-pci-devs.xml index 4c3f5f2..3bc263f 100644 --- a/tests/xmconfigdata/test-pci-devs.xml +++ b/tests/xmconfigdata/test-pci-devs.xml @@ -47,7 +47,9 @@ </console> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address'/> + </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> </video> -- 2.8.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_conf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9dae85d..72ab2d7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10707,10 +10707,9 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, if (network && network[0]) { if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { - /* network='xxx' never makes sense with anything except - * type='network' */ virReportError(VIR_ERR_XML_ERROR, "%s", - _("network attribute not allowed when listen type is not network")); + _("'network' attribute is valid only for listen " + "type 'network'")); goto error; } def->network = network; -- 2.8.2

So far we have only two listen types that supports only address:port method, but in the future we may want to add a new different listen type, for example socket. This patch moves the ports values out of graphics unions into listen element. The domain XML will now duplicate the ports from first listen element into the graphics element as we do also for address. This allows us to make part of the graphics code as listen-driven and prepare the code for new listen types. To support migration back to older versions the new attributes from listen elements are not written into migratable XML. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 87 +++-- docs/schemas/domaincommon.rng | 40 +++ src/conf/domain_conf.c | 349 ++++++++++++--------- src/conf/domain_conf.h | 23 +- src/libxl/libxl_conf.c | 53 ++-- src/libxl/libxl_domain.c | 17 +- src/qemu/qemu_command.c | 167 +++++----- src/qemu/qemu_hotplug.c | 31 +- src/qemu/qemu_migration.c | 14 +- src/qemu/qemu_parse_command.c | 39 ++- src/qemu/qemu_process.c | 257 ++++++++------- src/vbox/vbox_common.c | 26 +- src/vbox/vbox_tmpl.c | 34 +- src/vbox/vbox_uniformed_api.h | 4 +- src/vmx/vmx.c | 52 +-- src/vz/vz_sdk.c | 30 +- src/xenconfig/xen_common.c | 67 ++-- src/xenconfig/xen_sxpr.c | 69 ++-- src/xenconfig/xen_xl.c | 44 +-- .../generic-graphics-listen-back-compat-ports.xml | 30 ++ ...generic-graphics-vnc-listen-element-minimal.xml | 2 +- ...aphics-vnc-listen-element-with-address-port.xml | 30 ++ .../generic-graphics-listen-back-compat-ports.xml | 30 ++ .../generic-graphics-listen-back-compat.xml | 2 +- .../generic-graphics-vnc-listen-attr-only.xml | 2 +- ...generic-graphics-vnc-listen-element-minimal.xml | 4 +- ...aphics-vnc-listen-element-with-address-port.xml | 30 ++ ...ic-graphics-vnc-listen-element-with-address.xml | 2 +- .../generic-graphics-vnc-manual-port.xml | 2 +- .../generic-graphics-vnc-minimal.xml | 2 +- tests/genericxml2xmltest.c | 3 + .../qemuargv2xml-graphics-vnc-policy.xml | 2 +- .../qemuargv2xml-graphics-vnc-sasl.xml | 2 +- .../qemuargv2xml-graphics-vnc-tls.xml | 2 +- .../qemuargv2xml-graphics-vnc-websocket.xml | 2 +- .../qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml | 2 +- ...qemuhotplug-console-compat-2+console-virtio.xml | 2 +- .../qemuxml2argv-console-compat-2.xml | 2 +- .../qemuxml2xmlout-graphics-listen-network.xml | 2 +- .../qemuxml2xmlout-graphics-listen-network2.xml | 4 +- .../qemuxml2xmlout-graphics-spice-compression.xml | 2 +- .../qemuxml2xmlout-graphics-spice-qxl-vga.xml | 2 +- .../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +- .../qemuxml2xmlout-graphics-spice.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-no-listen-attr.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-sasl.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-tls.xml | 2 +- .../qemuxml2xmlout-graphics-vnc-websocket.xml | 2 +- .../qemuxml2xmlout-graphics-vnc.xml | 2 +- .../qemuxml2xmlout-interface-server.xml | 2 +- .../qemuxml2xmlout-net-bandwidth.xml | 2 +- .../qemuxml2xmlout-net-bandwidth2.xml | 2 +- .../qemuxml2xmlout-pci-bridge.xml | 2 +- ...emuxml2xmlout-seclabel-dynamic-none-relabel.xml | 2 +- .../qemuxml2xmlout-serial-spiceport.xml | 2 +- .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-curmem.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml | 2 +- .../sexpr2xml-fv-serial-dev-2-ports.xml | 2 +- .../sexpr2xml-fv-serial-dev-2nd-port.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +- .../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-sound.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-utc.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv-v2.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-fv.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +- .../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +- .../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 2 +- tests/sexpr2xmldata/sexpr2xml-vif-rate.xml | 2 +- tests/vmx2xmldata/vmx2xml-graphics-vnc.xml | 2 +- .../test-disk-positional-parms-full.xml | 2 +- .../test-disk-positional-parms-partial.xml | 2 +- ...est-fullvirt-direct-kernel-boot-bogus-extra.xml | 2 +- .../test-fullvirt-direct-kernel-boot-extra.xml | 2 +- .../test-fullvirt-direct-kernel-boot.xml | 2 +- tests/xlconfigdata/test-fullvirt-multiusb.xml | 2 +- tests/xlconfigdata/test-fullvirt-nohap.xml | 2 +- tests/xlconfigdata/test-new-disk.xml | 2 +- tests/xlconfigdata/test-rbd-multihost-noauth.xml | 2 +- tests/xlconfigdata/test-spice-features.xml | 2 +- tests/xlconfigdata/test-spice.xml | 2 +- tests/xlconfigdata/test-vif-rate.xml | 2 +- tests/xmconfigdata/test-escape-paths.xml | 2 +- .../xmconfigdata/test-fullvirt-default-feature.xml | 2 +- tests/xmconfigdata/test-fullvirt-force-hpet.xml | 2 +- tests/xmconfigdata/test-fullvirt-force-nohpet.xml | 2 +- tests/xmconfigdata/test-fullvirt-localtime.xml | 2 +- tests/xmconfigdata/test-fullvirt-net-netfront.xml | 2 +- tests/xmconfigdata/test-fullvirt-new-cdrom.xml | 2 +- tests/xmconfigdata/test-fullvirt-nohap.xml | 2 +- tests/xmconfigdata/test-fullvirt-parallel-tcp.xml | 2 +- .../test-fullvirt-serial-dev-2-ports.xml | 2 +- .../test-fullvirt-serial-dev-2nd-port.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +- .../test-fullvirt-serial-tcp-telnet.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +- tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +- tests/xmconfigdata/test-fullvirt-sound.xml | 2 +- tests/xmconfigdata/test-fullvirt-usbmouse.xml | 2 +- tests/xmconfigdata/test-fullvirt-usbtablet.xml | 2 +- tests/xmconfigdata/test-fullvirt-utc.xml | 2 +- tests/xmconfigdata/test-no-source-cdrom.xml | 2 +- tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +- tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +- .../test-paravirt-new-pvfb-vncdisplay.xml | 2 +- tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +- tests/xmconfigdata/test-pci-devs.xml | 2 +- 131 files changed, 1029 insertions(+), 715 deletions(-) create mode 100644 tests/genericxml2xmlindata/generic-graphics-listen-back-compat-ports.xml create mode 100644 tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address-port.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-listen-back-compat-ports.xml create mode 100644 tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address-port.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 1350519..0d22922 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5078,7 +5078,7 @@ qemu-kvm -net nic,model=? /dev/null <devices> <graphics type='sdl' display=':0.0'/> <graphics type='vnc' port='5904' sharePolicy='allow-exclusive'> - <listen type='address' address='1.2.3.4'/> + <listen type='address' address='1.2.3.4' port='5904'/> </graphics> <graphics type='rdp' autoport='yes' multiUser='yes' /> <graphics type='desktop' fullscreen='yes'/> @@ -5110,16 +5110,13 @@ qemu-kvm -net nic,model=? /dev/null <dt><code>vnc</code></dt> <dd> <p> - Starts a VNC server. The <code>port</code> attribute specifies - the TCP port number (with -1 as legacy syntax indicating that it - should be auto-allocated). The <code>autoport</code> attribute is - the new preferred syntax for indicating auto-allocation of the TCP - port to use. The <code>passwd</code> attribute provides a VNC - password in clear text. The <code>keymap</code> attribute specifies - the keymap to use. It is possible to set a limit on the validity of + Starts a VNC server. To set port or address use <code>listen</code> + element. The <code>passwd</code> attribute provides a VNC password + in clear text. The <code>keymap</code> attribute specifies the + keymap to use. It is possible to set a limit on the validity of the password by giving an timestamp - <code>passwdValidTo='2010-04-09T15:51:00'</code> assumed to be - in UTC. The <code>connected</code> attribute allows control of + <code>passwdValidTo='2010-04-09T15:51:00'</code> assumed to be in + UTC. The <code>connected</code> attribute allows control of connected client during password changes. VNC accepts <code>keep</code> value only <span class="since">since 0.9.3</span>. NB, this may not be supported by all hypervisors. @@ -5140,22 +5137,12 @@ qemu-kvm -net nic,model=? /dev/null attribute for listening on a unix domain socket path <span class="since">Since 0.8.8</span>. </p> - <p> - For VNC WebSocket functionality, <code>websocket</code> attribute - may be used to specify port to listen on (with -1 meaning - auto-allocation and <code>autoport</code> having no effect due to - security reasons) <span class="since">Since 1.0.6</span>. - </p> </dd> <dt><code>spice</code> <span class="since">Since 0.8.6</span></dt> <dd> <p> - Starts a SPICE server. The <code>port</code> attribute specifies - the TCP port number (with -1 as legacy syntax indicating that it - should be auto-allocated), while <code>tlsPort</code> gives - an alternative secure port number. The <code>autoport</code> - attribute is the new preferred syntax for indicating - auto-allocation of needed port numbers. The <code>passwd</code> + Starts a SPICE server. To set port or address use + <code>listen</code> element. The <code>passwd</code> attribute provides a SPICE password in clear text. The <code>keymap</code> attribute specifies the keymap to use. It is possible to set a limit on the validity of the password by giving @@ -5197,6 +5184,7 @@ qemu-kvm -net nic,model=? /dev/null </p> <pre> <graphics type='spice' port='-1' tlsPort='-1' autoport='yes'> + <listen type='address' autoport='yes'/> <channel name='main' mode='secure'/> <channel name='record' mode='insecure'/> <image compression='auto_glz'/> @@ -5254,16 +5242,13 @@ qemu-kvm -net nic,model=? /dev/null <dt><code>rdp</code></dt> <dd> <p> - Starts a RDP server. The <code>port</code> attribute specifies the - TCP port number (with -1 as legacy syntax indicating that it should - be auto-allocated). The <code>autoport</code> attribute is the new - preferred syntax for indicating auto-allocation of the TCP port to - use. The <code>replaceUser</code> attribute is a boolean deciding - whether multiple simultaneous connections to the VM are permitted. - The <code>multiUser</code> attribute is a boolean deciding whether - the existing connection must be dropped and a new connection must - be established by the VRDP server, when a new client connects in - single connection mode. + Starts a RDP server. To set port or address use <code>listen</code> + element. The <code>replaceUser</code> attribute is + a boolean deciding whether multiple simultaneous connections to + the VM are permitted. The <code>multiUser</code> attribute is + a boolean deciding whether the existing connection must be dropped + and a new connection must be established by the VRDP server, when + a new client connects in single connection mode. </p> </dd> <dt><code>desktop</code></dt> @@ -5306,6 +5291,40 @@ qemu-kvm -net nic,model=? /dev/null attribute in <code>graphics</code> element for backward compatibility. If both are provided they must be equal. </p> + <p> + With address it's also possible to specify ports to listen on and + whether those ports should be auto-generated or not + <span class="since">Since 1.3.5</span>. Depending on graphics type + those attributes are available: + </p> + <ul> + <li> + <code>port</code> TCP port number (<code>vnc</code>, + <code>spice</code>, <code>rdp</code>), + </li> + <li> + <code>tlsPort</code> secure TCP port number (<code>spice</code>), + </li> + <li> + <code>websocket</code> TCP port number (<code>vnc</code>), + </li> + <li> + <code>autoport</code> TCP port number (<code>vnc</code>, + <code>spice</code>, <code>rdp</code>). + </li> + </ul> + <p> + If <code>autoport='yes'</code> the <code>port</code> and + <code>tlsPort</code> are auto-generated. It's also possible to use + <code>-1</code> as legacy syntax to tell that the port should be + auto-generated. The <code>websocket</code> has an exception for + security reasons that it can be only auto-generated using the legacy + syntax <code>websocket='-1'</code>. + </p> + <p> + This ports configuration is duplicated into <code>graphics</code> + element for backwards compatibility. + </p> </dd> <dt><code>network</code></dt> <dd> @@ -5323,6 +5342,10 @@ qemu-kvm -net nic,model=? /dev/null describing one of the 'direct' (macvtap) modes, the first IPv4 address of the first forward dev will be used. </p> + <p> + Specifying ports uses the same rules and syntax as listen type + <code>address</code>. + </p> </dd> </dl> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index ffeafd2..e7eda77 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2960,6 +2960,26 @@ <ref name="addrIPorName"/> </attribute> </optional> + <optional> + <attribute name="port"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="tlsPort"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="websocket"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="autoport"> + <ref name="virYesNo"/> + </attribute> + </optional> </group> <group> <attribute name="type"> @@ -2973,6 +2993,26 @@ <ref name="addrIPorName"/> </attribute> </optional> + <optional> + <attribute name="port"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="tlsPort"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="websocket"> + <ref name="PortNumber"/> + </attribute> + </optional> + <optional> + <attribute name="autoport"> + <ref name="virYesNo"/> + </attribute> + </optional> </group> </choice> </element> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 72ab2d7..2168bac 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10642,9 +10642,131 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, /** + * virDomainGraphicsListenDefParsePorts: + * @def: listen def pointer to be filled + * @node: xml node of <listen/> element + * @graphics: graphics def pointer + * @parent: xml node of <graphics/> element + * @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_* + * + * Parses current <listen/> element from @node to @def. For backward + * compatibility the @parent element should contain node of <graphics/> element + * for the first <listen/> element in order to validate attributes from both + * elements. + */ +static int +virDomainGraphicsListenDefParsePorts(virDomainGraphicsListenDefPtr def, + xmlNodePtr node, + virDomainGraphicsDefPtr graphics, + xmlNodePtr parent, + unsigned int flags) +{ + char *port = virXMLPropString(node, "port"); + char *tlsPort = virXMLPropString(node, "tlsPort"); + char *websocket = virXMLPropString(node, "websocket"); + char *autoport = virXMLPropString(node, "autoport"); + char *portCompat = NULL; + char *tlsPortCompat = NULL; + char *websocketCompat = NULL; + char *autoportCompat = NULL; + int ret = -1; + + if (parent) { + portCompat = virXMLPropString(parent, "port"); + tlsPortCompat = virXMLPropString(parent, "tlsPort"); + websocketCompat = virXMLPropString(parent, "websocket"); + autoportCompat = virXMLPropString(parent, "autoport"); + } + +#define GRAPHICS_CHECK_PORT_COMPAT(PORT, PORT_COMPAT) \ + if (PORT && PORT_COMPAT && STRNEQ(PORT, PORT_COMPAT)) { \ + virReportError(VIR_ERR_XML_ERROR, \ + _("graphics '" #PORT "' attribute '%s' must match " \ + "'" #PORT "' attribute of first listen element " \ + "(found '%s')"), PORT_COMPAT, PORT); \ + goto error; \ + } \ + if (!PORT) { \ + PORT = PORT_COMPAT; \ + PORT_COMPAT = NULL; \ + } + + GRAPHICS_CHECK_PORT_COMPAT(port, portCompat); + GRAPHICS_CHECK_PORT_COMPAT(tlsPort, tlsPortCompat); + GRAPHICS_CHECK_PORT_COMPAT(websocket, websocketCompat); + GRAPHICS_CHECK_PORT_COMPAT(autoport, autoportCompat); + +#undef GRAPHICS_CHECK_PORT_COMPAT + +#define GRAPHICS_PARSE_PORT(PORT) \ + if (PORT) { \ + if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && \ + def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { \ + virReportError(VIR_ERR_XML_ERROR, "%s", \ + _("'" #PORT "' attribute is valid only for listen " \ + "type 'address' and 'network'")); \ + goto error; \ + } \ + if (virStrToLong_i(PORT, NULL, 10, &def->PORT) < 0) { \ + virReportError(VIR_ERR_XML_ERROR, \ + _("cannot parse " #PORT " '%s'"), PORT); \ + goto error; \ + } \ + } + + GRAPHICS_PARSE_PORT(port); + GRAPHICS_PARSE_PORT(tlsPort); + GRAPHICS_PARSE_PORT(websocket); + +#undef GRAPHICS_PARSE_PORT + + if (autoport) { + if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'autoport' attribute is valid only for listen " + "type 'address' and 'network'")); + goto error; + } + if (STREQ(autoport, "yes")) + def->autoport = true; + } + + if (!port && !tlsPort && !autoport) + def->autoport = true; + + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + if (def->port == -1 && def->tlsPort == -1) { + def->autoport = true; + def->port = def->tlsPort = 0; + } + } else { + if (def->port == -1) { + def->autoport = true; + def->port = 0; + } + } + + if (def->autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { + def->port = 0; + def->tlsPort = 0; + } + + ret = 0; + error: + VIR_FREE(port); + VIR_FREE(tlsPort); + VIR_FREE(websocket); + VIR_FREE(autoport); + return ret; +} + + +/** * virDomainGraphicsListenDefParseXML: * @def: listen def pointer to be filled * @node: xml node of <listen/> element + * @graphics: graphics def pointer * @parent: xml node of <graphics/> element * @flags: bit-wise or of VIR_DOMAIN_DEF_PARSE_* * @@ -10656,6 +10778,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node, static int virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, xmlNodePtr node, + virDomainGraphicsDefPtr graphics, xmlNodePtr parent, unsigned int flags) { @@ -10727,6 +10850,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, def->fromConfig = tmp != 0; } + if (virDomainGraphicsListenDefParsePorts(def, node, graphics, + parent, flags) < 0) + goto error; + ret = 0; error: if (ret < 0) @@ -10775,6 +10902,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, for (i = 0; i < nListens; i++) { if (virDomainGraphicsListenDefParseXML(&def->listens[i], listenNodes[i], + def, i == 0 ? node : NULL, flags) < 0) goto error; @@ -10790,6 +10918,10 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, if (STREQ_NULLABLE(newListen.address, "")) VIR_FREE(newListen.address); + if (virDomainGraphicsListenDefParsePorts(&newListen, node, def, + NULL, flags) < 0) + goto error; + if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) goto error; } @@ -10811,50 +10943,12 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - char *port = virXMLPropString(node, "port"); - char *websocket = virXMLPropString(node, "websocket"); char *sharePolicy = virXMLPropString(node, "sharePolicy"); - char *autoport = virXMLPropString(node, "autoport"); int ret = -1; if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto error; - if (port) { - if (virStrToLong_i(port, NULL, 10, &def->data.vnc.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vnc port %s"), port); - goto error; - } - /* Legacy compat syntax, used -1 for auto-port */ - if (def->data.vnc.port == -1) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - def->data.vnc.port = 0; - def->data.vnc.autoport = true; - } - } else { - def->data.vnc.port = 0; - def->data.vnc.autoport = true; - } - - if (autoport) { - if (STREQ(autoport, "yes")) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - def->data.vnc.port = 0; - def->data.vnc.autoport = true; - } - } - - if (websocket) { - if (virStrToLong_i(websocket, - NULL, 10, - &def->data.vnc.websocket) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse vnc WebSocket port %s"), websocket); - goto error; - } - } - if (sharePolicy) { int policy = virDomainGraphicsVNCSharePolicyTypeFromString(sharePolicy); @@ -10878,9 +10972,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(autoport); - VIR_FREE(websocket); VIR_FREE(sharePolicy); return ret; } @@ -10923,8 +11014,6 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, xmlXPathContextPtr ctxt, unsigned int flags) { - char *port = virXMLPropString(node, "port"); - char *autoport = virXMLPropString(node, "autoport"); char *replaceUser = virXMLPropString(node, "replaceUser"); char *multiUser = virXMLPropString(node, "multiUser"); int ret = -1; @@ -10932,27 +11021,6 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto error; - if (port) { - if (virStrToLong_i(port, NULL, 10, &def->data.rdp.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse rdp port %s"), port); - goto error; - } - /* Legacy compat syntax, used -1 for auto-port */ - if (def->data.rdp.port == -1) - def->data.rdp.autoport = true; - - } else { - def->data.rdp.port = 0; - def->data.rdp.autoport = true; - } - - if (STREQ_NULLABLE(autoport, "yes")) - def->data.rdp.autoport = true; - - if (def->data.rdp.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - def->data.rdp.port = 0; - if (STREQ_NULLABLE(replaceUser, "yes")) def->data.rdp.replaceUser = true; @@ -10961,8 +11029,6 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(autoport); VIR_FREE(replaceUser); VIR_FREE(multiUser); return ret; @@ -11006,9 +11072,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, unsigned int flags) { xmlNodePtr cur; - char *port = virXMLPropString(node, "port"); - char *tlsPort = virXMLPropString(node, "tlsPort"); - char *autoport = virXMLPropString(node, "autoport"); char *defaultMode = virXMLPropString(node, "defaultMode"); int defaultModeVal; int ret = -1; @@ -11016,29 +11079,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0) goto error; - if (port) { - if (virStrToLong_i(port, NULL, 10, &def->data.spice.port) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse spice port %s"), port); - goto error; - } - } else { - def->data.spice.port = 0; - } - - if (tlsPort) { - if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse spice tlsPort %s"), tlsPort); - goto error; - } - } else { - def->data.spice.tlsPort = 0; - } - - if (STREQ_NULLABLE(autoport, "yes")) - def->data.spice.autoport = true; - def->data.spice.defaultMode = VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY; if (defaultMode) { @@ -11051,16 +11091,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, def->data.spice.defaultMode = defaultModeVal; } - if (def->data.spice.port == -1 && def->data.spice.tlsPort == -1) { - /* Legacy compat syntax, used -1 for auto-port */ - def->data.spice.autoport = true; - } - - if (def->data.spice.autoport && (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) { - def->data.spice.port = 0; - def->data.spice.tlsPort = 0; - } - def->data.spice.keymap = virXMLPropString(node, "keymap"); if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth, @@ -11295,9 +11325,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(tlsPort); - VIR_FREE(autoport); VIR_FREE(defaultMode); return ret; } @@ -21391,6 +21418,26 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, virBufferEscapeString(buf, " network='%s'", def->network); } + /* Don't print the new port attributes into migratable XML in order to be + * able to migrate to old libvirt. */ + if (!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) { + if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || + def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { + if (!def->autoport || !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) { + if (def->port) + virBufferAsprintf(buf, " port='%d'", def->port); + + if (def->tlsPort) + virBufferAsprintf(buf, " tlsPort='%d'", def->tlsPort); + + if (def->websocket) + virBufferAsprintf(buf, " websocket='%d'", def->websocket); + } + + virBufferAsprintf(buf, " autoport='%s'", def->autoport ? "yes" : "no"); + } + } + if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig); @@ -21403,8 +21450,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf, virDomainGraphicsDefPtr def, unsigned int flags) { + virDomainGraphicsListenDefPtr glisten = NULL; const char *type = virDomainGraphicsTypeToString(def->type); - const char *listenAddr = NULL; bool children = false; size_t i; @@ -21414,23 +21461,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf, return -1; } - /* find the first listen subelement with a valid address and - * duplicate its address attribute as the listen attribute of - * <graphics>. This is done to improve backward compatibility. - */ - for (i = 0; i < def->nListens; i++) { - if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && - def->listens[i].fromConfig) - continue; - - if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK && - flags & (VIR_DOMAIN_DEF_FORMAT_INACTIVE | - VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) - continue; - - if ((listenAddr = def->listens[i].address)) - break; - } + glisten = virDomainGraphicsGetListen(def, 0); virBufferAsprintf(buf, "<graphics type='%s'", type); @@ -21442,22 +21473,21 @@ virDomainGraphicsDefFormat(virBufferPtr buf, virBufferEscapeString(buf, " socket='%s'", def->data.vnc.socket); } - } else { - if (def->data.vnc.port && - (!def->data.vnc.autoport || !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) - virBufferAsprintf(buf, " port='%d'", - def->data.vnc.port); - else if (def->data.vnc.autoport) + } else if (glisten) { + if (glisten->port && + (!glisten->autoport || !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))) + virBufferAsprintf(buf, " port='%d'", glisten->port); + else if (glisten->autoport) virBufferAddLit(buf, " port='-1'"); virBufferAsprintf(buf, " autoport='%s'", - def->data.vnc.autoport ? "yes" : "no"); + glisten->autoport ? "yes" : "no"); - if (def->data.vnc.websocket) - virBufferAsprintf(buf, " websocket='%d'", def->data.vnc.websocket); + if (glisten->websocket) + virBufferAsprintf(buf, " websocket='%d'", glisten->websocket); - if (listenAddr) - virBufferAsprintf(buf, " listen='%s'", listenAddr); + if (glisten->address && !glisten->fromConfig) + virBufferAsprintf(buf, " listen='%s'", glisten->address); } if (def->data.vnc.keymap) @@ -21486,24 +21516,24 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - if (def->data.rdp.port) + if (glisten->port) virBufferAsprintf(buf, " port='%d'", - def->data.rdp.port); - else if (def->data.rdp.autoport) + glisten->port); + else if (glisten->autoport) virBufferAddLit(buf, " port='0'"); - if (def->data.rdp.autoport) + if (glisten->autoport) virBufferAddLit(buf, " autoport='yes'"); + if (glisten->address && !glisten->fromConfig) + virBufferAsprintf(buf, " listen='%s'", glisten->address); + if (def->data.rdp.replaceUser) virBufferAddLit(buf, " replaceUser='yes'"); if (def->data.rdp.multiUser) virBufferAddLit(buf, " multiUser='yes'"); - if (listenAddr) - virBufferAsprintf(buf, " listen='%s'", listenAddr); - break; case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: @@ -21517,19 +21547,19 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (def->data.spice.port) + if (glisten->port) virBufferAsprintf(buf, " port='%d'", - def->data.spice.port); + glisten->port); - if (def->data.spice.tlsPort) + if (glisten->tlsPort) virBufferAsprintf(buf, " tlsPort='%d'", - def->data.spice.tlsPort); + glisten->tlsPort); virBufferAsprintf(buf, " autoport='%s'", - def->data.spice.autoport ? "yes" : "no"); + glisten->autoport ? "yes" : "no"); - if (listenAddr) - virBufferAsprintf(buf, " listen='%s'", listenAddr); + if (glisten->address && !glisten->fromConfig) + virBufferAsprintf(buf, " listen='%s'", glisten->address); if (def->data.spice.keymap) virBufferEscapeString(buf, " keymap='%s'", @@ -23844,23 +23874,32 @@ virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i) int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, - const char *address) + const char *address, + const int port, + const int tlsPort, + const int websocket, + const bool autoport) { - virDomainGraphicsListenDef gListen; + virDomainGraphicsListenDef glisten; + + memset(&glisten, 0, sizeof(glisten)); - memset(&gListen, 0, sizeof(gListen)); + glisten.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; - gListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; + glisten.port = port; + glisten.tlsPort = tlsPort; + glisten.websocket = websocket; + glisten.autoport = autoport; - if (VIR_STRDUP(gListen.address, address) < 0) + if (VIR_STRDUP(glisten.address, address) < 0) goto error; - if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, gListen) < 0) + if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, glisten) < 0) goto error; return 0; error: - VIR_FREE(gListen.address); + VIR_FREE(glisten.address); return -1; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b825477..0895136 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1556,6 +1556,12 @@ struct _virDomainGraphicsListenDef { char *address; char *network; bool fromConfig; /* true if the @address is config file originated */ + int port; + int tlsPort; + int websocket; + bool autoport; + bool portReserved; + bool tlsPortReserved; }; struct _virDomainGraphicsDef { @@ -1567,10 +1573,6 @@ struct _virDomainGraphicsDef { virDomainGraphicsType type; union { struct { - int port; - bool portReserved; - int websocket; - bool autoport; char *keymap; char *socket; bool socketAutogenerated; @@ -1583,8 +1585,6 @@ struct _virDomainGraphicsDef { bool fullscreen; } sdl; struct { - int port; - bool autoport; bool replaceUser; bool multiUser; } rdp; @@ -1593,14 +1593,9 @@ struct _virDomainGraphicsDef { bool fullscreen; } desktop; struct { - int port; - int tlsPort; - bool portReserved; - bool tlsPortReserved; virDomainGraphicsSpiceMouseMode mousemode; char *keymap; virDomainGraphicsAuthDef auth; - bool autoport; int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST]; virDomainGraphicsSpiceChannelMode defaultMode; int image; @@ -2839,7 +2834,11 @@ int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match, virDomainGraphicsListenDefPtr virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i); int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, - const char *address) + const char *address, + const int port, + const int tlsPort, + const int websocket, + const bool autoport) ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index d927b37..0144f87 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1424,7 +1424,7 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, libxl_device_vfb *x_vfb) { unsigned short port; - virDomainGraphicsListenDefPtr gListen = NULL; + virDomainGraphicsListenDefPtr glisten = NULL; libxl_device_vfb_init(x_vfb); @@ -1443,20 +1443,24 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports, libxl_defbool_set(&x_vfb->sdl.enable, 0); /* driver handles selection of free port */ libxl_defbool_set(&x_vfb->vnc.findunused, 0); - if (l_vfb->data.vnc.autoport) { - if (virPortAllocatorAcquire(graphicsports, &port) < 0) - return -1; - l_vfb->data.vnc.port = port; - } - x_vfb->vnc.display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN; + glisten = virDomainGraphicsGetListen(l_vfb, 0); - if ((gListen = virDomainGraphicsGetListen(l_vfb, 0)) && - gListen->address) { - /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1") */ - VIR_FREE(x_vfb->vnc.listen); - if (VIR_STRDUP(x_vfb->vnc.listen, gListen->address) < 0) - return -1; + if (glisten) { + if (glisten->autoport) { + + if (virPortAllocatorAcquire(graphicsports, &port) < 0) + return -1; + glisten->port = port; + } + x_vfb->vnc.display = glisten->port - LIBXL_VNC_PORT_MIN; + + if (glisten->address) { + /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1") */ + VIR_FREE(x_vfb->vnc.listen); + if (VIR_STRDUP(x_vfb->vnc.listen, glisten->address) < 0) + return -1; + } } if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd) < 0) return -1; @@ -1545,24 +1549,27 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports, for (i = 0; i < def->ngraphics; i++) { virDomainGraphicsDefPtr l_vfb = def->graphics[i]; unsigned short port; - virDomainGraphicsListenDefPtr gListen = NULL; + virDomainGraphicsListenDefPtr glisten = NULL; if (l_vfb->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) continue; + glisten = virDomainGraphicsGetListen(l_vfb, 0); + libxl_defbool_set(&b_info->u.hvm.spice.enable, true); - if (l_vfb->data.spice.autoport) { - if (virPortAllocatorAcquire(graphicsports, &port) < 0) + if (glisten) { + if (glisten->autoport) { + if (virPortAllocatorAcquire(graphicsports, &port) < 0) + return -1; + glisten->port = port; + } + b_info->u.hvm.spice.port = glisten->port; + + if (glisten->address && + VIR_STRDUP(b_info->u.hvm.spice.host, glisten->address) < 0) return -1; - l_vfb->data.spice.port = port; } - b_info->u.hvm.spice.port = l_vfb->data.spice.port; - - if ((gListen = virDomainGraphicsGetListen(l_vfb, 0)) && - gListen->address && - VIR_STRDUP(b_info->u.hvm.spice.host, gListen->address) < 0) - return -1; if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0) return -1; diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 14a900c..4bbf1e7 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -746,13 +746,16 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, driver->inhibitCallback(false, driver->inhibitOpaque); if ((vm->def->ngraphics == 1) && - vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - vm->def->graphics[0]->data.vnc.autoport) { - vnc_port = vm->def->graphics[0]->data.vnc.port; - if (vnc_port >= LIBXL_VNC_PORT_MIN) { - if (virPortAllocatorRelease(driver->reservedGraphicsPorts, - vnc_port) < 0) - VIR_DEBUG("Could not mark port %d as unused", vnc_port); + vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + virDomainGraphicsListenDefPtr glisten = + virDomainGraphicsGetListen(vm->def->graphics[0], 0); + if (glisten && glisten->autoport) { + vnc_port = glisten->port; + if (vnc_port >= LIBXL_VNC_PORT_MIN) { + if (virPortAllocatorRelease(driver->reservedGraphicsPorts, + vnc_port) < 0) + VIR_DEBUG("Could not mark port %d as unused", vnc_port); + } } } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 8ec550e..7f7ce60 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7322,7 +7322,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, const char *domainLibDir) { virBuffer opt = VIR_BUFFER_INITIALIZER; - virDomainGraphicsListenDefPtr gListen = NULL; + virDomainGraphicsListenDefPtr glisten = NULL; const char *listenAddr = NULL; char *netAddr = NULL; bool escapeAddr; @@ -7346,46 +7346,49 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); } else { - if (!graphics->data.vnc.autoport && - (graphics->data.vnc.port < 5900 || - graphics->data.vnc.port > 65535)) { + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + } + + if (!glisten->autoport && + (glisten->port < 5900 || + glisten->port > 65535)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("vnc port must be in range [5900,65535]")); goto error; } - if ((gListen = virDomainGraphicsGetListen(graphics, 0))) { + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + listenAddr = glisten->address; + break; - switch (gListen->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - listenAddr = gListen->address; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!glisten->network) break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - if (!gListen->network) - break; - - ret = networkGetNetworkAddress(gListen->network, &netAddr); - if (ret <= -2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("network-based listen not possible, " - "network driver not present")); - goto error; - } - if (ret < 0) - goto error; + ret = networkGetNetworkAddress(glisten->network, &netAddr); + if (ret <= -2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("network-based listen not possible, " + "network driver not present")); + goto error; + } + if (ret < 0) + goto error; - listenAddr = netAddr; - /* store the address we found in the <graphics> element so it - * will show up in status. */ - if (VIR_STRDUP(gListen->address, netAddr) < 0) - goto error; - break; + listenAddr = netAddr; + /* store the address we found in the <graphics> element so it + * will show up in status. */ + if (VIR_STRDUP(glisten->address, netAddr) < 0) + goto error; + break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: - break; - } + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } if (!listenAddr) @@ -7396,21 +7399,19 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, virBufferAsprintf(&opt, "[%s]", listenAddr); else virBufferAdd(&opt, listenAddr, -1); - virBufferAsprintf(&opt, ":%d", - graphics->data.vnc.port - 5900); + virBufferAsprintf(&opt, ":%d", glisten->port - 5900); VIR_FREE(netAddr); - } - if (!graphics->data.vnc.socket && - graphics->data.vnc.websocket) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VNC WebSockets are not supported " - "with this QEMU binary")); - goto error; + if (glisten->websocket) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC WebSockets are not supported " + "with this QEMU binary")); + goto error; + } + virBufferAsprintf(&opt, ",websocket=%d", glisten->websocket); } - virBufferAsprintf(&opt, ",websocket=%d", graphics->data.vnc.websocket); } if (graphics->data.vnc.sharePolicy) { @@ -7476,13 +7477,11 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, virDomainGraphicsDefPtr graphics) { virBuffer opt = VIR_BUFFER_INITIALIZER; - virDomainGraphicsListenDefPtr gListen = NULL; + virDomainGraphicsListenDefPtr glisten = NULL; const char *listenAddr = NULL; char *netAddr = NULL; int ret; int defaultMode = graphics->data.spice.defaultMode; - int port = graphics->data.spice.port; - int tlsPort = graphics->data.spice.tlsPort; size_t i; if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)) { @@ -7491,17 +7490,23 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, goto error; } - if (port > 0) - virBufferAsprintf(&opt, "port=%u,", port); + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + } + + if (glisten->port > 0) + virBufferAsprintf(&opt, "port=%u,", glisten->port); - if (tlsPort > 0) { + if (glisten->tlsPort > 0) { if (!cfg->spiceTLS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice TLS port set in XML configuration," " but TLS is disabled in qemu.conf")); goto error; } - virBufferAsprintf(&opt, "tls-port=%u,", tlsPort); + virBufferAsprintf(&opt, "tls-port=%u,", glisten->tlsPort); } if (cfg->spiceSASL) { @@ -7514,39 +7519,37 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, /* TODO: Support ACLs later */ } - if (port > 0 || tlsPort > 0) { - if ((gListen = virDomainGraphicsGetListen(graphics, 0))) { + if (glisten->port > 0 || glisten->tlsPort > 0) { - switch (gListen->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - listenAddr = gListen->address; - break; - - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - if (!gListen->network) - break; - - ret = networkGetNetworkAddress(gListen->network, &netAddr); - if (ret <= -2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("network-based listen not possible, " - "network driver not present")); - goto error; - } - if (ret < 0) - goto error; + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + listenAddr = glisten->address; + break; - listenAddr = netAddr; - /* store the address we found in the <graphics> element so it will - * show up in status. */ - if (VIR_STRDUP(gListen->address, listenAddr) < 0) - goto error; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!glisten->network) break; - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: - break; + ret = networkGetNetworkAddress(glisten->network, &netAddr); + if (ret <= -2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("network-based listen not possible, " + "network driver not present")); + goto error; } + if (ret < 0) + goto error; + + listenAddr = netAddr; + /* store the address we found in the <graphics> element so it will + * show up in status. */ + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto error; + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } if (!listenAddr) @@ -7577,7 +7580,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,"); - if (tlsPort > 0) + if (glisten->tlsPort > 0) virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); switch (defaultMode) { @@ -7595,7 +7598,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) { switch (graphics->data.spice.channels[i]) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (tlsPort <= 0) { + if (glisten->tlsPort <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice secure channels set in XML configuration, " "but TLS port is not provided")); @@ -7606,7 +7609,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: - if (port <= 0) { + if (glisten->port <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice insecure channels set in XML " "configuration, but plain port is not provided")); @@ -7619,7 +7622,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: switch (defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (tlsPort <= 0) { + if (glisten->tlsPort <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice defaultMode secure requested in XML " "configuration but TLS port not provided")); @@ -7628,7 +7631,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: - if (port <= 0) { + if (glisten->port <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice defaultMode insecure requested in XML " "configuration but plain port not provided")); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ca95004..1fb08c0 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2645,6 +2645,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, goto cleanup; } + if (oldlisten->autoport != newlisten->autoport || + oldlisten->port != newlisten->port || + oldlisten->websocket != newlisten->websocket || + oldlisten->tlsPort != newlisten->tlsPort) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen port settings " + "on '%s' graphics"), type); + goto cleanup; + } break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: if (STRNEQ_NULLABLE(newlisten->network, oldlisten->network)) { @@ -2654,6 +2663,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, goto cleanup; } + if (oldlisten->autoport != newlisten->autoport || + oldlisten->port != newlisten->port || + oldlisten->websocket != newlisten->websocket || + oldlisten->tlsPort != newlisten->tlsPort) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen port settings " + "on '%s' graphics"), type); + goto cleanup; + } break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: @@ -2665,12 +2683,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, switch (dev->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (olddev->data.vnc.autoport != dev->data.vnc.autoport || - olddev->data.vnc.port != dev->data.vnc.port) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change port settings on vnc graphics")); - goto cleanup; - } if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot change keymap setting on vnc graphics")); @@ -2708,13 +2720,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (olddev->data.spice.autoport != dev->data.spice.autoport || - olddev->data.spice.port != dev->data.spice.port || - olddev->data.spice.tlsPort != dev->data.spice.tlsPort) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot change port settings on spice graphics")); - goto cleanup; - } if (STRNEQ_NULLABLE(olddev->data.spice.keymap, dev->data.spice.keymap)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 680c9ba..6440cf1 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -319,20 +319,26 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver, { qemuMigrationCookieGraphicsPtr mig = NULL; const char *listenAddr; - virDomainGraphicsListenDefPtr gListen = virDomainGraphicsGetListen(def, 0); + virDomainGraphicsListenDefPtr glisten = virDomainGraphicsGetListen(def, 0); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); if (VIR_ALLOC(mig) < 0) goto error; + if (!glisten) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + } + mig->type = def->type; - mig->port = def->data.spice.port; + mig->port = glisten->port; if (cfg->spiceTLS) - mig->tlsPort = def->data.spice.tlsPort; + mig->tlsPort = glisten->tlsPort; else mig->tlsPort = -1; - if (!gListen || !(listenAddr = gListen->address)) + if (!glisten || !(listenAddr = glisten->address)) listenAddr = cfg->spiceListen; #ifdef WITH_GNUTLS diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 7ce90f9..429cc45 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -518,8 +518,11 @@ qemuParseCommandLineVnc(virDomainDefPtr def, * -vnc some.host.name:4 */ char *opts; - char *port; + char *portStr; const char *sep = ":"; + int port = 0; + int websocket = 0; + if (val[0] == '[') sep = "]:"; tmp = strstr(val, sep); @@ -528,17 +531,17 @@ qemuParseCommandLineVnc(virDomainDefPtr def, _("missing VNC port number in '%s'"), val); goto cleanup; } - port = tmp + strlen(sep); - if (virStrToLong_i(port, &opts, 10, - &vnc->data.vnc.port) < 0) { + + portStr = tmp + strlen(sep); + if (virStrToLong_i(portStr, &opts, 10, &port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse VNC port '%s'"), port); + _("cannot parse VNC port '%s'"), portStr); goto cleanup; } + if (val[0] == '[') val++; - if (VIR_STRNDUP(listenAddr, val, tmp-val) < 0 || - virDomainGraphicsListenAppendAddress(vnc, listenAddr) < 0) + if (VIR_STRNDUP(listenAddr, val, tmp-val) < 0) goto cleanup; if (*opts == ',') { @@ -554,18 +557,18 @@ qemuParseCommandLineVnc(virDomainDefPtr def, *(nextopt++) = '\0'; if (STRPREFIX(opts, "websocket")) { - char *websocket = opts + strlen("websocket"); - if (*(websocket++) == '=' && - *websocket) { + char *websocketStr = opts + strlen("websocket"); + if (*(websocketStr++) == '=' && + *websocketStr) { /* If the websocket continues with * '=<something>', we'll parse it */ - if (virStrToLong_i(websocket, + if (virStrToLong_i(websocketStr, NULL, 0, - &vnc->data.vnc.websocket) < 0) { + &websocket) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse VNC " "WebSocket port '%s'"), - websocket); + websocketStr); VIR_FREE(orig_opts); goto cleanup; } @@ -573,8 +576,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def, /* Otherwise, we'll compute the port the same * way QEMU does, by adding a 5700 to the * display value. */ - vnc->data.vnc.websocket = - vnc->data.vnc.port + 5700; + websocket = port + 5700; } } else if (STRPREFIX(opts, "share=")) { char *sharePolicy = opts + strlen("share="); @@ -603,8 +605,11 @@ qemuParseCommandLineVnc(virDomainDefPtr def, } VIR_FREE(orig_opts); } - vnc->data.vnc.port += 5900; - vnc->data.vnc.autoport = false; + port += 5900; + + if (virDomainGraphicsListenAppendAddress(vnc, listenAddr, port, 0, + websocket, false) < 0) + goto cleanup; } if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, vnc) < 0) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c3dfc3f..8f0cc9e 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3862,27 +3862,39 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, bool allocate) { unsigned short port; + size_t i; if (graphics->data.vnc.socket) return 0; - if (!allocate) { - if (graphics->data.vnc.autoport) - graphics->data.vnc.port = 5900; + for (i = 0; i < graphics->nListens; i++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[i]; - return 0; - } + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!allocate) { + if (glisten->autoport) + glisten->port = 5900; + continue; + } + if (glisten->autoport) { + if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) + return -1; + glisten->port = port; + } - if (graphics->data.vnc.autoport) { - if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) - return -1; - graphics->data.vnc.port = port; - } + if (glisten->websocket == -1) { + if (virPortAllocatorAcquire(driver->webSocketPorts, &port) < 0) + return -1; + glisten->websocket = port; + } + break; - if (graphics->data.vnc.websocket == -1) { - if (virPortAllocatorAcquire(driver->webSocketPorts, &port) < 0) - return -1; - graphics->data.vnc.websocket = port; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } } return 0; @@ -3902,24 +3914,8 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, bool needTLSPort = false; bool needPort = false; - if (graphics->data.spice.autoport) { - /* check if tlsPort or port need allocation */ - for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) { - switch (graphics->data.spice.channels[i]) { - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - needTLSPort = true; - break; - - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: - needPort = true; - break; - - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - /* default mode will be used */ - break; - } - } - switch (defaultMode) { + for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) { + switch (graphics->data.spice.channels[i]) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: needTLSPort = true; break; @@ -3929,48 +3925,74 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - if (cfg->spiceTLS) - needTLSPort = true; - needPort = true; + /* default mode will be used */ break; } } + switch (defaultMode) { + case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: + needTLSPort = true; + break; - if (!allocate) { - if (needPort || graphics->data.spice.port == -1) - graphics->data.spice.port = 5901; - - if (needTLSPort || graphics->data.spice.tlsPort == -1) - graphics->data.spice.tlsPort = 5902; + case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: + needPort = true; + break; - return 0; + case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: + if (cfg->spiceTLS) + needTLSPort = true; + needPort = true; + break; } - if (needPort || graphics->data.spice.port == -1) { - if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) - goto error; + for (i = 0; i < graphics->nListens; i++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[i]; - graphics->data.spice.port = port; + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!allocate) { + if ((glisten->autoport && needPort) || glisten->port == -1) + glisten->port = 5901; - if (!graphics->data.spice.autoport) - graphics->data.spice.portReserved = true; - } + if ((glisten->autoport && needTLSPort) || glisten->tlsPort == -1) + glisten->tlsPort = 5902; - if (needTLSPort || graphics->data.spice.tlsPort == -1) { - if (!cfg->spiceTLS) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Auto allocation of spice TLS port requested " - "but spice TLS is disabled in qemu.conf")); - goto error; - } + continue; + } - if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0) - goto error; + if ((glisten->autoport && needPort) || glisten->port == -1) { + if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0) + goto error; + + glisten->port = port; - graphics->data.spice.tlsPort = tlsPort; + if (!glisten->autoport) + glisten->portReserved = true; + } - if (!graphics->data.spice.autoport) - graphics->data.spice.tlsPortReserved = true; + if ((glisten->autoport && needTLSPort) || glisten->tlsPort == -1) { + if (!cfg->spiceTLS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Auto allocation of spice TLS port requested " + "but spice TLS is disabled in qemu.conf")); + goto error; + } + + if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0) + goto error; + + glisten->tlsPort = tlsPort; + + if (!glisten->autoport) + glisten->tlsPortReserved = true; + } + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } } return 0; @@ -4352,36 +4374,45 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, virDomainObjPtr vm) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - size_t i; + size_t i, j; int ret = -1; for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - !graphics->data.vnc.autoport) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.vnc.port, - true) < 0) - goto cleanup; - graphics->data.vnc.portReserved = true; - - } else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE && - !graphics->data.spice.autoport) { - if (graphics->data.spice.port > 0) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - true) < 0) - goto cleanup; - graphics->data.spice.portReserved = true; - } - if (graphics->data.spice.tlsPort > 0) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.tlsPort, - true) < 0) - goto cleanup; - graphics->data.spice.tlsPortReserved = true; + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + for (j = 0; j < graphics->nListens; j++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || + glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) { + if (!glisten->autoport) { + if (glisten->port > 0) { + if (virPortAllocatorSetUsed(driver->remotePorts, + glisten->port, + true) < 0) + goto cleanup; + glisten->portReserved = true; + } + if (glisten->tlsPort > 0 && + graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + if (virPortAllocatorSetUsed(driver->remotePorts, + glisten->tlsPort, + true) < 0) + goto cleanup; + glisten->tlsPortReserved = true; + } + } + } } + 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; } } @@ -6186,39 +6217,37 @@ void qemuProcessStop(virQEMUDriverPtr driver, */ for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { - if (graphics->data.vnc.autoport) { - virPortAllocatorRelease(driver->remotePorts, - graphics->data.vnc.port); - } else if (graphics->data.vnc.portReserved) { - virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - false); - graphics->data.vnc.portReserved = false; - } - virPortAllocatorRelease(driver->webSocketPorts, - graphics->data.vnc.websocket); - } - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (graphics->data.spice.autoport) { - virPortAllocatorRelease(driver->remotePorts, - graphics->data.spice.port); - virPortAllocatorRelease(driver->remotePorts, - graphics->data.spice.tlsPort); - } else { - if (graphics->data.spice.portReserved) { + size_t j; + + for (j = 0; j < graphics->nListens; j++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (glisten->autoport) { + virPortAllocatorRelease(driver->remotePorts, + glisten->port); + virPortAllocatorRelease(driver->remotePorts, + glisten->tlsPort); + } + if (glisten->portReserved) { virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.port, - false); - graphics->data.spice.portReserved = false; + glisten->port, false); + glisten->portReserved = false; } - - if (graphics->data.spice.tlsPortReserved) { + if (glisten->tlsPortReserved) { virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.tlsPort, - false); - graphics->data.spice.tlsPortReserved = false; + glisten->tlsPort, false); + glisten->tlsPortReserved = false; } + virPortAllocatorRelease(driver->webSocketPorts, + glisten->websocket); + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } } } diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 13c3fec..6261c09 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1579,7 +1579,7 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) char *guiDisplay = NULL; char *sdlDisplay = NULL; size_t i = 0; - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; for (i = 0; i < def->ngraphics; i++) { IVRDxServer *VRDxServer = NULL; @@ -1593,7 +1593,15 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) gVBoxAPI.UIVRDxServer.SetEnabled(VRDxServer, PR_TRUE); VIR_DEBUG("VRDP Support turned ON."); - gVBoxAPI.UIVRDxServer.SetPorts(data, VRDxServer, def->graphics[i]); + if (!(glisten = virDomainGraphicsGetListen(def->graphics[i], 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + return; + } + + gVBoxAPI.UIVRDxServer.SetPorts(data, VRDxServer, + glisten->port, + glisten->autoport); if (def->graphics[i]->data.rdp.replaceUser) { gVBoxAPI.UIVRDxServer.SetReuseSingleConnection(VRDxServer, @@ -1607,15 +1615,14 @@ vboxAttachDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) VIR_DEBUG("VRDP set to allow multiple connection"); } - if ((gListen = virDomainGraphicsGetListen(def->graphics[i], 0)) && - gListen->address) { + if (glisten->address) { PRUnichar *netAddressUtf16 = NULL; - VBOX_UTF8_TO_UTF16(gListen->address, &netAddressUtf16); + VBOX_UTF8_TO_UTF16(glisten->address, &netAddressUtf16); gVBoxAPI.UIVRDxServer.SetNetAddress(data, VRDxServer, netAddressUtf16); VIR_DEBUG("VRDP listen address is set to: %s", - gListen->address); + glisten->address); VBOX_UTF16_FREE(netAddressUtf16); } @@ -3371,11 +3378,13 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) PRUnichar *netAddressUtf16 = NULL; PRBool allowMultiConnection = PR_FALSE; PRBool reuseSingleConnection = PR_FALSE; + int port = 0; + bool autoport = false; if (VIR_ALLOC(graphics) < 0) goto cleanup; - gVBoxAPI.UIVRDxServer.GetPorts(data, VRDxServer, graphics); + gVBoxAPI.UIVRDxServer.GetPorts(data, VRDxServer, &port, &autoport); graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_RDP; @@ -3388,7 +3397,8 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) if (netAddressUtf8 && STREQ(netAddressUtf8, "")) VBOX_UTF8_FREE(netAddressUtf8); - if (virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, netAddressUtf8, + port, 0, 0, autoport) < 0) goto cleanup; gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection); diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 7a8205d..267367a 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3865,26 +3865,28 @@ _vrdxServerSetEnabled(IVRDxServer *VRDxServer, PRBool enabled) static nsresult _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) + IVRDxServer *VRDxServer, + int *port, + bool *autoport) { nsresult rc; #if VBOX_API_VERSION < 3001000 PRUint32 VRDPport = 0; rc = VRDxServer->vtbl->GetPort(VRDxServer, &VRDPport); if (VRDPport) { - graphics->data.rdp.port = VRDPport; + *port = VRDPport; } else { - graphics->data.rdp.autoport = true; + *autoport = true; } #elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */ PRUnichar *VRDPport = NULL; rc = VRDxServer->vtbl->GetPorts(VRDxServer, &VRDPport); if (VRDPport) { /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port = PRUnicharToInt(VRDPport); + *port = PRUnicharToInt(VRDPport); VBOX_UTF16_FREE(VRDPport); } else { - graphics->data.rdp.autoport = true; + *autoport = true; } #else /* VBOX_API_VERSION >= 4000000 */ PRUnichar *VRDEPortsKey = NULL; @@ -3894,10 +3896,10 @@ _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, VBOX_UTF16_FREE(VRDEPortsKey); if (VRDEPortsValue) { /* even if vbox supports mutilpe ports, single port for now here */ - graphics->data.rdp.port = PRUnicharToInt(VRDEPortsValue); + *port = PRUnicharToInt(VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsValue); } else { - graphics->data.rdp.autoport = true; + *autoport = true; } #endif /* VBOX_API_VERSION >= 4000000 */ return rc; @@ -3905,16 +3907,16 @@ _vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, static nsresult _vrdxServerSetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, - IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics) + IVRDxServer *VRDxServer, + const int port, + const bool autoport ATTRIBUTE_UNUSED) { nsresult rc = 0; #if VBOX_API_VERSION < 3001000 - if (graphics->data.rdp.port) { - rc = VRDxServer->vtbl->SetPort(VRDxServer, - graphics->data.rdp.port); - VIR_DEBUG("VRDP Port changed to: %d", - graphics->data.rdp.port); - } else if (graphics->data.rdp.autoport) { + if (port) { + rc = VRDxServer->vtbl->SetPort(VRDxServer, port); + VIR_DEBUG("VRDP Port changed to: %d", port); + } else if (autoport) { /* Setting the port to 0 will reset its value to * the default one which is 3389 currently */ @@ -3923,14 +3925,14 @@ _vrdxServerSetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED, } #elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */ PRUnichar *portUtf16 = NULL; - portUtf16 = PRUnicharFromInt(graphics->data.rdp.port); + portUtf16 = PRUnicharFromInt(port); rc = VRDxServer->vtbl->SetPorts(VRDxServer, portUtf16); VBOX_UTF16_FREE(portUtf16); #else /* VBOX_API_VERSION >= 4000000 */ PRUnichar *VRDEPortsKey = NULL; PRUnichar *VRDEPortsValue = NULL; VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey); - VRDEPortsValue = PRUnicharFromInt(graphics->data.rdp.port); + VRDEPortsValue = PRUnicharFromInt(port); rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey, VRDEPortsValue); VBOX_UTF16_FREE(VRDEPortsKey); diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index a469968..eb4c9c8 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -379,9 +379,9 @@ typedef struct { nsresult (*GetEnabled)(IVRDxServer *VRDxServer, PRBool *enabled); nsresult (*SetEnabled)(IVRDxServer *VRDxServer, PRBool enabled); nsresult (*GetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer, - virDomainGraphicsDefPtr graphics); + int *port, bool *autoport); nsresult (*SetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer, - virDomainGraphicsDefPtr graphics); + const int port, const bool autoport); nsresult (*GetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool *enabled); nsresult (*SetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool enabled); nsresult (*GetAllowMultiConnection)(IVRDxServer *VRDxServer, PRBool *enabled); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 6505dd7..8084a86 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1843,6 +1843,7 @@ int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) { bool enabled = false; + bool autoport = false; long long port = 0; char *listenAddr = NULL; @@ -1875,24 +1876,22 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) goto failure; } - if (virDomainGraphicsListenAppendAddress(*def, listenAddr) < 0) - goto failure; - VIR_FREE(listenAddr); - if (port < 0) { VIR_WARN("VNC is enabled but VMX entry 'RemoteDisplay.vnc.port' " "is missing, the VNC port is unknown"); - (*def)->data.vnc.port = 0; - (*def)->data.vnc.autoport = true; + port = 0; + autoport = true; } else { if (port < 5900 || port > 5964) VIR_WARN("VNC port %lld it out of [5900..5964] range", port); - - (*def)->data.vnc.port = port; - (*def)->data.vnc.autoport = false; } + if (virDomainGraphicsListenAppendAddress(*def, listenAddr, port, 0, 0, + autoport) < 0) + goto failure; + VIR_FREE(listenAddr); + return 0; failure: @@ -3402,7 +3401,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer) { - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); @@ -3411,23 +3410,26 @@ virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer) virBufferAddLit(buffer, "RemoteDisplay.vnc.enabled = \"true\"\n"); - if (def->data.vnc.autoport) { - VIR_WARN("VNC autoport is enabled, but the automatically assigned " - "VNC port cannot be read back"); - } else { - if (def->data.vnc.port < 5900 || def->data.vnc.port > 5964) { - VIR_WARN("VNC port %d it out of [5900..5964] range", - def->data.vnc.port); - } + glisten = virDomainGraphicsGetListen(def, 0); - virBufferAsprintf(buffer, "RemoteDisplay.vnc.port = \"%d\"\n", - def->data.vnc.port); - } + if (glisten) { + if (glisten->autoport) { + VIR_WARN("VNC autoport is enabled, but the automatically assigned " + "VNC port cannot be read back"); + } else { + if (glisten->port < 5900 || glisten->port > 5964) { + VIR_WARN("VNC port %d it out of [5900..5964] range", + glisten->port); + } - if ((gListen = virDomainGraphicsGetListen(def, 0)) && - gListen->address) { - virBufferAsprintf(buffer, "RemoteDisplay.vnc.ip = \"%s\"\n", - gListen->address); + virBufferAsprintf(buffer, "RemoteDisplay.vnc.port = \"%d\"\n", + glisten->port); + } + + if (glisten->address) { + virBufferAsprintf(buffer, "RemoteDisplay.vnc.ip = \"%s\"\n", + glisten->address); + } } if (def->data.vnc.keymap != NULL) { diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index b321d39..d0f2516 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -993,9 +993,7 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def) pret = PrlVmCfg_GetVNCPort(sdkdom, &port); prlsdkCheckRetGoto(pret, error); - gr->data.vnc.autoport = (vncMode == PRD_AUTO); gr->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - gr->data.vnc.port = port; gr->data.vnc.keymap = NULL; gr->data.vnc.socket = NULL; gr->data.vnc.auth.passwd = NULL; @@ -1007,12 +1005,13 @@ prlsdkAddVNCInfo(PRL_HANDLE sdkdom, virDomainDefPtr def) gr->nListens = 1; + gr->listens[0].type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; + gr->listens[0].autoport = (vncMode == PRD_AUTO); + gr->listens[0].port = port; if (!(gr->listens[0].address = prlsdkGetStringParamVar(PrlVmCfg_GetVNCHostName, sdkdom))) goto error; - gr->listens[0].type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; - if (VIR_APPEND_ELEMENT(def->graphics, def->ngraphics, gr) < 0) goto error; @@ -2683,7 +2682,7 @@ static int prlsdkCheckFSUnsupportedParams(virDomainFSDefPtr fs) static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom, virDomainDefPtr def) { virDomainGraphicsDefPtr gr; - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; PRL_RESULT pret; int ret = -1; @@ -2695,23 +2694,28 @@ static int prlsdkApplyGraphicsParams(PRL_HANDLE sdkdom, virDomainDefPtr def) gr = def->graphics[0]; - if (gr->data.vnc.autoport) { + if (!(glisten = virDomainGraphicsGetListen(gr, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto cleanup; + } + + if (glisten->autoport) { pret = PrlVmCfg_SetVNCMode(sdkdom, PRD_AUTO); prlsdkCheckRetGoto(pret, cleanup); } else { pret = PrlVmCfg_SetVNCMode(sdkdom, PRD_MANUAL); prlsdkCheckRetGoto(pret, cleanup); - pret = PrlVmCfg_SetVNCPort(sdkdom, gr->data.vnc.port); + pret = PrlVmCfg_SetVNCPort(sdkdom, glisten->port); prlsdkCheckRetGoto(pret, cleanup); } - if ((gListen = virDomainGraphicsGetListen(gr, 0))) { - if (!gListen->address) - goto cleanup; - pret = PrlVmCfg_SetVNCHostName(sdkdom, gListen->address); - prlsdkCheckRetGoto(pret, cleanup); - } + if (!glisten->address) + goto cleanup; + + pret = PrlVmCfg_SetVNCHostName(sdkdom, glisten->address); + prlsdkCheckRetGoto(pret, cleanup); ret = 0; cleanup: diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 629fbf5..a12ee74 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -570,6 +570,8 @@ static int xenParseVfb(virConfPtr conf, virDomainDefPtr def) { int val; + int port = 0; + bool autoport = false; char *listenAddr = NULL; int hvm = def->os.type == VIR_DOMAIN_OSTYPE_HVM; virConfValuePtr list; @@ -584,17 +586,18 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; if (xenConfigGetBool(conf, "vncunused", &val, 1) < 0) goto cleanup; - graphics->data.vnc.autoport = val ? 1 : 0; - if (!graphics->data.vnc.autoport) { + autoport = val ? 1 : 0; + if (!autoport) { unsigned long vncdisplay; if (xenConfigGetULong(conf, "vncdisplay", &vncdisplay, 0) < 0) goto cleanup; - graphics->data.vnc.port = (int)vncdisplay + 5900; + port = (int)vncdisplay + 5900; } if (xenConfigCopyStringOpt(conf, "vnclisten", &listenAddr) < 0) goto cleanup; - if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr, + port, 0, 0, autoport) < 0) goto cleanup; VIR_FREE(listenAddr); @@ -661,7 +664,7 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { if (STRPREFIX(key, "vncunused=")) { if (STREQ(key + 10, "1")) - graphics->data.vnc.autoport = true; + autoport = true; } else if (STRPREFIX(key, "vnclisten=")) { if (VIR_STRDUP(listenAddr, key+10) < 0) goto cleanup; @@ -672,14 +675,13 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) if (VIR_STRDUP(graphics->data.vnc.keymap, key + 7) < 0) goto cleanup; } else if (STRPREFIX(key, "vncdisplay=")) { - if (virStrToLong_i(key + 11, NULL, 10, - &graphics->data.vnc.port) < 0) { + if (virStrToLong_i(key + 11, NULL, 10, &port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("invalid vncdisplay value '%s'"), key + 11); goto cleanup; } - graphics->data.vnc.port += 5900; + port += 5900; } } else { if (STRPREFIX(key, "display=")) { @@ -699,9 +701,12 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) } if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { if (virDomainGraphicsListenAppendAddress(graphics, - listenAddr) < 0) + listenAddr, + port, 0, 0, + autoport) < 0) goto cleanup; } + if (VIR_ALLOC_N(def->graphics, 1) < 0) goto cleanup; def->graphics[0] = graphics; @@ -1631,7 +1636,7 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) def->graphics[0]->data.sdl.xauth) < 0) return -1; } else { - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; if (xenConfigSetInt(conf, "sdl", 0) < 0) return -1; @@ -1639,19 +1644,20 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) if (xenConfigSetInt(conf, "vnc", 1) < 0) return -1; - if (xenConfigSetInt(conf, "vncunused", - def->graphics[0]->data.vnc.autoport ? 1 : 0) < 0) - return -1; + if ((glisten = virDomainGraphicsGetListen(def->graphics[0], 0))) { + if (xenConfigSetInt(conf, "vncunused", + glisten->autoport ? 1 : 0) < 0) + return -1; - if (!def->graphics[0]->data.vnc.autoport && - xenConfigSetInt(conf, "vncdisplay", - def->graphics[0]->data.vnc.port - 5900) < 0) - return -1; + if (!glisten->autoport && + xenConfigSetInt(conf, "vncdisplay", + glisten->port - 5900) < 0) + return -1; - if ((gListen = virDomainGraphicsGetListen(def->graphics[0], 0)) && - gListen->address && - xenConfigSetString(conf, "vnclisten", gListen->address) < 0) - return -1; + if (glisten->address && + xenConfigSetString(conf, "vnclisten", glisten->address) < 0) + return -1; + } if (def->graphics[0]->data.vnc.auth.passwd && xenConfigSetString(conf, "vncpasswd", @@ -1677,17 +1683,20 @@ xenFormatVfb(virConfPtr conf, virDomainDefPtr def) virBufferAsprintf(&buf, ",xauthority=%s", def->graphics[0]->data.sdl.xauth); } else { - virDomainGraphicsListenDefPtr gListen + virDomainGraphicsListenDefPtr glisten = virDomainGraphicsGetListen(def->graphics[0], 0); virBufferAddLit(&buf, "type=vnc"); - virBufferAsprintf(&buf, ",vncunused=%d", - def->graphics[0]->data.vnc.autoport ? 1 : 0); - if (!def->graphics[0]->data.vnc.autoport) - virBufferAsprintf(&buf, ",vncdisplay=%d", - def->graphics[0]->data.vnc.port - 5900); - if (gListen && gListen->address) - virBufferAsprintf(&buf, ",vnclisten=%s", gListen->address); + + if (glisten) { + virBufferAsprintf(&buf, ",vncunused=%d", + glisten->autoport ? 1 : 0); + if (!glisten->autoport) + virBufferAsprintf(&buf, ",vncdisplay=%d", + glisten->port - 5900); + if (glisten->address) + virBufferAsprintf(&buf, ",vnclisten=%s", glisten->address); + } if (def->graphics[0]->data.vnc.auth.passwd) virBufferAsprintf(&buf, ",vncpasswd=%s", def->graphics[0]->data.vnc.auth.passwd); diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 381dbdc..616ab76 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -851,23 +851,21 @@ xenParseSxprGraphicsOld(virDomainDefPtr def, if ((tmp = sexpr_fmt_node(root, "domain/image/%s/vnc", hvm ? "hvm" : "linux")) && tmp[0] == '1') { /* Graphics device (HVM, or old (pre-3.0.4) style PV VNC config) */ - int port; + bool autoport = false; const char *listenAddr = sexpr_fmt_node(root, "domain/image/%s/vnclisten", hvm ? "hvm" : "linux"); const char *vncPasswd = sexpr_fmt_node(root, "domain/image/%s/vncpasswd", hvm ? "hvm" : "linux"); const char *keymap = sexpr_fmt_node(root, "domain/image/%s/keymap", hvm ? "hvm" : "linux"); const char *unused = sexpr_fmt_node(root, "domain/image/%s/vncunused", hvm ? "hvm" : "linux"); - port = vncport; - if (VIR_ALLOC(graphics) < 0) goto error; graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC; - if ((unused && STREQ(unused, "1")) || port == -1) - graphics->data.vnc.autoport = true; - graphics->data.vnc.port = port; + if ((unused && STREQ(unused, "1")) || vncport == -1) + autoport = true; - if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr, + vncport, 0, 0, autoport) < 0) goto error; if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0) @@ -962,14 +960,13 @@ xenParseSxprGraphicsNew(virDomainDefPtr def, if (VIR_STRDUP(graphics->data.sdl.xauth, xauth) < 0) goto error; } else { - int port; + int port = vncport; + bool autoport = false; const char *listenAddr = sexpr_node(node, "device/vfb/vnclisten"); const char *vncPasswd = sexpr_node(node, "device/vfb/vncpasswd"); const char *keymap = sexpr_node(node, "device/vfb/keymap"); const char *unused = sexpr_node(node, "device/vfb/vncunused"); - port = vncport; - /* Didn't find port entry in xenstore */ if (port == -1) { const char *str = sexpr_node(node, "device/vfb/vncdisplay"); @@ -979,13 +976,13 @@ xenParseSxprGraphicsNew(virDomainDefPtr def, } if ((unused && STREQ(unused, "1")) || port == -1) - graphics->data.vnc.autoport = true; + autoport = true; if (port >= 0 && port < 5900) port += 5900; - graphics->data.vnc.port = port; - if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr, + port, 0, 0, autoport) < 0) goto error; if (VIR_STRDUP(graphics->data.vnc.auth.passwd, vncPasswd) < 0) @@ -1521,7 +1518,7 @@ static int xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, virBufferPtr buf) { - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL && def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { @@ -1542,16 +1539,20 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, virBufferAsprintf(buf, "(xauthority '%s')", def->data.sdl.xauth); } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { virBufferAddLit(buf, "(type vnc)"); - if (def->data.vnc.autoport) { - virBufferAddLit(buf, "(vncunused 1)"); - } else { - virBufferAddLit(buf, "(vncunused 0)"); - virBufferAsprintf(buf, "(vncdisplay %d)", def->data.vnc.port-5900); - } - if ((gListen = virDomainGraphicsGetListen(def, 0)) && - gListen->address) - virBufferAsprintf(buf, "(vnclisten '%s')", gListen->address); + glisten = virDomainGraphicsGetListen(def, 0); + + if (glisten) { + if (glisten->autoport) { + virBufferAddLit(buf, "(vncunused 1)"); + } else { + virBufferAddLit(buf, "(vncunused 0)"); + virBufferAsprintf(buf, "(vncdisplay %d)", glisten->port-5900); + } + + if (glisten->address) + virBufferAsprintf(buf, "(vnclisten '%s')", glisten->address); + } if (def->data.vnc.auth.passwd) virBufferAsprintf(buf, "(vncpasswd '%s')", def->data.vnc.auth.passwd); if (def->data.vnc.keymap) @@ -1577,7 +1578,7 @@ xenFormatSxprGraphicsNew(virDomainGraphicsDefPtr def, static int xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf) { - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_SDL && def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { @@ -1595,16 +1596,18 @@ xenFormatSxprGraphicsOld(virDomainGraphicsDefPtr def, virBufferPtr buf) virBufferAsprintf(buf, "(xauthority '%s')", def->data.sdl.xauth); } else if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) { virBufferAddLit(buf, "(vnc 1)"); - if (def->data.vnc.autoport) { - virBufferAddLit(buf, "(vncunused 1)"); - } else { - virBufferAddLit(buf, "(vncunused 0)"); - virBufferAsprintf(buf, "(vncdisplay %d)", def->data.vnc.port-5900); - } - if ((gListen = virDomainGraphicsGetListen(def, 0)) && - gListen->address) - virBufferAsprintf(buf, "(vnclisten '%s')", gListen->address); + if ((glisten = virDomainGraphicsGetListen(def, 0))) { + if (glisten->autoport) { + virBufferAddLit(buf, "(vncunused 1)"); + } else { + virBufferAddLit(buf, "(vncunused 0)"); + virBufferAsprintf(buf, "(vncdisplay %d)", glisten->port-5900); + } + + if (glisten->address) + virBufferAsprintf(buf, "(vnclisten '%s')", glisten->address); + } if (def->data.vnc.auth.passwd) virBufferAsprintf(buf, "(vncpasswd '%s')", def->data.vnc.auth.passwd); if (def->data.vnc.keymap) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 7d41e05..8acc48c 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -172,6 +172,8 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) { virDomainGraphicsDefPtr graphics = NULL; unsigned long port; + unsigned long tlsPort; + bool autoport = false; char *listenAddr = NULL; int val; @@ -186,22 +188,20 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE; if (xenConfigCopyStringOpt(conf, "spicehost", &listenAddr) < 0) goto cleanup; - if (virDomainGraphicsListenAppendAddress(graphics, listenAddr) < 0) - goto cleanup; - VIR_FREE(listenAddr); - if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0) + if (xenConfigGetULong(conf, "spiceport", &port, 0) < 0) goto cleanup; - graphics->data.spice.tlsPort = (int)port; - if (xenConfigGetULong(conf, "spiceport", &port, 0) < 0) + if (xenConfigGetULong(conf, "spicetls_port", &tlsPort, 0) < 0) goto cleanup; - graphics->data.spice.port = (int)port; + if (!tlsPort && !port) + autoport = true; - if (!graphics->data.spice.tlsPort && - !graphics->data.spice.port) - graphics->data.spice.autoport = 1; + if (virDomainGraphicsListenAppendAddress(graphics, listenAddr, + (int)port, (int)tlsPort, + 0, autoport) < 0) + goto cleanup; if (xenConfigGetBool(conf, "spicedisable_ticketing", &val, 0) < 0) goto cleanup; @@ -236,6 +236,7 @@ xenParseXLSpice(virConfPtr conf, virDomainDefPtr def) } } + VIR_FREE(listenAddr); return 0; cleanup: @@ -837,7 +838,7 @@ xenFormatXLDomainDisks(virConfPtr conf, virDomainDefPtr def) static int xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) { - virDomainGraphicsListenDefPtr gListen; + virDomainGraphicsListenDefPtr glisten; virDomainGraphicsDefPtr graphics; if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) { @@ -854,18 +855,19 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr def) if (xenConfigSetInt(conf, "spice", 1) < 0) return -1; - if ((gListen = virDomainGraphicsGetListen(graphics, 0)) && - gListen->address && - xenConfigSetString(conf, "spicehost", gListen->address) < 0) - return -1; + if ((glisten = virDomainGraphicsGetListen(graphics, 0))) { + if (glisten->address && + xenConfigSetString(conf, "spicehost", glisten->address) < 0) + return -1; - if (xenConfigSetInt(conf, "spiceport", - graphics->data.spice.port) < 0) - return -1; + if (xenConfigSetInt(conf, "spiceport", + glisten->port) < 0) + return -1; - if (xenConfigSetInt(conf, "spicetls_port", - graphics->data.spice.tlsPort) < 0) - return -1; + if (xenConfigSetInt(conf, "spicetls_port", + glisten->tlsPort) < 0) + return -1; + } if (graphics->data.spice.auth.passwd) { if (xenConfigSetInt(conf, "spicedisable_ticketing", 0) < 0) diff --git a/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-ports.xml b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-ports.xml new file mode 100644 index 0000000..0ba6f9e --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-listen-back-compat-ports.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address' address='127.0.0.1' port='5900' autoport='no'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml index 8bbf5df..ef8426e 100644 --- a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-minimal.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc'> - <listen type='address' address='127.0.0.1'/> + <listen type='address'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1'/> diff --git a/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address-port.xml b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address-port.xml new file mode 100644 index 0000000..d638358 --- /dev/null +++ b/tests/genericxml2xmlindata/generic-graphics-vnc-listen-element-with-address-port.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='address' address='127.0.0.1' port='5900' autoport='no'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat-ports.xml b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat-ports.xml new file mode 100644 index 0000000..b0333c3 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat-ports.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1' port='5900' autoport='no'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml index aa00d34..2d61b41 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-listen-back-compat.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='192.168.123.123'> - <listen type='address' address='192.168.123.123'/> + <listen type='address' address='192.168.123.123' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml index ee4909b..e0eb61e 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-attr-only.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml index ee4909b..6309cf8 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-minimal.xml @@ -19,8 +19,8 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <graphics type='vnc' port='-1' autoport='yes'> + <listen type='address' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address-port.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address-port.xml new file mode 100644 index 0000000..b0333c3 --- /dev/null +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address-port.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='5900' autoport='no' listen='127.0.0.1'> + <listen type='address' address='127.0.0.1' port='5900' autoport='no'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml index ee4909b..e0eb61e 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-listen-element-with-address.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml index 7301057..6309cf8 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-manual-port.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml index 7301057..6309cf8 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-minimal.xml @@ -20,7 +20,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c index 70ecd2d..76c18e5 100644 --- a/tests/genericxml2xmltest.c +++ b/tests/genericxml2xmltest.c @@ -84,9 +84,12 @@ mymain(void) DO_TEST_DIFFERENT("graphics-listen-back-compat"); DO_TEST_FULL("graphics-listen-back-compat-mismatch", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); + DO_TEST_FULL("graphics-listen-back-compat-ports", 0, false, + TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); DO_TEST_DIFFERENT("graphics-vnc-listen-attr-only"); DO_TEST_DIFFERENT("graphics-vnc-listen-element-minimal"); DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address"); + DO_TEST_DIFFERENT("graphics-vnc-listen-element-with-address-port"); DO_TEST_FULL("name-slash-parse", 0, false, TEST_COMPARE_DOM_XML2XML_RESULT_FAIL_PARSE); diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-policy.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-policy.xml index 3ebb375..be722ed 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-policy.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-policy.xml @@ -26,7 +26,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='65530' autoport='no' listen='::' sharePolicy='allow-exclusive'> - <listen type='address' address='::'/> + <listen type='address' address='::' port='65530' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-sasl.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-sasl.xml index 5b7d560..298ffcd 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-sasl.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-sasl.xml @@ -26,7 +26,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-tls.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-tls.xml index 5b7d560..298ffcd 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-tls.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-tls.xml @@ -26,7 +26,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-websocket.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-websocket.xml index 260ad1c..0db910a 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-websocket.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-websocket.xml @@ -19,7 +19,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5900' autoport='no' websocket='5700' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5900' websocket='5700' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml index 374345b..d5603c3 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc.xml @@ -26,7 +26,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'> - <listen type='address' address='2001:1:2:3:4:5:1234:1234'/> + <listen type='address' address='2001:1:2:3:4:5:1234:1234' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml index a2796ec..b6d645b 100644 --- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml +++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2+console-virtio.xml @@ -85,7 +85,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'> - <listen type='address' address='0.0.0.0'/> + <listen type='address' address='0.0.0.0' autoport='yes'/> </graphics> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml index 2ae104e..cc6e3b8 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml @@ -82,7 +82,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'> - <listen type='address' address='0.0.0.0'/> + <listen type='address' address='0.0.0.0' autoport='yes'/> </graphics> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network.xml index 79f990c..3d80f33 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no'> - <listen type='network' network='Bobsnetwork'/> + <listen type='network' network='Bobsnetwork' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml index a0831aa..aac899f 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-listen-network2.xml @@ -29,8 +29,8 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='1.2.3.4'> - <listen type='address' address='1.2.3.4'/> - <listen type='network' network='Bobsnetwork'/> + <listen type='address' address='1.2.3.4' autoport='yes'/> + <listen type='network' network='Bobsnetwork' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-compression.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-compression.xml index dea1347..c421e1c 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-compression.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-compression.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' tlsPort='5904' autoport='no'/> <image compression='auto_glz'/> <jpeg compression='auto'/> <zlib compression='auto'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-qxl-vga.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-qxl-vga.xml index a17fab2..0bf6bf4 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-qxl-vga.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-qxl-vga.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' tlsPort='5904' autoport='no'/> <channel name='main' mode='secure'/> <channel name='inputs' mode='insecure'/> </graphics> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml index 912b542..f0dc9c1 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-timeout.xml @@ -78,7 +78,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='5900' autoport='no' passwd='sercet' passwdValidTo='2011-05-31T16:11:22' connected='disconnect'> - <listen type='address'/> + <listen type='address' port='5900' autoport='no'/> </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice.xml index 59ed507..934e1d2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1' defaultMode='secure'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' tlsPort='5904' autoport='no'/> <channel name='main' mode='secure'/> <channel name='inputs' mode='insecure'/> <image compression='auto_glz'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml index 7440533..7450566 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml @@ -29,7 +29,7 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' port='-1' autoport='yes'/> + <graphics type='vnc'/> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-no-listen-attr.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-no-listen-attr.xml index 0627bbd..5772fe2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-no-listen-attr.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-no-listen-attr.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'> - <listen type='address' address='2001:1:2:3:4:5:1234:1234'/> + <listen type='address' address='2001:1:2:3:4:5:1234:1234' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-sasl.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-sasl.xml index f29abe2..dcefb98 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-sasl.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-sasl.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-tls.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-tls.xml index f29abe2..dcefb98 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-tls.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-tls.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-websocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-websocket.xml index 6e879eb..35260ec 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-websocket.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-websocket.xml @@ -21,7 +21,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5900' autoport='no' websocket='5700' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5900' websocket='5700' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc.xml index 0627bbd..5772fe2 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5903' autoport='no' listen='2001:1:2:3:4:5:1234:1234'> - <listen type='address' address='2001:1:2:3:4:5:1234:1234'/> + <listen type='address' address='2001:1:2:3:4:5:1234:1234' port='5903' autoport='no'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml index 95b6e2d..4fc9f08 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-interface-server.xml @@ -120,7 +120,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <sound model='ich6'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml index 1fb740b..7243800 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth.xml @@ -64,7 +64,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml index 6464890..b93e714 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-bandwidth2.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-bridge.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-bridge.xml index 61de009..3feea02 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-bridge.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-bridge.xml @@ -238,7 +238,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml index 050967b..d6e40af 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-seclabel-dynamic-none-relabel.xml @@ -39,7 +39,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' autoport='yes' listen='0.0.0.0'> - <listen type='address' address='0.0.0.0'/> + <listen type='address' address='0.0.0.0' autoport='yes'/> </graphics> <video> <model type='cirrus' vram='8192' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml index 5b18cac..208529e 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-spiceport.xml @@ -38,7 +38,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5903' tlsPort='5904' autoport='no'/> </graphics> <video> <model type='qxl' ram='65536' vram='65536' vgamem='8192' heads='1' primary='yes'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml index a6dddab..fd260ea 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' autoport='no'> - <listen type='address'/> + <listen type='address' autoport='no'/> <gl enable='yes'/> </graphics> <video> diff --git a/tests/sexpr2xmldata/sexpr2xml-curmem.xml b/tests/sexpr2xmldata/sexpr2xml-curmem.xml index ab23c66..7f65832 100644 --- a/tests/sexpr2xmldata/sexpr2xml-curmem.xml +++ b/tests/sexpr2xmldata/sexpr2xml-curmem.xml @@ -34,7 +34,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml index 799e3ff..7f04d04 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml @@ -50,7 +50,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='5925' autoport='yes' keymap='en-us'> - <listen type='address'/> + <listen type='address' port='5925' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml index adc6b89..a880e61 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-empty-kernel.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml index 836f7e3..7cca138 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-hpet.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml index 9c17ce4..b493b57 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-force-nohpet.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml index 8d6a6a9..1b9d2ee 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-localtime.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml index 4f4f16a..1915e59 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-net-netfront.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml index e9a60af..78ea16e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-parallel-tcp.xml @@ -48,7 +48,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml index ed53287..c8e5308 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2-ports.xml @@ -55,7 +55,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml index d22719d..14c1736 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-dev-2nd-port.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml index ea82206..fba05dc 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml index ac248b9..eae1f55 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml index 4942800..12f2484 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml index 358e544..ce3fd0a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml index 5bded20..035aa0f 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml index b4447e2..dd2cc63 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp-telnet.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml index 798117e..795fe0a 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml index 941457e..cb39e0e 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml index 7ae7f01..1eb7dbe 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml index efbded1..cd796e4 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound-all.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <sound model='sb16'/> <sound model='es1370'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml index efbded1..cd796e4 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-sound.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <sound model='sb16'/> <sound model='es1370'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml index f53d00e..40fa8f5 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbmouse.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml index 9b41231..a226b63 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-usbtablet.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml index 8eba88f..ec37507 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-utc.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml index 8eba88f..ec37507 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv-v2.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-fv.xml b/tests/sexpr2xmldata/sexpr2xml-fv.xml index 8eba88f..ec37507 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv.xml +++ b/tests/sexpr2xmldata/sexpr2xml-fv.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml index 89dd87f..fb06652 100644 --- a/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml +++ b/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml @@ -48,7 +48,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml index dbdacf9..58b1b4c 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new-vncdisplay.xml @@ -27,7 +27,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='5925' autoport='no' listen='0.0.0.0' keymap='ja'> - <listen type='address' address='0.0.0.0'/> + <listen type='address' address='0.0.0.0' port='5925' autoport='no'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml index c415aab..44f5b51 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml @@ -27,7 +27,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='ja'> - <listen type='address' address='0.0.0.0'/> + <listen type='address' address='0.0.0.0' port='-1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml index e8b1cd5..2b1e293 100644 --- a/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml +++ b/tests/sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml @@ -32,7 +32,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml b/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml index 1e9d60b..0279419 100644 --- a/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml +++ b/tests/sexpr2xmldata/sexpr2xml-vif-rate.xml @@ -47,7 +47,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='ja'> - <listen type='address'/> + <listen type='address' port='-1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml index 3c57579..9a9c9a8 100644 --- a/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml +++ b/tests/vmx2xmldata/vmx2xml-graphics-vnc.xml @@ -12,7 +12,7 @@ <on_crash>destroy</on_crash> <devices> <graphics type='vnc' port='5903' autoport='no' keymap='de' passwd='password'> - <listen type='address'/> + <listen type='address' port='5903' autoport='no'/> </graphics> <video> <model type='vmvga' vram='4096' primary='yes'/> diff --git a/tests/xlconfigdata/test-disk-positional-parms-full.xml b/tests/xlconfigdata/test-disk-positional-parms-full.xml index 3d4868c..92efc4b 100644 --- a/tests/xlconfigdata/test-disk-positional-parms-full.xml +++ b/tests/xlconfigdata/test-disk-positional-parms-full.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-disk-positional-parms-partial.xml b/tests/xlconfigdata/test-disk-positional-parms-partial.xml index 402f479..fb28fb6 100644 --- a/tests/xlconfigdata/test-disk-positional-parms-partial.xml +++ b/tests/xlconfigdata/test-disk-positional-parms-partial.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml index 686a409..df7b02c 100644 --- a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml +++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-bogus-extra.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml index 686a409..df7b02c 100644 --- a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml +++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot-extra.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml index 686a409..df7b02c 100644 --- a/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml +++ b/tests/xlconfigdata/test-fullvirt-direct-kernel-boot.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-fullvirt-multiusb.xml b/tests/xlconfigdata/test-fullvirt-multiusb.xml index 5ec72c4..03ed011 100644 --- a/tests/xlconfigdata/test-fullvirt-multiusb.xml +++ b/tests/xlconfigdata/test-fullvirt-multiusb.xml @@ -45,7 +45,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-fullvirt-nohap.xml b/tests/xlconfigdata/test-fullvirt-nohap.xml index a997c7a..d1e7c14 100644 --- a/tests/xlconfigdata/test-fullvirt-nohap.xml +++ b/tests/xlconfigdata/test-fullvirt-nohap.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-new-disk.xml b/tests/xlconfigdata/test-new-disk.xml index 3d4868c..92efc4b 100644 --- a/tests/xlconfigdata/test-new-disk.xml +++ b/tests/xlconfigdata/test-new-disk.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-rbd-multihost-noauth.xml b/tests/xlconfigdata/test-rbd-multihost-noauth.xml index f8f663f..c838dd6 100644 --- a/tests/xlconfigdata/test-rbd-multihost-noauth.xml +++ b/tests/xlconfigdata/test-rbd-multihost-noauth.xml @@ -46,7 +46,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xlconfigdata/test-spice-features.xml b/tests/xlconfigdata/test-spice-features.xml index f9eb857..03096fb 100644 --- a/tests/xlconfigdata/test-spice-features.xml +++ b/tests/xlconfigdata/test-spice-features.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='590' tlsPort='500' autoport='no' listen='127.0.0.1' passwd='thebeast'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='590' tlsPort='500' autoport='no'/> <mouse mode='client'/> <clipboard copypaste='yes'/> </graphics> diff --git a/tests/xlconfigdata/test-spice.xml b/tests/xlconfigdata/test-spice.xml index fc2fa3f..1b19ebe 100644 --- a/tests/xlconfigdata/test-spice.xml +++ b/tests/xlconfigdata/test-spice.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='spice' port='590' tlsPort='500' autoport='no' listen='127.0.0.1' passwd='thebeast'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='590' tlsPort='500' autoport='no'/> <mouse mode='server'/> <clipboard copypaste='no'/> </graphics> diff --git a/tests/xlconfigdata/test-vif-rate.xml b/tests/xlconfigdata/test-vif-rate.xml index 0e13f2e..ec97208 100644 --- a/tests/xlconfigdata/test-vif-rate.xml +++ b/tests/xlconfigdata/test-vif-rate.xml @@ -52,7 +52,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-escape-paths.xml b/tests/xmconfigdata/test-escape-paths.xml index 6373fdf..1c9404d 100644 --- a/tests/xmconfigdata/test-escape-paths.xml +++ b/tests/xmconfigdata/test-escape-paths.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <sound model='sb16'/> <sound model='es1370'/> diff --git a/tests/xmconfigdata/test-fullvirt-default-feature.xml b/tests/xmconfigdata/test-fullvirt-default-feature.xml index 6f4dae6..4eb2087 100644 --- a/tests/xmconfigdata/test-fullvirt-default-feature.xml +++ b/tests/xmconfigdata/test-fullvirt-default-feature.xml @@ -45,7 +45,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-force-hpet.xml b/tests/xmconfigdata/test-fullvirt-force-hpet.xml index 6f4dae6..4eb2087 100644 --- a/tests/xmconfigdata/test-fullvirt-force-hpet.xml +++ b/tests/xmconfigdata/test-fullvirt-force-hpet.xml @@ -45,7 +45,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-force-nohpet.xml b/tests/xmconfigdata/test-fullvirt-force-nohpet.xml index 6015405..194b49c 100644 --- a/tests/xmconfigdata/test-fullvirt-force-nohpet.xml +++ b/tests/xmconfigdata/test-fullvirt-force-nohpet.xml @@ -45,7 +45,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-localtime.xml b/tests/xmconfigdata/test-fullvirt-localtime.xml index 5f81e25..f03aded 100644 --- a/tests/xmconfigdata/test-fullvirt-localtime.xml +++ b/tests/xmconfigdata/test-fullvirt-localtime.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-net-netfront.xml b/tests/xmconfigdata/test-fullvirt-net-netfront.xml index cb0615b..7d3f759 100644 --- a/tests/xmconfigdata/test-fullvirt-net-netfront.xml +++ b/tests/xmconfigdata/test-fullvirt-net-netfront.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-new-cdrom.xml b/tests/xmconfigdata/test-fullvirt-new-cdrom.xml index d29892e..8837849 100644 --- a/tests/xmconfigdata/test-fullvirt-new-cdrom.xml +++ b/tests/xmconfigdata/test-fullvirt-new-cdrom.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-nohap.xml b/tests/xmconfigdata/test-fullvirt-nohap.xml index f38366c..7f871d0 100644 --- a/tests/xmconfigdata/test-fullvirt-nohap.xml +++ b/tests/xmconfigdata/test-fullvirt-nohap.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml b/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml index 3269aee..8fea426 100644 --- a/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml +++ b/tests/xmconfigdata/test-fullvirt-parallel-tcp.xml @@ -48,7 +48,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.xml b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.xml index a20d6c8..5fb2c56 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2-ports.xml @@ -55,7 +55,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.xml b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.xml index 8344da3..8a0cca4 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-dev-2nd-port.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-file.xml b/tests/xmconfigdata/test-fullvirt-serial-file.xml index b9439d7..cb56f7e 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-file.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-file.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-null.xml b/tests/xmconfigdata/test-fullvirt-serial-null.xml index 6e8196b..777d94f 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-null.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-null.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml index da0c9bd..694d2cb 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-pipe.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-pipe.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-pty.xml b/tests/xmconfigdata/test-fullvirt-serial-pty.xml index acff588..3bbf9c2 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-pty.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-pty.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml index 6909053..47bd772 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-stdio.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-stdio.xml @@ -49,7 +49,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml index a3fd449..2f6ae43 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp-telnet.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml index 9dba76d..1a09cf5 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-tcp.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-tcp.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-udp.xml b/tests/xmconfigdata/test-fullvirt-serial-udp.xml index 3577f92..3bfd659 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-udp.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-udp.xml @@ -53,7 +53,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-serial-unix.xml b/tests/xmconfigdata/test-fullvirt-serial-unix.xml index 919108b..f98a55d 100644 --- a/tests/xmconfigdata/test-fullvirt-serial-unix.xml +++ b/tests/xmconfigdata/test-fullvirt-serial-unix.xml @@ -51,7 +51,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-sound.xml b/tests/xmconfigdata/test-fullvirt-sound.xml index 0e85953..ae9ebb5 100644 --- a/tests/xmconfigdata/test-fullvirt-sound.xml +++ b/tests/xmconfigdata/test-fullvirt-sound.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <sound model='sb16'/> <sound model='es1370'/> diff --git a/tests/xmconfigdata/test-fullvirt-usbmouse.xml b/tests/xmconfigdata/test-fullvirt-usbmouse.xml index 8eb5aa5..94febd9 100644 --- a/tests/xmconfigdata/test-fullvirt-usbmouse.xml +++ b/tests/xmconfigdata/test-fullvirt-usbmouse.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-usbtablet.xml b/tests/xmconfigdata/test-fullvirt-usbtablet.xml index dcdd951..ab07741 100644 --- a/tests/xmconfigdata/test-fullvirt-usbtablet.xml +++ b/tests/xmconfigdata/test-fullvirt-usbtablet.xml @@ -44,7 +44,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-fullvirt-utc.xml b/tests/xmconfigdata/test-fullvirt-utc.xml index d29892e..8837849 100644 --- a/tests/xmconfigdata/test-fullvirt-utc.xml +++ b/tests/xmconfigdata/test-fullvirt-utc.xml @@ -43,7 +43,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-no-source-cdrom.xml b/tests/xmconfigdata/test-no-source-cdrom.xml index 61cfb75..464ee10 100644 --- a/tests/xmconfigdata/test-no-source-cdrom.xml +++ b/tests/xmconfigdata/test-no-source-cdrom.xml @@ -48,7 +48,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-paravirt-net-e1000.xml b/tests/xmconfigdata/test-paravirt-net-e1000.xml index ad44d11..c4f59eb 100644 --- a/tests/xmconfigdata/test-paravirt-net-e1000.xml +++ b/tests/xmconfigdata/test-paravirt-net-e1000.xml @@ -30,7 +30,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-paravirt-net-vifname.xml b/tests/xmconfigdata/test-paravirt-net-vifname.xml index e94b685..d01fed9 100644 --- a/tests/xmconfigdata/test-paravirt-net-vifname.xml +++ b/tests/xmconfigdata/test-paravirt-net-vifname.xml @@ -31,7 +31,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml index 3ca3023..886b0fd 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml +++ b/tests/xmconfigdata/test-paravirt-new-pvfb-vncdisplay.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='5925' autoport='no' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' port='5925' autoport='no'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-paravirt-new-pvfb.xml b/tests/xmconfigdata/test-paravirt-new-pvfb.xml index d97799a..2830d2e 100644 --- a/tests/xmconfigdata/test-paravirt-new-pvfb.xml +++ b/tests/xmconfigdata/test-paravirt-new-pvfb.xml @@ -29,7 +29,7 @@ <input type='mouse' bus='xen'/> <input type='keyboard' bus='xen'/> <graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' passwd='123poi'> - <listen type='address' address='127.0.0.1'/> + <listen type='address' address='127.0.0.1' autoport='yes'/> </graphics> <video> <model type='xen' heads='1' primary='yes'/> diff --git a/tests/xmconfigdata/test-pci-devs.xml b/tests/xmconfigdata/test-pci-devs.xml index 3bc263f..3ccac93 100644 --- a/tests/xmconfigdata/test-pci-devs.xml +++ b/tests/xmconfigdata/test-pci-devs.xml @@ -48,7 +48,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'> - <listen type='address'/> + <listen type='address' autoport='yes'/> </graphics> <video> <model type='cirrus' heads='1' primary='yes'/> -- 2.8.2

This config option is broken, it will generate unix socket even if attribute 'listen' or listen element is specified. Also following commit will makes this option obsolete. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/libvirtd_qemu.aug | 1 - src/qemu/qemu.conf | 10 ------ src/qemu/qemu_command.c | 22 +++--------- src/qemu/qemu_conf.c | 1 - src/qemu/qemu_conf.h | 1 - src/qemu/test_libvirtd_qemu.aug.in | 1 - .../qemuxml2argv-graphics-vnc-autosocket.args | 22 ------------ .../qemuxml2argv-graphics-vnc-autosocket.xml | 34 ------------------- .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 39 ---------------------- tests/qemuxml2xmltest.c | 7 ---- 10 files changed, 5 insertions(+), 133 deletions(-) delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.args delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.xml delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index b6f6dc4..c18c7fd 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -25,7 +25,6 @@ module Libvirtd_qemu = (* Config entry grouped by function - same order as example config *) let vnc_entry = str_entry "vnc_listen" - | bool_entry "vnc_auto_unix_socket" | bool_entry "vnc_tls" | str_entry "vnc_tls_x509_cert_dir" | bool_entry "vnc_tls_x509_verify" diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 4fa5e8a..bb209a5 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -11,16 +11,6 @@ # #vnc_listen = "0.0.0.0" -# Enable this option to have VNC served over an automatically created -# 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. -# -#vnc_auto_unix_socket = 1 - # Enable use of TLS encryption on the VNC server. This requires # a VNC client which supports the VeNCrypt protocol extension. # Examples include vinagre, virt-viewer, virt-manager and vencrypt diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7f7ce60..67f781e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7318,8 +7318,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; @@ -7334,17 +7333,8 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, goto error; } - 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.socketAutogenerated = true; - } - + if (graphics->data.vnc.socket) { virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); - } else { if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -7726,8 +7716,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: @@ -7759,8 +7748,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); @@ -9488,7 +9476,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; } diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 5ed5776..b5cc4b7 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -527,7 +527,6 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, goto cleanup; \ } - GET_VALUE_BOOL("vnc_auto_unix_socket", cfg->vncAutoUnixSocket); GET_VALUE_BOOL("vnc_tls", cfg->vncTLS); GET_VALUE_BOOL("vnc_tls_x509_verify", cfg->vncTLSx509verify); GET_VALUE_STR("vnc_tls_x509_cert_dir", cfg->vncTLSx509certdir); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a714b84..a17110f 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -108,7 +108,6 @@ struct _virQEMUDriverConfig { char *channelTargetDir; char *nvramDir; - bool vncAutoUnixSocket; bool vncTLS; bool vncTLSx509verify; bool vncSASL; diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in index 8bec743..e04208b 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -3,7 +3,6 @@ module Test_libvirtd_qemu = test Libvirtd_qemu.lns get conf = { "vnc_listen" = "0.0.0.0" } -{ "vnc_auto_unix_socket" = "1" } { "vnc_tls" = "1" } { "vnc_tls_x509_cert_dir" = "/etc/pki/libvirt-vnc" } { "vnc_tls_x509_verify" = "1" } diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.args deleted file mode 100644 index 7e1fb6b..0000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.args +++ /dev/null @@ -1,22 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/home/test \ -USER=test \ -LOGNAME=test \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu \ --name QEMUGuest1 \ --S \ --M pc \ --m 214 \ --smp 1 \ --uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --nodefaults \ --monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ --no-acpi \ --boot c \ --usb \ --drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ --device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --vnc unix:/tmp/lib/domain--1-QEMUGuest1/vnc.socket \ --vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.xml deleted file mode 100644 index fa59c39..0000000 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-autosocket.xml +++ /dev/null @@ -1,34 +0,0 @@ -<domain type='qemu'> - <name>QEMUGuest1</name> - <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> - <memory unit='KiB'>219100</memory> - <currentMemory unit='KiB'>219100</currentMemory> - <vcpu placement='static'>1</vcpu> - <os> - <type arch='i686' machine='pc'>hvm</type> - <boot dev='hd'/> - </os> - <clock offset='utc'/> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>destroy</on_crash> - <devices> - <emulator>/usr/bin/qemu</emulator> - <disk type='block' device='disk'> - <driver name='qemu' type='raw'/> - <source dev='/dev/HostVG/QEMUGuest1'/> - <target dev='hda' bus='ide'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <controller type='usb' index='0'/> - <controller type='ide' index='0'/> - <controller type='pci' index='0' model='pci-root'/> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='vnc' socket='/tmp/lib/domain-99-QEMUGuest1/delete.this.socket'/> - <video> - <model type='cirrus' vram='16384' heads='1'/> - </video> - <memballoon model='none'/> - </devices> -</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml deleted file mode 100644 index 7450566..0000000 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ /dev/null @@ -1,39 +0,0 @@ -<domain type='qemu'> - <name>QEMUGuest1</name> - <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> - <memory unit='KiB'>219100</memory> - <currentMemory unit='KiB'>219100</currentMemory> - <vcpu placement='static'>1</vcpu> - <os> - <type arch='i686' machine='pc'>hvm</type> - <boot dev='hd'/> - </os> - <clock offset='utc'/> - <on_poweroff>destroy</on_poweroff> - <on_reboot>restart</on_reboot> - <on_crash>destroy</on_crash> - <devices> - <emulator>/usr/bin/qemu</emulator> - <disk type='block' device='disk'> - <driver name='qemu' type='raw'/> - <source dev='/dev/HostVG/QEMUGuest1'/> - <target dev='hda' bus='ide'/> - <address type='drive' controller='0' bus='0' target='0' unit='0'/> - </disk> - <controller type='usb' index='0'> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> - </controller> - <controller type='ide' index='0'> - <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> - </controller> - <controller type='pci' index='0' model='pci-root'/> - <input type='mouse' bus='ps2'/> - <input type='keyboard' bus='ps2'/> - <graphics type='vnc'/> - <video> - <model type='cirrus' vram='16384' heads='1' primary='yes'/> - <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> - </video> - <memballoon model='none'/> - </devices> -</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5a43fa9..6821895 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -263,7 +263,6 @@ mymain(void) { int ret = 0; struct testInfo info; - virQEMUDriverConfigPtr cfg = NULL; if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; @@ -788,12 +787,6 @@ mymain(void) DO_TEST("virtio-input"); DO_TEST("virtio-input-passthrough"); - cfg = virQEMUDriverGetConfig(&driver); - cfg->vncAutoUnixSocket = true; - DO_TEST_FULL("graphics-vnc-autosocket", WHEN_INACTIVE, NONE); - cfg->vncAutoUnixSocket = false; - - virObjectUnref(cfg); qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; -- 2.8.2

On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
This config option is broken, it will generate unix socket even if attribute 'listen' or listen element is specified.
Also following commit will makes this option obsolete.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
IMO this is not acceptable. For one, there's no precedent for removing a qemu.conf option; IMO it's part of our API. But the reason this option exists is so site admins can make listen type=socket/socket= the graphical default, as opposed to a wide open listen=127.0.0.1 that any user on the host can trivially access. VNC passwords are known insecure, so locking down the listening mechanism is really the only (current) way to secure VNC. Some related discussions: https://bugzilla.redhat.com/show_bug.cgi?id=1043919 https://bugzilla.redhat.com/show_bug.cgi?id=1044570 - Cole

On Thu, May 05, 2016 at 12:39:24PM -0400, Cole Robinson wrote:
On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
This config option is broken, it will generate unix socket even if attribute 'listen' or listen element is specified.
Also following commit will makes this option obsolete.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
IMO this is not acceptable. For one, there's no precedent for removing a qemu.conf option; IMO it's part of our API.
But the reason this option exists is so site admins can make listen type=socket/socket= the graphical default, as opposed to a wide open listen=127.0.0.1 that any user on the host can trivially access. VNC passwords are known insecure, so locking down the listening mechanism is really the only (current) way to secure VNC.
...TLS with x509 certs and/or SASL is an alternative current secure VNC mechanism. I agree though its desirable to have a global way to make VNC listen UNIX sockets instead of localhost Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Thu, May 05, 2016 at 05:41:45PM +0100, Daniel P. Berrange wrote:
On Thu, May 05, 2016 at 12:39:24PM -0400, Cole Robinson wrote:
On 05/05/2016 12:20 PM, Pavel Hrdina wrote:
This config option is broken, it will generate unix socket even if attribute 'listen' or listen element is specified.
Also following commit will makes this option obsolete.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
IMO this is not acceptable. For one, there's no precedent for removing a qemu.conf option; IMO it's part of our API.
But the reason this option exists is so site admins can make listen type=socket/socket= the graphical default, as opposed to a wide open listen=127.0.0.1 that any user on the host can trivially access. VNC passwords are known insecure, so locking down the listening mechanism is really the only (current) way to secure VNC.
...TLS with x509 certs and/or SASL is an alternative current secure VNC mechanism.
I agree though its desirable to have a global way to make VNC listen UNIX sockets instead of localhost
I was afraid that someone would object to this patch :) but it worth the try. Anyway, I'll redo this so the option is still there and in that case I'll also add similar option for Spice. Pavel

Introduce a new listen type that will be used to tell a graphics device to listen on unix socket and use it for VNC graphics instead of socket attribute. The socket attribute will remain in the XML for backward compatibility. Since old libvirt supports 'socket' attribute inside 'graphics' element for socket path provided by user libvirt will generate migratable XML without that listen type='socket' but only with 'socket' attribute in order to be able to migrate back to old libvirt. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 16 +++ docs/schemas/domaincommon.rng | 10 ++ src/conf/domain_conf.c | 119 ++++++++++++++++----- src/conf/domain_conf.h | 8 +- src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 27 +++-- src/qemu/qemu_domain.c | 19 ++-- src/qemu/qemu_hotplug.c | 9 ++ src/qemu/qemu_parse_command.c | 2 +- src/qemu/qemu_process.c | 33 ++++-- src/security/virt-aa-helper.c | 15 ++- .../generic-graphics-vnc-socket-listen.xml | 4 +- .../generic-graphics-vnc-socket.xml | 4 +- .../qemuargv2xml-graphics-vnc-socket.xml | 4 +- ...qemuxml2argv-graphics-vnc-auto-unix-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-auto-unix-socket.xml | 30 ++++++ .../qemuxml2argv-graphics-vnc-unix-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-unix-socket.xml | 30 ++++++ tests/qemuxml2argvtest.c | 2 + ...emuxml2xmlout-graphics-vnc-auto-unix-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-vnc-unix-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 22 files changed, 387 insertions(+), 58 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 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-unix-socket.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 0d22922..c5cf107 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5347,6 +5347,22 @@ qemu-kvm -net nic,model=? /dev/null <code>address</code>. </p> </dd> + <dt><code>socket</code> <span class="since">since 1.3.5</span></dt> + <dd> + <p> + This listen type tells a graphics server to listen on unix socket. + Attribute <code>socket</code> contains a path to unix socket. If this + attribute is omitted libvirt will generate this path for you. + Supported by graphics type <code>vnc</code>. + </p> + <p> + For <code>vnc</code> graphics be backward compatible + the <code>socket</code> attribute of first <code>listen</code> element + is duplicated as <code>socket</code> attribute in <code>graphics</code> + element. If <code>graphics</code> element contains a <code>socket</code> + attribute all <code>listen</code> elements are ignored. + </p> + </dd> </dl> <h4><a name="elementsVideo">Video devices</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e7eda77..e3dbcc6 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3014,6 +3014,16 @@ </attribute> </optional> </group> + <group> + <attribute name="type"> + <value>socket</value> + </attribute> + <optional> + <attribute name="socket"> + <ref name="absFilePath"/> + </attribute> + </optional> + </group> </choice> </element> </zeroOrMore> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2168bac..5075fb5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -561,7 +561,8 @@ VIR_ENUM_IMPL(virDomainGraphics, VIR_DOMAIN_GRAPHICS_TYPE_LAST, VIR_ENUM_IMPL(virDomainGraphicsListen, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST, "none", "address", - "network") + "network", + "socket") VIR_ENUM_IMPL(virDomainGraphicsAuthConnected, VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST, @@ -1229,6 +1230,7 @@ virDomainGraphicsListenDefClear(virDomainGraphicsListenDefPtr def) VIR_FREE(def->address); VIR_FREE(def->network); + VIR_FREE(def->socket); return; } @@ -1242,7 +1244,6 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def) switch ((virDomainGraphicsType)def->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - VIR_FREE(def->data.vnc.socket); VIR_FREE(def->data.vnc.keymap); virDomainGraphicsAuthDefClear(&def->data.vnc.auth); break; @@ -10786,8 +10787,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, char *type = virXMLPropString(node, "type"); char *address = virXMLPropString(node, "address"); char *network = virXMLPropString(node, "network"); + char *socket = virXMLPropString(node, "socket"); char *fromConfig = virXMLPropString(node, "fromConfig"); char *addressCompat = NULL; + const char *graphicsType = virDomainGraphicsTypeToString(graphics->type); int tmp; if (parent) @@ -10805,6 +10808,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, goto error; } + if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("listen type 'socket' is not available for " + "graphics type '%s'"), graphicsType); + goto error; + } + if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { if (address && addressCompat && STRNEQ(address, addressCompat)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -10839,6 +10850,17 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, network = NULL; } + if (socket && socket[0]) { + if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'socket' attribute is valid only for listen " + "type 'socket'")); + goto error; + } + def->socket = socket; + socket = NULL; + } + if (fromConfig && flags & VIR_DOMAIN_DEF_PARSE_STATUS) { if (virStrToLong_i(fromConfig, NULL, 10, &tmp) < 0) { @@ -10882,18 +10904,15 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, ctxt->node = node; - if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - (socketPath = virXMLPropString(node, "socket"))) { - ret = 0; - goto error; - } + if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) + socketPath = virXMLPropString(node, "socket"); /* parse the <listen> subelements for graphics types that support it */ nListens = virXPathNodeSet("./listen", ctxt, &listenNodes); if (nListens < 0) goto error; - if (nListens > 0) { + if (nListens > 0 && !socketPath) { size_t i; if (VIR_ALLOC_N(def->listens, nListens) < 0) @@ -10913,14 +10932,20 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, } else { /* If not <listen/> element was found in XML for backward compatibility * we should try to parse 'listen' attribute from <graphics/> element. */ - newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; - newListen.address = virXMLPropString(node, "listen"); - if (STREQ_NULLABLE(newListen.address, "")) - VIR_FREE(newListen.address); + if (socketPath) { + newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + newListen.socket = socketPath; + socketPath = NULL; + } else { + newListen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS; + newListen.address = virXMLPropString(node, "listen"); + if (STREQ_NULLABLE(newListen.address, "")) + VIR_FREE(newListen.address); - if (virDomainGraphicsListenDefParsePorts(&newListen, node, def, - NULL, flags) < 0) - goto error; + if (virDomainGraphicsListenDefParsePorts(&newListen, node, def, + NULL, flags) < 0) + goto error; + } if (VIR_APPEND_ELEMENT(def->listens, def->nListens, newListen) < 0) goto error; @@ -10963,7 +10988,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, } } - def->data.vnc.socket = virXMLPropString(node, "socket"); def->data.vnc.keymap = virXMLPropString(node, "keymap"); if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth, @@ -21438,6 +21462,13 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, } } + if (def->socket && + def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + !(def->autogenerated && + (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) { + virBufferEscapeString(buf, " socket='%s'", def->socket); + } + if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig); @@ -21467,11 +21498,17 @@ virDomainGraphicsDefFormat(virBufferPtr buf, switch (def->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (def->data.vnc.socket) { - if (!def->data.vnc.socketAutogenerated || - !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE)) { - virBufferEscapeString(buf, " socket='%s'", - def->data.vnc.socket); + if (!glisten) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element for graphics")); + return -1; + } + + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET) { + if (glisten->socket && + !(glisten->autogenerated && + (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) { + virBufferEscapeString(buf, " socket='%s'", glisten->socket); } } else if (glisten) { if (glisten->port && @@ -21579,9 +21616,19 @@ virDomainGraphicsDefFormat(virBufferPtr buf, for (i = 0; i < def->nListens; i++) { if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE) continue; - if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && - def->listens[i].fromConfig) - continue; + if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { + if (def->listens[i].fromConfig) + continue; + + /* If the socket is provided by user in the XML we need to skip this + * listen type to support migration back to old libvirt since old + * libvirt supports specifying socket path inside graphics element + * as 'socket' attribute. */ + if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && + def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + !def->listens[i].autogenerated) + continue; + } if (!children) { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); @@ -23904,6 +23951,30 @@ virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, } +int +virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def, + const char *socket) +{ + virDomainGraphicsListenDef listen; + + memset(&listen, 0, sizeof(listen)); + + listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + + if (VIR_STRDUP(listen.socket, socket) < 0) + goto error; + + if (VIR_APPEND_ELEMENT_COPY(def->listens, def->nListens, listen) < 0) + goto error; + + return 0; + + error: + VIR_FREE(listen.socket); + return -1; +} + + /** * virDomainNetFind: * @def: domain's def diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 0895136..6def5be 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1539,6 +1539,7 @@ typedef enum { VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK, + VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST } virDomainGraphicsListenType; @@ -1555,6 +1556,7 @@ struct _virDomainGraphicsListenDef { virDomainGraphicsListenType type; char *address; char *network; + char *socket; bool fromConfig; /* true if the @address is config file originated */ int port; int tlsPort; @@ -1562,6 +1564,7 @@ struct _virDomainGraphicsListenDef { bool autoport; bool portReserved; bool tlsPortReserved; + bool autogenerated; }; struct _virDomainGraphicsDef { @@ -1574,8 +1577,6 @@ struct _virDomainGraphicsDef { union { struct { char *keymap; - char *socket; - bool socketAutogenerated; virDomainGraphicsAuthDef auth; int sharePolicy; } vnc; @@ -2840,6 +2841,9 @@ int virDomainGraphicsListenAppendAddress(virDomainGraphicsDefPtr def, const int websocket, const bool autoport) ATTRIBUTE_NONNULL(1); +int virDomainGraphicsListenAppendSocket(virDomainGraphicsDefPtr def, + const char *socket) + ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index c445d9f..d38e98e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -305,6 +305,7 @@ virDomainGraphicsAuthConnectedTypeToString; virDomainGraphicsDefFree; virDomainGraphicsGetListen; virDomainGraphicsListenAppendAddress; +virDomainGraphicsListenAppendSocket; virDomainGraphicsSpiceChannelModeTypeFromString; virDomainGraphicsSpiceChannelModeTypeToString; virDomainGraphicsSpiceChannelNameTypeFromString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 67f781e..842679f 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7333,15 +7333,19 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, goto error; } - if (graphics->data.vnc.socket) { - virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); - } else { - if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing listen element")); - goto error; - } + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + } + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + virBufferAsprintf(&opt, "unix:%s", glisten->socket); + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: if (!glisten->autoport && (glisten->port < 5900 || glisten->port > 65535)) { @@ -7377,6 +7381,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } @@ -7402,6 +7407,11 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, } virBufferAsprintf(&opt, ",websocket=%d", glisten->websocket); } + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } if (graphics->data.vnc.sharePolicy) { @@ -7538,6 +7548,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 173f82c..8f4c664 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1945,17 +1945,22 @@ qemuDomainRecheckInternalPaths(virDomainDefPtr def, unsigned int flags) { size_t i = 0; + size_t j = 0; for (i = 0; i < def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = def->graphics[i]; - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - graphics->data.vnc.socket && - STRPREFIX(graphics->data.vnc.socket, cfg->libDir)) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - VIR_FREE(graphics->data.vnc.socket); - else - graphics->data.vnc.socketAutogenerated = true; + for (j = 0; j < graphics->nListens; ++j) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; + + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + glisten->socket && + STRPREFIX(glisten->socket, cfg->libDir)) { + if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) + VIR_FREE(glisten->socket); + else + glisten->autogenerated = true; + } } } } diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1fb08c0..5670c20 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2674,6 +2674,15 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, } break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + if (STRNEQ_NULLABLE(newlisten->socket, oldlisten->socket)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("cannot change listen socket setting " + "on '%s' graphics"), type); + goto cleanup; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: /* nada */ diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c index 429cc45..a3c73e1 100644 --- a/src/qemu/qemu_parse_command.c +++ b/src/qemu/qemu_parse_command.c @@ -509,7 +509,7 @@ qemuParseCommandLineVnc(virDomainDefPtr def, if (STRPREFIX(val, "unix:")) { /* -vnc unix:/some/big/path */ - if (VIR_STRDUP(vnc->data.vnc.socket, val + 5) < 0) + if (virDomainGraphicsListenAppendSocket(vnc, val + 5) < 0) goto cleanup; } else { /* diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 8f0cc9e..968e74c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3864,9 +3864,6 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, unsigned short port; size_t i; - if (graphics->data.vnc.socket) - return 0; - for (i = 0; i < graphics->nListens; i++) { virDomainGraphicsListenDefPtr glisten = &graphics->listens[i]; @@ -3892,6 +3889,7 @@ qemuProcessVNCAllocatePorts(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } @@ -3990,6 +3988,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } @@ -5210,6 +5209,7 @@ qemuProcessPrepareDomain(virConnectPtr conn, for (i = 0; i < vm->def->ngraphics; i++) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; char *listenAddr = NULL; + const char *type = virDomainGraphicsTypeToString(graphics->type); size_t j; switch (graphics->type) { @@ -5222,12 +5222,26 @@ qemuProcessPrepareDomain(virConnectPtr conn, for (j = 0; j < graphics->nListens; j++) { virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; - if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && - !glisten->address) { - if (VIR_STRDUP(glisten->address, listenAddr) < 0) - goto cleanup; - - glisten->fromConfig = true; + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + if (!glisten->address) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto cleanup; + glisten->fromConfig = true; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + if (!glisten->socket) { + if (virAsprintf(&glisten->socket, "%s/%s.sock", + priv->libDir, type) < 0) + goto cleanup; + glisten->autogenerated = true; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } } break; @@ -6246,6 +6260,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 7eeb4ef..b144250 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1060,10 +1060,17 @@ get_files(vahControl * ctl) goto cleanup; for (i = 0; i < ctl->def->ngraphics; i++) { - if (ctl->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - ctl->def->graphics[i]->data.vnc.socket && - vah_add_file(&buf, ctl->def->graphics[i]->data.vnc.socket, "w")) - goto cleanup; + virDomainGraphicsDefPtr graphics = ctl->def->graphics[i]; + size_t n; + + for (n = 0; n < graphics->nListens; n++) { + virDomainGraphicsListenDef listenObj = graphics->listens[n]; + + if (listenObj.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + listenObj.socket && + vah_add_file(&buf, listenObj.socket, "rw")) + goto cleanup; + } } if (ctl->def->ngraphics == 1 && diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml index d8742c6..cb4e5ac 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket-listen.xml @@ -19,7 +19,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'> + <listen type='socket' socket='/tmp/QEMUGuest1-vnc.sock'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> diff --git a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml index d8742c6..cb4e5ac 100644 --- a/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml +++ b/tests/genericxml2xmloutdata/generic-graphics-vnc-socket.xml @@ -19,7 +19,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'/> + <graphics type='vnc' socket='/tmp/QEMUGuest1-vnc.sock'> + <listen type='socket' socket='/tmp/QEMUGuest1-vnc.sock'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> diff --git a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-socket.xml b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-socket.xml index 93daa76..8f2478a 100644 --- a/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-socket.xml +++ b/tests/qemuargv2xmldata/qemuargv2xml-graphics-vnc-socket.xml @@ -25,7 +25,9 @@ <controller type='ide' index='0'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc' socket='/tmp/foo.socket'/> + <graphics type='vnc' socket='/tmp/foo.socket'> + <listen type='socket' socket='/tmp/foo.socket'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1' primary='yes'/> </video> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args new file mode 100644 index 0000000..84ce727 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args @@ -0,0 +1,20 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-vnc unix:/tmp/lib/domain--1-QEMUGuest1/vnc.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml new file mode 100644 index 0000000..3e455df --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='socket'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.args new file mode 100644 index 0000000..abf724c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.args @@ -0,0 +1,20 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-vnc unix:/tmp/vnc.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.xml new file mode 100644 index 0000000..522c3af --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-unix-socket.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='socket' socket='/tmp/vnc.sock'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e41444d..d2517ad 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -876,6 +876,8 @@ mymain(void) DO_TEST("graphics-vnc-websocket", QEMU_CAPS_VNC, QEMU_CAPS_VNC_WEBSOCKET); DO_TEST("graphics-vnc-policy", QEMU_CAPS_VNC, QEMU_CAPS_VNC_SHARE_POLICY); DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-unix-socket", QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-auto-unix-socket", QEMU_CAPS_VNC); driver.config->vncSASL = 1; VIR_FREE(driver.config->vncSASLdir); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-unix-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-unix-socket.xml new file mode 100644 index 0000000..e14bbd1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-unix-socket.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc'> + <listen type='socket'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-unix-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-unix-socket.xml new file mode 100644 index 0000000..9a83328 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-unix-socket.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' socket='/tmp/vnc.sock'> + <listen type='socket' socket='/tmp/vnc.sock'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 6821895..fa343d2 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -433,6 +433,8 @@ mymain(void) DO_TEST("graphics-vnc-sasl"); DO_TEST("graphics-vnc-tls"); DO_TEST("graphics-vnc-no-listen-attr"); + DO_TEST("graphics-vnc-unix-socket"); + DO_TEST("graphics-vnc-auto-unix-socket"); DO_TEST("graphics-sdl"); DO_TEST("graphics-sdl-fullscreen"); DO_TEST("graphics-spice"); -- 2.8.2

Add a new capability to detect support of unix sockets for spice graphics. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + 2 files changed, 3 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c2ba69d..1ae18ea 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -328,6 +328,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "device-tray-moved-event", "nec-usb-xhci-ports", "virtio-scsi-pci.iothread", + "spice-unix", ); @@ -2666,6 +2667,7 @@ static struct virQEMUCapsCommandLineProps virQEMUCapsCommandLine[] = { { "spice", "gl", QEMU_CAPS_SPICE_GL }, { "chardev", "logfile", QEMU_CAPS_CHARDEV_LOGFILE }, { "name", "debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS }, + { "spice", "unix", QEMU_CAPS_SPICE_UNIX }, }; static int diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index e7d0a60..3ae4a46 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -359,6 +359,7 @@ typedef enum { QEMU_CAPS_DEVICE_TRAY_MOVED, /* DEVICE_TRAY_MOVED event */ QEMU_CAPS_NEC_USB_XHCI_PORTS, /* -device nec-usb-xhci.p3 ports setting */ QEMU_CAPS_VIRTIO_SCSI_IOTHREAD, /* virtio-scsi-{pci,ccw}.iothread */ + QEMU_CAPS_SPICE_UNIX, /* -spice unix */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; -- 2.8.2

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 2 +- src/conf/domain_conf.c | 33 +++-- src/qemu/qemu_command.c | 134 +++++++++++---------- src/qemu/qemu_migration.c | 41 ++++--- ...muxml2argv-graphics-spice-auto-unix-socket.args | 21 ++++ ...emuxml2argv-graphics-spice-auto-unix-socket.xml | 30 +++++ .../qemuxml2argv-graphics-spice-unix-socket.args | 20 +++ .../qemuxml2argv-graphics-spice-unix-socket.xml | 30 +++++ tests/qemuxml2argvtest.c | 6 + ...uxml2xmlout-graphics-spice-auto-unix-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-spice-unix-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 12 files changed, 299 insertions(+), 90 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-unix-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-unix-socket.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c5cf107..08e45e2 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5353,7 +5353,7 @@ qemu-kvm -net nic,model=? /dev/null This listen type tells a graphics server to listen on unix socket. Attribute <code>socket</code> contains a path to unix socket. If this attribute is omitted libvirt will generate this path for you. - Supported by graphics type <code>vnc</code>. + Supported by graphics type <code>vnc</code> and <code>spice</code>. </p> <p> For <code>vnc</code> graphics be backward compatible diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5075fb5..e76c71d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10809,7 +10809,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && - graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC) { + graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC && + graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("listen type 'socket' is not available for " "graphics type '%s'"), graphicsType); @@ -21584,19 +21585,29 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (glisten->port) - virBufferAsprintf(buf, " port='%d'", - glisten->port); + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (glisten->port) + virBufferAsprintf(buf, " port='%d'", + glisten->port); - if (glisten->tlsPort) - virBufferAsprintf(buf, " tlsPort='%d'", - glisten->tlsPort); + if (glisten->tlsPort) + virBufferAsprintf(buf, " tlsPort='%d'", + glisten->tlsPort); - virBufferAsprintf(buf, " autoport='%s'", - glisten->autoport ? "yes" : "no"); + virBufferAsprintf(buf, " autoport='%s'", + glisten->autoport ? "yes" : "no"); - if (glisten->address && !glisten->fromConfig) - virBufferAsprintf(buf, " listen='%s'", glisten->address); + if (glisten->address && !glisten->fromConfig) + virBufferAsprintf(buf, " listen='%s'", glisten->address); + 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 842679f..0664473 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7483,6 +7483,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, int ret; int defaultMode = graphics->data.spice.defaultMode; size_t i; + bool useTLS = false; if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -7496,69 +7497,92 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, goto error; } - if (glisten->port > 0) - virBufferAsprintf(&opt, "port=%u,", glisten->port); - - if (glisten->tlsPort > 0) { - if (!cfg->spiceTLS) { + switch (glisten->type) { + 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")); goto error; } - virBufferAsprintf(&opt, "tls-port=%u,", glisten->tlsPort); - } + virBufferAsprintf(&opt, "addr=%s,unix,", glisten->socket); + useTLS = cfg->spiceTLS; + break; - if (cfg->spiceSASL) { - virBufferAddLit(&opt, "sasl,"); + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - if (cfg->spiceSASLdir) - virCommandAddEnvPair(cmd, "SASL_CONF_PATH", - cfg->spiceSASLdir); + if (glisten->port > 0) + virBufferAsprintf(&opt, "port=%u,", glisten->port); - /* TODO: Support ACLs later */ - } + if (glisten->tlsPort > 0) { + if (!cfg->spiceTLS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spice TLS port set in XML configuration," + " but TLS is disabled in qemu.conf")); + goto error; + } + virBufferAsprintf(&opt, "tls-port=%u,", glisten->tlsPort); + useTLS = true; + } - if (glisten->port > 0 || glisten->tlsPort > 0) { + if (cfg->spiceSASL) { + virBufferAddLit(&opt, "sasl,"); - switch (glisten->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - listenAddr = glisten->address; - break; + if (cfg->spiceSASLdir) + virCommandAddEnvPair(cmd, "SASL_CONF_PATH", + cfg->spiceSASLdir); - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: - if (!glisten->network) + /* TODO: Support ACLs later */ + } + + if (glisten->port > 0 || glisten->tlsPort > 0) { + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + listenAddr = glisten->address; break; - ret = networkGetNetworkAddress(glisten->network, &netAddr); - if (ret <= -2) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("network-based listen not possible, " - "network driver not present")); - goto error; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + if (!glisten->network) + break; + + ret = networkGetNetworkAddress(glisten->network, &netAddr); + if (ret <= -2) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("network-based listen not possible, " + "network driver not present")); + goto error; + } + if (ret < 0) + goto error; + + listenAddr = netAddr; + /* store the address we found in the <graphics> element so it will + * show up in status. */ + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto error; + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } - if (ret < 0) - goto error; - listenAddr = netAddr; - /* store the address we found in the <graphics> element so it will - * show up in status. */ - if (VIR_STRDUP(glisten->address, listenAddr) < 0) - goto error; - break; + if (!listenAddr) + listenAddr = cfg->spiceListen; + if (listenAddr) + virBufferAsprintf(&opt, "addr=%s,", listenAddr); - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: - break; + VIR_FREE(netAddr); } - if (!listenAddr) - listenAddr = cfg->spiceListen; - if (listenAddr) - virBufferAsprintf(&opt, "addr=%s,", listenAddr); + break; - VIR_FREE(netAddr); + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } if (graphics->data.spice.mousemode) { @@ -7581,7 +7605,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,"); - if (glisten->tlsPort > 0) + if (useTLS) virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); switch (defaultMode) { @@ -7599,7 +7623,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) { switch (graphics->data.spice.channels[i]) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { + if (!useTLS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice secure channels set in XML configuration, " "but TLS port is not provided")); @@ -7610,12 +7634,6 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: - if (glisten->port <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice insecure channels set in XML " - "configuration, but plain port is not provided")); - goto error; - } virBufferAsprintf(&opt, "plaintext-channel=%s,", virDomainGraphicsSpiceChannelNameTypeToString(i)); break; @@ -7623,7 +7641,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: switch (defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { + if (!useTLS) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("spice defaultMode secure requested in XML " "configuration but TLS port not provided")); @@ -7632,12 +7650,6 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: - if (glisten->port <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice defaultMode insecure requested in XML " - "configuration but plain port not provided")); - goto error; - } break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6440cf1..26c1201 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -315,23 +315,16 @@ qemuDomainExtractTLSSubject(const char *certdir) static qemuMigrationCookieGraphicsPtr qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver, - virDomainGraphicsDefPtr def) + virDomainGraphicsListenDefPtr glisten) { qemuMigrationCookieGraphicsPtr mig = NULL; const char *listenAddr; - virDomainGraphicsListenDefPtr glisten = virDomainGraphicsGetListen(def, 0); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); if (VIR_ALLOC(mig) < 0) goto error; - if (!glisten) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing listen element")); - goto error; - } - - mig->type = def->type; + mig->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE; mig->port = glisten->port; if (cfg->spiceTLS) mig->tlsPort = glisten->tlsPort; @@ -458,14 +451,28 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig, } for (i = 0; i < dom->def->ngraphics; i++) { - if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (!(mig->graphics = - qemuMigrationCookieGraphicsSpiceAlloc(driver, - dom->def->graphics[i]))) - return -1; - mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; - break; - } + 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; + } + + /* Skip all listen types different than address or network because + * only those two are currently supported. */ + if (glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + glisten->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) + break; + + if (!(mig->graphics = + qemuMigrationCookieGraphicsSpiceAlloc(driver, glisten))) + return -1; + mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; + break; + } } return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.args new file mode 100644 index 0000000..8cc099f --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=spice \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-spice addr=/tmp/lib/domain--1-QEMUGuest1/spice.sock,unix,\ +x509-dir=/etc/pki/libvirt-spice \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.xml new file mode 100644 index 0000000..acb325a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-unix-socket.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='socket'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.args new file mode 100644 index 0000000..ecaad91 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.args @@ -0,0 +1,20 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=spice \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-usb \ +-spice addr=/tmp/spice.sock,unix,x509-dir=/etc/pki/libvirt-spice \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.xml new file mode 100644 index 0000000..13bbef1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix-socket.xml @@ -0,0 +1,30 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'/> + <controller type='ide' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='socket' socket='/tmp/spice.sock'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d2517ad..bd31ec5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -941,6 +941,12 @@ mymain(void) QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_SPICE_FILE_XFER_DISABLE); + DO_TEST("graphics-spice-unix-socket", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); + DO_TEST("graphics-spice-auto-unix-socket", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-unix-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-unix-socket.xml new file mode 100644 index 0000000..931ec0f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-unix-socket.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='socket'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-unix-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-unix-socket.xml new file mode 100644 index 0000000..dd672ed --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-unix-socket.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='i686' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu</emulator> + <controller type='usb' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> + </controller> + <controller type='ide' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='spice'> + <listen type='socket' socket='/tmp/spice.sock'/> + </graphics> + <video> + <model type='cirrus' vram='16384' heads='1' primary='yes'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </video> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index fa343d2..ca5ffa6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -440,6 +440,8 @@ mymain(void) DO_TEST("graphics-spice"); DO_TEST("graphics-spice-compression"); DO_TEST("graphics-spice-qxl-vga"); + DO_TEST("graphics-spice-unix-socket"); + DO_TEST("graphics-spice-auto-unix-socket"); DO_TEST("nographics-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); -- 2.8.2

This new listen type is currently supported only by spice graphics. It's introduced to make it easier and clearer specify to not listen anywhere in order to start a guest with OpenGL support. The old way to do this was set spice graphics autoport='no' and don't specify any ports. The new way is to use <listen type='none'/>. In order to be able to migrate to old libvirt the migratable XML will be generated without the listen element and with autoport='no'. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 11 ++++ docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 62 +++++++++++++++++----- src/qemu/qemu_command.c | 11 ++-- .../qemuxml2argv-video-virtio-gpu-spice-gl.args | 2 +- .../qemuxml2xmlout-video-virtio-gpu-spice-gl.xml | 4 +- 6 files changed, 72 insertions(+), 23 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 08e45e2..1688761 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5363,6 +5363,17 @@ qemu-kvm -net nic,model=? /dev/null attribute all <code>listen</code> elements are ignored. </p> </dd> + <dt><code>none</code> <span class="since">since 1.3.5</span></dt> + <dd> + <p> + This listen type doesn't have any other attribute. Libvirt supports + passing a file descriptor through our APIs virDomainOpenGraphics() and + virDomainOpenGraphicsFD(). No other listen types are allowed if this + one is used and the graphics device doesn't listen anywhere. You need + to use one of the two APIs to pass a FD to QEMU in order to connect to + this graphics device. Supported only by <code>spice</code>. + </p> + </dd> </dl> <h4><a name="elementsVideo">Video devices</a></h4> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e3dbcc6..c1a26a8 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -3024,6 +3024,11 @@ </attribute> </optional> </group> + <group> + <attribute name="type"> + <value>none</value> + </attribute> + </group> </choice> </element> </zeroOrMore> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e76c71d..7a497f2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10808,13 +10808,28 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, goto error; } - if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && - graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC && - graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("listen type 'socket' is not available for " - "graphics type '%s'"), graphicsType); - goto error; + switch (def->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + if (graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC && + graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("listen type 'socket' is not available for " + "graphics type '%s'"), graphicsType); + goto error; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + if (graphics->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("listen type 'none' is not available for " + "graphics type '%s'"), graphicsType); + goto error; + } + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; } if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { @@ -10899,6 +10914,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, xmlNodePtr *listenNodes = NULL; xmlNodePtr save = ctxt->node; virDomainGraphicsListenDef newListen = {0}; + virDomainGraphicsListenDefPtr glisten = NULL; char *socketPath = NULL; int nListens; int ret = -1; @@ -10952,6 +10968,19 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, goto error; } + /* If spice graphics is configured without ports and with autoport='no' then + * we start qemu with Spice to not listen anywhere. Let's convert this + * configuration to the new listen type='none' which does the same. */ + if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + glisten = &def->listens[0]; + + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + glisten->port == 0 && glisten->tlsPort == 0 && !glisten->autoport) { + VIR_FREE(glisten->address); + glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE; + } + } + ret = 0; error: if (ret < 0) @@ -21424,10 +21453,8 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, return; virBufferAddLit(buf, "<listen"); - if (def->type) { - virBufferAsprintf(buf, " type='%s'", - virDomainGraphicsListenTypeToString(def->type)); - } + virBufferAsprintf(buf, " type='%s'", + virDomainGraphicsListenTypeToString(def->type)); if (def->address && (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS || @@ -21604,6 +21631,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) + virBufferAddStr(buf, " autoport='no'"); + break; + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; @@ -21625,8 +21656,6 @@ virDomainGraphicsDefFormat(virBufferPtr buf, } for (i = 0; i < def->nListens; i++) { - if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE) - continue; if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE) { if (def->listens[i].fromConfig) continue; @@ -21639,6 +21668,13 @@ virDomainGraphicsDefFormat(virBufferPtr buf, def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && !def->listens[i].autogenerated) continue; + + /* The new listen type none is in the migratable XML represented as + * port=0 and autoport=no because old libvirt support this + * configuration for spice. */ + if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE && + def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE) + continue; } if (!children) { virBufferAddLit(buf, ">\n"); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0664473..4212351 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7581,6 +7581,9 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + /* QEMU requires either port or tls-port to be specified */ + virBufferAddLit(&opt, "port=0,"); + break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } @@ -7711,13 +7714,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, virBufferTrim(&opt, ",", -1); virCommandAddArg(cmd, "-spice"); - /* If we did not add any SPICE arguments, add a dummy 'port=0' one - * as -spice alone is not allowed on QEMU command line - */ - if (virBufferUse(&opt) == 0) - virCommandAddArg(cmd, "port=0"); - else - virCommandAddArgBuffer(cmd, &opt); + virCommandAddArgBuffer(cmd, &opt); if (graphics->data.spice.keymap) virCommandAddArgList(cmd, "-k", graphics->data.spice.keymap, NULL); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args index b80ad16..edecca1 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-video-virtio-gpu-spice-gl.args @@ -19,6 +19,6 @@ QEMU_AUDIO_DRV=spice \ -drive file=/var/lib/libvirt/images/QEMUGuest1,format=qcow2,if=none,\ id=drive-ide0-0-0,cache=none \ -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ --spice gl=on \ +-spice port=0,gl=on \ -device virtio-vga,id=video0,virgl=on,bus=pci.0,addr=0x2 \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml index fd260ea..9fb533a 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-video-virtio-gpu-spice-gl.xml @@ -29,8 +29,8 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='spice' autoport='no'> - <listen type='address' autoport='no'/> + <graphics type='spice'> + <listen type='none'/> <gl enable='yes'/> </graphics> <video> -- 2.8.2
participants (4)
-
Cole Robinson
-
Daniel P. Berrange
-
Pavel Hrdina
-
Peter Krempa