[libvirt] [PATCH v2 00/12] 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 out 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. Changes in v2: - don't remove vnc_auto_unix_socket from qemu.conf - add spice_auto_unix_socket Pavel Hrdina (12): graphics: don't parse listens if socket attribute is present domain_conf: parse listen attribute while parsing listen elements graphics: make address attribute for listen type='address' optional domain_conf: cleanup virDomainGraphicsListenDefParseXML graphics: move port definition to listen element graphics: introduce listen type=socket and use it for VNC qemu_capabilites: add QEMU_CAPS_SPICE_UNIX spice: add support for listen type socket qemu_process: separate graphics socket and address generation tests: cleanup vnc auto socket test spice: introduce spice_auto_unix_socket config option spice: introduce listen type none docs/formatdomain.html.in | 138 +++-- docs/schemas/domaincommon.rng | 63 ++- src/conf/domain_conf.c | 602 +++++++++++++-------- src/conf/domain_conf.h | 31 +- src/libvirt_private.syms | 1 + src/libxl/libxl_conf.c | 53 +- src/libxl/libxl_domain.c | 17 +- src/qemu/qemu.conf | 11 + src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 256 ++++----- src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_domain.c | 19 +- src/qemu/qemu_hotplug.c | 40 +- src/qemu/qemu_migration.c | 50 +- src/qemu/qemu_parse_command.c | 41 +- src/qemu/qemu_process.c | 351 +++++++----- 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-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 | 4 +- .../generic-graphics-vnc-minimal.xml | 4 +- .../generic-graphics-vnc-socket-listen.xml | 2 +- .../generic-graphics-vnc-socket.xml | 4 +- tests/genericxml2xmltest.c | 3 + .../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 +- .../qemuxml2argv-console-compat-2.xml | 2 +- ...emuxml2argv-graphics-spice-auto-socket-cfg.args | 20 + ...qemuxml2argv-graphics-spice-auto-socket-cfg.xml | 30 + .../qemuxml2argv-graphics-spice-auto-socket.args | 20 + .../qemuxml2argv-graphics-spice-auto-socket.xml | 30 + .../qemuxml2argv-graphics-spice-socket.args | 20 + .../qemuxml2argv-graphics-spice-socket.xml | 30 + .../qemuxml2argv-graphics-vnc-auto-socket-cfg.args | 22 + .../qemuxml2argv-graphics-vnc-auto-socket-cfg.xml | 34 ++ .../qemuxml2argv-graphics-vnc-auto-socket.args | 20 + .../qemuxml2argv-graphics-vnc-auto-socket.xml | 30 + .../qemuxml2argv-graphics-vnc-autosocket.args | 22 - .../qemuxml2argv-graphics-vnc-autosocket.xml | 34 -- .../qemuxml2argv-graphics-vnc-socket.args | 4 +- .../qemuxml2argv-graphics-vnc-socket.xml | 10 +- .../qemuxml2argv-video-virtio-gpu-spice-gl.args | 2 +- tests/qemuxml2argvtest.c | 16 + .../qemuxml2xmlout-graphics-listen-network.xml | 2 +- .../qemuxml2xmlout-graphics-listen-network2.xml | 4 +- ...muxml2xmlout-graphics-spice-auto-socket-cfg.xml | 35 ++ .../qemuxml2xmlout-graphics-spice-auto-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-spice-compression.xml | 2 +- .../qemuxml2xmlout-graphics-spice-qxl-vga.xml | 2 +- .../qemuxml2xmlout-graphics-spice-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-spice-timeout.xml | 4 +- .../qemuxml2xmlout-graphics-spice.xml | 2 +- ...qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml | 41 ++ .../qemuxml2xmlout-graphics-vnc-auto-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-socket.xml | 35 ++ .../qemuxml2xmlout-graphics-vnc-tls.xml | 2 +- .../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 | 19 +- 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 +- 165 files changed, 2092 insertions(+), 987 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 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-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/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml -- 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 571b7bf..df2258a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10721,11 +10721,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) @@ -10778,6 +10785,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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 571b7bf..df2258a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10721,11 +10721,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; + }
Even if we keep the <listen> for compatibility purposes, perhaps there is a log/warning to give that it is ignored. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
+ /* parse the <listen> subelements for graphics types that support it */ nListens = virXPathNodeSet("./listen", ctxt, &listenNodes); if (nListens < 0) @@ -10778,6 +10785,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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

