[libvirt] [PATCH 00/15] Move unix socket creation out of qemuBuildCommandLine

Add test coverage for all the possible devices and move all the socket creation to qemuProcessPrepareHost. TBD: remove the racy qemuSecuritySetSocketLabel call as well as the rest of host state modification out of qemuBuildCommandLine Ján Tomko (15): tests: add smartcard-passthrough-unix tests: add parallel-unix-chardev tests: add channel-unix-guestfwd tests: add console-virtio-unix tests: add usb-redir-unix tests: add virtio-rng-egd-unix tests: use real capabilities for net-vhostuser qemuProcessPrepareDomain: pass xmlopt when creating monConfig qemu: add fd to qemuDomainChrSourcePrivate qemuBuildChrChardevStr: split attribute formatting qemuBuildChrChardevStr: increase scope of qemuBuildChrChardevStr qemuBuildChrChardevStr: pass fd from private data qemu: remove QEMU_BUILD_CHARDEV_UNIX_FD_PASS qemuBuildCommandLine: do not pass security manager qemuOpenChrChardevUNIXSocket: move to qemu_process src/qemu/qemu_command.c | 192 +++++---------------- src/qemu/qemu_command.h | 5 - src/qemu/qemu_domain.c | 3 + src/qemu/qemu_domain.h | 2 + src/qemu/qemu_process.c | 188 +++++++++++++++++++- src/qemu/qemu_process.h | 3 + .../channel-unix-guestfwd.x86_64-2.5.0.args | 33 ++++ .../channel-unix-guestfwd.x86_64-latest.args | 36 ++++ tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 37 ++++ .../console-virtio-unix.x86_64-2.5.0.args | 34 ++++ .../console-virtio-unix.x86_64-latest.args | 37 ++++ tests/qemuxml2argvdata/console-virtio-unix.xml | 33 ++++ .../net-vhostuser.x86_64-2.5.0.args | 39 +++++ .../net-vhostuser.x86_64-latest.args | 42 +++++ .../parallel-unix-chardev.x86_64-2.5.0.args | 33 ++++ .../parallel-unix-chardev.x86_64-latest.args | 36 ++++ tests/qemuxml2argvdata/parallel-unix-chardev.xml | 35 ++++ .../smartcard-passthrough-unix.x86_64-2.5.0.args | 30 ++++ .../smartcard-passthrough-unix.x86_64-latest.args | 33 ++++ .../smartcard-passthrough-unix.xml | 19 ++ .../usb-redir-unix.x86_64-2.5.0.args | 35 ++++ .../usb-redir-unix.x86_64-latest.args | 38 ++++ tests/qemuxml2argvdata/usb-redir-unix.xml | 45 +++++ .../virtio-rng-egd-unix.x86_64-2.5.0.args | 30 ++++ .../virtio-rng-egd-unix.x86_64-latest.args | 33 ++++ tests/qemuxml2argvdata/virtio-rng-egd-unix.xml | 29 ++++ tests/qemuxml2argvmock.c | 3 +- tests/qemuxml2argvtest.c | 14 ++ 28 files changed, 939 insertions(+), 158 deletions(-) create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.xml create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.xml create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.xml create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.xml create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.xml create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.xml -- 2.16.4

Test CCID smartcard passthrough from a unix listen socket. Use the capabilities of QEMU 2.5.0 which did not support chardev FD passing and the latest one, which (at the time of this commit) it does. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../smartcard-passthrough-unix.x86_64-2.5.0.args | 30 ++++++++++++++++++++ .../smartcard-passthrough-unix.x86_64-latest.args | 33 ++++++++++++++++++++++ .../smartcard-passthrough-unix.xml | 19 +++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 84 insertions(+) create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.xml diff --git a/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args b/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args new file mode 100644 index 0000000000..19ec438392 --- /dev/null +++ b/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args @@ -0,0 +1,30 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ +-chardev socket,id=charsmartcard0,path=/tmp/smartcard.sock,server,nowait \ +-device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args b/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args new file mode 100644 index 0000000000..eaa3e0b71d --- /dev/null +++ b/tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args @@ -0,0 +1,33 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ +-chardev socket,id=charsmartcard0,fd=1729,server,nowait \ +-device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/smartcard-passthrough-unix.xml b/tests/qemuxml2argvdata/smartcard-passthrough-unix.xml new file mode 100644 index 0000000000..054ae9128e --- /dev/null +++ b/tests/qemuxml2argvdata/smartcard-passthrough-unix.xml @@ -0,0 +1,19 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64' machine='pc'>hvm</type> + <boot dev='hd'/> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <smartcard mode='passthrough' type='unix'> + <source mode='bind' path='/tmp/smartcard.sock'/> + <protocol type='raw'/> + </smartcard> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a7cde3ed7e..13a1092e10 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1504,6 +1504,8 @@ mymain(void) QEMU_CAPS_CCID_PASSTHRU); DO_TEST("smartcard-controller", QEMU_CAPS_CCID_EMULATED); + DO_TEST_CAPS_VER("smartcard-passthrough-unix", "2.5.0"); + DO_TEST_CAPS_LATEST("smartcard-passthrough-unix"); DO_TEST("chardev-reconnect", QEMU_CAPS_CHARDEV_RECONNECT, -- 2.16.4

