virtio,pc,acpi: fixes, tests
changes from v1:
rebased on master
pick a fixed patch version - noticed by Raphael
The following changes since commit e883b492c221241d28aaa322c61536436090538a:
Merge remote-tracking branch 'remotes/legoater/tags/pull-aspeed-20200918' into staging (2020-09-18 13:36:42 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to b98061bc65dae34cfabcfe2c123a5b14347c6135:
virtio-iommu-pci: force virtio version 1 (2020-09-18 12:18:05 -0400)
----------------------------------------------------------------
virtio,pc,acpi: fixes, tests
Fixes and tests all over the place.
Batch iommu updates for vdpa.
Removal of deprecated cpu hotplug commands.
----------------------------------------------------------------
David Hildenbrand (1):
pc: fix auto_enable_numa_with_memhp/auto_enable_numa_with_memdev for the 5.0 machine
Dima Stepanov (7):
vhost: recheck dev state in the vhost_migration_log routine
vhost: check queue state in the vhost_dev_set_log routine tests/qtest/vhost-user-test: prepare the tests for adding new dev class tests/qtest/libqos/virtio-blk: add support for vhost-user-blk tests/qtest/vhost-user-test: add support for the vhost-user-blk device tests/qtest/vhost-user-test: add migrate_reconnect test tests/qtest/vhost-user-test: enable the reconnect tests
Eric Auger (2):
virtio-iommu: Check gtrees are non null before destroying them
virtio-iommu-pci: force virtio version 1
Igor Mammedov (1):
cphp: remove deprecated cpu-add command(s)
Jason Wang (3):
linux headers: sync to 5.9-rc4
vhost: switch to use IOTLB v2 format
vhost-vdpa: batch updating IOTLB mappings
Li Qiang (1):
virtio-mem: detach the element from the virtqueue when error occurs
qapi/machine.json | 24 -- include/hw/boards.h | 1 - include/hw/i386/pc.h | 1 - include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost-user-blk.h | 10 + include/hw/virtio/vhost-vdpa.h | 1 + include/hw/virtio/vhost.h | 1 + include/monitor/hmp.h | 1 - include/standard-headers/drm/drm_fourcc.h | 140 ++++++++++ include/standard-headers/linux/ethtool.h | 87 +++++++ include/standard-headers/linux/input-event-codes.h | 3 +- include/standard-headers/linux/vhost_types.h | 11 + include/standard-headers/linux/virtio_9p.h | 4 +- include/standard-headers/linux/virtio_blk.h | 26 +- include/standard-headers/linux/virtio_config.h | 8 +- include/standard-headers/linux/virtio_console.h | 8 +- include/standard-headers/linux/virtio_net.h | 6 +- include/standard-headers/linux/virtio_scsi.h | 20 +- linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/kvm.h | 5 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/kvm.h | 7 +- linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 4 + linux-headers/linux/vfio.h | 2 +- linux-headers/linux/vhost.h | 2 + hw/block/vhost-user-blk.c | 19 +- hw/core/machine-hmp-cmds.c | 12 - hw/core/machine-qmp-cmds.c | 12 - hw/i386/pc.c | 27 -- hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 2 +- hw/s390x/s390-virtio-ccw.c | 12 - hw/virtio/vhost-backend.c | 88 +++++-- hw/virtio/vhost-vdpa.c | 66 +++++ hw/virtio/vhost.c | 49 +++- hw/virtio/virtio-iommu-pci.c | 2 +- hw/virtio/virtio-iommu.c | 8 +- hw/virtio/virtio-mem.c | 3 + tests/qtest/cpu-plug-test.c | 100 +------ tests/qtest/libqos/virtio-blk.c | 14 +- tests/qtest/test-hmp.c | 1 - tests/qtest/vhost-user-test.c | 290 ++++++++++++++++++--- docs/system/deprecated.rst | 25 +- hmp-commands.hx | 15 -- 53 files changed, 813 insertions(+), 323 deletions(-)
[PULL v2 01/15] linux headers: sync to 5.9-rc4
From: Jason Wang <[email protected]>
Update against Linux 5.9-rc4.
Message-Id: <[email protected]>
--- include/standard-headers/drm/drm_fourcc.h | 140 ++++++++++++++++++ include/standard-headers/linux/ethtool.h | 87 +++++++++++ .../linux/input-event-codes.h | 3 +- include/standard-headers/linux/vhost_types.h | 11 ++ include/standard-headers/linux/virtio_9p.h | 4 +- include/standard-headers/linux/virtio_blk.h | 26 ++-- .../standard-headers/linux/virtio_config.h | 8 +- .../standard-headers/linux/virtio_console.h | 8 +- include/standard-headers/linux/virtio_net.h | 6 +- include/standard-headers/linux/virtio_scsi.h | 20 +-- linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/kvm.h | 5 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/kvm.h | 7 +- linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 4 + linux-headers/linux/vfio.h | 2 +- linux-headers/linux/vhost.h | 2 + 26 files changed, 308 insertions(+), 41 deletions(-)
include/standard-headers/drm/drm_fourcc.h +140 -0
@@ -235,6 +235,12 @@ extern "C" {#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1')/* 2x1 subsampled Cb:Cr plane */ #define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4')/* non-subsampled Cr:Cb plane */ #define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2')/* non-subsampled Cb:Cr plane */ +/* +* 2 plane YCbCr +* index 0 = Y plane, [39:0] Y3:Y2:Y1:Y0 little endian +* index 1 = Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian +*/ +#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5')/* 2x2 subsampled Cr:Cb plane */ /* * 2 plane YCbCr MSB aligned
@@ -264,6 +270,22 @@ extern "C" {*/ #define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6')/* 2x2 subsampled Cr:Cb plane 16 bits per channel */ +/* 3 plane non-subsampled (444) YCbCr +* 16 bits per component, but only 10 bits are used and 6 bits are padded +* index 0: Y plane, [15:0] Y:x [10:6] little endian +* index 1: Cb plane, [15:0] Cb:x [10:6] little endian +* index 2: Cr plane, [15:0] Cr:x [10:6] little endian +*/ +#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') + +/* 3 plane non-subsampled (444) YCrCb +* 16 bits per component, but only 10 bits are used and 6 bits are padded +* index 0: Y plane, [15:0] Y:x [10:6] little endian +* index 1: Cr plane, [15:0] Cr:x [10:6] little endian +* index 2: Cb plane, [15:0] Cb:x [10:6] little endian +*/ +#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') +/* * 3 plane YCbCr * index 0: Y plane, [7:0] Y
@@ -308,6 +330,7 @@ extern "C" {#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07#define DRM_FORMAT_MOD_VENDOR_ARM 0x08#define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 +#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a/* add more to the end as needed */
@@ -322,8 +345,33 @@ extern "C" {* When adding a new token please document the layout with a code comment, * similar to the fourcc codes above. drm_fourcc.h is considered the * authoritative source for all of these. +* +* Generic modifier names: +* +* DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral names +* for layouts which are common across multiple vendors. To preserve +* compatibility, in cases where a vendor-specific definition already exists and +* a generic name for it is desired, the common name is a purely symbolic alias +* and must use the same numerical value as the original definition. +* +* Note that generic names should only be used for modifiers which describe +* generic layouts (such as pixel re-ordering), which may have +* independently-developed support across multiple vendors. +* +* In future cases where a generic layout is identified before merging with a +* vendor-specific modifier, a new 'GENERIC' vendor or modifier using vendor +* 'NONE' could be considered. This should only be for obvious, exceptional +* cases to avoid polluting the 'GENERIC' namespace with modifiers which only +* apply to a single vendor. +* +* Generic names should not be used for cases where multiple hardware vendors +* have implementations of the same standardised compression scheme (such as +* AFBC). In those cases, all implementations should use the same format +* modifier(s), reflecting the vendor of the standard. */ +#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE +/* * Invalid Modifier *
@@ -891,6 +939,18 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t modifier)*/ #define AFBC_FORMAT_MOD_BCH (1ULL << 11) +/* AFBC uncompressed storage mode +* +* Indicates that the buffer is using AFBC uncompressed storage mode. +* In this mode all superblock payloads in the buffer use the uncompressed +* storage mode, which is usually only used for data which cannot be compressed. +* The buffer layout is the same as for AFBC buffers without USM set, this only +* affects the storage mode of the individual superblocks. Note that even a +* buffer without USM set may use uncompressed storage mode for some or all +* superblocks, USM just guarantees it for all. +*/ +#define AFBC_FORMAT_MOD_USM (1ULL << 12) +/* * Arm 16x16 Block U-Interleaved modifier *
@@ -915,6 +975,86 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t modifier)*/ #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) +/* +* Amlogic Video Framebuffer Compression modifiers +* +* Amlogic uses a proprietary lossless image compression protocol and format +* for their hardware video codec accelerators, either video decoders or +* video input encoders. +* +* It considerably reduces memory bandwidth while writing and reading +* frames in memory. +* +* The underlying storage is considered to be 3 components, 8bit or 10-bit +* per component YCbCr 420, single plane : +* - DRM_FORMAT_YUV420_8BIT +* - DRM_FORMAT_YUV420_10BIT +* +* The first 8 bits of the mode defines the layout, then the following 8 bits +* defines the options changing the layout. +* +* Not all combinations are valid, and different SoCs may support different +* combinations of layout and options. +*/ +#define __fourcc_mod_amlogic_layout_mask 0xf +#define __fourcc_mod_amlogic_options_shift 8 +#define __fourcc_mod_amlogic_options_mask 0xf + +#define DRM_FORMAT_MOD_AMLOGIC_FBC (__layout, __options) \ + fourcc_mod_code(AMLOGIC, \ + ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ + (((__options) & __fourcc_mod_amlogic_options_mask) \ + << __fourcc_mod_amlogic_options_shift)) + +/* Amlogic FBC Layouts */ + +/* +* Amlogic FBC Basic Layout +* +* The basic layout is composed of: +* - a body content organized in 64x32 superblocks with 4096 bytes per +* superblock in default mode. +* - a 32 bytes per 128x64 header block +* +* This layout is transferrable between Amlogic SoCs supporting this modifier. +*/ +#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) + +/* +* Amlogic FBC Scatter Memory layout +* +* Indicates the header contains IOMMU references to the compressed +* frames content to optimize memory access and layout. +* +* In this mode, only the header memory address is needed, thus the +* content memory organization is tied to the current producer +* execution and cannot be saved/dumped neither transferrable between +* Amlogic SoCs supporting this modifier. +* +* Due to the nature of the layout, these buffers are not expected to +* be accessible by the user-space clients, but only accessible by the +* hardware producers and consumers. +* +* The user-space clients should expect a failure while trying to mmap +* the DMA-BUF handle returned by the producer. +*/ +#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) + +/* Amlogic FBC Layout Options Bit Mask */ + +/* +* Amlogic FBC Memory Saving mode +* +* Indicates the storage is packed when pixel size is multiple of word +* boudaries, i.e. 8bit should be stored in this mode to save allocation +* memory. +* +* This mode reduces body layout to 3072 bytes per 64x32 superblock with +* the basic layout and 3200 bytes per 64x32 superblock combined with +* the scatter layout. +*/ +#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) +#if defined(__cplusplus) }#endif
include/standard-headers/linux/ethtool.h +87 -0
111 lines not on this page · raw message
include/standard-headers/linux/input-event-codes.h +2 -1
@@ -888,7 +888,8 @@#define SW_LINEIN_INSERT 0x0d/* set = inserted */ #define SW_MUTE_DEVICE 0x0e/* set = device disabled */ #define SW_PEN_INSERTED 0x0f/* set = pen inserted */ -#define SW_MAX_ 0x0f +#define SW_MACHINE_COVER 0x10/* set = cover closed */ +#define SW_MAX_ 0x10#define SW_CNT (SW_MAX_+1)/*
include/standard-headers/linux/vhost_types.h +11 -0
@@ -60,6 +60,17 @@ struct vhost_iotlb_msg {#define VHOST_IOTLB_UPDATE 2#define VHOST_IOTLB_INVALIDATE 3#define VHOST_IOTLB_ACCESS_FAIL 4 +/* +* VHOST_IOTLB_BATCH_BEGIN and VHOST_IOTLB_BATCH_END allow modifying +* multiple mappings in one go: beginning with +* VHOST_IOTLB_BATCH_BEGIN, followed by any number of +* VHOST_IOTLB_UPDATE messages, and ending with VHOST_IOTLB_BATCH_END. +* When one of these two values is used as the message type, the rest +* of the fields in the message are ignored. There's no guarantee that +* these changes take place automatically in the device. +*/ +#define VHOST_IOTLB_BATCH_BEGIN 5 +#define VHOST_IOTLB_BATCH_END 6uint8_t type; };
include/standard-headers/linux/virtio_9p.h +2 -2
@@ -25,7 +25,7 @@* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "standard-headers/linux/types.h" +#include "standard-headers/linux/virtio_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_config.h"
@@ -36,7 +36,7 @@struct virtio_9p_config {/* length of the tag name */ -uint16_t tag_len; +__virtio16 tag_len;/* non-NULL terminated tag name */ uint8_t tag[0 ]; }QEMU_PACKED ;
include/standard-headers/linux/virtio_blk.h +13 -13
@@ -55,20 +55,20 @@struct virtio_blk_config {/* The capacity (in 512-byte sectors). */ -uint64_t capacity; +__virtio64 capacity;/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ -uint32_t size_max; +__virtio32 size_max;/* The maximum number of segments (if VIRTIO_BLK_F_SEG_MAX) */ -uint32_t seg_max; +__virtio32 seg_max;/* geometry of the device (if VIRTIO_BLK_F_GEOMETRY) */ struct virtio_blk_geometry { -uint16_t cylinders; +__virtio16 cylinders;uint8_t heads;uint8_t sectors; } geometry;/* block size of device (if VIRTIO_BLK_F_BLK_SIZE) */ -uint32_t blk_size; +__virtio32 blk_size;/* the next 4 entries are guarded by VIRTIO_BLK_F_TOPOLOGY */ /* exponent for physical block per logical block. */
@@ -76,42 +76,42 @@ struct virtio_blk_config {/* alignment offset in logical blocks. */ uint8_t alignment_offset;/* minimum I/O size without performance penalty in logical blocks. */ -uint16_t min_io_size; +__virtio16 min_io_size;/* optimal sustained I/O size in logical blocks. */ -uint32_t opt_io_size; +__virtio32 opt_io_size;/* writeback mode (if VIRTIO_BLK_F_CONFIG_WCE) */ uint8_t wce;uint8_t unused;/* number of vqs, only available when VIRTIO_BLK_F_MQ is set */ -uint16_t num_queues; +__virtio16 num_queues;/* the next 3 entries are guarded by VIRTIO_BLK_F_DISCARD */ /* * The maximum discard sectors (in 512-byte sectors) for * one segment. */ -uint32_t max_discard_sectors; +__virtio32 max_discard_sectors;/* * The maximum number of discard segments in a * discard command. */ -uint32_t max_discard_seg; +__virtio32 max_discard_seg;/* Discard commands must be aligned to this number of sectors. */ -uint32_t discard_sector_alignment; +__virtio32 discard_sector_alignment;/* the next 3 entries are guarded by VIRTIO_BLK_F_WRITE_ZEROES */ /* * The maximum number of write zeroes sectors (in 512-byte sectors) in * one segment. */ -uint32_t max_write_zeroes_sectors; +__virtio32 max_write_zeroes_sectors;/* * The maximum number of segments in a write zeroes * command. */ -uint32_t max_write_zeroes_seg; +__virtio32 max_write_zeroes_seg;/* * Set if a VIRTIO_BLK_T_WRITE_ZEROES request may result in the * deallocation of one or more of the sectors.
include/standard-headers/linux/virtio_config.h +5 -3
@@ -67,13 +67,15 @@#define VIRTIO_F_VERSION_1 32/* -* If clear - device has the IOMMU bypass quirk feature. -* If set - use platform tools to detect the IOMMU. +* If clear - device has the platform DMA (e.g. IOMMU) bypass quirk feature. +* If set - use platform DMA tools to access the memory. * * Note the reverse polarity (compared to most other features), * this is for compatibility with legacy systems. */ -#define VIRTIO_F_IOMMU_PLATFORM 33 +#define VIRTIO_F_ACCESS_PLATFORM 33 +/* Legacy name for VIRTIO_F_ACCESS_PLATFORM (for compatibility with old userspace) */ +#define VIRTIO_F_IOMMU_PLATFORM VIRTIO_F_ACCESS_PLATFORM/* This feature indicates support for the packed virtqueue layout. */ #define VIRTIO_F_RING_PACKED 34
include/standard-headers/linux/virtio_console.h +4 -4
@@ -45,13 +45,13 @@struct virtio_console_config {/* colums of the screens */ -uint16_t cols; +__virtio16 cols;/* rows of the screens */ -uint16_t rows; +__virtio16 rows;/* max. number of ports this device can hold */ -uint32_t max_nr_ports; +__virtio32 max_nr_ports;/* emergency write register */ -uint32_t emerg_wr; +__virtio32 emerg_wr; }QEMU_PACKED ;/*
include/standard-headers/linux/virtio_net.h +3 -3
@@ -87,14 +87,14 @@ struct virtio_net_config {/* The config defining mac address (if VIRTIO_NET_F_MAC) */ uint8_t mac[ETH_ALEN ];/* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ -uint16_t status; +__virtio16 status;/* Maximum number of each of transmit and receive queues; * see VIRTIO_NET_F_MQ and VIRTIO_NET_CTRL_MQ. * Legal values are between 1 and 0x8000 */ -uint16_t max_virtqueue_pairs; +__virtio16 max_virtqueue_pairs;/* Default maximum transmit unit advice */ -uint16_t mtu; +__virtio16 mtu;/* * speed, in units of 1Mb. All values 0 to INT_MAX are legal. * Any other value stands for unknown.
include/standard-headers/linux/virtio_scsi.h +10 -10
@@ -103,16 +103,16 @@ struct virtio_scsi_event { }QEMU_PACKED ;struct virtio_scsi_config { -uint32_t num_queues; -uint32_t seg_max; -uint32_t max_sectors; -uint32_t cmd_per_lun; -uint32_t event_info_size; -uint32_t sense_size; -uint32_t cdb_size; -uint16_t max_channel; -uint16_t max_target; -uint32_t max_lun; +__virtio32 num_queues; +__virtio32 seg_max; +__virtio32 max_sectors; +__virtio32 cmd_per_lun; +__virtio32 event_info_size; +__virtio32 sense_size; +__virtio32 cdb_size; +__virtio16 max_channel; +__virtio16 max_target; +__virtio32 max_lun; }QEMU_PACKED ;/* Feature Bits */
linux-headers/asm-generic/unistd.h +4 -2
@@ -606,9 +606,9 @@ __SYSCALL(__NR_sendto, sys_sendto)#define __NR_recvfrom 207 __SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom)#define __NR_setsockopt 208 -__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt) +__SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt)#define __NR_getsockopt 209 -__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt) +__SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt)#define __NR_shutdown 210 __SYSCALL(__NR_shutdown, sys_shutdown)#define __NR_sendmsg 211
@@ -850,6 +850,8 @@ __SYSCALL(__NR_pidfd_open, sys_pidfd_open)#define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3)#endif +#define __NR_close_range 436 +__SYSCALL(__NR_close_range, sys_close_range)#define __NR_openat2 437__SYSCALL (__NR_openat2, sys_openat2)
linux-headers/asm-mips/unistd_n32.h +1 -0
@@ -365,6 +365,7 @@#define __NR_fspick (__NR_Linux + 433)#define __NR_pidfd_open (__NR_Linux + 434)#define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436)#define __NR_openat2 (__NR_Linux + 437)#define __NR_pidfd_getfd (__NR_Linux + 438)#define __NR_faccessat2 (__NR_Linux + 439)
linux-headers/asm-mips/unistd_n64.h +1 -0
@@ -341,6 +341,7 @@#define __NR_fspick (__NR_Linux + 433)#define __NR_pidfd_open (__NR_Linux + 434)#define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436)#define __NR_openat2 (__NR_Linux + 437)#define __NR_pidfd_getfd (__NR_Linux + 438)#define __NR_faccessat2 (__NR_Linux + 439)
linux-headers/asm-mips/unistd_o32.h +1 -0
@@ -411,6 +411,7 @@#define __NR_fspick (__NR_Linux + 433)#define __NR_pidfd_open (__NR_Linux + 434)#define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436)#define __NR_openat2 (__NR_Linux + 437)#define __NR_pidfd_getfd (__NR_Linux + 438)#define __NR_faccessat2 (__NR_Linux + 439)
linux-headers/asm-powerpc/kvm.h +5 -0
@@ -640,6 +640,11 @@ struct kvm_ppc_cpu_char {#define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)#define KVM_REG_PPC_PTCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc0) +/* POWER10 registers */ +#define KVM_REG_PPC_MMCR3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc1) +#define KVM_REG_PPC_SIER2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc2) +#define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3) +/* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs */
linux-headers/asm-powerpc/unistd_32.h +1 -0
@@ -418,6 +418,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-powerpc/unistd_64.h +1 -0
@@ -390,6 +390,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-s390/kvm.h +5 -2
@@ -231,11 +231,13 @@ struct kvm_guest_debug_arch {#define KVM_SYNC_GSCB (1UL << 9)#define KVM_SYNC_BPBC (1UL << 10)#define KVM_SYNC_ETOKEN (1UL << 11) +#define KVM_SYNC_DIAG318 (1UL << 12)#define KVM_SYNC_S390_VALID_FIELDS \ (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \ KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \ - KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN) + KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \ + KVM_SYNC_DIAG318)/* length and alignment of the sdnx as a power of two */ #define SDNXC 8
@@ -264,7 +266,8 @@ struct kvm_sync_regs { __u8 reserved2 : 7;__u8 padding1[51 ];/* riccb needs to be 64byte aligned */ __u8 riccb[64 ];/* runtime instrumentation controls block */ -__u8 padding2[192 ];/* sdnx needs to be 256byte aligned */ +__u64 diag318;/* diagnose 0x318 info */ +__u8 padding2[184 ];/* sdnx needs to be 256byte aligned */ union {__u8 sdnx[SDNXL ];/* state description annex */ struct {
linux-headers/asm-s390/unistd_32.h +1 -0
@@ -408,6 +408,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-s390/unistd_64.h +1 -0
@@ -356,6 +356,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-x86/unistd_32.h +1 -0
@@ -426,6 +426,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-x86/unistd_64.h +1 -0
@@ -348,6 +348,7 @@#define __NR_fspick 433#define __NR_pidfd_open 434#define __NR_clone3 435 +#define __NR_close_range 436#define __NR_openat2 437#define __NR_pidfd_getfd 438#define __NR_faccessat2 439
linux-headers/asm-x86/unistd_x32.h +1 -0
@@ -301,6 +301,7 @@#define __NR_fspick (__X32_SYSCALL_BIT + 433)#define __NR_pidfd_open (__X32_SYSCALL_BIT + 434)#define __NR_clone3 (__X32_SYSCALL_BIT + 435) +#define __NR_close_range (__X32_SYSCALL_BIT + 436)#define __NR_openat2 (__X32_SYSCALL_BIT + 437)#define __NR_pidfd_getfd (__X32_SYSCALL_BIT + 438)#define __NR_faccessat2 (__X32_SYSCALL_BIT + 439)
linux-headers/linux/kvm.h +4 -0
@@ -289,6 +289,7 @@ struct kvm_run {/* KVM_EXIT_FAIL_ENTRY */ struct {__u64 hardware_entry_failure_reason; +__u32 cpu; } fail_entry;/* KVM_EXIT_EXCEPTION */ struct {
@@ -1031,6 +1032,9 @@ struct kvm_ppc_resize_hpt {#define KVM_CAP_PPC_SECURE_GUEST 181#define KVM_CAP_HALT_POLL 182#define KVM_CAP_ASYNC_PF_INT 183 +#define KVM_CAP_LAST_CPU 184 +#define KVM_CAP_SMALLER_MAXPHYADDR 185 +#define KVM_CAP_S390_DIAG318 186#ifdef KVM_CAP_IRQ_ROUTING
linux-headers/linux/vfio.h +1 -1
@@ -1030,7 +1030,7 @@ struct vfio_iommu_type1_info_cap_iova_range {* size in bytes that can be used by user applications when getting the dirty * bitmap. */ -#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 1 +#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2struct vfio_iommu_type1_info_cap_migration {struct vfio_info_cap_header header;
linux-headers/linux/vhost.h +2 -0
@@ -91,6 +91,8 @@/* Use message type V2 */ #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 +/* IOTLB can accept batching hints */ +#define VHOST_BACKEND_F_IOTLB_BATCH 0x2#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
Signature · 1 line
MST
[PULL v2 09/15] tests/qtest/libqos/virtio-blk: add support for vhost-user-blk
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
Add support for the vhost-user-blk-pci device. This node can be used by the vhost-user-blk tests. Tests for the vhost-user-blk device are added in the following patches.
Message-Id: <4d3e683a87557bcef520826c54aa3e5ab7c64111.1599813294.git.dimastep@yandex-team.ru>
--- tests/qtest/libqos/virtio-blk.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tests/qtest/libqos/virtio-blk.c +13 -1
@@ -30,7 +30,8 @@static void *qvirtio_blk_get_driver (QVirtioBlk *v_blk,const char *interface) { -if (!g_strcmp0 (interface,"virtio-blk" )) { +if (!g_strcmp0 (interface,"virtio-blk" ) || + !g_strcmp0 (interface,"vhost-user-blk" )) {return v_blk; }if (!g_strcmp0 (interface,"virtio" )) {
@@ -120,6 +121,17 @@ static void virtio_blk_register_nodes(void)qos_node_produces ("virtio-blk-pci" ,"virtio-blk" );g_free (arg); + +/* vhost-user-blk-pci */ + arg =g_strdup_printf ("id=drv0,chardev=chdev0,addr=%x.%x" , +PCI_SLOT ,PCI_FN ); + opts.extra_device_opts = arg; +add_qpci_address (&opts, &addr); +qos_node_create_driver ("vhost-user-blk-pci" , virtio_blk_pci_create); +qos_node_consumes ("vhost-user-blk-pci" ,"pci-bus" , &opts); +qos_node_produces ("vhost-user-blk-pci" ,"vhost-user-blk" ); + +g_free (arg); }libqos_init (virtio_blk_register_nodes);
Signature · 1 line
MST
[PULL v2 04/15] virtio-mem: detach the element from the virtqueue when error occurs
In reply to Michael S. TsirkinFrom: Li Qiang <[email protected]>
If error occurs while processing the virtio request we should call 'virtqueue_detach_element' to detach the element from the virtqueue before free the elem.
Message-Id: <[email protected]>
--- hw/virtio/virtio-mem.c | 3 +++ 1 file changed, 3 insertions(+)
hw/virtio/virtio-mem.c +3 -0
@@ -318,6 +318,7 @@ static void virtio_mem_handle_request(VirtIODevice *vdev, VirtQueue *vq)if (iov_to_buf (elem->out_sg, elem->out_num,0 , &req, len) < len) {virtio_error (vdev,"virtio-mem protocol violation: invalid request" " size: %d" , len); +virtqueue_detach_element (vq, elem,0 );g_free (elem);return ; }
@@ -327,6 +328,7 @@ static void virtio_mem_handle_request(VirtIODevice *vdev, VirtQueue *vq)virtio_error (vdev,"virtio-mem protocol violation: not enough space" " for response: %zu" ,iov_size (elem->in_sg, elem->in_num)); +virtqueue_detach_element (vq, elem,0 );g_free (elem);return ; }
@@ -348,6 +350,7 @@ static void virtio_mem_handle_request(VirtIODevice *vdev, VirtQueue *vq)default :virtio_error (vdev,"virtio-mem protocol violation: unknown request" " type: %d" , type); +virtqueue_detach_element (vq, elem,0 );g_free (elem);return ; }
Signature · 1 line
MST
[PULL v2 02/15] vhost: switch to use IOTLB v2 format
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
This patch tries to switch to use new kernel IOTLB format V2. Previous version may have inconsistent ABI between 32bit and 64bit machines because of the hole after type field. Refer kernel commit ("429711aec282 vhost: switch to use new message format") for more information.
To enable this feature, qemu need to use a new ioctl VHOST_SET_BACKEND_FEATURE with VHOST_BACKEND_F_IOTLB_MSG_V2 bit. A new vhost setting backend features ops was introduced. And when we try to set features for vhost dev, we will examine the support of new IOTLB format and enable it. This process is total transparent to guest, which means we can have different IOTLB message type in src and dst during migration.
The conversion of IOTLB message is straightforward, just check the type and behave accordingly.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost.h | 1 + hw/virtio/vhost-backend.c | 88 +++++++++++++++++++++++++------ hw/virtio/vhost.c | 10 ++++ 4 files changed, 84 insertions(+), 17 deletions(-)
include/hw/virtio/vhost-backend.h +2 -0
@@ -74,6 +74,7 @@ typedef int (*vhost_set_features_op)(struct vhost_dev *dev, uint64_t features);typedef int (*vhost_get_features_op )(struct vhost_dev *dev,uint64_t *features); +typedef int (*vhost_set_backend_cap_op )(struct vhost_dev *dev);typedef int (*vhost_set_owner_op )(struct vhost_dev *dev);typedef int (*vhost_reset_device_op )(struct vhost_dev *dev);typedef int (*vhost_get_vq_index_op )(struct vhost_dev *dev,int idx);
@@ -146,6 +147,7 @@ typedef struct VhostOps {vhost_set_vring_busyloop_timeout_op vhost_set_vring_busyloop_timeout;vhost_set_features_op vhost_set_features;vhost_get_features_op vhost_get_features; +vhost_set_backend_cap_op vhost_set_backend_cap;vhost_set_owner_op vhost_set_owner;vhost_reset_device_op vhost_reset_device;vhost_get_vq_index_op vhost_get_vq_index;
include/hw/virtio/vhost.h +1 -0
@@ -79,6 +79,7 @@ struct vhost_dev {uint64_t backend_features;uint64_t protocol_features;uint64_t max_queues; +uint64_t backend_cap;bool started;bool log_enabled;uint64_t log_size;
hw/virtio/vhost-backend.c +71 -17
117 lines not on this page · raw message
hw/virtio/vhost.c +10 -0
@@ -818,7 +818,17 @@ static int vhost_dev_set_features(struct vhost_dev *dev, r = dev->vhost_ops->vhost_set_features (dev, features);if (r <0 ) {VHOST_OPS_DEBUG ("vhost_set_features failed" ); + goto out; } +if (dev->vhost_ops->vhost_set_backend_cap) { + r = dev->vhost_ops->vhost_set_backend_cap (dev); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_set_backend_cap failed" ); + goto out; + } + } + +out:return r <0 ? -errno :0 ; }
Signature · 1 line
MST
[PULL v2 07/15] vhost: check queue state in the vhost_dev_set_log routine
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
If the vhost-user-blk daemon provides only one virtqueue, but device was added with several queues, then QEMU will send more VHOST-USER command than expected by daemon side. The vhost_virtqueue_start() routine handles such case by checking the return value from the virtio_queue_get_desc_addr() function call. Add the same check to the vhost_dev_set_log() routine.
Message-Id: <6232946d5af09e9775076645909964a6539b8ab5.1599813294.git.dimastep@yandex-team.ru>
--- hw/virtio/vhost.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
hw/virtio/vhost.c +12 -0
@@ -835,12 +835,24 @@ out:static int vhost_dev_set_log (struct vhost_dev *dev,bool enable_log) {int r, i, idx; +hwaddr addr; + r =vhost_dev_set_features (dev, enable_log);if (r <0 ) { goto err_features; }for (i =0 ; i < dev->nvqs; ++i) { idx = dev->vhost_ops->vhost_get_vq_index (dev, dev->vq_index + i); + addr =virtio_queue_get_desc_addr (dev->vdev, idx); +if (!addr) { +/* +* The queue might not be ready for start. If this +* is the case there is no reason to continue the process. +* The similar logic is used by the vhost_virtqueue_start() +* routine. +*/ +continue ; + } r =vhost_virtqueue_set_addr (dev, dev->vqs + i, idx, enable_log);if (r <0 ) {
Signature · 1 line
MST
[PULL v2 03/15] vhost-vdpa: batch updating IOTLB mappings
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
To speed up the memory mapping updating between vhost-vDPA and vDPA device driver, this patch passes the IOTLB batching flags via IOTLB API. Two new flags was introduced, VHOST_IOTLB_BATCH_BEGIN is a hint that a bathced IOTLB updating may be initiated from the userspace. VHOST_IOTLB_BATCH_END is a hint that userspace has finished the updating:
VHOST_IOTLB_BATCH_BEGIN
VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE
...VHOST_IOTLB_BATCH_END
Vhost-vDPA can then know that all mappings has been set and can do optimization like passing all the mappings to the vDPA device driver.
Message-Id: <[email protected]>
--- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 66 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
include/hw/virtio/vhost-vdpa.h +1 -0
@@ -18,6 +18,7 @@ typedef struct vhost_vdpa {int device_fd;uint32_t msg_type;MemoryListener listener; +struct vhost_dev *dev; } VhostVDPA;extern AddressSpace address_space_memory;
hw/virtio/vhost-vdpa.c +66 -0
96 lines not on this page · raw message
Signature · 1 line
MST
[PULL v2 06/15] vhost: recheck dev state in the vhost_migration_log routine
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
vhost-user devices can get a disconnect in the middle of the VHOST-USER handshake on the migration start. If disconnect event happened right before sending next VHOST-USER command, then the vhost_dev_set_log() call in the vhost_migration_log() function will return error. This error will lead to the assert() and close the QEMU migration source process. For the vhost-user devices the disconnect event should not break the migration process, because:
- the device will be in the stopped state, so it will not be changed during migration
- if reconnect will be made the migration log will be reinitialized as
part of reconnect/init process:
#0 vhost_log_global_start (listener=0x563989cf7be0)
at hw/virtio/vhost.c:920
#1 0x000056398603d8bc in listener_add_address_space (listener=0x563989cf7be0,
as=0x563986ea4340 <address_space_memory>)
at softmmu/memory.c:2664
#2 0x000056398603dd30 in memory_listener_register (listener=0x563989cf7be0,
as=0x563986ea4340 <address_space_memory>)
at softmmu/memory.c:2740
#3 0x0000563985fd6956 in vhost_dev_init (hdev=0x563989cf7bd8,
opaque=0x563989cf7e30, backend_type=VHOST_BACKEND_TYPE_USER,
busyloop_timeout=0)
at hw/virtio/vhost.c:1385
#4 0x0000563985f7d0b8 in vhost_user_blk_connect (dev=0x563989cf7990)
at hw/block/vhost-user-blk.c:315
#5 0x0000563985f7d3f6 in vhost_user_blk_event (opaque=0x563989cf7990,
event=CHR_EVENT_OPENED)
at hw/block/vhost-user-blk.c:379Update the vhost-user-blk device with the internal started_vu field which will be used for initialization (vhost_user_blk_start) and clean up (vhost_user_blk_stop). This additional flag in the VhostUserBlk structure will be used to track whether the device really needs to be stopped and cleaned up on a vhost-user level.
The disconnect event will set the overall VHOST device (not vhost-user) to the stopped state, so it can be used by the general vhost_migration_log routine.
Such approach could be propogated to the other vhost-user devices, but better idea is just to make the same connect/disconnect code for all the vhost-user devices.
This migration issue was slightly discussed earlier:
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg01509.html
- https://lists.gnu.org/archive/html/qemu-devel/2020-05/msg05241.html
Message-Id: <9fbfba06791a87813fcee3e2315f0b904cc6789a.1599813294.git.dimastep@yandex-team.ru>
--- include/hw/virtio/vhost-user-blk.h | 10 ++++++++++ hw/block/vhost-user-blk.c | 19 ++++++++++++++++--- hw/virtio/vhost.c | 27 ++++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 6 deletions(-)
include/hw/virtio/vhost-user-blk.h +10 -0
@@ -42,7 +42,17 @@ struct VHostUserBlk {VhostUserState vhost_user;struct vhost_virtqueue *vhost_vqs;VirtQueue **virtqs; + +/* +* There are at least two steps of initialization of the +* vhost-user device. The first is a "connect" step and +* second is a "start" step. Make a separation between +* those initialization phases by using two fields. +*/ +/* vhost_user_blk_connect/vhost_user_blk_disconnect */ bool connected; +/* vhost_user_blk_start/vhost_user_blk_stop */ + bool started_vu; };#endif
hw/block/vhost-user-blk.c +16 -3
@@ -150,6 +150,7 @@ static int vhost_user_blk_start(VirtIODevice *vdev)error_report ("Error starting vhost: %d" , -ret); goto err_guest_notifiers; } + s->started_vu = true;/* guest_notifier_mask/pending not used yet, so just unmask * everything here. virtio-pci will do the right thing by
@@ -175,6 +176,11 @@ static void vhost_user_blk_stop(VirtIODevice *vdev)VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus);int ret; +if (!s->started_vu) { +return ; + } + s->started_vu = false; +if (!k->set_guest_notifiers) {return ; }
@@ -341,9 +347,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) } s->connected = false; -if (s->dev.started) { -vhost_user_blk_stop (vdev); - } +vhost_user_blk_stop (vdev);vhost_dev_cleanup (&s->dev); }
@@ -399,6 +403,15 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) NULL, NULL, false);aio_bh_schedule_oneshot (ctx, vhost_user_blk_chr_closed_bh, opaque); } + +/* +* Move vhost device to the stopped state. The vhost-user device +* will be clean up and disconnected in BH. This can be useful in +* the vhost migration code. If disconnect was caught there is an +* option for the general vhost code to get the dev state without +* knowing its type (in this case vhost-user). +*/ + s->dev.started = false;break ;case CHR_EVENT_BREAK :case CHR_EVENT_MUX_IN :
hw/virtio/vhost.c +24 -3
@@ -871,21 +871,42 @@ static int vhost_migration_log(MemoryListener *listener, bool enable) dev->log_enabled = enable;return 0 ; } + + r =0 ;if (!enable) { r =vhost_dev_set_log (dev, false);if (r <0 ) { -return r; + goto check_dev_state; }vhost_log_put (dev, false); }else {vhost_dev_log_resize (dev,vhost_get_log_size (dev)); r =vhost_dev_set_log (dev, true);if (r <0 ) { -return r; + goto check_dev_state; } } + +check_dev_state: dev->log_enabled = enable; -return 0 ; +/* +* vhost-user-* devices could change their state during log +* initialization due to disconnect. So check dev state after +* vhost communication. +*/ +if (!dev->started) { +/* +* Since device is in the stopped state, it is okay for +* migration. Return success. +*/ + r =0 ; + } +if (r) { +/* An error is occured. */ + dev->log_enabled = false; + } + +return r; }static void vhost_log_global_start (MemoryListener *listener)
Signature · 1 line
MST
[PULL v2 11/15] tests/qtest/vhost-user-test: add migrate_reconnect test
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
Add new migrate_reconnect test for the vhost-user-blk device. Perform a disconnect after sending response for the VHOST_USER_SET_LOG_BASE command.
Message-Id: <6f38139d24a1be703a6f1c7d983faccdf21d2a9a.1599813294.git.dimastep@yandex-team.ru>
--- tests/qtest/vhost-user-test.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
tests/qtest/vhost-user-test.c +25 -0
@@ -146,6 +146,7 @@ static VhostUserMsg m __attribute__ ((unused));enum {TEST_FLAGS_OK ,TEST_FLAGS_DISCONNECT , +TEST_FLAGS_MIGRATE_DISCONNECT ,TEST_FLAGS_BAD ,TEST_FLAGS_END , };
@@ -436,6 +437,15 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE );g_cond_broadcast (&s->data_cond); +/* +* Perform disconnect after sending a response. In this +* case the next write command on the QEMU side (for now +* it is SET_FEATURES will return -1, because of disconnect. +*/ +if (s->test_flags ==TEST_FLAGS_MIGRATE_DISCONNECT ) { +qemu_chr_fe_disconnect (chr); + s->test_flags =TEST_FLAGS_BAD ; + }break ;case VHOST_USER_SET_VRING_BASE :
@@ -737,6 +747,17 @@ static void *vhost_user_test_setup_memfd(GString *cmd_line, void *arg)return server; } +static void *vhost_user_test_setup_migrate_reconnect (GString *cmd_line, +void *arg) +{ +TestServer *server; + + server =vhost_user_test_setup_memfd (cmd_line, arg); + server->test_flags =TEST_FLAGS_MIGRATE_DISCONNECT ; + +return server; +} +static void test_read_guest_mem (void *obj,void *arg,QGuestAllocator *alloc) {TestServer *server = arg;
@@ -1150,5 +1171,9 @@ static void register_vhost_user_test(void) opts.before = vhost_user_test_setup_memfd;qos_add_test ("migrate" ,"vhost-user-blk" , test_migrate, &opts); + + opts.before = vhost_user_test_setup_migrate_reconnect; +qos_add_test ("migrate_reconnect" ,"vhost-user-blk" , + test_migrate, &opts); }libqos_init (register_vhost_user_test);
Signature · 1 line
MST
[PULL v2 12/15] tests/qtest/vhost-user-test: enable the reconnect tests
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
For now a QTEST_VHOST_USER_FIXME environment variable is used to separate reconnect tests for the vhost-user-net device. Looks like the reconnect functionality is pretty stable, so this separation is deprecated.
Remove it and enable these tests for the default run.
Message-Id: <9fee5b17c7940f9126ba7cc014b09106c98118db.1599813294.git.dimastep@yandex-team.ru>
--- tests/qtest/vhost-user-test.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
tests/qtest/vhost-user-test.c +9 -12
@@ -1140,20 +1140,17 @@ static void register_vhost_user_test(void)"virtio-net" , test_migrate, &opts); -/* keeps failing on build-system since Aug 15 2017 */ -if (getenv ("QTEST_VHOST_USER_FIXME" )) { - opts.before = vhost_user_test_setup_reconnect; -qos_add_test ("vhost-user/reconnect" ,"virtio-net" , - test_reconnect, &opts); + opts.before = vhost_user_test_setup_reconnect; +qos_add_test ("vhost-user/reconnect" ,"virtio-net" , + test_reconnect, &opts); - opts.before = vhost_user_test_setup_connect_fail; -qos_add_test ("vhost-user/connect-fail" ,"virtio-net" , - test_vhost_user_started, &opts); + opts.before = vhost_user_test_setup_connect_fail; +qos_add_test ("vhost-user/connect-fail" ,"virtio-net" , + test_vhost_user_started, &opts); - opts.before = vhost_user_test_setup_flags_mismatch; -qos_add_test ("vhost-user/flags-mismatch" ,"virtio-net" , - test_vhost_user_started, &opts); - } + opts.before = vhost_user_test_setup_flags_mismatch; +qos_add_test ("vhost-user/flags-mismatch" ,"virtio-net" , + test_vhost_user_started, &opts); opts.before = vhost_user_test_setup_multiqueue; opts.edge.extra_device_opts ="mq=on" ;
Signature · 1 line
MST
[PULL v2 13/15] cphp: remove deprecated cpu-add command(s)
In reply to Michael S. TsirkinFrom: Igor Mammedov <[email protected]>
These were deprecated since 4.0, remove both HMP and QMP variants.
Users should use device_add command instead. To get list of possible CPUs and options, use 'info hotpluggable-cpus' HMP or query-hotpluggable-cpus QMP command.
Message-Id: <[email protected]>
--- qapi/machine.json | 24 --------- include/hw/boards.h | 1 - include/hw/i386/pc.h | 1 - include/monitor/hmp.h | 1 - hw/core/machine-hmp-cmds.c | 12 ----- hw/core/machine-qmp-cmds.c | 12 ----- hw/i386/pc.c | 27 ---------- hw/i386/pc_piix.c | 1 - hw/s390x/s390-virtio-ccw.c | 12 ----- tests/qtest/cpu-plug-test.c | 100 ++++-------------------------------- tests/qtest/test-hmp.c | 1 - docs/system/deprecated.rst | 25 +++++---- hmp-commands.hx | 15 ------ 13 files changed, 21 insertions(+), 211 deletions(-)
qapi/machine.json +0 -24
@@ -307,30 +307,6 @@ ## { 'command': 'query-cpus-fast', 'returns': [ 'CpuInfoFast' ] } -## -# @cpu-add: -# -# Adds CPU with specified ID. -# -# @id: ID of CPU to be created, valid values [0..max_cpus) -# -# Features: -# @deprecated: This command is deprecated. Use `device_add` instead. -# See the `query-hotpluggable-cpus` command for details. -# -# Returns: Nothing on success -# -# Since: 1.5 -# -# Example: -# -# -> { "execute": "cpu-add", "arguments": { "id": 2 } } -# <- { "return": {} } -# -## -{ 'command': 'cpu-add', 'data': {'id': 'int'}, - 'features': [ 'deprecated' ] } - ## # @MachineInfo: #
include/hw/boards.h +0 -1
@@ -169,7 +169,6 @@ struct MachineClass {void (*init)(MachineState *state);void (*reset)(MachineState *state);void (*wakeup)(MachineState *state); -void (*hot_add_cpu)(MachineState *state,const int64_t id,Error **errp);int (*kvm_type)(MachineState *machine,const char *arg);void (*smp_parse)(MachineState *ms,QemuOpts *opts);
include/hw/i386/pc.h +0 -1
@@ -134,7 +134,6 @@ extern int fd_bootchk;void pc_acpi_smi_interrupt (void *opaque,int irq,int level); -void pc_hot_add_cpu (MachineState *ms,const int64_t id,Error **errp);void pc_smp_parse (MachineState *ms,QemuOpts *opts);void pc_guest_info_init (PCMachineState *pcms);
include/monitor/hmp.h +0 -1
@@ -89,7 +89,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);void hmp_chardev_change (Monitor *mon,const QDict *qdict);void hmp_chardev_remove (Monitor *mon,const QDict *qdict);void hmp_chardev_send_break (Monitor *mon,const QDict *qdict); -void hmp_cpu_add (Monitor *mon,const QDict *qdict);void hmp_object_add (Monitor *mon,const QDict *qdict);void hmp_object_del (Monitor *mon,const QDict *qdict);void hmp_info_memdev (Monitor *mon,const QDict *qdict);
hw/core/machine-hmp-cmds.c +0 -12
@@ -46,18 +46,6 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)qapi_free_CpuInfoFastList (cpu_list); } -void hmp_cpu_add (Monitor *mon,const QDict *qdict) -{ -int cpuid; -Error *err =NULL ; - -error_report ("cpu_add is deprecated, please use device_add instead" ); - - cpuid =qdict_get_int (qdict,"id" ); -qmp_cpu_add (cpuid, &err); -hmp_handle_error (mon, err); -} -void hmp_hotpluggable_cpus (Monitor *mon,const QDict *qdict) {Error *err =NULL ;
hw/core/machine-qmp-cmds.c +0 -12
@@ -284,18 +284,6 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)return machine_query_hotpluggable_cpus (ms); } -void qmp_cpu_add (int64_t id,Error **errp) -{ -MachineClass *mc; - - mc =MACHINE_GET_CLASS (current_machine); -if (mc->hot_add_cpu) { - mc->hot_add_cpu (current_machine, id, errp); - }else { -error_setg (errp,"Not supported" ); - } -} -void qmp_set_numa_node (NumaOptions *cmd,Error **errp) {if (!runstate_check (RUN_STATE_PRECONFIG )) {
hw/i386/pc.c +0 -27
@@ -777,32 +777,6 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts) } } -void pc_hot_add_cpu (MachineState *ms,const int64_t id,Error **errp) -{ -X86MachineState *x86ms =X86_MACHINE (ms); -int64_t apic_id =x86_cpu_apic_id_from_index (x86ms, id); -Error *local_err =NULL ; - -if (id <0 ) { -error_setg (errp,"Invalid CPU id: %" PRIi64, id); -return ; - } - -if (apic_id >=ACPI_CPU_HOTPLUG_ID_LIMIT ) { -error_setg (errp,"Unable to add CPU: %" PRIi64 -", resulting APIC ID (%" PRIi64") is too large" , - id, apic_id); -return ; - } - - -x86_cpu_new (X86_MACHINE (ms), apic_id, &local_err); -if (local_err) { -error_propagate (errp, local_err); -return ; - } -} -static void pc_machine_done (Notifier *notifier,void *data) {
@@ -1699,7 +1673,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->auto_enable_numa_with_memdev = true; mc->has_hotpluggable_cpus = true; mc->default_boot_order ="cad" ; - mc->hot_add_cpu = pc_hot_add_cpu; mc->smp_parse = pc_smp_parse; mc->block_default_type =IF_IDE ; mc->max_cpus =255 ;
hw/i386/pc_piix.c +0 -1
@@ -752,7 +752,6 @@ static void pc_i440fx_1_4_machine_options(MachineClass *m) {pc_i440fx_1_5_machine_options (m); m->hw_version ="1.4.0" ; - m->hot_add_cpu =NULL ;compat_props_add (m->compat_props, pc_compat_1_4, pc_compat_1_4_len); }
hw/s390x/s390-virtio-ccw.c +0 -12
@@ -553,17 +553,6 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,return NULL ; } -static void s390_hot_add_cpu (MachineState *machine, -const int64_t id,Error **errp) -{ -ObjectClass *oc; - -g_assert (machine->possible_cpus->cpus[0 ].cpu); - oc =OBJECT_CLASS (CPU_GET_CLASS (machine->possible_cpus->cpus[0 ].cpu)); - -s390x_new_cpu (object_class_get_name (oc), id, errp); -} -static void s390_nmi (NMIState *n,int cpu_index,Error **errp) {CPUState *cs =qemu_get_cpu (cpu_index);
@@ -604,7 +593,6 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) s390mc->hpage_1m_allowed = true; mc->init = ccw_init; mc->reset = s390_machine_reset; - mc->hot_add_cpu = s390_hot_add_cpu; mc->block_default_type =IF_VIRTIO ; mc->no_cdrom =1 ; mc->no_floppy =1 ;
tests/qtest/cpu-plug-test.c +9 -91
127 lines not on this page · raw message
tests/qtest/test-hmp.c +0 -1
@@ -27,7 +27,6 @@ static const char *hmp_cmds[] = {"chardev-change testchardev1 ringbuf" ,"chardev-remove testchardev1" ,"commit all" , -"cpu-add 1" ,"cpu 0" ,"device_add ?" , "device_add usb-mouse,id=mouse1",
docs/system/deprecated.rst +12 -13
@@ -284,13 +284,6 @@ The ``query-cpus`` command is replaced by the ``query-cpus-fast`` command. The ``arch`` output member of the ``query-cpus-fast`` command is replaced by the ``target`` output member. -``cpu-add`` (since 4.0) -''''''''''''''''''''''' - -Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See -documentation of ``query-hotpluggable-cpus`` for additional -details. - ``query-events`` (since 4.0) ''''''''''''''''''''''''''''
@@ -306,12 +299,6 @@ the 'wait' field, which is only applicable to sockets in server mode Human Monitor Protocol (HMP) commands ------------------------------------- -``cpu-add`` (since 4.0) -''''''''''''''''''''''' - -Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See -documentation of ``query-hotpluggable-cpus`` for additional details. - ``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (since 4.0.0) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -529,6 +516,12 @@ QEMU Machine Protocol (QMP) commands The "autoload" parameter has been ignored since 2.12.0. All bitmaps are automatically loaded from qcow2 images. +``cpu-add`` (removed in 5.2) +'''''''''''''''''''''''''''' + +Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See +documentation of ``query-hotpluggable-cpus`` for additional details. + Human Monitor Protocol (HMP) commands -------------------------------------
@@ -538,6 +531,12 @@ The ``hub_id`` parameter of ``hostfwd_add`` / ``hostfwd_remove`` (removed in 5.0 The ``[hub_id name]`` parameter tuple of the 'hostfwd_add' and 'hostfwd_remove' HMP commands has been replaced by ``netdev_id``. +``cpu-add`` (removed in 5.2) +'''''''''''''''''''''''''''' + +Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See +documentation of ``query-hotpluggable-cpus`` for additional details. + Guest Emulator ISAs -------------------
hmp-commands.hx +0 -15
@@ -1761,21 +1761,6 @@ SRST Executes a qemu-io command on the given block device. ERST - { - .name = "cpu-add", - .args_type = "id:i", - .params = "id", - .help = "add cpu (deprecated, use device_add instead)", - .cmd = hmp_cpu_add, - }, - -SRST -``cpu-add`` *id* - Add CPU with id *id*. This command is deprecated, please - +use ``device_add`` instead. For details, refer to - 'docs/cpu-hotplug.rst'. -ERST - { .name = "qom-list", .args_type = "path:s?",
Signature · 1 line
MST
[PULL v2 05/15] pc: fix auto_enable_numa_with_memhp/auto_enable_numa_with_memdev for the 5.0 machine
In reply to Michael S. TsirkinFrom: David Hildenbrand <[email protected]>
Unfortunately, a typo sneeked in: we want to set auto_enable_numa_with_memdev to false, not auto_enable_numa_with_memhp.
Message-Id: <[email protected]>
--- hw/i386/pc_q35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc_q35.c +1 -1
@@ -382,7 +382,7 @@ static void pc_q35_5_0_machine_options(MachineClass *m) m->numa_mem_supported = true;compat_props_add (m->compat_props, hw_compat_5_0, hw_compat_5_0_len);compat_props_add (m->compat_props, pc_compat_5_0, pc_compat_5_0_len); - m->auto_enable_numa_with_memhp = false; + m->auto_enable_numa_with_memdev = false; } DEFINE_Q35_MACHINE(v5_0, "pc-q35-5.0", NULL,
Signature · 1 line
MST
[PULL v2 08/15] tests/qtest/vhost-user-test: prepare the tests for adding new dev class
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
For now only vhost-user-net device is supported by the test. Other vhost-user devices are not tested. As a first step make source code refactoring so new devices can reuse the same test routines. To make this provide a new vhost_user_ops structure with the methods to initialize device, its command line or make a proper vhost-user responses.
Message-Id: <a48b60fb96fef230b75fff72a2d77040dcb5ef7c.1599813294.git.dimastep@yandex-team.ru>
--- tests/qtest/vhost-user-test.c | 105 ++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 29 deletions(-)
tests/qtest/vhost-user-test.c +76 -29
@@ -135,6 +135,10 @@ enum { TEST_FLAGS_END, }; +enum { +VHOST_USER_NET , +}; + typedef struct TestServer { gchar *socket_path; gchar *mig_path;
@@ -154,10 +158,25 @@ typedef struct TestServer {bool test_fail;int test_flags;int queues; +struct vhost_user_ops *vu_ops; } TestServer; +struct vhost_user_ops { +/* Device types. */ +int type; +void (*append_opts)(TestServer *s,GString *cmd_line, +const char *chr_opts); + +/* VHOST-USER commands. */ +void (*set_features)(TestServer *s,CharBackend *chr, +VhostUserMsg *msg); +void (*get_protocol_features)(TestServer *s, +CharBackend *chr,VhostUserMsg *msg); +}; +static const char *init_hugepagefs (void ); -static TestServer *test_server_new (const gchar *name); +static TestServer *test_server_new (const gchar *name, +struct vhost_user_ops *ops);static void test_server_free (TestServer *server);static void test_server_listen (TestServer *server);
@@ -167,7 +186,7 @@ enum test_memfd { TEST_MEMFD_NO, }; -static void append_vhost_opts (TestServer *s,GString *cmd_line, +static void append_vhost_net_opts (TestServer *s,GString *cmd_line,const char *chr_opts) { g_string_append_printf(cmd_line, QEMU_CMD_CHR QEMU_CMD_NETDEV,
@@ -332,25 +351,15 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)break ;case VHOST_USER_SET_FEATURES : -g_assert_cmpint (msg.payload.u64 & (0x1ULL <<VHOST_USER_F_PROTOCOL_FEATURES ), - !=, 0ULL); -if (s->test_flags ==TEST_FLAGS_DISCONNECT ) { -qemu_chr_fe_disconnect (chr); - s->test_flags =TEST_FLAGS_BAD ; +if (s->vu_ops->set_features) { + s->vu_ops->set_features (s, chr, &msg); }break ;case VHOST_USER_GET_PROTOCOL_FEATURES : -/* send back features to qemu */ - msg.flags |=VHOST_USER_REPLY_MASK ; - msg.size =sizeof (m.payload.u64); - msg.payload.u64 =1 <<VHOST_USER_PROTOCOL_F_LOG_SHMFD ; - msg.payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_CROSS_ENDIAN ; -if (s->queues >1 ) { - msg.payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_MQ ; +if (s->vu_ops->get_protocol_features) { + s->vu_ops->get_protocol_features (s, chr, &msg); } - p = (uint8_t *) &msg; -qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE + msg.size);break ;case VHOST_USER_GET_VRING_BASE :
@@ -467,7 +476,8 @@ static const char *init_hugepagefs(void)#endif } -static TestServer *test_server_new (const gchar *name) +static TestServer *test_server_new (const gchar *name, +struct vhost_user_ops *ops) {TestServer *server =g_new0 (TestServer,1 );char template[] ="/tmp/vhost-test-XXXXXX" ;
@@ -495,6 +505,7 @@ static TestServer *test_server_new(const gchar *name) server->log_fd =-1 ; server->queues =1 ; + server->vu_ops = ops;return server; }
@@ -669,11 +680,11 @@ static void vhost_user_test_cleanup(void *s)static void *vhost_user_test_setup (GString *cmd_line,void *arg) { -TestServer *server =test_server_new ("vhost-user-test" ); +TestServer *server =test_server_new ("vhost-user-test" , arg);test_server_listen (server);append_mem_opts (server, cmd_line,256 ,TEST_MEMFD_AUTO ); -append_vhost_opts (server, cmd_line,"" ); + server->vu_ops->append_opts (server, cmd_line,"" );g_test_queue_destroy (vhost_user_test_cleanup, server);
@@ -682,11 +693,11 @@ static void *vhost_user_test_setup(GString *cmd_line, void *arg)static void *vhost_user_test_setup_memfd (GString *cmd_line,void *arg) { -TestServer *server =test_server_new ("vhost-user-test" ); +TestServer *server =test_server_new ("vhost-user-test" , arg);test_server_listen (server);append_mem_opts (server, cmd_line,256 ,TEST_MEMFD_YES ); -append_vhost_opts (server, cmd_line,"" ); + server->vu_ops->append_opts (server, cmd_line,"" );g_test_queue_destroy (vhost_user_test_cleanup, server);
@@ -720,7 +731,7 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)return ; } - dest =test_server_new ("dest" ); + dest =test_server_new ("dest" , s->vu_ops); dest_cmdline =g_string_new (qos_get_current_command_line ()); uri =g_strdup_printf ("%s%s" ,"unix:" , dest->mig_path);
@@ -730,7 +741,7 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)test_server_listen (dest);g_string_append_printf (dest_cmdline," -incoming %s" , uri);append_mem_opts (dest, dest_cmdline,256 ,TEST_MEMFD_AUTO ); -append_vhost_opts (dest, dest_cmdline,"" ); + dest->vu_ops->append_opts (dest, dest_cmdline,"" ); to =qtest_init (dest_cmdline->str);/* This would be where you call qos_allocate_objects(to, NULL), if you want
@@ -831,11 +842,11 @@ connect_thread(gpointer data)static void *vhost_user_test_setup_reconnect (GString *cmd_line,void *arg) { -TestServer *s =test_server_new ("reconnect" ); +TestServer *s =test_server_new ("reconnect" , arg);g_thread_new ("connect" , connect_thread, s);append_mem_opts (s, cmd_line,256 ,TEST_MEMFD_AUTO ); -append_vhost_opts (s, cmd_line,",server" ); + s->vu_ops->append_opts (s, cmd_line,",server" );g_test_queue_destroy (vhost_user_test_cleanup, s);
@@ -866,13 +877,13 @@ static void test_reconnect(void *obj, void *arg, QGuestAllocator *alloc)static void *vhost_user_test_setup_connect_fail (GString *cmd_line,void *arg) { -TestServer *s =test_server_new ("connect-fail" ); +TestServer *s =test_server_new ("connect-fail" , arg); s->test_fail = true;g_thread_new ("connect" , connect_thread, s);append_mem_opts (s, cmd_line,256 ,TEST_MEMFD_AUTO ); -append_vhost_opts (s, cmd_line,",server" ); + s->vu_ops->append_opts (s, cmd_line,",server" );g_test_queue_destroy (vhost_user_test_cleanup, s);
@@ -881,13 +892,13 @@ static void *vhost_user_test_setup_connect_fail(GString *cmd_line, void *arg)static void *vhost_user_test_setup_flags_mismatch (GString *cmd_line,void *arg) { -TestServer *s =test_server_new ("flags-mismatch" ); +TestServer *s =test_server_new ("flags-mismatch" , arg); s->test_flags =TEST_FLAGS_DISCONNECT ;g_thread_new ("connect" , connect_thread, s);append_mem_opts (s, cmd_line,256 ,TEST_MEMFD_AUTO ); -append_vhost_opts (s, cmd_line,",server" ); + s->vu_ops->append_opts (s, cmd_line,",server" );g_test_queue_destroy (vhost_user_test_cleanup, s);
@@ -924,11 +935,47 @@ static void test_multiqueue(void *obj, void *arg, QGuestAllocator *alloc)wait_for_rings_started (s, s->queues *2 ); } +static void vu_net_set_features (TestServer *s,CharBackend *chr, +VhostUserMsg *msg) +{ +g_assert_cmpint (msg->payload.u64 & + (0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES), !=, 0ULL); +if (s->test_flags ==TEST_FLAGS_DISCONNECT ) { +qemu_chr_fe_disconnect (chr); + s->test_flags =TEST_FLAGS_BAD ; + } +} + +static void vu_net_get_protocol_features (TestServer *s,CharBackend *chr, +VhostUserMsg *msg) +{ +/* send back features to qemu */ + msg->flags |=VHOST_USER_REPLY_MASK ; + msg->size =sizeof (m.payload.u64); + msg->payload.u64 =1 <<VHOST_USER_PROTOCOL_F_LOG_SHMFD ; + msg->payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_CROSS_ENDIAN ; +if (s->queues >1 ) { + msg->payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_MQ ; + } +qemu_chr_fe_write_all (chr, (uint8_t *)msg,VHOST_USER_HDR_SIZE + msg->size); +} + +/* Each VHOST-USER device should have its ops structure defined. */ +static struct vhost_user_ops g_vu_net_ops = { + .type =VHOST_USER_NET , + + .append_opts = append_vhost_net_opts, + + .set_features = vu_net_set_features, + .get_protocol_features = vu_net_get_protocol_features, +}; +static void register_vhost_user_test (void ) {QOSGraphTestOptions opts = { .before = vhost_user_test_setup, .subprocess = true, + .arg = &g_vu_net_ops, };qemu_add_opts (&qemu_chardev_opts);
Signature · 1 line
MST
[PULL v2 10/15] tests/qtest/vhost-user-test: add support for the vhost-user-blk device
In reply to Michael S. TsirkinFrom: Dima Stepanov <[email protected]>
Add vhost_user_ops structure for the vhost-user-blk device class. Add the test_reconnect and test_migrate tests for this device.
Message-Id: <a01fc8f1480e3a9dd29cb3736fadc5a9a4b497a5.1599813294.git.dimastep@yandex-team.ru>
--- tests/qtest/vhost-user-test.c | 139 +++++++++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 2 deletions(-)
tests/qtest/vhost-user-test.c +137 -2
@@ -24,6 +24,7 @@#include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/virtio-pci.h" +#include "libqos/virtio-blk.h" #include "libqos/malloc-pc.h" #include "hw/virtio/virtio-net.h"
@@ -31,6 +32,7 @@#include "standard-headers/linux/vhost_types.h" #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h" +#include "standard-headers/linux/virtio_blk.h" #ifdef CONFIG_LINUX #include <sys/vfs.h>
@@ -43,6 +45,7 @@ " -numa node,memdev=mem"#define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s"#define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce" +#define QEMU_CMD_BLKCHR " -chardev socket,id=chdev0,path=%s%s"#define HUGETLBFS_MAGIC 0x958458f6
@@ -55,6 +58,7 @@#define VHOST_USER_PROTOCOL_F_MQ 0#define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1#define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 +#define VHOST_USER_PROTOCOL_F_CONFIG 9#define VHOST_LOG_PAGE 0x1000
@@ -78,6 +82,8 @@ typedef enum VhostUserRequest {VHOST_USER_SET_PROTOCOL_FEATURES =16 ,VHOST_USER_GET_QUEUE_NUM =17 ,VHOST_USER_SET_VRING_ENABLE =18 , +VHOST_USER_GET_CONFIG =24 , +VHOST_USER_SET_CONFIG =25 , VHOST_USER_MAX } VhostUserRequest;
@@ -99,6 +105,14 @@ typedef struct VhostUserLog {uint64_t mmap_offset; } VhostUserLog; +#define VHOST_USER_MAX_CONFIG_SIZE 256 +typedef struct VhostUserConfig { +uint32_t offset; +uint32_t size; +uint32_t flags; +uint8_t region[VHOST_USER_MAX_CONFIG_SIZE ]; +}VhostUserConfig ; + typedef struct VhostUserMsg { VhostUserRequest request;
@@ -114,6 +128,7 @@ typedef struct VhostUserMsg {struct vhost_vring_addr addr;VhostUserMemory memory;VhostUserLog log; +VhostUserConfig config; } payload; }QEMU_PACKED VhostUserMsg;
@@ -137,6 +152,7 @@ enum {enum {VHOST_USER_NET , +VHOST_USER_BLK , }; typedef struct TestServer {
@@ -166,12 +182,15 @@ struct vhost_user_ops {int type;void (*append_opts)(TestServer *s,GString *cmd_line,const char *chr_opts); +void (*driver_init)(void *obj,QGuestAllocator *alloc);/* VHOST-USER commands. */ void (*set_features)(TestServer *s,CharBackend *chr,VhostUserMsg *msg);void (*get_protocol_features)(TestServer *s,CharBackend *chr,VhostUserMsg *msg); +void (*get_config)(TestServer *s,CharBackend *chr, +VhostUserMsg *msg); };static const char *init_hugepagefs (void );
@@ -194,6 +213,14 @@ static void append_vhost_net_opts(TestServer *s, GString *cmd_line, chr_opts, s->chr_name); } +static void append_vhost_blk_opts (TestServer *s,GString *cmd_line, +const char *chr_opts) +{ +g_string_append_printf (cmd_line,QEMU_CMD_BLKCHR , + s->socket_path, + chr_opts); +} +static void append_mem_opts (TestServer *server,GString *cmd_line,int size,enum test_memfd memfd) {
@@ -425,6 +452,12 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)qemu_chr_fe_write_all (chr, p,VHOST_USER_HDR_SIZE + msg.size);break ; +case VHOST_USER_GET_CONFIG : +if (s->vu_ops->get_config) { + s->vu_ops->get_config (s, chr, &msg); + } +break ; +default :break ; }
@@ -727,6 +760,9 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)guint8 *log;guint64 size; +if (s->vu_ops->driver_init) { + s->vu_ops->driver_init (obj, alloc); + }if (!wait_for_fds (s)) {return ; }
@@ -796,6 +832,24 @@ static void test_migrate(void *obj, void *arg, QGuestAllocator *alloc)g_string_free (dest_cmdline, true); } +static void vu_blk_driver_init (void *obj,QGuestAllocator *alloc) +{ +QVirtioBlk *blk_if; +QVirtioDevice *dev; +QVirtQueue *vq; +uint64_t features; + + blk_if = obj; + dev = blk_if->vdev; + features =qvirtio_get_features (dev); +qvirtio_set_features (dev, features); + + vq =qvirtqueue_setup (dev, alloc,0 ); +g_assert (vq); + +qvirtio_set_driver_ok (dev); +} +static void wait_for_rings_started (TestServer *s,size_t count) {gint64 end_time;
@@ -857,12 +911,21 @@ static void test_reconnect(void *obj, void *arg, QGuestAllocator *alloc) {TestServer *s = arg;GSource *src; +int nq; +if (s->vu_ops->driver_init) { + s->vu_ops->driver_init (obj, alloc); + }if (!wait_for_fds (s)) {return ; } -wait_for_rings_started (s,2 ); + nq =1 ; +if (s->vu_ops->type ==VHOST_USER_NET ) { +/* tx and rx queues */ + nq =2 ; + } +wait_for_rings_started (s, nq);/* reconnect */ s->fds_num =0 ;
@@ -872,7 +935,7 @@ static void test_reconnect(void *obj, void *arg, QGuestAllocator *alloc)g_source_attach (src, s->context);g_source_unref (src);g_assert (wait_for_fds (s)); -wait_for_rings_started (s,2 ); +wait_for_rings_started (s, nq); }static void *vhost_user_test_setup_connect_fail (GString *cmd_line,void *arg)
@@ -960,6 +1023,56 @@ static void vu_net_get_protocol_features(TestServer *s, CharBackend *chr,qemu_chr_fe_write_all (chr, (uint8_t *)msg,VHOST_USER_HDR_SIZE + msg->size); } +static void vu_blk_set_features (TestServer *s,CharBackend *chr, +VhostUserMsg *msg) +{ +if (s->test_flags ==TEST_FLAGS_DISCONNECT ) { +qemu_chr_fe_disconnect (chr); + s->test_flags =TEST_FLAGS_BAD ; + } +} + +static void vu_blk_get_protocol_features (TestServer *s, +CharBackend *chr,VhostUserMsg *msg) +{ +/* send back features to qemu */ + msg->flags |=VHOST_USER_REPLY_MASK ; + msg->size =sizeof (m.payload.u64); + msg->payload.u64 =1 <<VHOST_USER_PROTOCOL_F_LOG_SHMFD ; + msg->payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_CONFIG ; +if (s->queues >1 ) { + msg->payload.u64 |=1 <<VHOST_USER_PROTOCOL_F_MQ ; + } +qemu_chr_fe_write_all (chr, (uint8_t *)msg,VHOST_USER_HDR_SIZE + msg->size); +} + +static void vu_blk_get_config (TestServer *s,CharBackend *chr, +VhostUserMsg *msg) +{ +VhostUserConfig *config; +struct virtio_blk_config *blk_config; + + config = &msg->payload.config; +memset (config,0 ,sizeof (*config)); + config->size =sizeof (*blk_config); + + blk_config = (struct virtio_blk_config *)&config->region; +/* +* Represent 128Mb test disk, with no real backend, just +* to test vhost-user functionality. +*/ + blk_config->capacity =262144 ; + blk_config->size_max =0x20000 ; + blk_config->seg_max =0x7e ; + blk_config->blk_size =512 ; + blk_config->min_io_size =0x1 ; + blk_config->num_queues =0x1 ; + + msg->size =sizeof (*config) -sizeof (config->region) + config->size; + msg->flags |=VHOST_USER_REPLY_MASK ; +qemu_chr_fe_write_all (chr, (uint8_t *)msg,VHOST_USER_HDR_SIZE + msg->size); +} +/* Each VHOST-USER device should have its ops structure defined. */ static struct vhost_user_ops g_vu_net_ops = { .type =VHOST_USER_NET ,
@@ -970,6 +1083,17 @@ static struct vhost_user_ops g_vu_net_ops = { .get_protocol_features = vu_net_get_protocol_features, }; +static struct vhost_user_ops g_vu_blk_ops = { + .type =VHOST_USER_BLK , + + .append_opts = append_vhost_blk_opts, + .driver_init = vu_blk_driver_init, + + .set_features = vu_blk_set_features, + .get_protocol_features = vu_blk_get_protocol_features, + .get_config = vu_blk_get_config, +}; +static void register_vhost_user_test (void ) {QOSGraphTestOptions opts = {
@@ -1015,5 +1139,16 @@ static void register_vhost_user_test(void)qos_add_test ("vhost-user/multiqueue" ,"virtio-net" , test_multiqueue, &opts); + opts.edge.extra_device_opts =NULL ; + +/* vhost-user-blk tests */ + opts.arg = &g_vu_blk_ops; + opts.before = vhost_user_test_setup_reconnect; +qos_add_test ("reconnect" ,"vhost-user-blk" , + test_reconnect, &opts); + + opts.before = vhost_user_test_setup_memfd; +qos_add_test ("migrate" ,"vhost-user-blk" , + test_migrate, &opts); }libqos_init (register_vhost_user_test);
Signature · 1 line
MST
found a problem on some build systems. sorry.
will post v3.
Quoted 108 lines · Michael S. Tsirkin
changes from v1:
rebased on master
pick a fixed patch version - noticed by RaphaelThe following changes since commit
e883b492c221241d28aaa322c61536436090538a:Merge remote-tracking branch 'remotes/legoater/tags/pull-aspeed-20200918' into staging (2020-09-18 13:36:42 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
b98061bc65dae34cfabcfe2c123a5b14347c6135:virtio-iommu-pci: force virtio version 1 (2020-09-18 12:18:05 -0400)
----------------------------------------------------------------
virtio,pc,acpi: fixes, testsFixes and tests all over the place.
Batch iommu updates for vdpa.
Removal of deprecated cpu hotplug commands.Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
David Hildenbrand (1):
pc: fix auto_enable_numa_with_memhp/auto_enable_numa_with_memdev for the 5.0 machineDima Stepanov (7):
vhost: recheck dev state in thevhost_migration_logroutine
vhost: check queue state in thevhost_dev_set_logroutine tests/qtest/vhost-user-test: prepare the tests for adding new dev class tests/qtest/libqos/virtio-blk: add support for vhost-user-blk tests/qtest/vhost-user-test: add support for the vhost-user-blk device tests/qtest/vhost-user-test: addmigrate_reconnecttest tests/qtest/vhost-user-test: enable the reconnect testsEric Auger (2):
virtio-iommu: Check gtrees are non null before destroying them
virtio-iommu-pci: force virtio version 1Igor Mammedov (1):
cphp: remove deprecated cpu-add command(s)Jason Wang (3):
linux headers: sync to 5.9-rc4
vhost: switch to use IOTLB v2 format
vhost-vdpa: batch updating IOTLB mappingsLi Qiang (1):
virtio-mem: detach the element from the virtqueue when error occursqapi/machine.json | 24 -- include/hw/boards.h | 1 - include/hw/i386/pc.h | 1 - include/hw/virtio/vhost-backend.h | 2 + include/hw/virtio/vhost-user-blk.h | 10 + include/hw/virtio/vhost-vdpa.h | 1 + include/hw/virtio/vhost.h | 1 + include/monitor/hmp.h | 1 - include/standard-headers/drm/drm_fourcc.h | 140 ++++++++++ include/standard-headers/linux/ethtool.h | 87 +++++++ include/standard-headers/linux/input-event-codes.h | 3 +- include/standard-headers/linux/vhost_types.h | 11 + include/standard-headers/linux/virtio_9p.h | 4 +- include/standard-headers/linux/virtio_blk.h | 26 +- include/standard-headers/linux/virtio_config.h | 8 +- include/standard-headers/linux/virtio_console.h | 8 +- include/standard-headers/linux/virtio_net.h | 6 +- include/standard-headers/linux/virtio_scsi.h | 20 +- linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/kvm.h | 5 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/kvm.h | 7 +- linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 4 + linux-headers/linux/vfio.h | 2 +- linux-headers/linux/vhost.h | 2 + hw/block/vhost-user-blk.c | 19 +- hw/core/machine-hmp-cmds.c | 12 - hw/core/machine-qmp-cmds.c | 12 - hw/i386/pc.c | 27 -- hw/i386/pc_piix.c | 1 - hw/i386/pc_q35.c | 2 +- hw/s390x/s390-virtio-ccw.c | 12 - hw/virtio/vhost-backend.c | 88 +++++-- hw/virtio/vhost-vdpa.c | 66 +++++ hw/virtio/vhost.c | 49 +++- hw/virtio/virtio-iommu-pci.c | 2 +- hw/virtio/virtio-iommu.c | 8 +- hw/virtio/virtio-mem.c | 3 + tests/qtest/cpu-plug-test.c | 100 +------ tests/qtest/libqos/virtio-blk.c | 14 +- tests/qtest/test-hmp.c | 1 - tests/qtest/vhost-user-test.c | 290 ++++++++++++++++++--- docs/system/deprecated.rst | 25 +- hmp-commands.hx | 15 -- 53 files changed, 813 insertions(+), 323 deletions(-)
Quoted 3 lines · Michael S. Tsirkin
found a problem on some build systems. sorry.
will post v3.
aarch64, osx, x86-64 clang all run into this one:
../../tests/qtest/vhost-user-test.c: In function ‘vu_blk_get_config’:../../tests/qtest/vhost-user-test.c:1076:14: error: taking address of packed member of ‘struct VhostUserMsg’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
1076 | config = &msg->payload.config;
| ^~~~~~~~~~~~~~~~~~~~thanks
-- PMM
[PULL v2 15/15] virtio-iommu-pci: force virtio version 1
In reply to Michael S. TsirkinFrom: Eric Auger <[email protected]>
Commit 9b3a35ec82 ("virtio: verify that legacy support is not accidentally on") added a safety check that requires to set 'disable-legacy=on' on virtio-iommu-pci:
qemu-system-aarch64: -device virtio-iommu-pci: device is modern-only, use disable-legacy=on
virtio-iommu was introduced after the release of VIRTIO 1.0 specifications, so it should be 'modern-only'.
This patch forces virtio version 1 and removes the 'transitional_name' property removing the need to specify 'disable-legacy=on' on virtio-iommu-pci device.
Message-Id: <[email protected]>
--- hw/virtio/virtio-iommu-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-iommu-pci.c +1 -1
@@ -69,6 +69,7 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)object_property_set_link (OBJECT (dev),"primary-bus" ,OBJECT (pci_get_bus (&vpci_dev->pci_dev)), &error_abort); +virtio_pci_force_virtio_1 (vpci_dev);qdev_realize (vdev,BUS (&vpci_dev->bus), errp); }
@@ -98,7 +99,6 @@ static void virtio_iommu_pci_instance_init(Object *obj)static const VirtioPCIDeviceTypeInfo virtio_iommu_pci_info = { .base_name =TYPE_VIRTIO_IOMMU_PCI , .generic_name ="virtio-iommu-pci" , - .transitional_name ="virtio-iommu-pci-transitional" , .non_transitional_name ="virtio-iommu-pci-non-transitional" , .instance_size =sizeof (VirtIOIOMMUPCI), .instance_init = virtio_iommu_pci_instance_init,
Signature · 1 line
MST
[PULL v2 14/15] virtio-iommu: Check gtrees are non null before destroying them
In reply to Michael S. TsirkinFrom: Eric Auger <[email protected]>
If realize fails, domains and endpoints trees may be NULL. On unrealize(), this produces assertions:
"GLib: g_tree_destroy: assertion 'tree != NULL' failed"
Check that the trees are non NULL before destroying them.
Message-Id: <[email protected]>
--- hw/virtio/virtio-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/virtio/virtio-iommu.c +6 -2
@@ -801,8 +801,12 @@ static void virtio_iommu_device_unrealize(DeviceState *dev)VirtIOIOMMU *s =VIRTIO_IOMMU (dev);g_hash_table_destroy (s->as_by_busptr); -g_tree_destroy (s->domains); -g_tree_destroy (s->endpoints); +if (s->domains) { +g_tree_destroy (s->domains); + } +if (s->endpoints) { +g_tree_destroy (s->endpoints); + }virtio_delete_queue (s->req_vq);virtio_delete_queue (s->event_vq);
Signature · 1 line
MST
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-mingw@fedora/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]