On Wed, May 11, 2016 at 08:12:48PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 571b7bf..df2258a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10721,11 +10721,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; + }
Even if we keep the <listen> for compatibility purposes, perhaps there is a log/warning to give that it is ignored.
Hi, with old libvirt if vnc graphics had a socket attribute we've passed to qemu only the socket, the <listen> element was ignored. This only improve the domain definition that we don't parse the <listen> element at all. I don't think that there should be log/warning. Thanks for review Pavel

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 df2258a..45d2789 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, typeVal; + if (parent) + addressCompat = virXMLPropString(parent, "listen"); + if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", _("graphics listen type must be specified")); @@ -10665,9 +10683,21 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal; - /* 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 && @@ -10707,6 +10737,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, VIR_FREE(address); VIR_FREE(network); VIR_FREE(fromConfig); + VIR_FREE(addressCompat); return ret; } @@ -10719,8 +10750,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; @@ -10747,44 +10777,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 no <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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 df2258a..45d2789 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");
code-style change only
char *fromConfig = virXMLPropString(node, "fromConfig"); + char *addressCompat = NULL; int tmp, typeVal;
+ if (parent) + addressCompat = virXMLPropString(parent, "listen"); + if (!type) { virReportError(VIR_ERR_XML_ERROR, "%s", _("graphics listen type must be specified")); @@ -10665,9 +10683,21 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal;
- /* 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 && @@ -10707,6 +10737,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, VIR_FREE(address); VIR_FREE(network); VIR_FREE(fromConfig); + VIR_FREE(addressCompat); return ret; }
@@ -10719,8 +10750,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; @@ -10747,44 +10777,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 no <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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> -- Marc-André Lureau

On Wed, May 11, 2016 at 08:12:59PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 df2258a..45d2789 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");
code-style change only
Yes, I took the opportunity to change the code-style together with this patch :) Pavel

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 | 16 +++++++---- 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(+), 79 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 58b8cb6..fd2dd33 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5126,11 +5126,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 @@ -5168,14 +5167,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 @@ -5312,6 +5309,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 45d2789..e70456d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10792,8 +10792,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 eddf3a7..f4bf6c1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4394,7 +4394,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); - size_t i; + size_t i, j; int ret = -1; if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0) @@ -4426,12 +4426,16 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, break; } - if (graphics->nListens == 0 && listenAddr) { - if (virDomainGraphicsListenAppendAddress(graphics, - listenAddr) < 0) - goto cleanup; + for (j = 0; j < graphics->nListens; j++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; - graphics->listens[0].fromConfig = true; + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + !glisten->address && listenAddr) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto cleanup; + + glisten->fromConfig = true; + } } } 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 d4aa5e9..8b5e063 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) @@ -988,8 +987,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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 | 16 +++++++---- 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(+), 79 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 58b8cb6..fd2dd33 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5126,11 +5126,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 @@ -5168,14 +5167,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 @@ -5312,6 +5309,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 45d2789..e70456d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10792,8 +10792,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 eddf3a7..f4bf6c1 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4394,7 +4394,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); - size_t i; + size_t i, j; int ret = -1;
if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0) @@ -4426,12 +4426,16 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, break; }
- if (graphics->nListens == 0 && listenAddr) { - if (virDomainGraphicsListenAppendAddress(graphics, - listenAddr) < 0) - goto cleanup; + for (j = 0; j < graphics->nListens; j++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[j];
- graphics->listens[0].fromConfig = true; + if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && + !glisten->address && listenAddr) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + goto cleanup; + + glisten->fromConfig = true; + } } }
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;
I think it's missing a VIR_FREE(listenAddr) here.
+ } 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 d4aa5e9..8b5e063 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) @@ -988,8 +987,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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Other than that, Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> -- Marc-André Lureau

On Wed, May 11, 2016 at 08:13:11PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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> ---
[...]
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;
I think it's missing a VIR_FREE(listenAddr) here.
Nice catch, I'll fix it. Thanks, Pavel

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 e70456d..cd06384 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10708,10 +10708,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

On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 e70456d..cd06384 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10708,10 +10708,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; }
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
def->network = network; -- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

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 fd2dd33..b0847b7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5090,7 +5090,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'/> @@ -5122,16 +5122,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. @@ -5152,22 +5149,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 @@ -5209,6 +5196,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'/> @@ -5266,16 +5254,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> @@ -5318,6 +5303,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> @@ -5335,6 +5354,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 cd06384..990cab0 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) { @@ -10728,6 +10851,10 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, def->fromConfig = tmp != 0; } + if (virDomainGraphicsListenDefParsePorts(def, node, graphics, + parent, flags) < 0) + goto error; + ret = 0; error: if (ret < 0) @@ -10776,6 +10903,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; @@ -10791,6 +10919,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; } @@ -10812,50 +10944,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); @@ -10879,9 +10973,6 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(autoport); - VIR_FREE(websocket); VIR_FREE(sharePolicy); return ret; } @@ -10924,8 +11015,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; @@ -10933,27 +11022,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; @@ -10962,8 +11030,6 @@ virDomainGraphicsDefParseXMLRDP(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(autoport); VIR_FREE(replaceUser); VIR_FREE(multiUser); return ret; @@ -11007,9 +11073,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; @@ -11017,29 +11080,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) { @@ -11052,16 +11092,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, @@ -11296,9 +11326,6 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def, ret = 0; error: - VIR_FREE(port); - VIR_FREE(tlsPort); - VIR_FREE(autoport); VIR_FREE(defaultMode); return ret; } @@ -21396,6 +21423,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); @@ -21408,8 +21455,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; @@ -21419,23 +21466,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); @@ -21447,22 +21478,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) @@ -21491,24 +21521,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: @@ -21522,19 +21552,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'", @@ -23849,23 +23879,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 b9e696d..3247177 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 5fa1bd9..30ee6cb 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 7e39b8a..16fa068 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7377,7 +7377,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; @@ -7401,46 +7401,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) @@ -7451,21 +7454,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) { @@ -7531,13 +7532,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)) { @@ -7546,17 +7545,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) { @@ -7569,39 +7574,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) @@ -7632,7 +7635,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) { @@ -7650,7 +7653,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")); @@ -7661,7 +7664,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")); @@ -7674,7 +7677,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")); @@ -7683,7 +7686,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 f40b34d..06033df 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: @@ -2655,6 +2664,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: @@ -2666,12 +2684,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")); @@ -2709,13 +2721,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 f4bf6c1..9f96545 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; + + if (!glisten->autoport) + glisten->portReserved = 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; + } - graphics->data.spice.tlsPort = tlsPort; + if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0) + goto error; + + glisten->tlsPort = tlsPort; - if (!graphics->data.spice.autoport) - graphics->data.spice.tlsPortReserved = true; + if (!glisten->autoport) + glisten->tlsPortReserved = true; + } + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } } return 0; @@ -4351,35 +4373,44 @@ static int qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, virDomainObjPtr vm) { - size_t i; + size_t i, j; 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) - return -1; - 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) - return -1; - graphics->data.spice.portReserved = true; - } - if (graphics->data.spice.tlsPort > 0) { - if (virPortAllocatorSetUsed(driver->remotePorts, - graphics->data.spice.tlsPort, - true) < 0) - return -1; - 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) + return -1; + glisten->portReserved = true; + } + if (glisten->tlsPort > 0 && + graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { + if (virPortAllocatorSetUsed(driver->remotePorts, + glisten->tlsPort, + true) < 0) + return -1; + 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; } } @@ -6172,39 +6203,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 8b5e063..43356f7 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) @@ -964,14 +962,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"); @@ -981,13 +978,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) @@ -1523,7 +1520,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) { @@ -1544,16 +1541,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) @@ -1579,7 +1580,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) { @@ -1597,16 +1598,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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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>
This patch is pretty large, so I have been only skimming through, most changes are straightforward. Overall, it looks good to me. Someone more familiar with libvirt & network code, and migration support, should do a more thorough review. Tested-by: Marc-André Lureau <marcandre.lureau@redhat.com> -- Marc-André Lureau

On Wed, May 11, 2016 at 05:08:24PM +0200, Pavel Hrdina wrote:
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.
This patch keeps the port=-1 legacy syntax in the <listen> element, shouln't we use this as an opportunity to drop it? Or is it making the code much more complicated to handle 'port'/'tlsPort' differently in <listen> nodes?
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 fd2dd33..b0847b7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5090,7 +5090,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'/> @@ -5122,16 +5122,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. @@ -5152,22 +5149,12 @@ qemu-kvm -net nic,model=? /dev/null Rather than using listen/port, QEMU supports a socket attribute for listening on a unix domain socket path
I'd amend the sentence above too if you remove references to listen/port. Shouldn't we keep a mention of the old listen/port/... attributes somewhere (for people looking at old XML, for people who want to write backward compatible XML,. ..) Christophe

On Thu, May 12, 2016 at 01:23:18PM +0200, Christophe Fergeau wrote:
On Wed, May 11, 2016 at 05:08:24PM +0200, Pavel Hrdina wrote:
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.
This patch keeps the port=-1 legacy syntax in the <listen> element, shouln't we use this as an opportunity to drop it? Or is it making the code much more complicated to handle 'port'/'tlsPort' differently in <listen> nodes?
It's possible for SPICE to have something like this: <graphics type='spice' port='5900' tlsPort='-1' autoport='no'/> <listen type='address' port='5900' tlsPort='-1' autoport='no'/> </graphics> or: <graphics type='vnc' port='-1' websocket='-1' autoport='yes'/> <listen type='address' websocket='-1' autoport='yes'/> </graphics> So we cannot remove it from listen elements. The first example is the case where you specify port, but tlsPort is automatically generated. The second example is the only way, how to get websocket automatically generated because for security reasons autoport='yes' will generate only port.
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 fd2dd33..b0847b7 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5090,7 +5090,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'/> @@ -5122,16 +5122,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. @@ -5152,22 +5149,12 @@ qemu-kvm -net nic,model=? /dev/null Rather than using listen/port, QEMU supports a socket attribute for listening on a unix domain socket path
I'd amend the sentence above too if you remove references to listen/port. Shouldn't we keep a mention of the old listen/port/... attributes somewhere (for people looking at old XML, for people who want to write backward compatible XML,. ..)
Christophe
This is mentioned in the listen part of the documentation that for backward compatibility they are duplicated into graphics element. 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 | 45 ++++---- src/qemu/qemu_domain.c | 19 ++-- src/qemu/qemu_hotplug.c | 9 ++ src/qemu/qemu_parse_command.c | 2 +- src/qemu/qemu_process.c | 47 ++++++-- 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-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-auto-socket.xml | 30 ++++++ .../qemuxml2argv-graphics-vnc-socket.args | 4 +- .../qemuxml2argv-graphics-vnc-socket.xml | 10 +- tests/qemuxml2argvtest.c | 2 + .../qemuxml2xmlout-graphics-vnc-auto-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 4 +- .../qemuxml2xmlout-graphics-vnc-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 23 files changed, 361 insertions(+), 84 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b0847b7..f67076d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5359,6 +5359,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 990cab0..fd071e1 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 (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, typeVal; if (parent) @@ -10806,6 +10809,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal; + 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, @@ -10840,6 +10851,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) { @@ -10883,18 +10905,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) @@ -10914,14 +10933,20 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, } else { /* If no <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; @@ -10964,7 +10989,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, @@ -21443,6 +21467,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); @@ -21472,11 +21503,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 || glisten->fromConfig) && + (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) { + virBufferEscapeString(buf, " socket='%s'", glisten->socket); } } else if (glisten) { if (glisten->port && @@ -21584,9 +21621,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); @@ -23909,6 +23956,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 3247177..0eba888 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 a980a32..4b8b2de 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 16fa068..13df7cb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7373,8 +7373,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; @@ -7389,24 +7388,19 @@ 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; - } - - virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + } - } else { - 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)) { @@ -7442,6 +7436,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; } @@ -7467,6 +7462,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) { @@ -7603,6 +7603,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; } @@ -7781,8 +7782,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg, virCommandPtr cmd, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, - virDomainGraphicsDefPtr graphics, - const char *domainLibDir) + virDomainGraphicsDefPtr graphics) { switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_SDL: @@ -7814,8 +7814,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); @@ -9543,7 +9542,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_domain.c b/src/qemu/qemu_domain.c index 3da0079..0068c33 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1993,17 +1993,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 06033df..53cf8e1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2675,6 +2675,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 9f96545..3d78455 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; } @@ -4424,6 +4423,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, unsigned int flags) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv = vm->privateData; bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); size_t i, j; int ret = -1; @@ -4433,6 +4433,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + const char *type = virDomainGraphicsTypeToString(graphics->type); char *listenAddr = NULL; switch (graphics->type) { @@ -4460,12 +4461,39 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (j = 0; j < graphics->nListens; j++) { virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; - if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && - !glisten->address && listenAddr) { - 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 there is no address specified and qemu.conf has + * vnc_auto_unix_socket set we should use unix socket as + * default instead of tcp listen. */ + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && + cfg->vncAutoUnixSocket) { + memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); + if (virAsprintf(&glisten->socket, "%s/%s.sock", + priv->libDir, type) < 0) + goto cleanup; + glisten->fromConfig = true; + glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + } else if (listenAddr) { + 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; } } } @@ -6232,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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args new file mode 100644 index 0000000..84ce727 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-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-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml new file mode 100644 index 0000000..3e455df --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args index 2464867..abf724c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args @@ -16,7 +16,5 @@ QEMU_AUDIO_DRV=none \ -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/foo.socket \ +-vnc unix:/tmp/vnc.sock \ -vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml index de70bc4..522c3af 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml @@ -14,18 +14,14 @@ <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/foo.socket'/> + <graphics type='vnc'> + <listen type='socket' socket='/tmp/vnc.sock'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1'/> </video> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d1cfbec..43deebd 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-socket", QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC); driver.config->vncSASL = 1; VIR_FREE(driver.config->vncSASLdir); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml new file mode 100644 index 0000000..e14bbd1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-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-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml index 7450566..5013b18 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml @@ -29,7 +29,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc'/> + <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'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml new file mode 100644 index 0000000..9a83328 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-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 5a43fa9..b67d687 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -434,6 +434,8 @@ mymain(void) DO_TEST("graphics-vnc-sasl"); DO_TEST("graphics-vnc-tls"); DO_TEST("graphics-vnc-no-listen-attr"); + DO_TEST("graphics-vnc-socket"); + DO_TEST("graphics-vnc-auto-socket"); DO_TEST("graphics-sdl"); DO_TEST("graphics-sdl-fullscreen"); DO_TEST("graphics-spice"); -- 2.8.2

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 | 45 ++++---- src/qemu/qemu_domain.c | 19 ++-- src/qemu/qemu_hotplug.c | 9 ++ src/qemu/qemu_parse_command.c | 2 +- src/qemu/qemu_process.c | 47 ++++++-- 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-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-auto-socket.xml | 30 ++++++ .../qemuxml2argv-graphics-vnc-socket.args | 4 +- .../qemuxml2argv-graphics-vnc-socket.xml | 10 +- tests/qemuxml2argvtest.c | 2 + .../qemuxml2xmlout-graphics-vnc-auto-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 4 +- .../qemuxml2xmlout-graphics-vnc-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 23 files changed, 361 insertions(+), 84 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b0847b7..f67076d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5359,6 +5359,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 990cab0..fd071e1 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 (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");
Missing corresponding VIR_FREE(socket) under error:
char *fromConfig = virXMLPropString(node, "fromConfig"); char *addressCompat = NULL; + const char *graphicsType = virDomainGraphicsTypeToString(graphics->type); int tmp, typeVal;
if (parent) @@ -10806,6 +10809,14 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal;
+ 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, @@ -10840,6 +10851,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) { @@ -10883,18 +10905,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) @@ -10914,14 +10933,20 @@ virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def, } else { /* If no <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; @@ -10964,7 +10989,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, @@ -21443,6 +21467,13 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, } }
+ if (def->socket && + def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET && + !(def->autogenerated && + (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) {
I am not familiar with the FORMAT_MIGRATABLE flag
+ virBufferEscapeString(buf, " socket='%s'", def->socket); + } + if (flags & VIR_DOMAIN_DEF_FORMAT_STATUS) virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig);
@@ -21472,11 +21503,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 || glisten->fromConfig) && + (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))) { + virBufferEscapeString(buf, " socket='%s'", glisten->socket); } } else if (glisten) { if (glisten->port && @@ -21584,9 +21621,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); @@ -23909,6 +23956,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 3247177..0eba888 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 a980a32..4b8b2de 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 16fa068..13df7cb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7373,8 +7373,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; @@ -7389,24 +7388,19 @@ 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; - } - - virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket); + if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing listen element")); + goto error; + }
- } else { - 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)) { @@ -7442,6 +7436,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; } @@ -7467,6 +7462,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) { @@ -7603,6 +7603,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; } @@ -7781,8 +7782,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg, virCommandPtr cmd, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, - virDomainGraphicsDefPtr graphics, - const char *domainLibDir) + virDomainGraphicsDefPtr graphics) { switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_SDL: @@ -7814,8 +7814,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); @@ -9543,7 +9542,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_domain.c b/src/qemu/qemu_domain.c index 3da0079..0068c33 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1993,17 +1993,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 06033df..53cf8e1 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2675,6 +2675,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 9f96545..3d78455 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; } @@ -4424,6 +4423,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, unsigned int flags) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + qemuDomainObjPrivatePtr priv = vm->privateData; bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); size_t i, j; int ret = -1; @@ -4433,6 +4433,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + const char *type = virDomainGraphicsTypeToString(graphics->type); char *listenAddr = NULL;
switch (graphics->type) { @@ -4460,12 +4461,39 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (j = 0; j < graphics->nListens; j++) { virDomainGraphicsListenDefPtr glisten = &graphics->listens[j];
- if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && - !glisten->address && listenAddr) { - 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 there is no address specified and qemu.conf has + * vnc_auto_unix_socket set we should use unix socket as + * default instead of tcp listen. */ + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && + cfg->vncAutoUnixSocket) { + memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
Why not calling virDomainGraphicsListenDefClear() ?
+ if (virAsprintf(&glisten->socket, "%s/%s.sock", + priv->libDir, type) < 0) + goto cleanup; + glisten->fromConfig = true; + glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + } else if (listenAddr) { + 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; } } } @@ -6232,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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args new file mode 100644 index 0000000..84ce727 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-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-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml new file mode 100644 index 0000000..3e455df --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args index 2464867..abf724c 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.args @@ -16,7 +16,5 @@ QEMU_AUDIO_DRV=none \ -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/foo.socket \ +-vnc unix:/tmp/vnc.sock \ -vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml index de70bc4..522c3af 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-socket.xml @@ -14,18 +14,14 @@ <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/foo.socket'/> + <graphics type='vnc'> + <listen type='socket' socket='/tmp/vnc.sock'/> + </graphics> <video> <model type='cirrus' vram='16384' heads='1'/> </video> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d1cfbec..43deebd 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-socket", QEMU_CAPS_VNC); + DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC);
driver.config->vncSASL = 1; VIR_FREE(driver.config->vncSASLdir); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml new file mode 100644 index 0000000..e14bbd1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-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-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml index 7450566..5013b18 100644 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml @@ -29,7 +29,9 @@ <controller type='pci' index='0' model='pci-root'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> - <graphics type='vnc'/> + <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'/> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml new file mode 100644 index 0000000..9a83328 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-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 5a43fa9..b67d687 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -434,6 +434,8 @@ mymain(void) DO_TEST("graphics-vnc-sasl"); DO_TEST("graphics-vnc-tls"); DO_TEST("graphics-vnc-no-listen-attr"); + DO_TEST("graphics-vnc-socket"); + DO_TEST("graphics-vnc-auto-socket"); DO_TEST("graphics-sdl"); DO_TEST("graphics-sdl-fullscreen"); DO_TEST("graphics-spice"); -- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Other than that, looks good to me. -- Marc-André Lureau

