Implement the qemu-vdagent channel introduced in the previous commit.
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/qemu/qemu_command.c | 13 +++++
src/qemu/qemu_monitor_json.c | 10 ++++
src/qemu/qemu_process.c | 1 +
src/qemu/qemu_validate.c | 1 +
src/security/security_dac.c | 2 +
.../channel-qemu-vdagent.x86_64-latest.args | 41 ++++++++++++++
.../qemuxml2argvdata/channel-qemu-vdagent.xml | 34 ++++++++++++
tests/qemuxml2argvtest.c | 1 +
.../channel-qemu-vdagent.x86_64-latest.xml | 55 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
tests/testutilsqemu.c | 1 +
11 files changed, 160 insertions(+)
create mode 100644 tests/qemuxml2argvdata/channel-qemu-vdagent.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/channel-qemu-vdagent.xml
create mode 100644 tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c836799888..d022b001ac 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1389,6 +1389,17 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev,
dev->data.spiceport.channel);
break;
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ virBufferAsprintf(&buf, "qemu-vdagent,id=%s,name=vdagent",
+ charAlias);
+ if (dev->data.qemuVdagent.clipboard != VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(&buf, ",clipboard=%s",
+
virTristateSwitchTypeToString(dev->data.qemuVdagent.clipboard));
+ if (dev->data.qemuVdagent.mouse != VIR_TRISTATE_SWITCH_ABSENT)
+ virBufferAsprintf(&buf, ",mouse=%s",
+
virTristateSwitchTypeToString(dev->data.qemuVdagent.mouse));
+ break;
+
case VIR_DOMAIN_CHR_TYPE_NMDM:
case VIR_DOMAIN_CHR_TYPE_LAST:
default:
@@ -1473,6 +1484,7 @@ qemuBuildChardevCommand(virCommand *cmd,
case VIR_DOMAIN_CHR_TYPE_UDP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
break;
case VIR_DOMAIN_CHR_TYPE_NMDM:
@@ -8610,6 +8622,7 @@ qemuInterfaceVhostuserConnect(virCommand *cmd,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
case VIR_DOMAIN_CHR_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("vhost-user type '%s' not supported"),
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d5622bd6d9..fcb46d156d 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6814,6 +6814,16 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID,
break;
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
+ backendType = "qemu-vdagent";
+
+ if (virJSONValueObjectAdd(&backendData,
+ "T:clipboard",
chr->data.qemuVdagent.clipboard,
+ "T:mouse", chr->data.qemuVdagent.mouse,
+ NULL) < 0)
+ return NULL;
+ break;
+
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_PIPE:
case VIR_DOMAIN_CHR_TYPE_STDIO:
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1ed60917ea..1b089cb0d5 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6833,6 +6833,7 @@ qemuProcessPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
case VIR_DOMAIN_CHR_TYPE_UDP:
case VIR_DOMAIN_CHR_TYPE_TCP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
break;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index f27e480696..0c3551338d 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1984,6 +1984,7 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index e9e316551e..5b840f4225 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -1555,6 +1555,7 @@ virSecurityDACSetChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_TCP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
@@ -1639,6 +1640,7 @@ virSecurityDACRestoreChardevLabelHelper(virSecurityManager *mgr,
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
case VIR_DOMAIN_CHR_TYPE_NMDM:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
case VIR_DOMAIN_CHR_TYPE_LAST:
break;
}
diff --git a/tests/qemuxml2argvdata/channel-qemu-vdagent.x86_64-latest.args
b/tests/qemuxml2argvdata/channel-qemu-vdagent.x86_64-latest.args
new file mode 100644
index 0000000000..651246bdfd
--- /dev/null
+++ b/tests/qemuxml2argvdata/channel-qemu-vdagent.x86_64-latest.args
@@ -0,0 +1,41 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object
'{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}'
\
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-accel tcg \
+-cpu qemu64 \
+-m 214 \
+-object
'{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'
\
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device
'{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}'
\
+-device
'{"driver":"virtio-serial-pci","id":"virtio-serial1","bus":"pci.0","addr":"0xa"}'
\
+-blockdev
'{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'
\
+-blockdev
'{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}'
\
+-device
'{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}'
\
+-chardev qemu-vdagent,id=charchannel0,name=vdagent,clipboard=on,mouse=on \
+-device
'{"driver":"virtserialport","bus":"virtio-serial1.0","nr":3,"chardev":"charchannel0","id":"channel0","name":"com.redhat.spice.0"}'
\
+-audiodev
'{"id":"audio1","driver":"none"}' \
+-vnc 127.0.0.1:3,audiodev=audio1 \
+-device
'{"driver":"cirrus-vga","id":"video0","bus":"pci.0","addr":"0x2"}'
\
+-device
'{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x3"}'
\
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/channel-qemu-vdagent.xml
b/tests/qemuxml2argvdata/channel-qemu-vdagent.xml
new file mode 100644
index 0000000000..63a5949065
--- /dev/null
+++ b/tests/qemuxml2argvdata/channel-qemu-vdagent.xml
@@ -0,0 +1,34 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <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-system-x86_64</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='virtio-serial' index='1'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x0a' function='0x0'/>
+ </controller>
+ <graphics type='vnc' port='5903' autoport='no'
listen='127.0.0.1'/>
+ <channel type='qemu-vdagent'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <address type='virtio-serial' controller='1' bus='0'
port='3'/>
+ <source mouse='on' clipboard='on'/>
+ </channel>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e7fecb24d3..9df264df57 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1726,6 +1726,7 @@ mymain(void)
DO_TEST("channel-spicevmc",
QEMU_CAPS_SPICE,
QEMU_CAPS_DEVICE_CIRRUS_VGA);
+ DO_TEST_CAPS_LATEST("channel-qemu-vdagent");
DO_TEST("channel-virtio-default",
QEMU_CAPS_SPICE);
DO_TEST_NOCAPS("channel-virtio-unix");
diff --git a/tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml
b/tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml
new file mode 100644
index 0000000000..13b3b6f750
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml
@@ -0,0 +1,55 @@
+<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>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu64</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</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' model='piix3-uhci'>
+ <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='virtio-serial' index='1'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x0a' function='0x0'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <channel type='qemu-vdagent'>
+ <source clipboard='on' mouse='on'/>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <address type='virtio-serial' controller='1' bus='0'
port='3'/>
+ </channel>
+ <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'/>
+ </graphics>
+ <audio id='1' type='none'/>
+ <video>
+ <model type='cirrus' vram='16384' heads='1'
primary='yes'/>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x02' function='0x0'/>
+ </video>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x03' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 31917e5238..22c2cacb6c 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1464,6 +1464,7 @@ mymain(void)
QEMU_CAPS_DEVICE_PL011,
QEMU_CAPS_DEVICE_VIRTIO_RNG,
QEMU_CAPS_OBJECT_RNG_RANDOM);
+ DO_TEST_CAPS_LATEST("channel-qemu-vdagent");
cleanup:
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index fe8908f533..10fdeacaa2 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -1042,6 +1042,7 @@ testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
case VIR_DOMAIN_CHR_TYPE_TCP:
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+ case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT:
break;
case VIR_DOMAIN_CHR_TYPE_FILE:
--
2.35.1