Implement the qemu-vdagent channel introduced in the previous commit. Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx> --- src/qemu/qemu_command.c | 21 ++++++- src/qemu/qemu_monitor_json.c | 28 ++++++++- src/qemu/qemu_validate.c | 10 +++- ...l-qemu-vdagent-features.x86_64-latest.args | 41 +++++++++++++ .../channel-qemu-vdagent-features.xml | 37 ++++++++++++ .../channel-qemu-vdagent.x86_64-latest.args | 41 +++++++++++++ .../qemuxml2argvdata/channel-qemu-vdagent.xml | 37 ++++++++++++ tests/qemuxml2argvtest.c | 2 + ...el-qemu-vdagent-features.x86_64-latest.xml | 58 +++++++++++++++++++ .../channel-qemu-vdagent.x86_64-latest.xml | 58 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 11 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 tests/qemuxml2argvdata/channel-qemu-vdagent-features.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/channel-qemu-vdagent-features.xml 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-features.x86_64-latest.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 1eef9fb6d0..67921229dd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1389,8 +1389,27 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev, dev->data.spiceport.channel); break; - case VIR_DOMAIN_CHR_TYPE_NMDM: case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT: + virBufferAsprintf(&buf, "qemu-vdagent,id=%s,name=vdagent", + charAlias); + if (dev->data.qemuVdagent.clipboard != VIR_TRISTATE_BOOL_ABSENT) + virBufferAsprintf(&buf, ",clipboard=%s", + virTristateSwitchTypeToString(dev->data.qemuVdagent.clipboard)); + switch (dev->data.qemuVdagent.mouse) { + case VIR_DOMAIN_MOUSE_MODE_CLIENT: + virBufferAddLit(&buf, ",mouse=on"); + break; + case VIR_DOMAIN_MOUSE_MODE_SERVER: + virBufferAddLit(&buf, ",mouse=off"); + break; + case VIR_DOMAIN_MOUSE_MODE_DEFAULT: + case VIR_DOMAIN_MOUSE_MODE_LAST: + default: + break; + } + break; + + case VIR_DOMAIN_CHR_TYPE_NMDM: case VIR_DOMAIN_CHR_TYPE_LAST: default: break; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 1ac5377449..c7e18073c2 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -6814,11 +6814,37 @@ qemuMonitorJSONAttachCharDevGetProps(const char *chrID, break; + case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT: { + virTristateBool mouse = VIR_TRISTATE_BOOL_ABSENT; + switch (chr->data.qemuVdagent.mouse) { + case VIR_DOMAIN_MOUSE_MODE_CLIENT: + mouse = VIR_TRISTATE_BOOL_YES; + break; + case VIR_DOMAIN_MOUSE_MODE_SERVER: + mouse = VIR_TRISTATE_BOOL_NO; + break; + case VIR_DOMAIN_MOUSE_MODE_DEFAULT: + break; + case VIR_DOMAIN_MOUSE_MODE_LAST: + default: + virReportEnumRangeError(virDomainMouseMode, + chr->data.qemuVdagent.mouse); + return NULL; + } + backendType = "qemu-vdagent"; + + if (virJSONValueObjectAdd(&backendData, + "T:clipboard", chr->data.qemuVdagent.clipboard, + "T:mouse", mouse, + NULL) < 0) + return NULL; + break; + } + case VIR_DOMAIN_CHR_TYPE_SPICEPORT: case VIR_DOMAIN_CHR_TYPE_PIPE: case VIR_DOMAIN_CHR_TYPE_STDIO: case VIR_DOMAIN_CHR_TYPE_NMDM: - case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT: virReportError(VIR_ERR_OPERATION_FAILED, _("Hotplug unsupported for char device type '%s'"), virDomainChrTypeToString(chr->type)); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 5ad3d914dc..2b60e63a2b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1981,6 +1981,15 @@ qemuValidateDomainChrSourceDef(const virDomainChrSourceDef *def, } break; + case VIR_DOMAIN_CHR_TYPE_QEMU_VDAGENT: + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_QEMU_VDAGENT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("chardev '%s' not supported in this QEMU binary"), + virDomainChrTypeToString(def->type)); + return -1; + } + break; + case VIR_DOMAIN_CHR_TYPE_NULL: case VIR_DOMAIN_CHR_TYPE_VC: case VIR_DOMAIN_CHR_TYPE_PTY: @@ -1991,7 +2000,6 @@ 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/tests/qemuxml2argvdata/channel-qemu-vdagent-features.x86_64-latest.args b/tests/qemuxml2argvdata/channel-qemu-vdagent-features.x86_64-latest.args new file mode 100644 index 0000000000..651246bdfd --- /dev/null +++ b/tests/qemuxml2argvdata/channel-qemu-vdagent-features.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-features.xml b/tests/qemuxml2argvdata/channel-qemu-vdagent-features.xml new file mode 100644 index 0000000000..2d8afe3d33 --- /dev/null +++ b/tests/qemuxml2argvdata/channel-qemu-vdagent-features.xml @@ -0,0 +1,37 @@ +<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 mode='client'/> + <clipboard copypaste='yes'/> + </source> + </channel> + <memballoon model='virtio'/> + </devices> +</domain> 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..0f49b48ca8 --- /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=off,mouse=off \ +-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..91a62888df --- /dev/null +++ b/tests/qemuxml2argvdata/channel-qemu-vdagent.xml @@ -0,0 +1,37 @@ +<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='x86_64' 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> + <clipboard copypaste='no'/> + <mouse mode='server'/> + </source> + </channel> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e7fecb24d3..a20dec1d25 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1726,6 +1726,8 @@ mymain(void) DO_TEST("channel-spicevmc", QEMU_CAPS_SPICE, QEMU_CAPS_DEVICE_CIRRUS_VGA); + DO_TEST_CAPS_LATEST("channel-qemu-vdagent"); + DO_TEST_CAPS_LATEST("channel-qemu-vdagent-features"); DO_TEST("channel-virtio-default", QEMU_CAPS_SPICE); DO_TEST_NOCAPS("channel-virtio-unix"); diff --git a/tests/qemuxml2xmloutdata/channel-qemu-vdagent-features.x86_64-latest.xml b/tests/qemuxml2xmloutdata/channel-qemu-vdagent-features.x86_64-latest.xml new file mode 100644 index 0000000000..66a9135fc7 --- /dev/null +++ b/tests/qemuxml2xmloutdata/channel-qemu-vdagent-features.x86_64-latest.xml @@ -0,0 +1,58 @@ +<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 copypaste='yes'/> + <mouse mode='client'/> + </source> + <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/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml b/tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml new file mode 100644 index 0000000000..c85acce85d --- /dev/null +++ b/tests/qemuxml2xmloutdata/channel-qemu-vdagent.x86_64-latest.xml @@ -0,0 +1,58 @@ +<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='x86_64' 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 copypaste='no'/> + <mouse mode='server'/> + </source> + <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..2718b1e365 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1464,6 +1464,8 @@ mymain(void) QEMU_CAPS_DEVICE_PL011, QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); + DO_TEST_CAPS_LATEST("channel-qemu-vdagent"); + DO_TEST_CAPS_LATEST("channel-qemu-vdagent-features"); cleanup: if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) -- 2.35.1