On Wed, May 11, 2016 at 08:13:37PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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> ---
[...]
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 990cab0..fd071e1 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 (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");
Missing corresponding VIR_FREE(socket) under error:
I'll fix it. [...]
@@ -4460,12 +4461,39 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (j = 0; j < graphics->nListens; j++) { virDomainGraphicsListenDefPtr glisten = &graphics->listens[j];
- if (glisten->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS && - !glisten->address && listenAddr) { - 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 there is no address specified and qemu.conf has + * vnc_auto_unix_socket set we should use unix socket as + * default instead of tcp listen. */ + if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && + cfg->vncAutoUnixSocket) { + memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
Why not calling virDomainGraphicsListenDefClear() ?
Because it doesn't do what I want to clear with the memset. That function frees the address, network and socket strings but doesn't clear ports. In this particular case those strings are NULL and there is no need to free them, I need to only set all ports to 0. Thanks, Pavel

Hey, On Wed, May 11, 2016 at 05:08:25PM +0200, Pavel Hrdina wrote:
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 | 45 ++++---- src/qemu/qemu_domain.c | 19 ++-- src/qemu/qemu_hotplug.c | 9 ++ src/qemu/qemu_parse_command.c | 2 +- src/qemu/qemu_process.c | 47 ++++++-- 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-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-auto-socket.xml | 30 ++++++ .../qemuxml2argv-graphics-vnc-socket.args | 4 +- .../qemuxml2argv-graphics-vnc-socket.xml | 10 +- tests/qemuxml2argvtest.c | 2 + .../qemuxml2xmlout-graphics-vnc-auto-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 4 +- .../qemuxml2xmlout-graphics-vnc-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 23 files changed, 361 insertions(+), 84 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b0847b7..f67076d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5359,6 +5359,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>
If both a socket attribute and a listen type="socket" node are present, shouldn't this check if they are using the same path? This is what is done for 'listen' attribute and listen type="address", but I could not find the same thing in this patch.
+ </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>
Imo this would be better as <listen type="unix" socket="/some/path"/> This would be more consistent with /disk/source/host vhost-user also uses type="unix" but with a path attribute rather than socket There is also <channel type="unix"> (again with 'path' rather than 'socket'). Christophe

On Thu, May 12, 2016 at 01:06:41PM +0200, Christophe Fergeau wrote:
Hey,
On Wed, May 11, 2016 at 05:08:25PM +0200, Pavel Hrdina wrote:
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 | 45 ++++---- src/qemu/qemu_domain.c | 19 ++-- src/qemu/qemu_hotplug.c | 9 ++ src/qemu/qemu_parse_command.c | 2 +- src/qemu/qemu_process.c | 47 ++++++-- 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-socket.args | 20 ++++ .../qemuxml2argv-graphics-vnc-auto-socket.xml | 30 ++++++ .../qemuxml2argv-graphics-vnc-socket.args | 4 +- .../qemuxml2argv-graphics-vnc-socket.xml | 10 +- tests/qemuxml2argvtest.c | 2 + .../qemuxml2xmlout-graphics-vnc-auto-socket.xml | 35 ++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 4 +- .../qemuxml2xmlout-graphics-vnc-socket.xml | 35 ++++++ tests/qemuxml2xmltest.c | 2 + 23 files changed, 361 insertions(+), 84 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-socket.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index b0847b7..f67076d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5359,6 +5359,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>
If both a socket attribute and a listen type="socket" node are present, shouldn't this check if they are using the same path? This is what is done for 'listen' attribute and listen type="address", but I could not find the same thing in this patch.
I know, that I had that code somewhere but I cannot remember why I didn't use it. I can probably add this check in to the code. Right know I can think of only one case, where it could break things: if some application uses socket and tries to change it. But in that case it's probably OK to print an error.
+ </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>
Imo this would be better as <listen type="unix" socket="/some/path"/>
This would be more consistent with /disk/source/host vhost-user also uses type="unix" but with a path attribute rather than socket There is also <channel type="unix"> (again with 'path' rather than 'socket').
Yes, it would be better to use unix and path, but I've tired to follow the same logic based on current listen types address and network. I actually don't care about the type name and the attribute name, so if someone else has any idea, please share it :). Thanks, Pavel
Christophe

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 1bddf43..4efb8c2 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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 1bddf43..4efb8c2 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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> -- Marc-André Lureau

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 2 +- src/conf/domain_conf.c | 33 +++-- src/qemu/qemu_command.c | 157 +++++++++++---------- src/qemu/qemu_migration.c | 50 ++++--- .../qemuxml2argv-graphics-spice-auto-socket.args | 20 +++ .../qemuxml2argv-graphics-spice-auto-socket.xml | 30 ++++ .../qemuxml2argv-graphics-spice-socket.args | 20 +++ .../qemuxml2argv-graphics-spice-socket.xml | 30 ++++ tests/qemuxml2argvtest.c | 6 + .../qemuxml2xmlout-graphics-spice-auto-socket.xml | 35 +++++ .../qemuxml2xmlout-graphics-spice-socket.xml | 35 +++++ tests/qemuxml2xmltest.c | 2 + 12 files changed, 313 insertions(+), 107 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f67076d..8f3e17f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5365,7 +5365,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 fd071e1..86b211c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10810,7 +10810,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, def->type = typeVal; 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); @@ -21589,19 +21590,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 13df7cb..b911076 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7538,6 +7538,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", @@ -7551,69 +7552,91 @@ 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, "unix,addr=%s,", glisten->socket); + 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) { @@ -7636,11 +7659,17 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,"); - if (glisten->tlsPort > 0) + if (useTLS) virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir); switch (defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: + if (!useTLS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spice defaultMode secure requested in XML " + "configuration, but TLS is not available")); + goto error; + } virBufferAddLit(&opt, "tls-channel=default,"); break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: @@ -7654,10 +7683,10 @@ 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")); + _("spice secure channels set in XML " + "configuration, but TLS is not available")); goto error; } virBufferAsprintf(&opt, "tls-channel=%s,", @@ -7665,40 +7694,12 @@ 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; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - switch (defaultMode) { - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice defaultMode secure requested in XML " - "configuration but TLS port not provided")); - goto error; - } - 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: - /* don't care */ break; - } } } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6440cf1..9970be4 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,37 @@ 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; + } + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + /* Seamless migration is supported only for listen types + * 'address and 'network'. */ + if (!(mig->graphics = + qemuMigrationCookieGraphicsSpiceAlloc(driver, glisten))) + return -1; + mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } + + /* Seamless migration is supported only for one graphics. */ + if (mig->graphics) + break; + } } return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args new file mode 100644 index 0000000..61335b0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-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 unix,addr=/tmp/lib/domain--1-QEMUGuest1/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml new file mode 100644 index 0000000..acb325a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args new file mode 100644 index 0000000..26d0671 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-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 unix,addr=/tmp/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml new file mode 100644 index 0000000..13bbef1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-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 43deebd..4bf5249 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-socket", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); + DO_TEST("graphics-spice-auto-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-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml new file mode 100644 index 0000000..931ec0f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-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-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml new file mode 100644 index 0000000..dd672ed --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-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 b67d687..172fbf9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -441,6 +441,8 @@ mymain(void) DO_TEST("graphics-spice"); DO_TEST("graphics-spice-compression"); DO_TEST("graphics-spice-qxl-vga"); + DO_TEST("graphics-spice-socket"); + DO_TEST("graphics-spice-auto-socket"); DO_TEST("nographics-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); -- 2.8.2

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.html.in | 2 +- src/conf/domain_conf.c | 33 +++-- src/qemu/qemu_command.c | 157 +++++++++++---------- src/qemu/qemu_migration.c | 50 ++++--- .../qemuxml2argv-graphics-spice-auto-socket.args | 20 +++ .../qemuxml2argv-graphics-spice-auto-socket.xml | 30 ++++ .../qemuxml2argv-graphics-spice-socket.args | 20 +++ .../qemuxml2argv-graphics-spice-socket.xml | 30 ++++ tests/qemuxml2argvtest.c | 6 + .../qemuxml2xmlout-graphics-spice-auto-socket.xml | 35 +++++ .../qemuxml2xmlout-graphics-spice-socket.xml | 35 +++++ tests/qemuxml2xmltest.c | 2 + 12 files changed, 313 insertions(+), 107 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index f67076d..8f3e17f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5365,7 +5365,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 fd071e1..86b211c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10810,7 +10810,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, def->type = typeVal;
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); @@ -21589,19 +21590,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 13df7cb..b911076 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7538,6 +7538,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", @@ -7551,69 +7552,91 @@ 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, "unix,addr=%s,", glisten->socket); + 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) { @@ -7636,11 +7659,17 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,");
- if (glisten->tlsPort > 0) + if (useTLS) virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir);
switch (defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: + if (!useTLS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spice defaultMode secure requested in XML " + "configuration, but TLS is not available")); + goto error; + }
I am not quite sure about the simpification you have made to defaultMode checks. Why not put it in a previous seperate patch to make this more clear?
virBufferAddLit(&opt, "tls-channel=default,"); break; case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE: @@ -7654,10 +7683,10 @@ 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")); + _("spice secure channels set in XML " + "configuration, but TLS is not available")); goto error; } virBufferAsprintf(&opt, "tls-channel=%s,", @@ -7665,40 +7694,12 @@ 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;
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - switch (defaultMode) { - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice defaultMode secure requested in XML " - "configuration but TLS port not provided")); - goto error; - } - 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: - /* don't care */ break; - } } }
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 6440cf1..9970be4 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,37 @@ 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; + } + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK: + /* Seamless migration is supported only for listen types + * 'address and 'network'. */ + if (!(mig->graphics = + qemuMigrationCookieGraphicsSpiceAlloc(driver, glisten))) + return -1; + mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS; + break; + + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE: + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: + break; + } + + /* Seamless migration is supported only for one graphics. */ + if (mig->graphics) + break; + } }
return 0; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.args new file mode 100644 index 0000000..61335b0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-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 unix,addr=/tmp/lib/domain--1-QEMUGuest1/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket.xml new file mode 100644 index 0000000..acb325a --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-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-socket.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.args new file mode 100644 index 0000000..26d0671 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-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 unix,addr=/tmp/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-socket.xml new file mode 100644 index 0000000..13bbef1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-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 43deebd..4bf5249 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-socket", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); + DO_TEST("graphics-spice-auto-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-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket.xml new file mode 100644 index 0000000..931ec0f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-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-socket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-socket.xml new file mode 100644 index 0000000..dd672ed --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-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 b67d687..172fbf9 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -441,6 +441,8 @@ mymain(void) DO_TEST("graphics-spice"); DO_TEST("graphics-spice-compression"); DO_TEST("graphics-spice-qxl-vga"); + DO_TEST("graphics-spice-socket"); + DO_TEST("graphics-spice-auto-socket"); DO_TEST("nographics-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); -- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Other than that, looks good -- Marc-André Lureau

On Wed, May 11, 2016 at 08:13:53PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> ---
[...]
@@ -7636,11 +7659,17 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, !cfg->spicePassword) virBufferAddLit(&opt, "disable-ticketing,");
- if (glisten->tlsPort > 0) + if (useTLS) virBufferAsprintf(&opt, "x509-dir=%s,", cfg->spiceTLSx509certdir);
switch (defaultMode) { case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: + if (!useTLS) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("spice defaultMode secure requested in XML " + "configuration, but TLS is not available")); + goto error; + }
I am not quite sure about the simpification you have made to defaultMode checks. Why not put it in a previous seperate patch to make this more clear?
I was just lazy to create a separate patch, but I can do that. Pavel