Test creating a parallel port backed by a UNIX socket. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../parallel-unix-chardev.x86_64-2.5.0.args | 33 ++++++++++++++++++++ .../parallel-unix-chardev.x86_64-latest.args | 36 ++++++++++++++++++++++ tests/qemuxml2argvdata/parallel-unix-chardev.xml | 35 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 106 insertions(+) create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.xml diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args new file mode 100644 index 0000000000..d7d55ac611 --- /dev/null +++ b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args @@ -0,0 +1,33 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charparallel0,path=/tmp/parport0.socket,server,nowait \ +-device isa-parallel,chardev=charparallel0,id=parallel0 \ +-chardev socket,id=charparallel1,path=/tmp/parport1.socket \ +-device isa-parallel,chardev=charparallel1,id=parallel1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args new file mode 100644 index 0000000000..94841ea8c0 --- /dev/null +++ b/tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args @@ -0,0 +1,36 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charparallel0,fd=1729,server,nowait \ +-device isa-parallel,chardev=charparallel0,id=parallel0 \ +-chardev socket,id=charparallel1,path=/tmp/parport1.socket \ +-device isa-parallel,chardev=charparallel1,id=parallel1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/parallel-unix-chardev.xml b/tests/qemuxml2argvdata/parallel-unix-chardev.xml new file mode 100644 index 0000000000..d4fe94779e --- /dev/null +++ b/tests/qemuxml2argvdata/parallel-unix-chardev.xml @@ -0,0 +1,35 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>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='ide' index='0'/> + <parallel type='unix'> + <source mode='bind' path='/tmp/parport0.socket'/> + <protocol type='raw'/> + <target port='0'/> + </parallel> + <parallel type='unix'> + <source mode='connect' path='/tmp/parport1.socket'/> + <protocol type='raw'/> + <target port='1'/> + </parallel> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 13a1092e10..6203e45e6a 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1463,6 +1463,8 @@ mymain(void) QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("parallel-tcp-chardev", NONE); DO_TEST("parallel-parport-chardev", NONE); + DO_TEST_CAPS_VER("parallel-unix-chardev", "2.5.0"); + DO_TEST_CAPS_LATEST("parallel-unix-chardev"); DO_TEST("console-compat-chardev", QEMU_CAPS_DEVICE_ISA_SERIAL); DO_TEST("pci-serial-dev-chardev", -- 2.16.4

Test guestfwd channels backed by UNIX sockets. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../channel-unix-guestfwd.x86_64-2.5.0.args | 33 +++++++++++++++++++ .../channel-unix-guestfwd.x86_64-latest.args | 36 +++++++++++++++++++++ tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 37 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 108 insertions(+) create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.xml diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args new file mode 100644 index 0000000000..f0e718e4a2 --- /dev/null +++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args @@ -0,0 +1,33 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charchannel0,path=/tmp/guestfwd-listen.socket,server,nowait \ +-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ +-chardev socket,id=charchannel1,path=/tmp/guestfwd-connect.socket \ +-netdev user,guestfwd=tcp:10.0.2.1:4601-chardev:charchannel1,id=user-channel1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args new file mode 100644 index 0000000000..f9b9ee5fdb --- /dev/null +++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args @@ -0,0 +1,36 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charchannel0,fd=1729,server,nowait \ +-netdev user,guestfwd=tcp:10.0.2.1:4600-chardev:charchannel0,id=user-channel0 \ +-chardev socket,id=charchannel1,path=/tmp/guestfwd-connect.socket \ +-netdev user,guestfwd=tcp:10.0.2.1:4601-chardev:charchannel1,id=user-channel1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/channel-unix-guestfwd.xml b/tests/qemuxml2argvdata/channel-unix-guestfwd.xml new file mode 100644 index 0000000000..c9698a1259 --- /dev/null +++ b/tests/qemuxml2argvdata/channel-unix-guestfwd.xml @@ -0,0 +1,37 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu>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='pci' index='0' model='pci-root'/> + <channel type='unix'> + <source mode='bind' path='/tmp/guestfwd-listen.socket'/> + <target type='guestfwd' address='10.0.2.1' port='4600'/> + </channel> + <channel type='unix'> + <source mode='connect' path='/tmp/guestfwd-connect.socket'/> + <target type='guestfwd' address='10.0.2.1' port='4601'/> + </channel> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6203e45e6a..ca2bdac7ee 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1471,6 +1471,8 @@ mymain(void) QEMU_CAPS_DEVICE_PCI_SERIAL); DO_TEST("channel-guestfwd", NONE); + DO_TEST_CAPS_VER("channel-unix-guestfwd", "2.5.0"); + DO_TEST_CAPS_LATEST("channel-unix-guestfwd"); DO_TEST("channel-virtio", NONE); DO_TEST("channel-virtio-state", NONE); DO_TEST("channel-virtio-auto", NONE); -- 2.16.4

Test a virtio console backed by a UNIX socket. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../console-virtio-unix.x86_64-2.5.0.args | 34 ++++++++++++++++++++ .../console-virtio-unix.x86_64-latest.args | 37 ++++++++++++++++++++++ tests/qemuxml2argvdata/console-virtio-unix.xml | 33 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 106 insertions(+) create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.xml diff --git a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args new file mode 100644 index 0000000000..425bdc5d12 --- /dev/null +++ b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args @@ -0,0 +1,34 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charconsole0,path=/tmp/listen.socket,server,nowait \ +-device virtconsole,chardev=charconsole0,id=console0 \ +-chardev socket,id=charconsole1,path=/tmp/connect.socket \ +-device virtconsole,chardev=charconsole1,id=console1 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args new file mode 100644 index 0000000000..193d4b1295 --- /dev/null +++ b/tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charconsole0,fd=1729,server,nowait \ +-device virtconsole,chardev=charconsole0,id=console0 \ +-chardev socket,id=charconsole1,path=/tmp/connect.socket \ +-device virtconsole,chardev=charconsole1,id=console1 \ +-device 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/console-virtio-unix.xml b/tests/qemuxml2argvdata/console-virtio-unix.xml new file mode 100644 index 0000000000..941e5a4a8a --- /dev/null +++ b/tests/qemuxml2argvdata/console-virtio-unix.xml @@ -0,0 +1,33 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu>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'/> + <console type='unix'> + <source mode='bind' path='/tmp/listen.socket'/> + <target type='virtio'/> + </console> + <console type='unix'> + <source mode='connect' path='/tmp/connect.socket'/> + <target type='virtio'/> + </console> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index ca2bdac7ee..d8617557d8 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1486,6 +1486,8 @@ mymain(void) DO_TEST("console-virtio-ccw", QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390); + DO_TEST_CAPS_VER("console-virtio-unix", "2.5.0"); + DO_TEST_CAPS_LATEST("console-virtio-unix"); DO_TEST("console-sclp", QEMU_CAPS_VIRTIO_S390, QEMU_CAPS_DEVICE_SCLPCONSOLE); -- 2.16.4

