mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-08 12:41:29 +00:00
qemu: introduce spiceport chardev backend
Add a new backend for any character device. This backend uses channel in spice connection. This channel is similar to spicevmc, but all-purpose in contrast to spicevmc. Apart from spicevmc, spiceport-backed chardev will not be formatted into the command-line if there is no spice to use (with test for that as well). For this I moved the def->graphics counting to the start of the function so its results can be used in rest of the code even in the future. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
296a4791eb
commit
d27e6bc40f
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_capabilities.c: QEMU capabilities generation
|
* qemu_capabilities.c: QEMU capabilities generation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2013 Red Hat, Inc.
|
* Copyright (C) 2006-2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -247,7 +247,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
|
|||||||
"boot-strict", /* 160 */
|
"boot-strict", /* 160 */
|
||||||
"pvpanic",
|
"pvpanic",
|
||||||
"enable-fips",
|
"enable-fips",
|
||||||
"spice-file-xfer-disable"
|
"spice-file-xfer-disable",
|
||||||
|
"spiceport",
|
||||||
);
|
);
|
||||||
|
|
||||||
struct _virQEMUCaps {
|
struct _virQEMUCaps {
|
||||||
@ -1012,6 +1013,8 @@ virQEMUCapsComputeCmdFlags(const char *help,
|
|||||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV);
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV);
|
||||||
if (strstr(help, "-chardev spicevmc"))
|
if (strstr(help, "-chardev spicevmc"))
|
||||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEVMC);
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEVMC);
|
||||||
|
if (strstr(help, "-chardev spiceport"))
|
||||||
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT);
|
||||||
}
|
}
|
||||||
if (strstr(help, "-balloon"))
|
if (strstr(help, "-balloon"))
|
||||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON);
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_BALLOON);
|
||||||
@ -2567,6 +2570,12 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
|
|||||||
if (qemuCaps->version >= 1003001)
|
if (qemuCaps->version >= 1003001)
|
||||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET);
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET);
|
||||||
|
|
||||||
|
/* -chardev spiceport is supported from 1.4.0, but usable through
|
||||||
|
* qapi only since 1.5.0, however, it still cannot be queried
|
||||||
|
* for as a capability */
|
||||||
|
if (qemuCaps->version >= 1005000)
|
||||||
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT);
|
||||||
|
|
||||||
if (qemuCaps->version >= 1006000)
|
if (qemuCaps->version >= 1006000)
|
||||||
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_capabilities.h: QEMU capabilities generation
|
* qemu_capabilities.h: QEMU capabilities generation
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2013 Red Hat, Inc.
|
* Copyright (C) 2006-2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -202,6 +202,7 @@ enum virQEMUCapsFlags {
|
|||||||
QEMU_CAPS_DEVICE_PANIC = 161, /* -device pvpanic */
|
QEMU_CAPS_DEVICE_PANIC = 161, /* -device pvpanic */
|
||||||
QEMU_CAPS_ENABLE_FIPS = 162, /* -enable-fips */
|
QEMU_CAPS_ENABLE_FIPS = 162, /* -enable-fips */
|
||||||
QEMU_CAPS_SPICE_FILE_XFER_DISABLE = 163, /* -spice disable-agent-file-xfer */
|
QEMU_CAPS_SPICE_FILE_XFER_DISABLE = 163, /* -spice disable-agent-file-xfer */
|
||||||
|
QEMU_CAPS_CHARDEV_SPICEPORT = 164, /* -chardev spiceport */
|
||||||
|
|
||||||
QEMU_CAPS_LAST, /* this must always be the last item */
|
QEMU_CAPS_LAST, /* this must always be the last item */
|
||||||
};
|
};
|
||||||
|
@ -5977,6 +5977,16 @@ qemuBuildChrChardevStr(virDomainChrSourceDefPtr dev, const char *alias,
|
|||||||
virDomainChrSpicevmcTypeToString(dev->data.spicevmc));
|
virDomainChrSpicevmcTypeToString(dev->data.spicevmc));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
|
||||||
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_SPICEPORT)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("spiceport not supported in this QEMU binary"));
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
virBufferAsprintf(&buf, "spiceport,id=char%s,name=%s", alias,
|
||||||
|
dev->data.spiceport.channel);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported chardev '%s'"),
|
_("unsupported chardev '%s'"),
|
||||||
@ -6072,6 +6082,9 @@ qemuBuildChrArgStr(virDomainChrSourceDefPtr dev, const char *prefix)
|
|||||||
dev->data.nix.path,
|
dev->data.nix.path,
|
||||||
dev->data.nix.listen ? ",server,nowait" : "");
|
dev->data.nix.listen ? ",server,nowait" : "");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virBufferError(&buf)) {
|
if (virBufferError(&buf)) {
|
||||||
@ -7740,6 +7753,20 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
|
|
||||||
emulator = def->emulator;
|
emulator = def->emulator;
|
||||||
|
|
||||||
|
for (i = 0; i < def->ngraphics; ++i) {
|
||||||
|
switch (def->graphics[i]->type) {
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
||||||
|
++sdl;
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
||||||
|
++vnc;
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
||||||
|
++spice;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* do not use boot=on for drives when not using KVM since this
|
* do not use boot=on for drives when not using KVM since this
|
||||||
* is not supported at all in upstream QEmu.
|
* is not supported at all in upstream QEmu.
|
||||||
@ -8811,6 +8838,9 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
virDomainChrDefPtr serial = def->serials[i];
|
virDomainChrDefPtr serial = def->serials[i];
|
||||||
char *devstr;
|
char *devstr;
|
||||||
|
|
||||||
|
if (serial->source.type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !spice)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* Use -chardev with -device if they are available */
|
/* Use -chardev with -device if they are available */
|
||||||
if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
|
if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
|
||||||
virCommandAddArg(cmd, "-chardev");
|
virCommandAddArg(cmd, "-chardev");
|
||||||
@ -9021,19 +9051,6 @@ qemuBuildCommandLine(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < def->ngraphics; ++i) {
|
|
||||||
switch (def->graphics[i]->type) {
|
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
|
|
||||||
++sdl;
|
|
||||||
break;
|
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
|
|
||||||
++vnc;
|
|
||||||
break;
|
|
||||||
case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
|
|
||||||
++spice;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_0_10) && sdl + vnc + spice > 1) {
|
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_0_10) && sdl + vnc + spice > 1) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("only 1 graphics device is supported"));
|
_("only 1 graphics device is supported"));
|
||||||
|
@ -134,4 +134,5 @@
|
|||||||
<flag name='boot-strict'/>
|
<flag name='boot-strict'/>
|
||||||
<flag name='pvpanic'/>
|
<flag name='pvpanic'/>
|
||||||
<flag name='reboot-timeout'/>
|
<flag name='reboot-timeout'/>
|
||||||
|
<flag name='spiceport'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -140,4 +140,5 @@
|
|||||||
<flag name='reboot-timeout'/>
|
<flag name='reboot-timeout'/>
|
||||||
<flag name='enable-fips'/>
|
<flag name='enable-fips'/>
|
||||||
<flag name='spice-file-xfer-disable'/>
|
<flag name='spice-file-xfer-disable'/>
|
||||||
|
<flag name='spiceport'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -138,4 +138,5 @@
|
|||||||
<flag name='pvpanic'/>
|
<flag name='pvpanic'/>
|
||||||
<flag name='reboot-timeout'/>
|
<flag name='reboot-timeout'/>
|
||||||
<flag name='spice-file-xfer-disable'/>
|
<flag name='spice-file-xfer-disable'/>
|
||||||
|
<flag name='spiceport'/>
|
||||||
</qemuCaps>
|
</qemuCaps>
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
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 -nographic -monitor \
|
||||||
|
unix:/tmp/test-monitor,server,nowait -no-acpi -boot c \
|
||||||
|
-usb -hda /dev/HostVG/QEMUGuest1 -net none -serial \
|
||||||
|
none -parallel 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>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<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'/>
|
||||||
|
<serial type='spiceport'>
|
||||||
|
<source channel='org.qemu.console.serial.0'/>
|
||||||
|
<target port='0'/>
|
||||||
|
</serial>
|
||||||
|
<console type='spiceport'>
|
||||||
|
<source channel='org.qemu.console.serial.0'/>
|
||||||
|
<target type='serial' port='0'/>
|
||||||
|
</console>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
13
tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
Normal file
13
tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=spice \
|
||||||
|
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
|
||||||
|
-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
|
||||||
|
-mon chardev=charmonitor,id=monitor,mode=readline \
|
||||||
|
-no-acpi -boot c -usb \
|
||||||
|
-hda /dev/HostVG/QEMUGuest1 \
|
||||||
|
-chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \
|
||||||
|
-device isa-serial,chardev=charserial0,id=serial0 \
|
||||||
|
-device usb-tablet,id=input0 \
|
||||||
|
-spice port=5903,tls-port=5904,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
|
||||||
|
-device \
|
||||||
|
qxl-vga,id=video0,ram_size=67107840,vram_size=67107840,bus=pci.0,addr=0x2 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
43
tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
Normal file
43
tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.xml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219136</memory>
|
||||||
|
<currentMemory unit='KiB'>219136</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='1-4,8-20,525'>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'>
|
||||||
|
<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'/>
|
||||||
|
<serial type='spiceport'>
|
||||||
|
<source channel='org.qemu.console.serial.0'/>
|
||||||
|
<target port='0'/>
|
||||||
|
</serial>
|
||||||
|
<console type='spiceport'>
|
||||||
|
<source channel='org.qemu.console.serial.0'/>
|
||||||
|
<target type='serial' port='0'/>
|
||||||
|
</console>
|
||||||
|
<input type='tablet' bus='usb'/>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<graphics type='spice' port='5903' tlsPort='5904' autoport='no' listen='127.0.0.1'>
|
||||||
|
<listen type='address' address='127.0.0.1'/>
|
||||||
|
</graphics>
|
||||||
|
<video>
|
||||||
|
<model type='qxl' ram='65535' vram='65535' heads='1'/>
|
||||||
|
</video>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -949,6 +949,13 @@ mymain(void)
|
|||||||
DO_TEST("serial-udp", NONE);
|
DO_TEST("serial-udp", NONE);
|
||||||
DO_TEST("serial-tcp-telnet", NONE);
|
DO_TEST("serial-tcp-telnet", NONE);
|
||||||
DO_TEST("serial-many", NONE);
|
DO_TEST("serial-many", NONE);
|
||||||
|
DO_TEST("serial-spiceport",
|
||||||
|
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE,
|
||||||
|
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
|
||||||
|
QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_DEVICE_QXL_VGA,
|
||||||
|
QEMU_CAPS_SPICE, QEMU_CAPS_CHARDEV_SPICEPORT);
|
||||||
|
DO_TEST("serial-spiceport-nospice", QEMU_CAPS_NAME);
|
||||||
|
|
||||||
DO_TEST("parallel-tcp", NONE);
|
DO_TEST("parallel-tcp", NONE);
|
||||||
DO_TEST("console-compat", NONE);
|
DO_TEST("console-compat", NONE);
|
||||||
DO_TEST("console-compat-auto", NONE);
|
DO_TEST("console-compat-auto", NONE);
|
||||||
|
@ -241,6 +241,8 @@ mymain(void)
|
|||||||
DO_TEST("serial-udp");
|
DO_TEST("serial-udp");
|
||||||
DO_TEST("serial-tcp-telnet");
|
DO_TEST("serial-tcp-telnet");
|
||||||
DO_TEST("serial-many");
|
DO_TEST("serial-many");
|
||||||
|
DO_TEST("serial-spiceport");
|
||||||
|
DO_TEST("serial-spiceport-nospice");
|
||||||
DO_TEST("parallel-tcp");
|
DO_TEST("parallel-tcp");
|
||||||
DO_TEST("console-compat");
|
DO_TEST("console-compat");
|
||||||
DO_TEST("console-virtio-many");
|
DO_TEST("console-virtio-many");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user