Hey, On Wed, May 11, 2016 at 05:08:27PM +0200, Pavel Hrdina wrote:
@@ -7665,40 +7694,12 @@ 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;
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - switch (defaultMode) { - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice defaultMode secure requested in XML " - "configuration but TLS port not provided")); - goto error; - } - 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: - /* don't care */ break; - } } }
Didn't we lose the error when asking for plaintext channels without setting a non-secure port? Christophe

On Thu, May 12, 2016 at 01:17:54PM +0200, Christophe Fergeau wrote:
Hey,
On Wed, May 11, 2016 at 05:08:27PM +0200, Pavel Hrdina wrote:
@@ -7665,40 +7694,12 @@ 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;
case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_ANY: - switch (defaultMode) { - case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE: - if (glisten->tlsPort <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("spice defaultMode secure requested in XML " - "configuration but TLS port not provided")); - goto error; - } - 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: - /* don't care */ break; - } } }
Didn't we lose the error when asking for plaintext channels without setting a non-secure port?
Christophe
Yes, we lose that error and I have a v3 that fixes it already prepared. I'm just waiting in case someone else wants to review this series. Thanks, Pavel

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 123 ++++++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 46 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3d78455..21c2db2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4418,14 +4418,87 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver, static int +qemuProcessGraphicsListenGenerate(virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, + virDomainGraphicsDefPtr graphics) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + const char *type = virDomainGraphicsTypeToString(graphics->type); + char *listenAddr = NULL; + bool autoSocket = false; + size_t i; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + if (cfg->vncAutoUnixSocket) { + autoSocket = true; + } else { + listenAddr = cfg->vncListen; + } + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + listenAddr = cfg->spiceListen; + 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; + } + + for (i = 0; i < graphics->nListens; i++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[i]; + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + /* If there is no address specified we will use address from + * qemu.conf from '*Listen'. If '*_auto_unix_socket' is set it has + * higher priority and we will use unix socket as a default listen + * type. */ + if (!glisten->address) { + if (autoSocket) { + memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); + if (virAsprintf(&glisten->socket, "%s/%s.sock", + priv->libDir, type) < 0) + return -1; + glisten->fromConfig = true; + glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + } else if (listenAddr) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + return -1; + 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) + return -1; + 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; + } + } + + return 0; +} + + +static int qemuProcessSetupGraphics(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - qemuDomainObjPrivatePtr priv = vm->privateData; bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); - size_t i, j; + size_t i; int ret = -1; if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0) @@ -4433,22 +4506,16 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - const char *type = virDomainGraphicsTypeToString(graphics->type); - char *listenAddr = NULL; switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0) goto cleanup; - - listenAddr = cfg->vncListen; break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, allocate) < 0) goto cleanup; - - listenAddr = cfg->spiceListen; break; case VIR_DOMAIN_GRAPHICS_TYPE_SDL: @@ -4458,44 +4525,8 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, break; } - for (j = 0; j < graphics->nListens; j++) { - virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; - - switch (glisten->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - if (!glisten->address) { - /* If there is no address specified and qemu.conf has - * vnc_auto_unix_socket set we should use unix socket as - * default instead of tcp listen. */ - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - cfg->vncAutoUnixSocket) { - memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); - if (virAsprintf(&glisten->socket, "%s/%s.sock", - priv->libDir, type) < 0) - goto cleanup; - glisten->fromConfig = true; - glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; - } else if (listenAddr) { - 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; - } - } + if (qemuProcessGraphicsListenGenerate(vm, cfg, graphics) < 0) + goto cleanup; } ret = 0; -- 2.8.2