Test USB redirdevs backed by UNIX sockets. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../usb-redir-unix.x86_64-2.5.0.args | 35 +++++++++++++++++ .../usb-redir-unix.x86_64-latest.args | 38 ++++++++++++++++++ tests/qemuxml2argvdata/usb-redir-unix.xml | 45 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 + 4 files changed, 120 insertions(+) create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.xml diff --git a/tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args b/tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args new file mode 100644 index 0000000000..bc122db077 --- /dev/null +++ b/tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args @@ -0,0 +1,35 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x4.0x7 \ +-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,\ +addr=0x4 \ +-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \ +-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \ +-chardev socket,id=charredir0,path=/tmp/connect.socket \ +-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \ +-chardev socket,id=charredir1,path=/tmp/listen.socket,server,nowait \ +-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args b/tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args new file mode 100644 index 0000000000..2d2dab1dea --- /dev/null +++ b/tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x4.0x7 \ +-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,\ +addr=0x4 \ +-device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \ +-device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \ +-chardev socket,id=charredir0,path=/tmp/connect.socket \ +-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \ +-chardev socket,id=charredir1,fd=1729,server,nowait \ +-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/usb-redir-unix.xml b/tests/qemuxml2argvdata/usb-redir-unix.xml new file mode 100644 index 0000000000..471999c6bc --- /dev/null +++ b/tests/qemuxml2argvdata/usb-redir-unix.xml @@ -0,0 +1,45 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>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> + <controller type='usb' index='0' model='ich9-ehci1'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/> + </controller> + <controller type='usb' index='0' model='ich9-uhci1'> + <master startport='0'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/> + </controller> + <controller type='usb' index='0' model='ich9-uhci2'> + <master startport='2'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/> + </controller> + <controller type='usb' index='0' model='ich9-uhci3'> + <master startport='4'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/> + </controller> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <redirdev bus='usb' type='unix'> + <source mode='connect' path='/tmp/connect.socket'/> + <protocol type='raw'/> + </redirdev> + <redirdev bus='usb' type='unix'> + <source mode='bind' path='/tmp/listen.socket'/> + <protocol type='raw'/> + </redirdev> + <memballoon model='virtio'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index d8617557d8..6919722188 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1577,6 +1577,8 @@ mymain(void) QEMU_CAPS_USB_REDIR, QEMU_CAPS_SPICE, QEMU_CAPS_USB_REDIR_FILTER); + DO_TEST_CAPS_VER("usb-redir-unix", "2.5.0"); + DO_TEST_CAPS_LATEST("usb-redir-unix"); DO_TEST("usb1-usb2", QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_USB_HUB, -- 2.16.4

Test RNG devices connected to EGD via UNIX sockets. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../virtio-rng-egd-unix.x86_64-2.5.0.args | 30 ++++++++++++++++++++ .../virtio-rng-egd-unix.x86_64-latest.args | 33 ++++++++++++++++++++++ tests/qemuxml2argvdata/virtio-rng-egd-unix.xml | 29 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 94 insertions(+) create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.xml diff --git a/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args b/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args new file mode 100644 index 0000000000..ce19aa0bdf --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args @@ -0,0 +1,30 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-chardev socket,id=charrng0,path=/tmp/rng.socket,server,nowait \ +-object rng-egd,id=objrng0,chardev=charrng0 \ +-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x3 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args new file mode 100644 index 0000000000..2d5575aa53 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args @@ -0,0 +1,33 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=kvm,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ +-chardev socket,id=charrng0,fd=1729,server,nowait \ +-object rng-egd,id=objrng0,chardev=charrng0 \ +-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x3 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-rng-egd-unix.xml b/tests/qemuxml2argvdata/virtio-rng-egd-unix.xml new file mode 100644 index 0000000000..ce959cbfe6 --- /dev/null +++ b/tests/qemuxml2argvdata/virtio-rng-egd-unix.xml @@ -0,0 +1,29 @@ +<domain type='kvm'> + <name>QEMUGuest1</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219100</memory> + <currentMemory unit='KiB'>219100</currentMemory> + <vcpu>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> + <controller type='usb' index='0'/> + <controller type='pci' index='0' model='pci-root'/> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='virtio'/> + <rng model='virtio'> + <backend model='egd' type='unix'> + <source mode='bind' path='/tmp/rng.socket'/> + <protocol type='raw'/> + </backend> + </rng> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6919722188..3d25e0a4ea 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2095,6 +2095,8 @@ mymain(void) DO_TEST("virtio-rng-egd", QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_EGD); + DO_TEST_CAPS_VER("virtio-rng-egd-unix", "2.5.0"); + DO_TEST_CAPS_LATEST("virtio-rng-egd-unix"); DO_TEST("virtio-rng-multiple", QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_EGD, -- 2.16.4

Commit ed5aa85f371aebb0103e712f9a103d011ab9ae43 qemu: don't use chardev FD passing for vhostuser backend altered the legacy DO_TEST macro. Run the test against capabilities of QEMU 2.5.0 (which did not support QEMU_CAPS_CHARDEV_FD_PASS) as well as the latest version. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- .../net-vhostuser.x86_64-2.5.0.args | 39 ++++++++++++++++++++ .../net-vhostuser.x86_64-latest.args | 42 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 83 insertions(+) create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args diff --git a/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args b/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args new file mode 100644 index 0000000000..677a3c9e49 --- /dev/null +++ b/tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args @@ -0,0 +1,39 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-machine pc-i440fx-2.5,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +-netdev vhost-user,chardev=charnet0,id=hostnet0 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ +addr=0x2 \ +-chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +-netdev vhost-user,chardev=charnet1,id=hostnet1 \ +-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ +addr=0x3 \ +-netdev socket,listen=:2015,id=hostnet2 \ +-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\ +addr=0x4 \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args b/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args new file mode 100644 index 0000000000..7dee2bdf58 --- /dev/null +++ b/tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args @@ -0,0 +1,42 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object secret,id=masterKey0,format=raw,\ +file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-realtime mlock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \ +-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \ +-netdev vhost-user,chardev=charnet0,id=hostnet0 \ +-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\ +addr=0x2 \ +-chardev socket,id=charnet1,path=/tmp/vhost1.sock \ +-netdev vhost-user,chardev=charnet1,id=hostnet1 \ +-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\ +addr=0x3 \ +-netdev socket,listen=:2015,id=hostnet2 \ +-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\ +addr=0x4 \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ +resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3d25e0a4ea..39a7f1f53c 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1359,6 +1359,8 @@ mymain(void) DO_TEST("misc-uuid", NONE); DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE); DO_TEST("net-vhostuser", QEMU_CAPS_CHARDEV_FD_PASS); + DO_TEST_CAPS_VER("net-vhostuser", "2.5.0"); + DO_TEST_CAPS_LATEST("net-vhostuser"); DO_TEST("net-vhostuser-multiq", QEMU_CAPS_VHOSTUSER_MULTIQUEUE); DO_TEST_FAILURE("net-vhostuser-multiq", NONE); -- 2.16.4

Pass the driver's xmlopt to allocate the chardev source private data correctly. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index e9c76188a4..77b7464436 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5984,7 +5984,7 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver, goto cleanup; } - if (!(priv->monConfig = virDomainChrSourceDefNew(NULL))) + if (!(priv->monConfig = virDomainChrSourceDefNew(driver->xmlopt))) goto cleanup; VIR_DEBUG("Preparing monitor state"); -- 2.16.4

Introduce a variable to store the file descriptor for possible fd passing. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_domain.c | 3 +++ src/qemu/qemu_domain.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f00f1b3fdb..70f82c9e81 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1180,6 +1180,8 @@ qemuDomainChrSourcePrivateNew(void) if (!(priv = virObjectNew(qemuDomainChrSourcePrivateClass))) return NULL; + priv->fd = -1; + return (virObjectPtr) priv; } @@ -1190,6 +1192,7 @@ qemuDomainChrSourcePrivateDispose(void *obj) qemuDomainChrSourcePrivatePtr priv = obj; qemuDomainSecretInfoFree(&priv->secinfo); + VIR_FORCE_CLOSE(priv->fd); } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 80bd4bde91..827e2e44d7 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -466,6 +466,8 @@ struct _qemuDomainChrSourcePrivate { /* for char devices using secret * NB: *not* to be written to qemu domain object XML */ qemuDomainSecretInfoPtr secinfo; + + int fd; }; -- 2.16.4

