[PATCH 0/5] conf: Introduce @guestReset to hostdev's <source/>

There are couple of examples where this knob would be useful: https://bugs.launchpad.net/qemu/+bug/1846451 (look for those cmd line passthrough hacks), and one pretty recent request: https://listman.redhat.com/archives/libvir-list/2022-June/232611.html The last patch uses info from Kraxel's patch (which he posted after our private discussion): https://lists.gnu.org/archive/html/qemu-devel/2022-07/msg01733.html Michal Prívozník (5): tests: Update hostdev-usb-* hostdev-pci-* xml2xml and xml2argv tests conf: Introduce @guestReset to hostdev's <source/> qemu_capabilities: Track usb-host.guest-resets-all capability qemu_validate: Validate that QEMU's capable of guestReset qemu: Generate cmd line for guestReset docs/formatdomain.rst | 15 +++++++- src/conf/domain_conf.c | 18 +++++++++ src/conf/domain_conf.h | 13 +++++++ src/conf/schemas/domaincommon.rng | 9 +++++ src/qemu/qemu_capabilities.c | 2 + src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 21 ++++++++++ src/qemu/qemu_validate.c | 8 ++++ .../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 + .../caps_3.1.0.x86_64.xml | 1 + .../caps_4.0.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 + .../caps_4.0.0.riscv32.xml | 1 + .../caps_4.0.0.riscv64.xml | 1 + .../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 + .../caps_4.0.0.x86_64.xml | 1 + .../caps_4.1.0.x86_64.xml | 1 + .../caps_4.2.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 + .../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 + .../caps_4.2.0.x86_64.xml | 1 + .../caps_5.0.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + .../caps_5.0.0.riscv64.xml | 1 + .../caps_5.0.0.x86_64.xml | 1 + .../caps_5.1.0.x86_64.xml | 1 + .../caps_5.2.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 + .../caps_5.2.0.riscv64.xml | 1 + .../caps_5.2.0.x86_64.xml | 1 + .../caps_6.0.0.aarch64.xml | 1 + .../caps_6.0.0.x86_64.xml | 1 + .../caps_6.1.0.x86_64.xml | 1 + .../caps_6.2.0.aarch64.xml | 1 + .../caps_6.2.0.x86_64.xml | 1 + .../caps_7.0.0.aarch64.xml | 1 + .../qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + .../caps_7.0.0.x86_64.xml | 1 + .../caps_7.1.0.x86_64.xml | 1 + .../hostdev-pci-address-device.args | 34 ----------------- ...tdev-pci-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-pci-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-pci-address.args | 33 ---------------- .../hostdev-pci-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-pci-address.xml | 2 +- .../hostdev-usb-address-device-boot.args | 34 ----------------- ...usb-address-device-boot.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device-boot.xml | 2 +- .../hostdev-usb-address-device.args | 34 ----------------- ...tdev-usb-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-usb-address.args | 33 ---------------- .../hostdev-usb-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-usb-address.xml | 4 +- tests/qemuxml2argvtest.c | 10 ++--- ... => hostdev-pci-address.x86_64-latest.xml} | 7 +++- ... => hostdev-usb-address.x86_64-latest.xml} | 9 +++-- tests/qemuxml2xmltest.c | 4 +- 58 files changed, 329 insertions(+), 187 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args rename tests/qemuxml2xmloutdata/{hostdev-pci-address.xml => hostdev-pci-address.x86_64-latest.xml} (86%) rename tests/qemuxml2xmloutdata/{hostdev-usb-address.xml => hostdev-usb-address.x86_64-latest.xml} (83%) -- 2.35.1