On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 123 ++++++++++++++++++++++++++++++------------------ 1 file changed, 77 insertions(+), 46 deletions(-)
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3d78455..21c2db2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4418,14 +4418,87 @@ qemuProcessGraphicsReservePorts(virQEMUDriverPtr driver,
static int +qemuProcessGraphicsListenGenerate(virDomainObjPtr vm, + virQEMUDriverConfigPtr cfg, + virDomainGraphicsDefPtr graphics) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + const char *type = virDomainGraphicsTypeToString(graphics->type); + char *listenAddr = NULL; + bool autoSocket = false; + size_t i; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + if (cfg->vncAutoUnixSocket) { + autoSocket = true; + } else { + listenAddr = cfg->vncListen; + } + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + listenAddr = cfg->spiceListen; + 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; + } + + for (i = 0; i < graphics->nListens; i++) { + virDomainGraphicsListenDefPtr glisten = &graphics->listens[i]; + + switch (glisten->type) { + case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: + /* If there is no address specified we will use address from + * qemu.conf from '*Listen'. If '*_auto_unix_socket' is set it has + * higher priority and we will use unix socket as a default listen + * type. */ + if (!glisten->address) { + if (autoSocket) { + memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); + if (virAsprintf(&glisten->socket, "%s/%s.sock", + priv->libDir, type) < 0) + return -1; + glisten->fromConfig = true; + glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; + } else if (listenAddr) { + if (VIR_STRDUP(glisten->address, listenAddr) < 0) + return -1; + 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) + return -1; + 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; + } + } + + return 0; +} + + +static int qemuProcessSetupGraphics(virQEMUDriverPtr driver, virDomainObjPtr vm, unsigned int flags) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - qemuDomainObjPrivatePtr priv = vm->privateData; bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND); - size_t i, j; + size_t i; int ret = -1;
if (allocate && qemuProcessGraphicsReservePorts(driver, vm) < 0) @@ -4433,22 +4506,16 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->ngraphics; ++i) { virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - const char *type = virDomainGraphicsTypeToString(graphics->type); - char *listenAddr = NULL;
switch (graphics->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: if (qemuProcessVNCAllocatePorts(driver, graphics, allocate) < 0) goto cleanup; - - listenAddr = cfg->vncListen; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, allocate) < 0) goto cleanup; - - listenAddr = cfg->spiceListen; break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL: @@ -4458,44 +4525,8 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver, break; }
- for (j = 0; j < graphics->nListens; j++) { - virDomainGraphicsListenDefPtr glisten = &graphics->listens[j]; - - switch (glisten->type) { - case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: - if (!glisten->address) { - /* If there is no address specified and qemu.conf has - * vnc_auto_unix_socket set we should use unix socket as - * default instead of tcp listen. */ - if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC && - cfg->vncAutoUnixSocket) { - memset(glisten, 0, sizeof(virDomainGraphicsListenDef)); - if (virAsprintf(&glisten->socket, "%s/%s.sock", - priv->libDir, type) < 0) - goto cleanup; - glisten->fromConfig = true; - glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET; - } else if (listenAddr) { - 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; - } - } + if (qemuProcessGraphicsListenGenerate(vm, cfg, graphics) < 0) + goto cleanup; }
ret = 0; -- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