Remove repetition of the 'socket' device and its alias. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index d77cf8c2d6..ef91fa7d27 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5195,6 +5195,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_TYPE_UNIX: + virBufferAsprintf(&buf, "socket,id=%s", charAlias); if (dev->data.nix.listen && (flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) { @@ -5208,11 +5209,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, if (fd < 0) goto cleanup; - virBufferAsprintf(&buf, "socket,id=%s,fd=%d", charAlias, fd); + virBufferAsprintf(&buf, ",fd=%d", fd); virCommandPassFD(cmd, fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); } else { - virBufferAsprintf(&buf, "socket,id=%s,path=", charAlias); + virBufferAddLit(&buf, ",path="); virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path); } if (dev->data.nix.listen) { -- 2.16.4

Make it avaiable to other chardev types. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ef91fa7d27..25ea127095 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5067,6 +5067,7 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, virQEMUCapsPtr qemuCaps, unsigned int flags) { + qemuDomainChrSourcePrivatePtr chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev); virBuffer buf = VIR_BUFFER_INITIALIZER; bool telnet; char *charAlias = NULL; @@ -5160,8 +5161,6 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, qemuBuildChrChardevReconnectStr(&buf, &dev->data.tcp.reconnect); if (dev->data.tcp.haveTLS == VIR_TRISTATE_BOOL_YES) { - qemuDomainChrSourcePrivatePtr chrSourcePriv = - QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev); char *objalias = NULL; const char *tlsCertEncSecAlias = NULL; -- 2.16.4

