From patchwork Mon Mar 21 23:30:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 64145 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1729839lbc; Mon, 21 Mar 2016 16:34:16 -0700 (PDT) X-Received: by 10.194.179.168 with SMTP id dh8mr37551923wjc.130.1458603256325; Mon, 21 Mar 2016 16:34:16 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id y3si34171891wjy.136.2016.03.21.16.34.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 21 Mar 2016 16:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2LNUupX006919; Mon, 21 Mar 2016 19:30:57 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u2LNUrb2032496 for ; Mon, 21 Mar 2016 19:30:53 -0400 Received: from colepc.redhat.com (ovpn-113-66.phx2.redhat.com [10.3.113.66]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2LNUq20012675; Mon, 21 Mar 2016 19:30:53 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Mon, 21 Mar 2016 19:30:44 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Christophe Fergeau Subject: [libvirt] [PATCH 1/2] qemu: Support SPICE listen over unix socket X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com Add support for SPICE listen over unix socket. This has been in qemu since v2.3. The XML is: Which matches support for VNC listen over unix socket. https://bugzilla.redhat.com/show_bug.cgi?id=1151761 --- docs/schemas/domaincommon.rng | 5 ++++ src/conf/domain_conf.c | 26 +++++++++++++-------- src/conf/domain_conf.h | 1 + src/qemu/qemu_command.c | 4 +++- src/qemu/qemu_process.c | 3 +++ src/security/virt-aa-helper.c | 5 ++++ .../qemuxml2argv-graphics-spice-unix.args | 21 +++++++++++++++++ .../qemuxml2argv-graphics-spice-unix.xml | 27 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 4 ++++ 9 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.xml -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index da6de40..4d3f951 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2700,6 +2700,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d5d9ff7..985d8bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1249,6 +1249,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def) break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + VIR_FREE(def->data.spice.socket); VIR_FREE(def->data.spice.keymap); virDomainGraphicsAuthDefClear(&def->data.spice.auth); break; @@ -10986,6 +10987,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, def->data.spice.tlsPort = 0; } + def->data.spice.socket = virXMLPropString(node, "socket"); def->data.spice.keymap = virXMLPropString(node, "keymap"); if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth, @@ -21267,19 +21269,23 @@ virDomainGraphicsDefFormat(virBufferPtr buf, break; case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (def->data.spice.port) - virBufferAsprintf(buf, " port='%d'", - def->data.spice.port); + if (def->data.spice.socket) { + virBufferEscapeString(buf, " socket='%s'", def->data.spice.socket); + } else { + if (def->data.spice.port) + virBufferAsprintf(buf, " port='%d'", + def->data.spice.port); - if (def->data.spice.tlsPort) - virBufferAsprintf(buf, " tlsPort='%d'", - def->data.spice.tlsPort); + if (def->data.spice.tlsPort) + virBufferAsprintf(buf, " tlsPort='%d'", + def->data.spice.tlsPort); - virBufferAsprintf(buf, " autoport='%s'", - def->data.spice.autoport ? "yes" : "no"); + virBufferAsprintf(buf, " autoport='%s'", + def->data.spice.autoport ? "yes" : "no"); - if (listenAddr) - virBufferAsprintf(buf, " listen='%s'", listenAddr); + if (listenAddr) + virBufferAsprintf(buf, " listen='%s'", listenAddr); + } if (def->data.spice.keymap) virBufferEscapeString(buf, " keymap='%s'", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 83bdd67..884476d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1578,6 +1578,7 @@ struct _virDomainGraphicsDef { bool tlsPortReserved; int mousemode; char *keymap; + char *socket; virDomainGraphicsAuthDef auth; bool autoport; int channels[VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST]; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index eb02553..8a5baf5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7411,7 +7411,9 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, /* TODO: Support ACLs later */ } - if (port > 0 || tlsPort > 0) { + if (graphics->data.spice.socket) { + virBufferAsprintf(&opt, "unix,addr=%s,", graphics->data.spice.socket); + } else if (port > 0 || tlsPort > 0) { switch (virDomainGraphicsListenGetType(graphics, 0)) { case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: listenAddr = virDomainGraphicsListenGetAddress(graphics, 0); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c332747..6cf993b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3759,6 +3759,9 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, bool needTLSPort = false; bool needPort = false; + if (graphics->data.spice.socket) + return 0; + if (graphics->data.spice.autoport) { /* check if tlsPort or port need allocation */ for (i = 0; i < VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_LAST; i++) { diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index a2d7226..f46742c 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1064,6 +1064,11 @@ get_files(vahControl * ctl) ctl->def->graphics[i]->data.vnc.socket && vah_add_file(&buf, ctl->def->graphics[i]->data.vnc.socket, "rw")) goto cleanup; + + if (ctl->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE && + ctl->def->graphics[i]->data.spice.socket && + vah_add_file(&buf, ctl->def->graphics[i]->data.spice.socket, "rw")) + goto cleanup; } if (ctl->def->ngraphics == 1 && diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.args new file mode 100644 index 0000000..b965ea4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=spice \ +/usr/bin/qemu \ +-name QEMUGuest1 \ +-S \ +-M pc \ +-m 214 \ +-smp 1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-spice unix,addr=/tmp/spice.socket \ +-vga qxl \ +-global qxl-vga.ram_size=67108864 \ +-global qxl-vga.vram_size=33554432 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.xml new file mode 100644 index 0000000..6c6be44 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-unix.xml @@ -0,0 +1,27 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 4fac77d..76b64bd 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -990,6 +990,10 @@ mymain(void) QEMU_CAPS_DEVICE_QXL_VGA, QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_SPICE_FILE_XFER_DISABLE); + DO_TEST("graphics-spice-unix", + QEMU_CAPS_VGA_QXL, + QEMU_CAPS_SPICE, + QEMU_CAPS_DEVICE_QXL); DO_TEST("input-usbmouse", NONE); DO_TEST("input-usbtablet", NONE);