Commit 55320c23 introduced a new test for VNC to test if vnc_auto_unix_socket is set in qemu.conf, but forget to enable it in qemuxml2argvtest.c. This patch also moves the code in qemuxml2xmltest.c next to other VNC tests. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- .../qemuxml2argv-graphics-vnc-auto-socket-cfg.args | 22 ++++++++++++ .../qemuxml2argv-graphics-vnc-auto-socket-cfg.xml | 34 ++++++++++++++++++ .../qemuxml2argv-graphics-vnc-autosocket.args | 22 ------------ .../qemuxml2argv-graphics-vnc-autosocket.xml | 34 ------------------ tests/qemuxml2argvtest.c | 3 ++ ...qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml | 41 ++++++++++++++++++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 41 ---------------------- tests/qemuxml2xmltest.c | 11 +++--- 8 files changed, 106 insertions(+), 102 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.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/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args new file mode 100644 index 0000000..cfa63b1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args @@ -0,0 +1,22 @@ +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.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml new file mode 100644 index 0000000..fa59c39 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml @@ -0,0 +1,34 @@ +<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/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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4bf5249..a3651c9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -878,6 +878,9 @@ mymain(void) DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_VNC); DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC); DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC); + driver.config->vncAutoUnixSocket = true; + DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC); + driver.config->vncAutoUnixSocket = false; driver.config->vncSASL = 1; VIR_FREE(driver.config->vncSASLdir); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml new file mode 100644 index 0000000..5013b18 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml @@ -0,0 +1,41 @@ +<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'> + <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-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml deleted file mode 100644 index 5013b18..0000000 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ /dev/null @@ -1,41 +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'> - <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/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 172fbf9..49bf557 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -268,6 +268,8 @@ mymain(void) if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE; + cfg = virQEMUDriverGetConfig(&driver); + /* TODO: test with format probing disabled too */ driver.config->allowDiskFormatProbing = true; @@ -436,6 +438,10 @@ mymain(void) DO_TEST("graphics-vnc-no-listen-attr"); DO_TEST("graphics-vnc-socket"); DO_TEST("graphics-vnc-auto-socket"); + cfg->vncAutoUnixSocket = true; + DO_TEST_FULL("graphics-vnc-auto-socket-cfg", WHEN_INACTIVE, NONE); + cfg->vncAutoUnixSocket = false; + DO_TEST("graphics-sdl"); DO_TEST("graphics-sdl-fullscreen"); DO_TEST("graphics-spice"); @@ -792,11 +798,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); -- 2.8.2

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Commit 55320c23 introduced a new test for VNC to test if vnc_auto_unix_socket is set in qemu.conf, but forget to enable it in qemuxml2argvtest.c. This patch also moves the code in qemuxml2xmltest.c next to other VNC tests.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
--- .../qemuxml2argv-graphics-vnc-auto-socket-cfg.args | 22 ++++++++++++ .../qemuxml2argv-graphics-vnc-auto-socket-cfg.xml | 34 ++++++++++++++++++ .../qemuxml2argv-graphics-vnc-autosocket.args | 22 ------------ .../qemuxml2argv-graphics-vnc-autosocket.xml | 34 ------------------ tests/qemuxml2argvtest.c | 3 ++ ...qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml | 41 ++++++++++++++++++++++ .../qemuxml2xmlout-graphics-vnc-autosocket.xml | 41 ---------------------- tests/qemuxml2xmltest.c | 11 +++--- 8 files changed, 106 insertions(+), 102 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.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/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml delete mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args new file mode 100644 index 0000000..cfa63b1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.args @@ -0,0 +1,22 @@ +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.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml new file mode 100644 index 0000000..fa59c39 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-socket-cfg.xml @@ -0,0 +1,34 @@ +<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/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/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4bf5249..a3651c9 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -878,6 +878,9 @@ mymain(void) DO_TEST("graphics-vnc-no-listen-attr", QEMU_CAPS_VNC); DO_TEST("graphics-vnc-socket", QEMU_CAPS_VNC); DO_TEST("graphics-vnc-auto-socket", QEMU_CAPS_VNC); + driver.config->vncAutoUnixSocket = true; + DO_TEST("graphics-vnc-auto-socket-cfg", QEMU_CAPS_VNC); + driver.config->vncAutoUnixSocket = false;
driver.config->vncSASL = 1; VIR_FREE(driver.config->vncSASLdir); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml new file mode 100644 index 0000000..5013b18 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-auto-socket-cfg.xml @@ -0,0 +1,41 @@ +<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'> + <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-autosocket.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml deleted file mode 100644 index 5013b18..0000000 --- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-vnc-autosocket.xml +++ /dev/null @@ -1,41 +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'> - <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/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 172fbf9..49bf557 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -268,6 +268,8 @@ mymain(void) if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE;
+ cfg = virQEMUDriverGetConfig(&driver); + /* TODO: test with format probing disabled too */ driver.config->allowDiskFormatProbing = true;
@@ -436,6 +438,10 @@ mymain(void) DO_TEST("graphics-vnc-no-listen-attr"); DO_TEST("graphics-vnc-socket"); DO_TEST("graphics-vnc-auto-socket"); + cfg->vncAutoUnixSocket = true; + DO_TEST_FULL("graphics-vnc-auto-socket-cfg", WHEN_INACTIVE, NONE); + cfg->vncAutoUnixSocket = false; + DO_TEST("graphics-sdl"); DO_TEST("graphics-sdl-fullscreen"); DO_TEST("graphics-spice"); @@ -792,11 +798,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);
-- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu.conf | 11 +++++++ src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_process.c | 4 +++ ...emuxml2argv-graphics-spice-auto-socket-cfg.args | 20 +++++++++++++ ...qemuxml2argv-graphics-spice-auto-socket-cfg.xml | 30 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 ++++ ...muxml2xmlout-graphics-spice-auto-socket-cfg.xml | 35 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 4 +++ 9 files changed, 111 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 4fa5e8a..baf0b00 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -130,6 +130,17 @@ #spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice" +# Enable this option to have SPICE served over an automatically created +# unix socket. This prevents unprivileged access from users on the +# host machine, though most SPICE clients do not support it. +# +# This will only be enabled for SPICE configurations that do not have +# a hardcoded 'listen' or 'socket' value. This setting takes preference +# over spice_listen. +# +#spice_auto_unix_socket = 1 + + # The default SPICE password. This parameter is only used if the # per-domain XML config does not already provide a password. To # allow access without passwords, leave this commented out. An diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e00ddca..d4c34c9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -588,6 +588,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_STR("spice_sasl_dir", cfg->spiceSASLdir); GET_VALUE_STR("spice_listen", cfg->spiceListen); GET_VALUE_STR("spice_password", cfg->spicePassword); + GET_VALUE_BOOL("spice_auto_unix_socket", cfg->spiceAutoUnixSocket); GET_VALUE_ULONG("remote_websocket_port_min", cfg->webSocketPortMin); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a714b84..c94bf13 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -123,6 +123,7 @@ struct _virQEMUDriverConfig { char *spiceSASLdir; char *spiceListen; char *spicePassword; + bool spiceAutoUnixSocket; int remotePortMin; int remotePortMax; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 21c2db2..05ddb32 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4438,7 +4438,11 @@ qemuProcessGraphicsListenGenerate(virDomainObjPtr vm, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (cfg->spiceAutoUnixSocket) { + autoSocket = true; + } else { listenAddr = cfg->spiceListen; + } break; case VIR_DOMAIN_GRAPHICS_TYPE_SDL: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args new file mode 100644 index 0000000..61335b0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.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 unix,addr=/tmp/lib/domain--1-QEMUGuest1/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml new file mode 100644 index 0000000..ff155c3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.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/lib/domain-99-QEMUGuest1/delete.this.socket'/> + </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 a3651c9..f046060 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -950,6 +950,11 @@ mymain(void) DO_TEST("graphics-spice-auto-socket", QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX); + driver.config->spiceAutoUnixSocket = true; + DO_TEST("graphics-spice-auto-socket-cfg", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); + driver.config->spiceAutoUnixSocket = false; DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml new file mode 100644 index 0000000..931ec0f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.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/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 49bf557..9db7ddd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -449,6 +449,10 @@ mymain(void) DO_TEST("graphics-spice-qxl-vga"); DO_TEST("graphics-spice-socket"); DO_TEST("graphics-spice-auto-socket"); + cfg->spiceAutoUnixSocket = true; + DO_TEST_FULL("graphics-spice-auto-socket-cfg", WHEN_INACTIVE, NONE); + cfg->spiceAutoUnixSocket = false; + DO_TEST("nographics-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); -- 2.8.2

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> ---
make check fails : test_libvirtd_qemu.aug:68.3-145.28:exception thrown in test test_libvirtd_qemu.aug:68.8-.34:exception: Iterated lens matched less than it should Lens: ./qemu/libvirtd_qemu.aug:113.13-.43: Last match: ./qemu/libvirtd_qemu.aug:109.17-.31: Error encountered at 13:0 (324 characters into string) < = "/etc/pki/libvirt-spice"\n|=|spice_auto_unix_socket = 1\ns> Tbh, I don't understand the need for unix socket listening when using libvirt. If you use libvirt to manage your VM, you may as well just use it to connect to the display (virti-viewer --attach). These avoid having extra listening sockets. Other than that, looks good to me.
src/qemu/qemu.conf | 11 +++++++ src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_process.c | 4 +++ ...emuxml2argv-graphics-spice-auto-socket-cfg.args | 20 +++++++++++++ ...qemuxml2argv-graphics-spice-auto-socket-cfg.xml | 30 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 ++++ ...muxml2xmlout-graphics-spice-auto-socket-cfg.xml | 35 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 4 +++ 9 files changed, 111 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 4fa5e8a..baf0b00 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -130,6 +130,17 @@ #spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice"
+# Enable this option to have SPICE served over an automatically created +# unix socket. This prevents unprivileged access from users on the +# host machine, though most SPICE clients do not support it. +# +# This will only be enabled for SPICE configurations that do not have +# a hardcoded 'listen' or 'socket' value. This setting takes preference +# over spice_listen. +# +#spice_auto_unix_socket = 1 + + # The default SPICE password. This parameter is only used if the # per-domain XML config does not already provide a password. To # allow access without passwords, leave this commented out. An diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index e00ddca..d4c34c9 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -588,6 +588,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, GET_VALUE_STR("spice_sasl_dir", cfg->spiceSASLdir); GET_VALUE_STR("spice_listen", cfg->spiceListen); GET_VALUE_STR("spice_password", cfg->spicePassword); + GET_VALUE_BOOL("spice_auto_unix_socket", cfg->spiceAutoUnixSocket);
GET_VALUE_ULONG("remote_websocket_port_min", cfg->webSocketPortMin); diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index a714b84..c94bf13 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -123,6 +123,7 @@ struct _virQEMUDriverConfig { char *spiceSASLdir; char *spiceListen; char *spicePassword; + bool spiceAutoUnixSocket;
int remotePortMin; int remotePortMax; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 21c2db2..05ddb32 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4438,7 +4438,11 @@ qemuProcessGraphicsListenGenerate(virDomainObjPtr vm, break;
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (cfg->spiceAutoUnixSocket) { + autoSocket = true; + } else { listenAddr = cfg->spiceListen; + } break;
case VIR_DOMAIN_GRAPHICS_TYPE_SDL: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args new file mode 100644 index 0000000..61335b0 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.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 unix,addr=/tmp/lib/domain--1-QEMUGuest1/spice.sock \ +-vga cirrus diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml new file mode 100644 index 0000000..ff155c3 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.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/lib/domain-99-QEMUGuest1/delete.this.socket'/> + </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 a3651c9..f046060 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -950,6 +950,11 @@ mymain(void) DO_TEST("graphics-spice-auto-socket", QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX); + driver.config->spiceAutoUnixSocket = true; + DO_TEST("graphics-spice-auto-socket-cfg", + QEMU_CAPS_SPICE, + QEMU_CAPS_SPICE_UNIX); + driver.config->spiceAutoUnixSocket = false;
DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE); diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml new file mode 100644 index 0000000..931ec0f --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.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/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 49bf557..9db7ddd 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -449,6 +449,10 @@ mymain(void) DO_TEST("graphics-spice-qxl-vga"); DO_TEST("graphics-spice-socket"); DO_TEST("graphics-spice-auto-socket"); + cfg->spiceAutoUnixSocket = true; + DO_TEST_FULL("graphics-spice-auto-socket-cfg", WHEN_INACTIVE, NONE); + cfg->spiceAutoUnixSocket = false; + DO_TEST("nographics-vga"); DO_TEST("input-usbmouse"); DO_TEST("input-usbtablet"); -- 2.8.2
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Marc-André Lureau

On Wed, May 11, 2016 at 08:14:36PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> ---
make check fails : test_libvirtd_qemu.aug:68.3-145.28:exception thrown in test test_libvirtd_qemu.aug:68.8-.34:exception: Iterated lens matched less than it should Lens: ./qemu/libvirtd_qemu.aug:113.13-.43: Last match: ./qemu/libvirtd_qemu.aug:109.17-.31: Error encountered at 13:0 (324 characters into string) < = "/etc/pki/libvirt-spice"\n|=|spice_auto_unix_socket = 1\ns>
I guess that I should install augeas :) thanks.
Tbh, I don't understand the need for unix socket listening when using libvirt. If you use libvirt to manage your VM, you may as well just use it to connect to the display (virti-viewer --attach). These avoid having extra listening sockets. Other than that, looks good to me.
This will allow us to add another way how to restrict access to the graphics console. I'll add a <seclabel> for the <listen type='socket'/> and administrator can set a uid/gid to restrict access to this socket. Pavel

