mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
spice: add support for listen type socket
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1335832 Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
61a63abfe8
commit
e0c309b2dc
@ -5366,7 +5366,7 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
This listen type tells a graphics server to listen on unix socket.
|
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 <code>socket</code> contains a path to unix socket. If this
|
||||||
attribute is omitted libvirt will generate this path for you.
|
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>
|
||||||
<p>
|
<p>
|
||||||
For <code>vnc</code> graphics be backward compatible
|
For <code>vnc</code> graphics be backward compatible
|
||||||
|
@ -10943,7 +10943,8 @@ virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
|
|||||||
def->type = typeVal;
|
def->type = typeVal;
|
||||||
|
|
||||||
if (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET &&
|
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,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("listen type 'socket' is not available for "
|
_("listen type 'socket' is not available for "
|
||||||
"graphics type '%s'"), graphicsType);
|
"graphics type '%s'"), graphicsType);
|
||||||
@ -21924,18 +21925,28 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||||
if (def->data.spice.port)
|
switch (glisten->type) {
|
||||||
virBufferAsprintf(buf, " port='%d'",
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
|
||||||
def->data.spice.port);
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
|
||||||
|
if (def->data.spice.port)
|
||||||
|
virBufferAsprintf(buf, " port='%d'",
|
||||||
|
def->data.spice.port);
|
||||||
|
|
||||||
if (def->data.spice.tlsPort)
|
if (def->data.spice.tlsPort)
|
||||||
virBufferAsprintf(buf, " tlsPort='%d'",
|
virBufferAsprintf(buf, " tlsPort='%d'",
|
||||||
def->data.spice.tlsPort);
|
def->data.spice.tlsPort);
|
||||||
|
|
||||||
virBufferAsprintf(buf, " autoport='%s'",
|
virBufferAsprintf(buf, " autoport='%s'",
|
||||||
def->data.spice.autoport ? "yes" : "no");
|
def->data.spice.autoport ? "yes" : "no");
|
||||||
|
|
||||||
virDomainGraphicsListenDefFormatAddr(buf, glisten, flags);
|
virDomainGraphicsListenDefFormatAddr(buf, glisten, flags);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (def->data.spice.keymap)
|
if (def->data.spice.keymap)
|
||||||
virBufferEscapeString(buf, " keymap='%s'",
|
virBufferEscapeString(buf, " keymap='%s'",
|
||||||
|
@ -7347,27 +7347,53 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
glisten = virDomainGraphicsGetListen(graphics, 0);
|
if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
if (port > 0) {
|
_("missing listen element"));
|
||||||
virBufferAsprintf(&opt, "port=%u,", port);
|
goto error;
|
||||||
hasInsecure = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tlsPort > 0) {
|
switch (glisten->type) {
|
||||||
if (!cfg->spiceTLS) {
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_UNIX)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("spice TLS port set in XML configuration,"
|
_("unix socket for spice graphics are not supported "
|
||||||
" but TLS is disabled in qemu.conf"));
|
"with this QEMU"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(&opt, "tls-port=%u,", tlsPort);
|
|
||||||
hasSecure = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port > 0 || tlsPort > 0) {
|
virBufferAsprintf(&opt, "unix,addr=%s,", glisten->socket);
|
||||||
if (glisten && glisten->address)
|
hasInsecure = true;
|
||||||
virBufferAsprintf(&opt, "addr=%s,", glisten->address);
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
|
||||||
|
if (port > 0) {
|
||||||
|
virBufferAsprintf(&opt, "port=%u,", port);
|
||||||
|
hasInsecure = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (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);
|
||||||
|
hasSecure = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port > 0 || tlsPort > 0) {
|
||||||
|
if (glisten->address)
|
||||||
|
virBufferAsprintf(&opt, "addr=%s,", glisten->address);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cfg->spiceSASL) {
|
if (cfg->spiceSASL) {
|
||||||
|
@ -315,17 +315,17 @@ qemuDomainExtractTLSSubject(const char *certdir)
|
|||||||
|
|
||||||
static qemuMigrationCookieGraphicsPtr
|
static qemuMigrationCookieGraphicsPtr
|
||||||
qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
|
qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPtr driver,
|
||||||
virDomainGraphicsDefPtr def)
|
virDomainGraphicsDefPtr def,
|
||||||
|
virDomainGraphicsListenDefPtr glisten)
|
||||||
{
|
{
|
||||||
qemuMigrationCookieGraphicsPtr mig = NULL;
|
qemuMigrationCookieGraphicsPtr mig = NULL;
|
||||||
const char *listenAddr;
|
const char *listenAddr;
|
||||||
virDomainGraphicsListenDefPtr glisten = virDomainGraphicsGetListen(def, 0);
|
|
||||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||||
|
|
||||||
if (VIR_ALLOC(mig) < 0)
|
if (VIR_ALLOC(mig) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
mig->type = def->type;
|
mig->type = VIR_DOMAIN_GRAPHICS_TYPE_SPICE;
|
||||||
mig->port = def->data.spice.port;
|
mig->port = def->data.spice.port;
|
||||||
if (cfg->spiceTLS)
|
if (cfg->spiceTLS)
|
||||||
mig->tlsPort = def->data.spice.tlsPort;
|
mig->tlsPort = def->data.spice.tlsPort;
|
||||||
@ -452,14 +452,39 @@ qemuMigrationCookieAddGraphics(qemuMigrationCookiePtr mig,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < dom->def->ngraphics; i++) {
|
for (i = 0; i < dom->def->ngraphics; i++) {
|
||||||
if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
if (dom->def->graphics[i]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
|
||||||
if (!(mig->graphics =
|
virDomainGraphicsListenDefPtr glisten =
|
||||||
qemuMigrationCookieGraphicsSpiceAlloc(driver,
|
virDomainGraphicsGetListen(dom->def->graphics[i], 0);
|
||||||
dom->def->graphics[i])))
|
|
||||||
return -1;
|
if (!glisten) {
|
||||||
mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
break;
|
_("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,
|
||||||
|
dom->def->graphics[i],
|
||||||
|
glisten)))
|
||||||
|
return -1;
|
||||||
|
mig->flags |= QEMU_MIGRATION_COOKIE_GRAPHICS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE:
|
||||||
|
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_LAST:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Seamless migration is supported only for one graphics. */
|
||||||
|
if (mig->graphics)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -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
|
@ -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>
|
@ -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
|
@ -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>
|
@ -966,6 +966,12 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE_QXL_VGA,
|
QEMU_CAPS_DEVICE_QXL_VGA,
|
||||||
QEMU_CAPS_DEVICE_QXL,
|
QEMU_CAPS_DEVICE_QXL,
|
||||||
QEMU_CAPS_SPICE_FILE_XFER_DISABLE);
|
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-usbmouse", NONE);
|
||||||
DO_TEST("input-usbtablet", NONE);
|
DO_TEST("input-usbtablet", NONE);
|
||||||
|
@ -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>
|
@ -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>
|
@ -442,6 +442,8 @@ mymain(void)
|
|||||||
DO_TEST("graphics-spice");
|
DO_TEST("graphics-spice");
|
||||||
DO_TEST("graphics-spice-compression");
|
DO_TEST("graphics-spice-compression");
|
||||||
DO_TEST("graphics-spice-qxl-vga");
|
DO_TEST("graphics-spice-qxl-vga");
|
||||||
|
DO_TEST("graphics-spice-socket");
|
||||||
|
DO_TEST("graphics-spice-auto-socket");
|
||||||
DO_TEST("nographics-vga");
|
DO_TEST("nographics-vga");
|
||||||
DO_TEST("input-usbmouse");
|
DO_TEST("input-usbmouse");
|
||||||
DO_TEST("input-usbtablet");
|
DO_TEST("input-usbtablet");
|
||||||
|
Loading…
Reference in New Issue
Block a user