Currently, we have bunch of PCI/USB tests cases for qemuxml2argvtest and qemuxml2xmltest but all of them run without any capabilities. This makes is needlessly complicated when trying to extend them. Switch to DO_TEST_CAPS_LATEST(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .../hostdev-pci-address-device.args | 34 ----------------- ...tdev-pci-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-pci-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-pci-address.args | 33 ---------------- .../hostdev-pci-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-pci-address.xml | 2 +- .../hostdev-usb-address-device-boot.args | 34 ----------------- ...usb-address-device-boot.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device-boot.xml | 2 +- .../hostdev-usb-address-device.args | 34 ----------------- ...tdev-usb-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-usb-address.args | 33 ---------------- .../hostdev-usb-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-usb-address.xml | 2 +- tests/qemuxml2argvtest.c | 10 ++--- ... => hostdev-pci-address.x86_64-latest.xml} | 7 +++- ... => hostdev-usb-address.x86_64-latest.xml} | 7 +++- tests/qemuxml2xmltest.c | 4 +- 19 files changed, 210 insertions(+), 184 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args rename tests/qemuxml2xmloutdata/{hostdev-pci-address.xml => hostdev-pci-address.x86_64-latest.xml} (86%) rename tests/qemuxml2xmloutdata/{hostdev-usb-address.xml => hostdev-usb-address.x86_64-latest.xml} (85%) diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-device.args b/tests/qemuxml2argvdata/hostdev-pci-address-device.args deleted file mode 100644 index 4c39457ae5..0000000000 --- a/tests/qemuxml2argvdata/hostdev-pci-address-device.args +++ /dev/null @@ -1,34 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest2 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest2/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest2/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest2,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m 214 \ --overcommit mem-lock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9466-926a-d65c16db1809 \ --display none \ --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 \ --usb \ --drive file=/dev/HostVG/QEMUGuest2,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 \ --device vfio-pci,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x2 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args new file mode 100644 index 0000000000..a0b6777ce2 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest2 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest2/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest2/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest2,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest2/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-9466-926a-d65c16db1809 \ +-display none \ +-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"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","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}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","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/hostdev-pci-address-device.xml b/tests/qemuxml2argvdata/hostdev-pci-address-device.xml index 7a99fc8444..3fc4d12f7e 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address-device.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-address-device.xml @@ -13,7 +13,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <source dev='/dev/HostVG/QEMUGuest2'/> <target dev='hda' bus='ide'/> diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.args b/tests/qemuxml2argvdata/hostdev-pci-address.args deleted file mode 100644 index a985ff9dc1..0000000000 --- a/tests/qemuxml2argvdata/hostdev-pci-address.args +++ /dev/null @@ -1,33 +0,0 @@ -LC_ALL=C \ -PATH=/bin \ -HOME=/tmp/lib/domain--1-QEMUGuest2 \ -USER=test \ -LOGNAME=test \ -XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest2/.local/share \ -XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest2/.cache \ -XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest2,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest2/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m 214 \ --overcommit mem-lock=off \ --smp 1,sockets=1,cores=1,threads=1 \ --uuid c7a5fdbd-edaf-9466-926a-d65c16db1809 \ --display none \ --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 \ --usb \ --drive file=/dev/HostVG/QEMUGuest2,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 \ --device vfio-pci,host=0000:06:12.5,id=hostdev0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args new file mode 100644 index 0000000000..fe011d5f8a --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest2 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest2/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest2/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest2/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest2,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest2/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-9466-926a-d65c16db1809 \ +-display none \ +-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"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest2","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}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"vfio-pci","host":"0000:06:12.5","id":"hostdev0","bus":"pci.0","addr":"0x2"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-pci-address.xml b/tests/qemuxml2argvdata/hostdev-pci-address.xml index 5f8090336f..f35b8394f7 100644 --- a/tests/qemuxml2argvdata/hostdev-pci-address.xml +++ b/tests/qemuxml2argvdata/hostdev-pci-address.xml @@ -13,7 +13,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest2'/> diff --git a/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args b/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args deleted file mode 100644 index 7e72951fd1..0000000000 --- a/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args +++ /dev/null @@ -1,34 +0,0 @@ -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 \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m 214 \ --overcommit mem-lock=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=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --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 \ --device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bootindex=1,bus=usb.0,port=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args new file mode 100644 index 0000000000..2a5a085231 --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args @@ -0,0 +1,38 @@ +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 \ +-display none \ +-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"}' \ +-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"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"usb-host","hostdevice":"/dev/bus/usb/014/006","id":"hostdev0","bootindex":1,"bus":"usb.0","port":"1"}' \ +-device '{"driver":"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/hostdev-usb-address-device-boot.xml b/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.xml index ac1360f87f..a3c0618e37 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.xml +++ b/tests/qemuxml2argvdata/hostdev-usb-address-device-boot.xml @@ -12,7 +12,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> diff --git a/tests/qemuxml2argvdata/hostdev-usb-address-device.args b/tests/qemuxml2argvdata/hostdev-usb-address-device.args deleted file mode 100644 index c4003864c4..0000000000 --- a/tests/qemuxml2argvdata/hostdev-usb-address-device.args +++ /dev/null @@ -1,34 +0,0 @@ -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 \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m 214 \ --overcommit mem-lock=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=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --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 \ --device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1 \ --device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args new file mode 100644 index 0000000000..30809a076c --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args @@ -0,0 +1,38 @@ +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 \ +-display none \ +-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"}' \ +-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}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"usb-host","hostdevice":"/dev/bus/usb/014/006","id":"hostdev0","bus":"usb.0","port":"1"}' \ +-device '{"driver":"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/hostdev-usb-address-device.xml b/tests/qemuxml2argvdata/hostdev-usb-address-device.xml index 9027564584..f63ad30950 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address-device.xml +++ b/tests/qemuxml2argvdata/hostdev-usb-address-device.xml @@ -13,7 +13,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <source dev='/dev/HostVG/QEMUGuest1'/> <target dev='hda' bus='ide'/> diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.args b/tests/qemuxml2argvdata/hostdev-usb-address.args deleted file mode 100644 index a5bf6263d4..0000000000 --- a/tests/qemuxml2argvdata/hostdev-usb-address.args +++ /dev/null @@ -1,33 +0,0 @@ -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 \ -QEMU_AUDIO_DRV=none \ -/usr/bin/qemu-system-i386 \ --name guest=QEMUGuest1,debug-threads=on \ --S \ --object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ --machine pc,usb=off,dump-guest-core=off \ --accel tcg \ --m 214 \ --overcommit mem-lock=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=on,wait=off \ --mon chardev=charmonitor,id=monitor,mode=control \ --rtc base=utc \ --no-shutdown \ --no-acpi \ --boot strict=on \ --usb \ --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 \ --device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1 \ --msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args new file mode 100644 index 0000000000..f59c463f5e --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args @@ -0,0 +1,37 @@ +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 \ +-display none \ +-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"}' \ +-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}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"usb-host","hostdevice":"/dev/bus/usb/014/006","id":"hostdev0","bus":"usb.0","port":"1"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.xml b/tests/qemuxml2argvdata/hostdev-usb-address.xml index 7d0c338311..03c802a532 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address.xml +++ b/tests/qemuxml2argvdata/hostdev-usb-address.xml @@ -13,7 +13,7 @@ <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> - <emulator>/usr/bin/qemu-system-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest1'/> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a99b44bf2d..5b40a0d7f5 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1914,12 +1914,12 @@ mymain(void) DO_TEST_CAPS_LATEST("fs9p"); DO_TEST_CAPS_ARCH_LATEST("fs9p-ccw", "s390x"); - DO_TEST_NOCAPS("hostdev-usb-address"); - DO_TEST_NOCAPS("hostdev-usb-address-device"); - DO_TEST_NOCAPS("hostdev-usb-address-device-boot"); + DO_TEST_CAPS_LATEST("hostdev-usb-address"); + DO_TEST_CAPS_LATEST("hostdev-usb-address-device"); + DO_TEST_CAPS_LATEST("hostdev-usb-address-device-boot"); DO_TEST_PARSE_ERROR_NOCAPS("hostdev-usb-duplicate"); - DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI); - DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI); + DO_TEST_CAPS_LATEST("hostdev-pci-address"); + DO_TEST_CAPS_LATEST("hostdev-pci-address-device"); DO_TEST_PARSE_ERROR("hostdev-pci-duplicate", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio", diff --git a/tests/qemuxml2xmloutdata/hostdev-pci-address.xml b/tests/qemuxml2xmloutdata/hostdev-pci-address.x86_64-latest.xml similarity index 86% rename from tests/qemuxml2xmloutdata/hostdev-pci-address.xml rename to tests/qemuxml2xmloutdata/hostdev-pci-address.x86_64-latest.xml index 9ba3dfac45..84d9660316 100644 --- a/tests/qemuxml2xmloutdata/hostdev-pci-address.xml +++ b/tests/qemuxml2xmloutdata/hostdev-pci-address.x86_64-latest.xml @@ -8,19 +8,22 @@ <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-i386</emulator> + <emulator>/usr/bin/qemu-system-x86_64</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw'/> <source dev='/dev/HostVG/QEMUGuest2'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> - <controller type='usb' index='0'> + <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'> diff --git a/tests/qemuxml2xmloutdata/hostdev-usb-address.xml b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml similarity index 85% rename from tests/qemuxml2xmloutdata/hostdev-usb-address.xml rename to tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml index e4a1f798b2..e5e3620971 100644 --- a/tests/qemuxml2xmloutdata/hostdev-usb-address.xml +++ b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml @@ -8,19 +8,22 @@ <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-i386</emulator> + <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'> + <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'> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 71bce98c17..58929b68c1 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -526,8 +526,8 @@ mymain(void) DO_TEST_NOCAPS("channel-unix-source-path"); - DO_TEST_NOCAPS("hostdev-usb-address"); - DO_TEST_NOCAPS("hostdev-pci-address"); + DO_TEST_CAPS_LATEST("hostdev-usb-address"); + DO_TEST_CAPS_LATEST("hostdev-pci-address"); DO_TEST("hostdev-pci-address-unassigned", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-pci-multifunction", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI); -- 2.35.1

On a Tuesday in 2022, Michal Privoznik wrote:
Currently, we have bunch of PCI/USB tests cases for qemuxml2argvtest and qemuxml2xmltest but all of them run without any capabilities. This makes is needlessly complicated when trying to extend them. Switch to DO_TEST_CAPS_LATEST().
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- .../hostdev-pci-address-device.args | 34 ----------------- ...tdev-pci-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-pci-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-pci-address.args | 33 ---------------- .../hostdev-pci-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-pci-address.xml | 2 +- .../hostdev-usb-address-device-boot.args | 34 ----------------- ...usb-address-device-boot.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device-boot.xml | 2 +- .../hostdev-usb-address-device.args | 34 ----------------- ...tdev-usb-address-device.x86_64-latest.args | 38 +++++++++++++++++++ .../hostdev-usb-address-device.xml | 2 +- .../qemuxml2argvdata/hostdev-usb-address.args | 33 ---------------- .../hostdev-usb-address.x86_64-latest.args | 37 ++++++++++++++++++ .../qemuxml2argvdata/hostdev-usb-address.xml | 2 +- tests/qemuxml2argvtest.c | 10 ++--- ... => hostdev-pci-address.x86_64-latest.xml} | 7 +++- ... => hostdev-usb-address.x86_64-latest.xml} | 7 +++- tests/qemuxml2xmltest.c | 4 +- 19 files changed, 210 insertions(+), 184 deletions(-) delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-pci-address.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device-boot.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address-device.x86_64-latest.args delete mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.args create mode 100644 tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args rename tests/qemuxml2xmloutdata/{hostdev-pci-address.xml => hostdev-pci-address.x86_64-latest.xml} (86%) rename tests/qemuxml2xmloutdata/{hostdev-usb-address.xml => hostdev-usb-address.x86_64-latest.xml} (85%)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Some USB devices have a buggy firmware that either crashes on device reset, or make the device unusable in some other way. Fortunately, QEMU offers a way to skip device reset either completely, or if device is not initialized yet. Expose this ability to users under: <hostdev mode='subsystem' type='usb'> <source guestReset='off'/> </hostdev> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/formatdomain.rst | 15 ++++++++++++++- src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 13 +++++++++++++ src/conf/schemas/domaincommon.rng | 9 +++++++++ tests/qemuxml2argvdata/hostdev-usb-address.xml | 2 +- .../hostdev-usb-address.x86_64-latest.xml | 2 +- 6 files changed, 56 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 89b627f4bd..3ea094e64c 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4051,7 +4051,7 @@ for PCI (KVM only) and 1.0.6 for SCSI (KVM only)` : ... <devices> <hostdev mode='subsystem' type='usb'> - <source startupPolicy='optional'> + <source startupPolicy='optional' guestReset='off'> <vendor id='0x1234'/> <product id='0xbeef'/> </source> @@ -4231,6 +4231,19 @@ or: optional drop if missing at any start attempt ========= ===================================================================== + :since:`Since 8.6.0`, the ``source`` element can contain ``guestReset`` + attribute with the following value: + + ============= ===================================================== + off all guest initiated device reset requests are ignored + uninitialized device request is ignored if device is initialized, + otherwise reset is performed + on device is reset on every guest initiated request + ============= ===================================================== + + This attribute can be helpful when assigning an USB device with a + firmware that crashes on reset. + ``pci`` PCI devices can only be described by their ``address``. :since:`Since 6.8.0 (Xen only)` , the ``source`` element of a PCI device diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b639022396..ced25286bd 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1042,6 +1042,14 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol, "iscsi", ); +VIR_ENUM_IMPL(virDomainHostdevSubsysUSBGuestReset, + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST, + "default", + "off", + "uninitialized", + "on", +); + VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIHostProtocol, VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST, "none", @@ -5489,6 +5497,11 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, return -1; virTristateBoolToBool(autoAddress, &usbsrc->autoAddress); + if (virXMLPropEnum(node, "guestReset", + virDomainHostdevSubsysUSBGuestResetTypeFromString, + VIR_XML_PROP_NONZERO, &usbsrc->guestReset) < 0) + return -1; + /* Product can validly be 0, so we need some extra help to determine * if it is uninitialized */ vendorNode = virXPathNode("./vendor", ctxt); @@ -22989,6 +23002,11 @@ virDomainHostdevDefFormatSubsysUSB(virBuffer *buf, if (def->missing && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) virBufferAddLit(&sourceAttrBuf, " missing='yes'"); + if (usbsrc->guestReset) { + virBufferAsprintf(&sourceAttrBuf, " guestReset='%s'", + virDomainHostdevSubsysUSBGuestResetTypeToString(usbsrc->guestReset)); + } + if (usbsrc->vendor) { virBufferAsprintf(&sourceChildBuf, "<vendor id='0x%.4x'/>\n", usbsrc->vendor); virBufferAsprintf(&sourceChildBuf, "<product id='0x%.4x'/>\n", usbsrc->product); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index c56b84683c..90de50c12f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -233,6 +233,17 @@ typedef enum { VIR_ENUM_DECL(virDomainHostdevSubsysSCSIProtocol); +typedef enum { + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_DEFAULT = 0, + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_OFF, /* reset forbidden */ + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_UNINITIALIZED, /* reset iff uninitialized */ + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_ON, /* reset allowed */ + + VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST +} virDomainHostdevSubsysUSBGuestReset; + +VIR_ENUM_DECL(virDomainHostdevSubsysUSBGuestReset); + struct _virDomainHostdevSubsysUSB { bool autoAddress; /* bus/device were filled automatically based on vendor/product */ @@ -241,6 +252,8 @@ struct _virDomainHostdevSubsysUSB { unsigned vendor; unsigned product; + + virDomainHostdevSubsysUSBGuestReset guestReset; }; struct _virDomainHostdevSubsysPCI { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng index da2fb0d5cb..faa2561665 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5936,6 +5936,15 @@ <optional> <ref name="startupPolicy"/> </optional> + <optional> + <attribute name="guestReset"> + <choice> + <value>off</value> + <value>uninitialized</value> + <value>on</value> + </choice> + </attribute> + </optional> <choice> <group> <ref name="usbproduct"/> diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.xml b/tests/qemuxml2argvdata/hostdev-usb-address.xml index 03c802a532..50c02f9b0e 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address.xml +++ b/tests/qemuxml2argvdata/hostdev-usb-address.xml @@ -26,7 +26,7 @@ <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <hostdev mode='subsystem' type='usb' managed='no'> - <source> + <source guestReset='uninitialized'> <address bus='14' device='6'/> </source> </hostdev> diff --git a/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml index e5e3620971..2e927252a8 100644 --- a/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/hostdev-usb-address.x86_64-latest.xml @@ -34,7 +34,7 @@ <input type='keyboard' bus='ps2'/> <audio id='1' type='none'/> <hostdev mode='subsystem' type='usb' managed='no'> - <source> + <source guestReset='uninitialized'> <address bus='14' device='6'/> </source> </hostdev> -- 2.35.1

On a Tuesday in 2022, Michal Privoznik wrote:
Some USB devices have a buggy firmware that either crashes on device reset, or make the device unusable in some other way. Fortunately, QEMU offers a way to skip device reset either completely, or if device is not initialized yet. Expose this ability to users under:
<hostdev mode='subsystem' type='usb'> <source guestReset='off'/> </hostdev>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- docs/formatdomain.rst | 15 ++++++++++++++- src/conf/domain_conf.c | 18 ++++++++++++++++++ src/conf/domain_conf.h | 13 +++++++++++++ src/conf/schemas/domaincommon.rng | 9 +++++++++ tests/qemuxml2argvdata/hostdev-usb-address.xml | 2 +- .../hostdev-usb-address.x86_64-latest.xml | 2 +- 6 files changed, 56 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

We will need two attributes of usb-host device to set: guest-reset and guest-resets-all. The former was introduced in QEMU v4.0.0-rc0~56^2 and the other in v4.2.0-rc1~9^2. Hence, track the latter only as it's only starting from that commit when QEMU has both attributes. Our qemucapabilitiesdata are wrong though, as they enable the capability for quite old releases (for instance 3.1.0 when neither of the attributes existed). But this is because I didn't use actual QEMU to refresh .replies files in v6.9.0-rc1~457. I just blindly copied particular reply around. But that's okay, it doesn't really hurt anything. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml | 1 + 33 files changed, 34 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2c3be3ecec..2d352f406b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -671,6 +671,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "chardev.qemu-vdagent", /* QEMU_CAPS_CHARDEV_QEMU_VDAGENT */ "display-dbus", /* QEMU_CAPS_DISPLAY_DBUS */ "iothread.thread-pool-max", /* QEMU_CAPS_IOTHREAD_THREAD_POOL_MAX */ + "usb-host.guest-resets-all", /* QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL */ ); @@ -1459,6 +1460,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPCIeRootPort[] = static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBHost[] = { { "hostdevice", QEMU_CAPS_USB_HOST_HOSTDEVICE, NULL }, + { "guest-resets-all", QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL, NULL }, }; static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsSpaprPCIHostBridge[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6f35ba1485..a409c1272c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -650,6 +650,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_CHARDEV_QEMU_VDAGENT, /* -chardev qemu-vdagent */ QEMU_CAPS_DISPLAY_DBUS, /* -display dbus */ QEMU_CAPS_IOTHREAD_THREAD_POOL_MAX, /* -object iothread.thread-pool-max */ + QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL, /* -device usb-host.guest-resets-all */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml index cc6e75884b..b4acdebb37 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -135,6 +135,7 @@ <flag name='cpu-max'/> <flag name='input-linux'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>3001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml index 27be36f0ab..d62e543459 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml @@ -179,6 +179,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>3001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml index 7e0b8fbddf..cde5b4f54c 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -147,6 +147,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml index 19bbbd1de3..c8726cbb22 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -152,6 +152,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml index ef6f04f54b..81dcfaa5cb 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -144,6 +144,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml index 7c65aff290..ee855a1077 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -144,6 +144,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml index 9b5ed96ba3..a0c186c41f 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -114,6 +114,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>39100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 3cf6a66389..d0fbb90c89 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -187,6 +187,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml index 5daa7bda75..363bcf0739 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -194,6 +194,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml index 162ace7b2b..875e491581 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -162,6 +162,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml index 7c5275210b..428ecd4f42 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -159,6 +159,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml index ce5b782afd..725745593c 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -127,6 +127,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>39100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml index 9ee4c0534d..6a54c44d79 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -205,6 +205,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml index 29ee31473f..35998cabf0 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -174,6 +174,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml index 1fdec901a6..b8ddf2e9a8 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -180,6 +180,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml index 3b58e7fece..c49c258255 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -166,6 +166,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml index bee5a84cf9..ce297f2ef5 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -214,6 +214,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml index 070f64cb1c..a49650cbcc 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -218,6 +218,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml index 8e17532f3a..42a4418a08 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml @@ -181,6 +181,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml index df02e264d7..d0dd058743 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml @@ -185,6 +185,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml index 7cb4383693..25339f86d9 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml @@ -171,6 +171,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml index cad4ed40e6..4ff03dbead 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -222,6 +222,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml index 4b4cc2d3aa..2d861da97b 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml @@ -189,6 +189,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>6000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml index 8c61bf8a84..38acee5f18 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -231,6 +231,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>6000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index afd8f606eb..b03c6bfc24 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -236,6 +236,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml index 86fc46918f..942c0ba169 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -201,6 +201,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml index 19605d93ae..32f226acbd 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -238,6 +238,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml index e24e2235fb..f4d7cbdd10 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml @@ -209,6 +209,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6002092</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml index 83e0f50e3a..2f895294de 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -213,6 +213,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml index 05f844fd5b..17ea778d38 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -243,6 +243,7 @@ <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> <flag name='display-dbus'/> + <flag name='usb-host.guest-resets-all'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml index 3707d9b7c9..5f5c839fea 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml @@ -244,6 +244,7 @@ <flag name='chardev.qemu-vdagent'/> <flag name='display-dbus'/> <flag name='iothread.thread-pool-max'/> + <flag name='usb-host.guest-resets-all'/> <version>7000050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> -- 2.35.1

On a Tuesday in 2022, Michal Privoznik wrote:
We will need two attributes of usb-host device to set: guest-reset and guest-resets-all. The former was introduced in QEMU v4.0.0-rc0~56^2 and the other in v4.2.0-rc1~9^2. Hence, track the latter only as it's only starting from that commit when QEMU has both attributes.
Our qemucapabilitiesdata are wrong though, as they enable the capability for quite old releases (for instance 3.1.0 when neither of the attributes existed). But this is because I didn't use actual QEMU to refresh .replies files in v6.9.0-rc1~457. I just blindly copied particular reply around. But that's okay, it doesn't really hurt anything.
It hurts the usefulness of our test data. Just like in v6.9.0-rc1~457 you only added the relevant attribute only to QEMU versions that have it, you should delete it from older replies here, to demonstrate that the capability detection code actually works. So there should be no "guest-reset" until QEMU 4.0.0, no "guest-resets-all" until QEMU 4.2.0 and while you're at it, "hostdevice" was added in QEMU 5.1.0 by 9f815e83e983d and so was "suppress-remote-wake" by 7bacaf5fea Jano
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml | 1 + 33 files changed, 34 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2c3be3ecec..2d352f406b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -671,6 +671,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "chardev.qemu-vdagent", /* QEMU_CAPS_CHARDEV_QEMU_VDAGENT */ "display-dbus", /* QEMU_CAPS_DISPLAY_DBUS */ "iothread.thread-pool-max", /* QEMU_CAPS_IOTHREAD_THREAD_POOL_MAX */ + "usb-host.guest-resets-all", /* QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL */ );
@@ -1459,6 +1460,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPCIeRootPort[] =
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsUSBHost[] = { { "hostdevice", QEMU_CAPS_USB_HOST_HOSTDEVICE, NULL }, + { "guest-resets-all", QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL, NULL }, };
static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsSpaprPCIHostBridge[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 6f35ba1485..a409c1272c 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -650,6 +650,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */ QEMU_CAPS_CHARDEV_QEMU_VDAGENT, /* -chardev qemu-vdagent */ QEMU_CAPS_DISPLAY_DBUS, /* -display dbus */ QEMU_CAPS_IOTHREAD_THREAD_POOL_MAX, /* -object iothread.thread-pool-max */ + QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL, /* -device usb-host.guest-resets-all */
QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml index cc6e75884b..b4acdebb37 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.ppc64.xml @@ -135,6 +135,7 @@ <flag name='cpu-max'/> <flag name='input-linux'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>3001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml index 27be36f0ab..d62e543459 100644 --- a/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_3.1.0.x86_64.xml @@ -179,6 +179,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>3001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml index 7e0b8fbddf..cde5b4f54c 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.aarch64.xml @@ -147,6 +147,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml index 19bbbd1de3..c8726cbb22 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.ppc64.xml @@ -152,6 +152,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml index ef6f04f54b..81dcfaa5cb 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv32.xml @@ -144,6 +144,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml index 7c65aff290..ee855a1077 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.riscv64.xml @@ -144,6 +144,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml index 9b5ed96ba3..a0c186c41f 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml @@ -114,6 +114,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>39100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml index 3cf6a66389..d0fbb90c89 100644 --- a/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.0.0.x86_64.xml @@ -187,6 +187,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100240</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml index 5daa7bda75..363bcf0739 100644 --- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml @@ -194,6 +194,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml index 162ace7b2b..875e491581 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -162,6 +162,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml index 7c5275210b..428ecd4f42 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -159,6 +159,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml index ce5b782afd..725745593c 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -127,6 +127,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>39100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml index 9ee4c0534d..6a54c44d79 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -205,6 +205,7 @@ <flag name='input-linux'/> <flag name='query-display-options'/> <flag name='virtio-blk.queue-size'/> + <flag name='usb-host.guest-resets-all'/> <version>4002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml index 29ee31473f..35998cabf0 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -174,6 +174,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml index 1fdec901a6..b8ddf2e9a8 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -180,6 +180,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml index 3b58e7fece..c49c258255 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -166,6 +166,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml index bee5a84cf9..ce297f2ef5 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -214,6 +214,7 @@ <flag name='virtio-blk.queue-size'/> <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> + <flag name='usb-host.guest-resets-all'/> <version>5000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100241</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml index 070f64cb1c..a49650cbcc 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -218,6 +218,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml index 8e17532f3a..42a4418a08 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.aarch64.xml @@ -181,6 +181,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml index df02e264d7..d0dd058743 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.ppc64.xml @@ -185,6 +185,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml index 7cb4383693..25339f86d9 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.riscv64.xml @@ -171,6 +171,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>0</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml index cad4ed40e6..4ff03dbead 100644 --- a/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.2.0.x86_64.xml @@ -222,6 +222,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>5002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml index 4b4cc2d3aa..2d861da97b 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.aarch64.xml @@ -189,6 +189,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>6000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml index 8c61bf8a84..38acee5f18 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -231,6 +231,7 @@ <flag name='memory-backend-file.prealloc-threads'/> <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> + <flag name='usb-host.guest-resets-all'/> <version>6000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100242</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml index afd8f606eb..b03c6bfc24 100644 --- a/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.1.0.x86_64.xml @@ -236,6 +236,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6001000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml index 86fc46918f..942c0ba169 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.aarch64.xml @@ -201,6 +201,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6001050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml index 19605d93ae..32f226acbd 100644 --- a/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.2.0.x86_64.xml @@ -238,6 +238,7 @@ <flag name='virtio-iommu-pci'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6002000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml index e24e2235fb..f4d7cbdd10 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.aarch64.xml @@ -209,6 +209,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>6002092</version> <kvmVersion>0</kvmVersion> <microcodeVersion>61700243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml index 83e0f50e3a..2f895294de 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.ppc64.xml @@ -213,6 +213,7 @@ <flag name='virtio-iommu.boot-bypass'/> <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> + <flag name='usb-host.guest-resets-all'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>42900243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml index 05f844fd5b..17ea778d38 100644 --- a/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.0.0.x86_64.xml @@ -243,6 +243,7 @@ <flag name='virtio-net.rss'/> <flag name='chardev.qemu-vdagent'/> <flag name='display-dbus'/> + <flag name='usb-host.guest-resets-all'/> <version>7000000</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100243</microcodeVersion> diff --git a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml index 3707d9b7c9..5f5c839fea 100644 --- a/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_7.1.0.x86_64.xml @@ -244,6 +244,7 @@ <flag name='chardev.qemu-vdagent'/> <flag name='display-dbus'/> <flag name='iothread.thread-pool-max'/> + <flag name='usb-host.guest-resets-all'/> <version>7000050</version> <kvmVersion>0</kvmVersion> <microcodeVersion>43100244</microcodeVersion> -- 2.35.1

On 7/13/22 10:47, Ján Tomko wrote:
On a Tuesday in 2022, Michal Privoznik wrote:
We will need two attributes of usb-host device to set: guest-reset and guest-resets-all. The former was introduced in QEMU v4.0.0-rc0~56^2 and the other in v4.2.0-rc1~9^2. Hence, track the latter only as it's only starting from that commit when QEMU has both attributes.
Our qemucapabilitiesdata are wrong though, as they enable the capability for quite old releases (for instance 3.1.0 when neither of the attributes existed). But this is because I didn't use actual QEMU to refresh .replies files in v6.9.0-rc1~457. I just blindly copied particular reply around. But that's okay, it doesn't really hurt anything.
It hurts the usefulness of our test data. Just like in v6.9.0-rc1~457 you only added the relevant attribute only to QEMU versions that have it, you should delete it from older replies here, to demonstrate that the capability detection code actually works.
I'm not sure how capability detection could not have worked since I had to add <flag name='usb-host.guest-resets-all'/> to capabiliteis XMLs. Unless it would be set unconditionally, which it is not.
So there should be no "guest-reset" until QEMU 4.0.0, no "guest-resets-all" until QEMU 4.2.0 and while you're at it, "hostdevice" was added in QEMU 5.1.0 by 9f815e83e983d and so was "suppress-remote-wake" by 7bacaf5fea
I guess I just wanted to save myself from useless work since we are going to drop those files soon. But okay, let me post a patch to clean up those files. Michal

Now that we have a capability, validate that the QEMU we are talking to has everything we need for guestReset. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_validate.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 39210ba65b..764d5b029e 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -2543,6 +2543,14 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHostdevDef *hostdev, if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { switch ((virDomainHostdevSubsysType) hostdev->source.subsys.type) { case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: + if (hostdev->source.subsys.u.usb.guestReset && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_HOST_GUESTS_RESETS_ALL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("guestReset is not supported with this version of QEMU")); + return -1; + } + break; + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: break; -- 2.35.1

On a Tuesday in 2022, Michal Privoznik wrote:
Now that we have a capability, validate that the QEMU we are talking to has everything we need for guestReset.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_validate.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

QEMU offers two attributes for handling reset requests of an USB host device: guest-reset and guest-resets-all. When combined they act as follows: 1) guest-reset=false The guest is not allowed to reset the physical USB device. 2) guest-reset=true,guest-resets-all=false The guest is allowed to reset the device when it is not yet initialized (aka no USB bus address assigned). Usually this results in one guest reset being allowed. This is the default behavior. 3) guest-reset=true,guest-resets-all=true The guest is allowed to reset the device as it pleases. Now, there's a clear 1:1 mapping with our representation of guestReset, so generating cmd line is trivial. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 21 +++++++++++++++++++ .../hostdev-usb-address.x86_64-latest.args | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b307d3139c..262fffe5fe 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5001,6 +5001,8 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, unsigned int hostbus = 0; unsigned int hostaddr = 0; g_autofree char *hostdevice = NULL; + virTristateSwitch guestReset = VIR_TRISTATE_SWITCH_ABSENT; + virTristateSwitch guestResetsAll = VIR_TRISTATE_SWITCH_ABSENT; if (!dev->missing) { if (usbsrc->bus == 0 && usbsrc->device == 0) { @@ -5018,6 +5020,23 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, } } + switch (usbsrc->guestReset) { + case VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_OFF: + guestReset = VIR_TRISTATE_SWITCH_OFF; + break; + case VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_UNINITIALIZED: + guestReset = VIR_TRISTATE_SWITCH_ON; + guestResetsAll = VIR_TRISTATE_SWITCH_OFF; + break; + case VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_ON: + guestReset = VIR_TRISTATE_SWITCH_ON; + guestResetsAll = VIR_TRISTATE_SWITCH_ON; + break; + case VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_DEFAULT: + case VIR_DOMAIN_HOSTDEV_USB_GUEST_RESET_LAST: + break; + } + if (virJSONValueObjectAdd(&props, "s:driver", "usb-host", "S:hostdevice", hostdevice, @@ -5025,6 +5044,8 @@ qemuBuildUSBHostdevDevProps(const virDomainDef *def, "p:hostaddr", hostaddr, "s:id", dev->info->alias, "p:bootindex", dev->info->bootIndex, + "T:guest-reset", guestReset, + "T:guest-resets-all", guestResetsAll, NULL) < 0) return NULL; diff --git a/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args b/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args index f59c463f5e..978e6a6e6d 100644 --- a/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args +++ b/tests/qemuxml2argvdata/hostdev-usb-address.x86_64-latest.args @@ -32,6 +32,6 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -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}' \ -audiodev '{"id":"audio1","driver":"none"}' \ --device '{"driver":"usb-host","hostdevice":"/dev/bus/usb/014/006","id":"hostdev0","bus":"usb.0","port":"1"}' \ +-device '{"driver":"usb-host","hostdevice":"/dev/bus/usb/014/006","id":"hostdev0","guest-reset":true,"guest-resets-all":false,"bus":"usb.0","port":"1"}' \ -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ -msg timestamp=on -- 2.35.1

On a Tuesday in 2022, Michal Privoznik wrote:
QEMU offers two attributes for handling reset requests of an USB host device: guest-reset and guest-resets-all. When combined they act as follows:
1) guest-reset=false The guest is not allowed to reset the physical USB device.
2) guest-reset=true,guest-resets-all=false The guest is allowed to reset the device when it is not yet initialized (aka no USB bus address assigned). Usually this results in one guest reset being allowed. This is the default behavior.
3) guest-reset=true,guest-resets-all=true The guest is allowed to reset the device as it pleases.
Now, there's a clear 1:1 mapping with our representation of guestReset, so generating cmd line is trivial.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/qemu/qemu_command.c | 21 +++++++++++++++++++ .../hostdev-usb-address.x86_64-latest.args | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (3)
-
Ján Tomko
-
Michal Privoznik
-
Michal Prívozník