On Wed, May 11, 2016 at 05:08:30PM +0200, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu.conf | 11 +++++++ src/qemu/qemu_conf.c | 1 + src/qemu/qemu_conf.h | 1 + src/qemu/qemu_process.c | 4 +++ ...emuxml2argv-graphics-spice-auto-socket-cfg.args | 20 +++++++++++++ ...qemuxml2argv-graphics-spice-auto-socket-cfg.xml | 30 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 ++++ ...muxml2xmlout-graphics-spice-auto-socket-cfg.xml | 35 ++++++++++++++++++++++ tests/qemuxml2xmltest.c | 4 +++ 9 files changed, 111 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-auto-socket-cfg.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-graphics-spice-auto-socket-cfg.xml
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 4fa5e8a..baf0b00 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -130,6 +130,17 @@ #spice_tls_x509_cert_dir = "/etc/pki/libvirt-spice"
+# Enable this option to have SPICE served over an automatically created +# unix socket. This prevents unprivileged access from users on the +# host machine, though most SPICE clients do not support it. +# +# This will only be enabled for SPICE configurations that do not have +# a hardcoded 'listen' or 'socket' value. This setting takes preference
I think the "hardcoded 'listen' or 'socket' value" should be rephrased to refer to <listen> nodes instead. Christophe

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 8f3e17f..35bbf3f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5375,6 +5375,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 86b211c..99712ff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10809,13 +10809,28 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal; - 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) { @@ -10900,6 +10915,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; @@ -10953,6 +10969,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) @@ -21429,10 +21458,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 || @@ -21609,6 +21636,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; @@ -21630,8 +21661,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; @@ -21644,6 +21673,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 b911076..64b383d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7635,6 +7635,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; } @@ -7755,13 +7758,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