If present, prefer the file descriptor created earlier instead of creating one in a qemuBuild function. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 23 +++------ src/qemu/qemu_process.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 25ea127095..54a1a299e2 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5058,7 +5058,7 @@ enum { * host side of the character device */ static char * qemuBuildChrChardevStr(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, + virSecurityManagerPtr secManager ATTRIBUTE_UNUSED, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -5195,22 +5195,11 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager, case VIR_DOMAIN_CHR_TYPE_UNIX: virBufferAsprintf(&buf, "socket,id=%s", charAlias); - if (dev->data.nix.listen && - (flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) { - if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0) - goto cleanup; - int fd = qemuOpenChrChardevUNIXSocket(dev); - if (qemuSecurityClearSocketLabel(secManager, (virDomainDefPtr)def) < 0) { - VIR_FORCE_CLOSE(fd); - goto cleanup; - } - if (fd < 0) - goto cleanup; - - virBufferAsprintf(&buf, ",fd=%d", fd); - - virCommandPassFD(cmd, fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + if (chrSourcePriv && + chrSourcePriv->fd != -1) { + virBufferAsprintf(&buf, ",fd=%d", chrSourcePriv->fd); + virCommandPassFD(cmd, chrSourcePriv->fd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); + chrSourcePriv->fd = -1; } else { virBufferAddLit(&buf, ",path="); virQEMUBuildBufferEscapeComma(&buf, dev->data.nix.path); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 77b7464436..f315d28dd0 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6136,6 +6136,127 @@ qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) } +static int +qemuProcessMaybeOpenChrSource(virDomainObjPtr vm, + const virDomainChrSourceDef *src) +{ + qemuDomainChrSourcePrivatePtr srcPriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(src); + qemuDomainObjPrivatePtr priv = vm->privateData; + virQEMUDriverPtr driver = priv->driver; + virQEMUCapsPtr qemuCaps = priv->qemuCaps; + int fd = -1; + int ret = -1; + + if (src->type != VIR_DOMAIN_CHR_TYPE_UNIX) + return 0; + + if (!src->data.nix.listen) + return 0; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) + return 0; + + if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0) + goto cleanup; + fd = qemuOpenChrChardevUNIXSocket(src); + if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0) + goto cleanup; + + if (fd < 0) + goto cleanup; + + srcPriv->fd = fd; + fd = -1; + ret = 0; + + cleanup: + VIR_FORCE_CLOSE(fd); + return ret; +} + + +static int +qemuProcessPrepareChrFDs(virDomainObjPtr vm, + virDomainDefPtr def) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + int ret = -1; + size_t i; + + if (priv->monConfig) { + if (qemuProcessMaybeOpenChrSource(vm, priv->monConfig) < 0) + goto cleanup; + } + + /* VIR_DOMAIN_NET_TYPE_VHOSTUSER can be backed by a chardev + * but FD passing does not work, see commit ed5aa85f3 */ + + for (i = 0; i < def->nsmartcards; i++) { + virDomainSmartcardDefPtr smartcard = def->smartcards[i]; + if (smartcard->type != VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH) + continue; + if (qemuProcessMaybeOpenChrSource(vm, smartcard->data.passthru) < 0) + goto cleanup; + } + + /* Shmems can also have a chardev source, but the listen mode is + * set to false in the XML parser. Nothing to do here */ + + for (i = 0; i < def->nserials; i++) { + virDomainChrDefPtr serial = def->serials[i]; + if (qemuProcessMaybeOpenChrSource(vm, serial->source) < 0) + goto cleanup; + } + + for (i = 0; i < def->nparallels; i++) { + virDomainChrDefPtr parallel = def->parallels[i]; + if (qemuProcessMaybeOpenChrSource(vm, parallel->source) < 0) + goto cleanup; + } + + for (i = 0; i < def->nchannels; i++) { + virDomainChrDefPtr channel = def->channels[i]; + if (channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD && + channel->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) + continue; + if (qemuProcessMaybeOpenChrSource(vm, channel->source) < 0) + goto cleanup; + } + + for (i = 0; i < def->nconsoles; i++) { + virDomainChrDefPtr console = def->consoles[i]; + if (console->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) + continue; + if (qemuProcessMaybeOpenChrSource(vm, console->source) < 0) + goto cleanup; + } + + for (i = 0; i < def->nredirdevs; i++) { + virDomainRedirdevDefPtr redirdev = def->redirdevs[i]; + if (qemuProcessMaybeOpenChrSource(vm, redirdev->source) < 0) + goto cleanup; + } + + for (i = 0; i < def->nrngs; i++) { + virDomainRNGDefPtr rng = def->rngs[i]; + switch ((virDomainRNGBackend) rng->backend) { + case VIR_DOMAIN_RNG_BACKEND_RANDOM: + case VIR_DOMAIN_RNG_BACKEND_LAST: + /* no chardev backend is needed */ + return 0; + + case VIR_DOMAIN_RNG_BACKEND_EGD: + if (qemuProcessMaybeOpenChrSource(vm, rng->source.chardev) < 0) + goto cleanup; + } + } + + ret = 0; + cleanup: + return ret; +} + + /** * qemuProcessPrepareHost: * @driver: qemu driver @@ -6228,6 +6349,9 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, qemuProcessMakeDir(driver, vm, priv->channelTargetDir) < 0) goto cleanup; + if (qemuProcessPrepareChrFDs(vm, vm->def) < 0) + goto cleanup; + VIR_DEBUG("Write domain masterKey"); if (qemuDomainWriteMasterKeyFile(driver, vm) < 0) goto cleanup; @@ -6886,6 +7010,9 @@ qemuProcessCreatePretendCmd(virQEMUDriverPtr driver, if (qemuProcessPrepareDomain(driver, vm, flags) < 0) goto cleanup; + if (qemuProcessPrepareChrFDs(vm, vm->def) < 0) + goto cleanup; + VIR_DEBUG("Building emulator command line"); cmd = qemuBuildCommandLine(driver, NULL, -- 2.16.4

This reverts the flag addition parts of: commit ed5aa85f371aebb0103e712f9a103d011ab9ae43 Now that we format the file descriptor only if one was opened earlier, the flag is unused. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 54a1a299e2..7719cdc032 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5051,7 +5051,6 @@ qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) enum { QEMU_BUILD_CHARDEV_TCP_NOWAIT = (1 << 0), QEMU_BUILD_CHARDEV_FILE_LOGD = (1 << 1), - QEMU_BUILD_CHARDEV_UNIX_FD_PASS = (1 << 2), }; /* This function outputs a -chardev command line option which describes only the @@ -5494,8 +5493,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, qemuDomainObjPrivatePtr priv) { char *chrdev; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (priv->chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -5630,8 +5628,7 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, char **chr, bool chardevStdioLogd) { - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; *chr = NULL; @@ -8708,8 +8705,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, virBuffer opt = VIR_BUFFER_INITIALIZER; const char *database; const char *contAlias = NULL; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -8945,8 +8941,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, virBuffer buf = VIR_BUFFER_INITIALIZER; char *devstr = NULL; int rc; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -9117,8 +9112,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, { size_t i; bool havespice = false; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -9181,8 +9175,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, bool chardevStdioLogd) { size_t i; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -9219,8 +9212,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, bool chardevStdioLogd) { size_t i; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -9277,8 +9269,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, bool chardevStdioLogd) { size_t i; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; @@ -9451,8 +9442,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, bool chardevStdioLogd) { size_t i; - unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT | - QEMU_BUILD_CHARDEV_UNIX_FD_PASS; + unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT; if (chardevStdioLogd) cdevflags |= QEMU_BUILD_CHARDEV_FILE_LOGD; -- 2.16.4

Its purpose is to affect the host state, which qemuBuildCommandLine ideally should not do. Remove it now that it's no longer used. This reverts the remaining parts of: commit b0c6300fc42bbc3e5eb0b236392f7344581c5810 Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 80 ++++++++++++++++--------------------------------- src/qemu/qemu_command.h | 1 - src/qemu/qemu_process.c | 2 -- 3 files changed, 26 insertions(+), 57 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7719cdc032..94bb5d184d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5057,7 +5057,6 @@ enum { * host side of the character device */ static char * qemuBuildChrChardevStr(virLogManagerPtr logManager, - virSecurityManagerPtr secManager ATTRIBUTE_UNUSED, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -5486,7 +5485,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd, static int qemuBuildMonitorCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, virDomainDefPtr def, @@ -5500,8 +5498,7 @@ qemuBuildMonitorCommandLine(virLogManagerPtr logManager, if (!priv->monConfig) return 0; - if (!(chrdev = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(chrdev = qemuBuildChrChardevStr(logManager, cmd, cfg, def, priv->monConfig, "monitor", priv->qemuCaps, cdevflags))) return -1; @@ -5619,7 +5616,6 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev) static int qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -5640,8 +5636,7 @@ qemuBuildRNGBackendChrdevStr(virLogManagerPtr logManager, return 0; case VIR_DOMAIN_RNG_BACKEND_EGD: - if (!(*chr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(*chr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, rng->source.chardev, rng->info.alias, qemuCaps, cdevflags))) @@ -5764,7 +5759,6 @@ qemuBuildRNGDevStr(const virDomainDef *def, static int qemuBuildRNGCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -5787,7 +5781,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager, } /* possibly add character device for backend */ - if (qemuBuildRNGBackendChrdevStr(logManager, secManager, cmd, cfg, def, + if (qemuBuildRNGBackendChrdevStr(logManager, cmd, cfg, def, rng, qemuCaps, &tmp, chardevStdioLogd) < 0) return -1; @@ -8204,7 +8198,6 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg, static int qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virDomainDefPtr def, virDomainNetDefPtr net, @@ -8226,8 +8219,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, switch ((virDomainChrType)net->data.vhostuser->type) { case VIR_DOMAIN_CHR_TYPE_UNIX: - if (!(chardev = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(chardev = qemuBuildChrChardevStr(logManager, cmd, cfg, def, net->data.vhostuser, net->info.alias, qemuCaps, 0))) goto cleanup; @@ -8294,7 +8286,6 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, static int qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virDomainDefPtr def, virDomainNetDefPtr net, @@ -8425,7 +8416,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, break; case VIR_DOMAIN_NET_TYPE_VHOSTUSER: - ret = qemuBuildVhostuserCommandLine(driver, logManager, secManager, cmd, def, + ret = qemuBuildVhostuserCommandLine(driver, logManager, cmd, def, net, qemuCaps, bootindex); goto cleanup; break; @@ -8602,7 +8593,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, static int qemuBuildNetCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virDomainDefPtr def, virQEMUCapsPtr qemuCaps, @@ -8630,7 +8620,7 @@ qemuBuildNetCommandLine(virQEMUDriverPtr driver, for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - if (qemuBuildInterfaceCommandLine(driver, logManager, secManager, cmd, def, net, + if (qemuBuildInterfaceCommandLine(driver, logManager, cmd, def, net, qemuCaps, bootNet, vmop, standalone, nnicindexes, nicindexes) < 0) @@ -8692,7 +8682,6 @@ qemuBuildSmartcardFindCCIDController(const virDomainDef *def, static int qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -8769,8 +8758,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager, return -1; } - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, smartcard->data.passthru, smartcard->info.alias, qemuCaps, cdevflags))) { @@ -8929,7 +8917,6 @@ qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem) static int qemuBuildShmemCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, virDomainDefPtr def, @@ -9004,8 +8991,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, VIR_FREE(devstr); if (shmem->server.enabled) { - devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, &shmem->server.chr, shmem->info.alias, qemuCaps, cdevflags); @@ -9103,7 +9089,6 @@ qemuChrIsPlatformDevice(const virDomainDef *def, static int qemuBuildSerialCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -9130,8 +9115,7 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, if (serial->source->type == VIR_DOMAIN_CHR_TYPE_SPICEPORT && !havespice) continue; - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, serial->source, serial->info.alias, qemuCaps, cdevflags))) @@ -9167,7 +9151,6 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager, static int qemuBuildParallelsCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -9183,8 +9166,7 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, virDomainChrDefPtr parallel = def->parallels[i]; char *devstr; - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, parallel->source, parallel->info.alias, qemuCaps, cdevflags))) @@ -9204,7 +9186,6 @@ qemuBuildParallelsCommandLine(virLogManagerPtr logManager, static int qemuBuildChannelsCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -9222,8 +9203,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, switch (channel->targetType) { case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD: - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, channel->source, channel->info.alias, qemuCaps, cdevflags))) @@ -9239,8 +9219,7 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, channel->source, channel->info.alias, qemuCaps, cdevflags))) @@ -9261,7 +9240,6 @@ qemuBuildChannelsCommandLine(virLogManagerPtr logManager, static int qemuBuildConsoleCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -9286,8 +9264,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, return -1; } - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, console->source, console->info.alias, qemuCaps, cdevflags))) @@ -9307,8 +9284,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, return -1; } - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, console->source, console->info.alias, qemuCaps, cdevflags))) @@ -9322,8 +9298,7 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager, break; case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO: - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, console->source, console->info.alias, qemuCaps, cdevflags))) @@ -9434,7 +9409,6 @@ qemuBuildRedirdevDevStr(const virDomainDef *def, static int qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virCommandPtr cmd, virQEMUDriverConfigPtr cfg, const virDomainDef *def, @@ -9450,8 +9424,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager, virDomainRedirdevDefPtr redirdev = def->redirdevs[i]; char *devstr; - if (!(devstr = qemuBuildChrChardevStr(logManager, secManager, - cmd, cfg, def, + if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, redirdev->source, redirdev->info.alias, qemuCaps, cdevflags))) { @@ -10178,7 +10151,6 @@ qemuBuildVsockCommandLine(virCommandPtr cmd, virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virDomainObjPtr vm, const char *migrateURI, virDomainSnapshotObjPtr snapshot, @@ -10287,7 +10259,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSgaCommandLine(cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, priv) < 0) + if (qemuBuildMonitorCommandLine(logManager, cmd, cfg, def, priv) < 0) goto error; if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0) @@ -10317,28 +10289,28 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildFSDevCommandLine(cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildNetCommandLine(driver, logManager, secManager, cmd, def, + if (qemuBuildNetCommandLine(driver, logManager, cmd, def, qemuCaps, vmop, standalone, nnicindexes, nicindexes, &bootHostdevNet) < 0) goto error; - if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildSmartcardCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; - if (qemuBuildSerialCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildSerialCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; - if (qemuBuildParallelsCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildParallelsCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; - if (qemuBuildChannelsCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildChannelsCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; - if (qemuBuildConsoleCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildConsoleCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; @@ -10360,7 +10332,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildWatchdogCommandLine(cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildRedirdevCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildRedirdevCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; @@ -10373,7 +10345,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildMemballoonCommandLine(cmd, def, qemuCaps) < 0) goto error; - if (qemuBuildRNGCommandLine(logManager, secManager, cmd, cfg, def, qemuCaps, + if (qemuBuildRNGCommandLine(logManager, cmd, cfg, def, qemuCaps, chardevStdioLogd) < 0) goto error; @@ -10408,7 +10380,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, goto error; for (i = 0; i < def->nshmems; i++) { - if (qemuBuildShmemCommandLine(logManager, secManager, cmd, cfg, + if (qemuBuildShmemCommandLine(logManager, cmd, cfg, def, def->shmems[i], qemuCaps, chardevStdioLogd)) goto error; diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 98d4ac90b5..3f4a660e87 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -46,7 +46,6 @@ VIR_ENUM_DECL(qemuVideo) virCommandPtr qemuBuildCommandLine(virQEMUDriverPtr driver, virLogManagerPtr logManager, - virSecurityManagerPtr secManager, virDomainObjPtr vm, const char *migrateURI, virDomainSnapshotObjPtr snapshot, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f315d28dd0..9519178603 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6539,7 +6539,6 @@ qemuProcessLaunch(virConnectPtr conn, VIR_DEBUG("Building emulator command line"); if (!(cmd = qemuBuildCommandLine(driver, qemuDomainLogContextGetManager(logCtxt), - driver->securityManager, vm, incoming ? incoming->launchURI : NULL, snapshot, vmop, @@ -7016,7 +7015,6 @@ qemuProcessCreatePretendCmd(virQEMUDriverPtr driver, VIR_DEBUG("Building emulator command line"); cmd = qemuBuildCommandLine(driver, NULL, - driver->securityManager, vm, migrateURI, NULL, -- 2.16.4

Move it closer to its new user. Left exported because it needs to be mocked and it might be used for hotplug in the future. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/qemu/qemu_command.c | 57 ---------------------------------------------- src/qemu/qemu_command.h | 4 ---- src/qemu/qemu_process.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++- src/qemu/qemu_process.h | 3 +++ tests/qemuxml2argvmock.c | 3 ++- 5 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 94bb5d184d..0b2d8d29fa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4991,63 +4991,6 @@ qemuBuildChrChardevReconnectStr(virBufferPtr buf, } -int -qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) -{ - struct sockaddr_un addr; - socklen_t addrlen = sizeof(addr); - int fd; - - if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { - virReportSystemError(errno, "%s", - _("Unable to create UNIX socket")); - goto error; - } - - memset(&addr, 0, sizeof(addr)); - addr.sun_family = AF_UNIX; - if (virStrcpyStatic(addr.sun_path, dev->data.nix.path) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("UNIX socket path '%s' too long"), - dev->data.nix.path); - goto error; - } - - if (unlink(dev->data.nix.path) < 0 && errno != ENOENT) { - virReportSystemError(errno, - _("Unable to unlink %s"), - dev->data.nix.path); - goto error; - } - - if (bind(fd, (struct sockaddr *)&addr, addrlen) < 0) { - virReportSystemError(errno, - _("Unable to bind to UNIX socket path '%s'"), - dev->data.nix.path); - goto error; - } - - if (listen(fd, 1) < 0) { - virReportSystemError(errno, - _("Unable to listen to UNIX socket path '%s'"), - dev->data.nix.path); - goto error; - } - - /* We run QEMU with umask 0002. Compensate for the umask - * libvirtd might be running under to get the same permission - * QEMU would have. */ - if (virFileUpdatePerm(dev->data.nix.path, 0002, 0664) < 0) - goto error; - - return fd; - - error: - VIR_FORCE_CLOSE(fd); - return -1; -} - - enum { QEMU_BUILD_CHARDEV_TCP_NOWAIT = (1 << 0), QEMU_BUILD_CHARDEV_FILE_LOGD = (1 << 1), diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index 3f4a660e87..96cfa563bb 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -72,10 +72,6 @@ int qemuBuildTLSx509BackendProps(const char *tlspath, virQEMUCapsPtr qemuCaps, virJSONValuePtr *propsret); -/* Open a UNIX socket for chardev FD passing */ -int -qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev); - /* Generate '-device' string for chardev device */ int qemuBuildChrDeviceStr(char **deviceStr, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9519178603..ae1bac8ecb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6136,6 +6136,63 @@ qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock) } +int +qemuProcessOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev) +{ + struct sockaddr_un addr; + socklen_t addrlen = sizeof(addr); + int fd; + + if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + virReportSystemError(errno, "%s", + _("Unable to create UNIX socket")); + goto error; + } + + memset(&addr, 0, sizeof(addr)); + addr.sun_family = AF_UNIX; + if (virStrcpyStatic(addr.sun_path, dev->data.nix.path) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("UNIX socket path '%s' too long"), + dev->data.nix.path); + goto error; + } + + if (unlink(dev->data.nix.path) < 0 && errno != ENOENT) { + virReportSystemError(errno, + _("Unable to unlink %s"), + dev->data.nix.path); + goto error; + } + + if (bind(fd, (struct sockaddr *)&addr, addrlen) < 0) { + virReportSystemError(errno, + _("Unable to bind to UNIX socket path '%s'"), + dev->data.nix.path); + goto error; + } + + if (listen(fd, 1) < 0) { + virReportSystemError(errno, + _("Unable to listen to UNIX socket path '%s'"), + dev->data.nix.path); + goto error; + } + + /* We run QEMU with umask 0002. Compensate for the umask + * libvirtd might be running under to get the same permission + * QEMU would have. */ + if (virFileUpdatePerm(dev->data.nix.path, 0002, 0664) < 0) + goto error; + + return fd; + + error: + VIR_FORCE_CLOSE(fd); + return -1; +} + + static int qemuProcessMaybeOpenChrSource(virDomainObjPtr vm, const virDomainChrSourceDef *src) @@ -6158,7 +6215,7 @@ qemuProcessMaybeOpenChrSource(virDomainObjPtr vm, if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0) goto cleanup; - fd = qemuOpenChrChardevUNIXSocket(src); + fd = qemuProcessOpenChrChardevUNIXSocket(src); if (qemuSecurityClearSocketLabel(driver->securityManager, vm->def) < 0) goto cleanup; diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index c2f7c2b5d2..1135556a5a 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -116,6 +116,9 @@ int qemuProcessPrepareDomain(virQEMUDriverPtr driver, unsigned int flags); int qemuProcessOpenVhostVsock(virDomainVsockDefPtr vsock); +/* Open a UNIX socket for chardev FD passing */ +int qemuProcessOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev); + int qemuProcessPrepareHost(virQEMUDriverPtr driver, virDomainObjPtr vm, diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 79152d928e..dadf0f0a62 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -38,6 +38,7 @@ #include "virutil.h" #include "qemu/qemu_interface.h" #include "qemu/qemu_command.h" +#include "qemu/qemu_process.h" #include <time.h> #include <unistd.h> #include <fcntl.h> @@ -233,7 +234,7 @@ qemuInterfaceOpenVhostNet(virDomainDefPtr def ATTRIBUTE_UNUSED, int -qemuOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev ATTRIBUTE_UNUSED) +qemuProcessOpenChrChardevUNIXSocket(const virDomainChrSourceDef *dev ATTRIBUTE_UNUSED) { /* We need to return an FD number for a UNIX listener socket, -- 2.16.4

On 10/04/2018 09:22 PM, Ján Tomko wrote:
Add test coverage for all the possible devices and move all the socket creation to qemuProcessPrepareHost. TBD: remove the racy qemuSecuritySetSocketLabel call as well as the rest of host state modification out of qemuBuildCommandLine
Ján Tomko (15): tests: add smartcard-passthrough-unix tests: add parallel-unix-chardev tests: add channel-unix-guestfwd tests: add console-virtio-unix tests: add usb-redir-unix tests: add virtio-rng-egd-unix tests: use real capabilities for net-vhostuser qemuProcessPrepareDomain: pass xmlopt when creating monConfig qemu: add fd to qemuDomainChrSourcePrivate qemuBuildChrChardevStr: split attribute formatting qemuBuildChrChardevStr: increase scope of qemuBuildChrChardevStr qemuBuildChrChardevStr: pass fd from private data qemu: remove QEMU_BUILD_CHARDEV_UNIX_FD_PASS qemuBuildCommandLine: do not pass security manager qemuOpenChrChardevUNIXSocket: move to qemu_process
src/qemu/qemu_command.c | 192 +++++---------------- src/qemu/qemu_command.h | 5 - src/qemu/qemu_domain.c | 3 + src/qemu/qemu_domain.h | 2 + src/qemu/qemu_process.c | 188 +++++++++++++++++++- src/qemu/qemu_process.h | 3 + .../channel-unix-guestfwd.x86_64-2.5.0.args | 33 ++++ .../channel-unix-guestfwd.x86_64-latest.args | 36 ++++ tests/qemuxml2argvdata/channel-unix-guestfwd.xml | 37 ++++ .../console-virtio-unix.x86_64-2.5.0.args | 34 ++++ .../console-virtio-unix.x86_64-latest.args | 37 ++++ tests/qemuxml2argvdata/console-virtio-unix.xml | 33 ++++ .../net-vhostuser.x86_64-2.5.0.args | 39 +++++ .../net-vhostuser.x86_64-latest.args | 42 +++++ .../parallel-unix-chardev.x86_64-2.5.0.args | 33 ++++ .../parallel-unix-chardev.x86_64-latest.args | 36 ++++ tests/qemuxml2argvdata/parallel-unix-chardev.xml | 35 ++++ .../smartcard-passthrough-unix.x86_64-2.5.0.args | 30 ++++ .../smartcard-passthrough-unix.x86_64-latest.args | 33 ++++ .../smartcard-passthrough-unix.xml | 19 ++ .../usb-redir-unix.x86_64-2.5.0.args | 35 ++++ .../usb-redir-unix.x86_64-latest.args | 38 ++++ tests/qemuxml2argvdata/usb-redir-unix.xml | 45 +++++ .../virtio-rng-egd-unix.x86_64-2.5.0.args | 30 ++++ .../virtio-rng-egd-unix.x86_64-latest.args | 33 ++++ tests/qemuxml2argvdata/virtio-rng-egd-unix.xml | 29 ++++ tests/qemuxml2argvmock.c | 3 +- tests/qemuxml2argvtest.c | 14 ++ 28 files changed, 939 insertions(+), 158 deletions(-) create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/channel-unix-guestfwd.xml create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/console-virtio-unix.xml create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/net-vhostuser.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/parallel-unix-chardev.xml create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/smartcard-passthrough-unix.xml create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/usb-redir-unix.xml create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-2.5.0.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/virtio-rng-egd-unix.xml
ACK series Michal
participants (2)
-
Ján Tomko
-
Michal Privoznik