Hi On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 8f3e17f..35bbf3f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5375,6 +5375,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>.
I wonder if qemu would let you connect to the vnc server if started with -vnc none.
+ </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 86b211c..99712ff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10809,13 +10809,28 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal;
- 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) { @@ -10900,6 +10915,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; @@ -10953,6 +10969,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) @@ -21429,10 +21458,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 || @@ -21609,6 +21636,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; @@ -21630,8 +21661,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; @@ -21644,6 +21673,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 b911076..64b383d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7635,6 +7635,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,");
Does it? qemu-system-x86_64 -spice gl=on starts fine. It needs at least an argument though (that looks like a bug)
+ break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST: break; } @@ -7755,13 +7758,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
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Other than that, looks good to me -- Marc-André Lureau

On Wed, May 11, 2016 at 08:14:43PM +0200, Marc-André Lureau wrote:
Hi
On Wed, May 11, 2016 at 5:08 PM, Pavel Hrdina <phrdina@redhat.com> wrote:
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 8f3e17f..35bbf3f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -5375,6 +5375,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>.
I wonder if qemu would let you connect to the vnc server if started with -vnc none.
That's a good question. I didn't find this anywhere, but I'll try it.
+ </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 86b211c..99712ff 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10809,13 +10809,28 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def, } def->type = typeVal;
- 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) { @@ -10900,6 +10915,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; @@ -10953,6 +10969,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) @@ -21429,10 +21458,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 || @@ -21609,6 +21636,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; @@ -21630,8 +21661,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; @@ -21644,6 +21673,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 b911076..64b383d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7635,6 +7635,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,");
Does it? qemu-system-x86_64 -spice gl=on starts fine. It needs at least an argument though (that looks like a bug)
qemu doesn't allow to start if there is spice without arguments. So in case that there isn't anything else to add, like the gl=on we need to add port=0 in order to start qemu with spice. This actually probably doesn't happen in the real world as libvirt always adds some arguments for spice. The code I'm removing few lines below was introduce to start a guest with spice that doesn't listen for any connection. After this patch the only case where we could end up with spice without any arguments is the <listen type='none'>. For consistency I would rather put port=0 for <listen type='none'> even if there are other arguments. Pavel

On Thu, May 12, 2016 at 08:43:38AM +0200, Pavel Hrdina wrote:
@@ -21630,8 +21661,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; @@ -21644,6 +21673,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 b911076..64b383d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7635,6 +7635,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,");
Does it? qemu-system-x86_64 -spice gl=on starts fine. It needs at least an argument though (that looks like a bug)
qemu doesn't allow to start if there is spice without arguments. So in case that there isn't anything else to add, like the gl=on we need to add port=0
The comment which was used previously was probably more explicit than the new one: /* If we did not add any SPICE arguments, add a dummy 'port=0' one * as -spice alone is not allowed on QEMU command line */ QEMU does not care which argument is there after -spice, port/tls-port are good to use for that purpose as if they are set to 0 they will be ignored. Christophe

On Wed, May 11, 2016 at 05:08:31PM +0200, Pavel Hrdina wrote:
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'.
+ /* 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; + } + } +
Ah I assume this means libvirt is not going to error out when it finds configurations without ports and with autoport='no'? Maybe worth mentioning this in the commit log as it mentions the legacy behaviour, but I was not clear on how it would behave when encountering it. Christophe
participants (3)
-
Christophe Fergeau
-
Marc-André Lureau
-
Pavel Hrdina