qemu/queue.h usage cleanup, improved QTAILQ API
Subsystems (3)
v2 cover qemu/queue.h usage cleanup, improved QTAILQ API
This series includes two changes that are a bit intertwined.
The main one is to reimplement QTAILQ in a way that simplifies backwards walking of the list. The in-memory layout actually stays the same, but the C description of it changes so that (also thanks to typeof) you don't have to specify a name for the "head" struct in QTAILQ_{LAST,PREV,FOREACH_REVERSE}. This is done in patches 1, 4 and 5.
Once you do this, you actually almost never need to define a named head struct. Therefore, the series also cleans up other cases where the struct was given a name unnecessarily, and ensures that those queue.h structs are given a typedef and a camel case name, similar to all other structs in QEMU. This is done in patches 2 and 3, and at the end of the series we can add a checkpatch test for it in patch 6.
v1->v2: split out patches 2 and 5 [Markus for patch 5]
moved the other VFIO change from patch 3 to 4
Paolo Bonzini (8):
qemu/queue.h: do not access tqe_prev directly
vfio: make vfio_address_spaces static
qemu/queue.h: leave head structs anonymous unless necessary qemu/queue.h: typedef QTAILQ heads
qemu/queue.h: remove Q_TAILQ_{HEAD,ENTRY} qemu/queue.h: reimplement QTAILQ without pointer-to-pointers qemu/queue.h: simplify reverse access to QTAILQ
checkpatch: warn about qemu/queue.h head structs that are not
typedef-ed
accel/kvm/kvm-all.c | 4 +- block/gluster.c | 2 +- block/mirror.c | 2 +- block/qcow2-bitmap.c | 4 +- block/qcow2.h | 2 +- block/sheepdog.c | 6 +- block/vhdx.h | 2 +- blockdev.c | 4 +- contrib/ivshmem-client/ivshmem-client.h | 4 +- contrib/ivshmem-server/ivshmem-server.h | 5 +- cpus-common.c | 2 +- dump.c | 2 +- exec.c | 5 +- fsdev/qemu-fsdev.c | 2 +- hw/block/nvme.h | 8 +- hw/block/xen_disk.c | 6 +- hw/core/qdev.c | 4 +- hw/core/reset.c | 2 +- hw/i386/xen/xen-mapcache.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/scsi/scsi-bus.c | 2 +- hw/usb/ccid-card-emulated.c | 4 +- hw/usb/combined-packet.c | 2 +- hw/usb/dev-mtp.c | 4 +- hw/usb/dev-network.c | 2 +- hw/usb/hcd-ehci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-uhci.c | 4 +- hw/usb/xen-usb.c | 6 +- hw/vfio/common.c | 4 +- hw/watchdog/watchdog.c | 2 +- hw/xen/xen_pvdev.c | 4 +- include/exec/memory.h | 6 +- include/hw/qdev-core.h | 2 +- include/hw/usb.h | 2 +- include/hw/vfio/vfio-common.h | 4 +- include/hw/vfio/vfio-platform.h | 2 +- include/net/net.h | 2 +- include/qemu/option_int.h | 2 +- include/qemu/queue.h | 153 +++++++++++------------- include/qemu/rcu_queue.h | 45 +++---- include/qom/cpu.h | 9 +- include/sysemu/kvm.h | 2 - include/sysemu/memory_mapping.h | 2 +- include/sysemu/rng.h | 2 +- linux-user/elfload.c | 2 +- memory.c | 19 ++- memory_mapping.c | 2 +- migration/block-dirty-bitmap.c | 2 +- migration/block.c | 4 +- migration/ram.c | 2 +- monitor.c | 4 +- net/filter.c | 2 +- net/net.c | 2 +- net/queue.c | 2 +- net/slirp.c | 2 +- qga/commands-posix.c | 2 +- scripts/checkpatch.pl | 5 + scripts/cocci-macro-file.h | 24 ++-- slirp/slirp.c | 2 +- target/arm/kvm.c | 2 +- target/i386/hax-mem.c | 2 +- tcg/tcg.c | 2 +- tcg/tcg.h | 6 +- tests/libqos/malloc.c | 2 +- tests/test-rcu-list.c | 2 +- tests/test-vmstate.c | 8 +- ui/console.c | 4 +- ui/input.c | 14 ++- util/qemu-option.c | 4 +- vl.c | 2 +- 71 files changed, 217 insertions(+), 248 deletions(-)
Signature · 1 line
2.19.2
PATCH v2 1/8 qemu/queue.h: do not access tqe_prev directly
Use the QTAILQ_IN_USE macro instead, it does the same thing but in a few patches its definition will change.
--- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
blockdev.c +1 -1
@@ -4259,7 +4259,7 @@ void qmp_blockdev_del(const char *node_name, Error **errp) goto out; } -if (!bs->monitor_list.tqe_prev) { +if (!QTAILQ_IN_USE (bs, monitor_list)) {error_setg (errp,"Node %s is not owned by the monitor" , bs->node_name); goto out;
Signature · 1 line
2.19.2
PATCH v2 2/8 vfio: make vfio_address_spaces static
In reply to Paolo BonziniIt is not used outside hw/vfio/common.c, so it does not need to be extern.
--- hw/vfio/common.c | 2 +- include/hw/vfio/vfio-common.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
hw/vfio/common.c +1 -1
@@ -39,7 +39,7 @@struct vfio_group_head vfio_group_list =QLIST_HEAD_INITIALIZER (vfio_group_list); -struct vfio_as_head vfio_address_spaces = +static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =QLIST_HEAD_INITIALIZER (vfio_address_spaces);#ifdef CONFIG_KVM
include/hw/vfio/vfio-common.h +0 -1
@@ -181,7 +181,6 @@ int vfio_get_device(VFIOGroup *group, const char *name,extern const MemoryRegionOps vfio_region_ops; extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list; -extern QLIST_HEAD(vfio_as_head, VFIOAddressSpace) vfio_address_spaces;#ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index,
Signature · 1 line
2.19.2
PATCH v2 3/8 qemu/queue.h: leave head structs anonymous unless necessary
In reply to Paolo BonziniMost list head structs need not be given a name. In most cases the name is given just in case one is going to use QTAILQ_LAST, QTAILQ_PREV or reverse iteration, but this does not apply to lists of other kinds, and even for QTAILQ in practice this is only rarely needed. In addition, we will soon reimplement those macros completely so that they do not need a name for the head struct. So clean up everything, not giving a name except in the rare case where it is necessary.
--- accel/kvm/kvm-all.c | 4 ++-- block/gluster.c | 2 +- block/mirror.c | 2 +- block/qcow2-bitmap.c | 4 +--- block/qcow2.h | 2 +- block/sheepdog.c | 6 +++--- block/vhdx.h | 2 +- blockdev.c | 2 +- contrib/ivshmem-client/ivshmem-client.h | 4 +--- contrib/ivshmem-server/ivshmem-server.h | 5 +---- exec.c | 2 +- fsdev/qemu-fsdev.c | 2 +- hw/block/nvme.h | 8 ++++---- hw/block/xen_disk.c | 6 +++--- hw/core/reset.c | 2 +- hw/i386/xen/xen-mapcache.c | 2 +- hw/ppc/spapr_iommu.c | 2 +- hw/usb/ccid-card-emulated.c | 4 ++-- hw/usb/dev-network.c | 2 +- hw/usb/xen-usb.c | 6 +++--- hw/watchdog/watchdog.c | 2 +- hw/xen/xen_pvdev.c | 4 ++-- include/exec/memory.h | 4 ++-- include/hw/vfio/vfio-platform.h | 2 +- include/qom/cpu.h | 4 ++-- include/sysemu/kvm.h | 2 -- include/sysemu/rng.h | 2 +- linux-user/elfload.c | 2 +- memory.c | 2 +- migration/block-dirty-bitmap.c | 2 +- migration/block.c | 4 ++-- migration/ram.c | 2 +- monitor.c | 4 ++-- net/queue.c | 2 +- net/slirp.c | 2 +- slirp/slirp.c | 2 +- target/arm/kvm.c | 2 +- target/i386/hax-mem.c | 2 +- tcg/tcg.h | 2 +- tests/test-rcu-list.c | 2 +- vl.c | 2 +- 41 files changed, 56 insertions(+), 65 deletions(-)
accel/kvm/kvm-all.c +2 -2
@@ -86,7 +86,7 @@ struct KVMStateint robust_singlestep;int debugregs;#ifdef KVM_CAP_SET_GUEST_DEBUG -struct kvm_sw_breakpoint_head kvm_sw_breakpoints; + QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;#endif int many_ioeventfds;int intx_set_mask;
@@ -102,7 +102,7 @@ struct KVMStateint nr_allocated_irq_routes;unsigned long *used_gsi_bitmap;unsigned int gsi_count; - QTAILQ_HEAD(msi_hashtab, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE]; + QTAILQ_HEAD(, KVMMSIRoute) msi_hashtab[KVM_MSI_HASHTAB_SIZE];#endif KVMMemoryListener memory_listener; QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus;
block/gluster.c +1 -1
@@ -72,7 +72,7 @@ typedef struct ListElement {GlfsPreopened saved; } ListElement; -static QLIST_HEAD(glfs_list, ListElement) glfs_list; +static QLIST_HEAD(, ListElement) glfs_list;static QemuOptsList qemu_gluster_create_opts = { .name ="qemu-gluster-create-opts" ,
block/mirror.c +1 -1
@@ -72,7 +72,7 @@ typedef struct MirrorBlockJob {unsigned long *in_flight_bitmap;int in_flight;int64_t bytes_in_flight; - QTAILQ_HEAD(MirrorOpList, MirrorOp) ops_in_flight; + QTAILQ_HEAD(, MirrorOp) ops_in_flight;int ret;bool unmap;int target_cluster_size;
block/qcow2-bitmap.c +1 -3
@@ -77,8 +77,6 @@ typedef struct Qcow2BitmapTable {uint32_t size;/* number of 64bit entries */ QSIMPLEQ_ENTRY (Qcow2BitmapTable) entry; } Qcow2BitmapTable; -typedef QSIMPLEQ_HEAD(Qcow2BitmapTableList, Qcow2BitmapTable) -Qcow2BitmapTableList ; typedef struct Qcow2Bitmap { Qcow2BitmapTable table;
@@ -1316,7 +1314,7 @@ void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp)int ret;Qcow2BitmapList *bm_list;Qcow2Bitmap *bm; -Qcow2BitmapTableList drop_tables; + QSIMPLEQ_HEAD(, Qcow2BitmapTable) drop_tables;Qcow2BitmapTable *tb, *tb_next;if (!bdrv_has_changed_persistent_bitmaps (bs)) {
block/qcow2.h +1 -1
@@ -281,7 +281,7 @@ typedef struct BDRVQcow2State {uint8_t *cluster_cache;uint8_t *cluster_data;uint64_t cluster_cache_offset; - QLIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs; + QLIST_HEAD(, QCowL2Meta) cluster_allocs;uint64_t *refcount_table;uint64_t refcount_table_offset;
block/sheepdog.c +3 -3
@@ -391,12 +391,12 @@ struct BDRVSheepdogState {uint32_t aioreq_seq_num;/* Every aio request must be linked to either of these queues. */ - QLIST_HEAD(inflight_aio_head, AIOReq) inflight_aio_head; - QLIST_HEAD(failed_aio_head, AIOReq) failed_aio_head; + QLIST_HEAD(, AIOReq) inflight_aio_head; + QLIST_HEAD(, AIOReq) failed_aio_head;CoMutex queue_lock;CoQueue overlapping_queue; - QLIST_HEAD(inflight_aiocb_head, SheepdogAIOCB) inflight_aiocb_head; + QLIST_HEAD(, SheepdogAIOCB) inflight_aiocb_head; }; typedef struct BDRVSheepdogReopenState {
block/vhdx.h +1 -1
@@ -398,7 +398,7 @@ typedef struct BDRVVHDXState {bool log_replayed_on_open; - QLIST_HEAD(VHDXRegionHead, VHDXRegionEntry) regions; + QLIST_HEAD(, VHDXRegionEntry) regions; } BDRVVHDXState;void vhdx_guid_generate (MSGUID *guid);
blockdev.c +1 -1
@@ -2269,7 +2269,7 @@ void qmp_transaction(TransactionActionList *dev_list,BlkActionState *state, *next;Error *local_err =NULL ; - QSIMPLEQ_HEAD(snap_bdrv_states, BlkActionState) snap_bdrv_states; + QSIMPLEQ_HEAD(, BlkActionState) snap_bdrv_states;QSIMPLEQ_INIT (&snap_bdrv_states);/* Does this transaction get canceled as a group on failure?
contrib/ivshmem-client/ivshmem-client.h +1 -3
@@ -46,9 +46,7 @@ typedef struct IvshmemClientPeer {int vectors[IVSHMEM_CLIENT_MAX_VECTORS ];/**< one fd per vector */ unsigned vectors_count;/**< number of vectors */ } IvshmemClientPeer; -QTAILQ_HEAD (IvshmemClientPeerList, IvshmemClientPeer); -typedef struct IvshmemClientPeerList IvshmemClientPeerList ;typedef struct IvshmemClient IvshmemClient ;/**
@@ -73,7 +71,7 @@ struct IvshmemClient {int sock_fd;/**< unix sock filedesc */ int shm_fd;/**< shm file descriptor */ -IvshmemClientPeerList peer_list;/**< list of peers */ + QTAILQ_HEAD(, IvshmemClientPeer) peer_list; /**< list of peers */IvshmemClientPeer local;/**< our own infos */ IvshmemClientNotifCb notif_cb;/**< notification callback */
contrib/ivshmem-server/ivshmem-server.h +1 -4
@@ -52,9 +52,6 @@ typedef struct IvshmemServerPeer {EventNotifier vectors[IVSHMEM_SERVER_MAX_VECTORS ];/**< one per vector */ unsigned vectors_count;/**< number of vectors */ } IvshmemServerPeer; -QTAILQ_HEAD (IvshmemServerPeerList, IvshmemServerPeer); - -typedef struct IvshmemServerPeerList IvshmemServerPeerList ;/** * Structure describing an ivshmem server
@@ -72,7 +69,7 @@ typedef struct IvshmemServer {unsigned n_vectors;/**< number of vectors */ uint16_t cur_id;/**< id to be given to next client */ bool verbose;/**< true in verbose mode */ -IvshmemServerPeerList peer_list;/**< list of peers */ + QTAILQ_HEAD(, IvshmemServerPeer) peer_list; /**< list of peers */ } IvshmemServer;/**
exec.c +1 -1
@@ -3464,7 +3464,7 @@ typedef struct MapClient { } MapClient;QemuMutex map_client_list_lock; -static QLIST_HEAD(map_client_list, MapClient) map_client_list +static QLIST_HEAD(, MapClient) map_client_list =QLIST_HEAD_INITIALIZER (map_client_list);static void cpu_unregister_map_client_do (MapClient *client)
fsdev/qemu-fsdev.c +1 -1
@@ -18,7 +18,7 @@#include "qemu/error-report.h" #include "qemu/option.h" -static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries = +static QTAILQ_HEAD(, FsDriverListEntry) fsdriver_entries =QTAILQ_HEAD_INITIALIZER (fsdriver_entries);static FsDriverTable FsDrivers[] = {
hw/block/nvme.h +4 -4
@@ -29,8 +29,8 @@ typedef struct NvmeSQueue {uint64_t dma_addr;QEMUTimer *timer;NvmeRequest *io_req; - QTAILQ_HEAD(sq_req_list, NvmeRequest) req_list; - QTAILQ_HEAD(out_req_list, NvmeRequest) out_req_list; + QTAILQ_HEAD(, NvmeRequest) req_list; + QTAILQ_HEAD(, NvmeRequest) out_req_list;QTAILQ_ENTRY (NvmeSQueue) entry; } NvmeSQueue;
@@ -45,8 +45,8 @@ typedef struct NvmeCQueue {uint32_t size;uint64_t dma_addr;QEMUTimer *timer; - QTAILQ_HEAD(sq_list, NvmeSQueue) sq_list; - QTAILQ_HEAD(cq_req_list, NvmeRequest) req_list; + QTAILQ_HEAD(, NvmeSQueue) sq_list; + QTAILQ_HEAD(, NvmeRequest) req_list; } NvmeCQueue; typedef struct NvmeNamespace {
hw/block/xen_disk.c +3 -3
@@ -82,9 +82,9 @@ struct XenBlkDev {int more_work;/* request lists */ - QLIST_HEAD(inflight_head, ioreq) inflight; - QLIST_HEAD(finished_head, ioreq) finished; - QLIST_HEAD(freelist_head, ioreq) freelist; + QLIST_HEAD(, ioreq) inflight; + QLIST_HEAD(, ioreq) finished; + QLIST_HEAD(, ioreq) freelist;int requests_total;int requests_inflight;int requests_finished;
hw/core/reset.c +1 -1
@@ -35,7 +35,7 @@ typedef struct QEMUResetEntry {void *opaque; } QEMUResetEntry; -static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = +static QTAILQ_HEAD(, QEMUResetEntry) reset_handlers =QTAILQ_HEAD_INITIALIZER (reset_handlers);void qemu_register_reset (QEMUResetHandler *func,void *opaque)
hw/i386/xen/xen-mapcache.c +1 -1
@@ -71,7 +71,7 @@ typedef struct MapCacheRev { typedef struct MapCache { MapCacheEntry *entry; unsigned long nr_buckets; - QTAILQ_HEAD(map_cache_head, MapCacheRev) locked_entries; + QTAILQ_HEAD(, MapCacheRev) locked_entries; /* For most cases (>99.9%), the page address is the same. */ MapCacheEntry *last_entry;
hw/ppc/spapr_iommu.c +1 -1
@@ -42,7 +42,7 @@ enum sPAPRTCEAccess {#define IOMMU_PAGE_SIZE (shift) (1ULL << (shift))#define IOMMU_PAGE_MASK (shift) (~(IOMMU_PAGE_SIZE(shift) - 1)) -static QLIST_HEAD(spapr_tce_tables, sPAPRTCETable) spapr_tce_tables; +static QLIST_HEAD(, sPAPRTCETable) spapr_tce_tables;sPAPRTCETable *spapr_tce_find_by_liobn (target_ulong liobn) {
hw/usb/ccid-card-emulated.c +2 -2
@@ -119,11 +119,11 @@ struct EmulatedState {char *db;uint8_t atr[MAX_ATR_SIZE ];uint8_t atr_length; - QSIMPLEQ_HEAD(event_list, EmulEvent) event_list; + QSIMPLEQ_HEAD(, EmulEvent) event_list;QemuMutex event_list_mutex;QemuThread event_thread_id;VReader *reader; - QSIMPLEQ_HEAD(guest_apdu_list, EmulEvent) guest_apdu_list; + QSIMPLEQ_HEAD(, EmulEvent) guest_apdu_list;QemuMutex vreader_mutex;/* and guest_apdu_list mutex */ QemuMutex handle_apdu_mutex;QemuCond handle_apdu_cond;
hw/usb/dev-network.c +1 -1
@@ -648,7 +648,7 @@ typedef struct USBNetState {char usbstring_mac[13 ];NICState *nic;NICConf conf; - QTAILQ_HEAD(rndis_resp_head, rndis_response) rndis_resp; + QTAILQ_HEAD(, rndis_response) rndis_resp; } USBNetState;#define TYPE_USB_NET "usb-net"
hw/usb/xen-usb.c +3 -3
@@ -72,7 +72,7 @@ struct usbback_stub {USBPort port;unsigned int speed;bool attached; - QTAILQ_HEAD(submit_q_head, usbback_req) submit_q; + QTAILQ_HEAD(, usbback_req) submit_q; };struct usbback_req {
@@ -108,8 +108,8 @@ struct usbback_info {int num_ports;int usb_ver;bool ring_error; - QTAILQ_HEAD(req_free_q_head, usbback_req) req_free_q; - QSIMPLEQ_HEAD(hotplug_q_head, usbback_hotplug) hotplug_q; + QTAILQ_HEAD(, usbback_req) req_free_q; + QSIMPLEQ_HEAD(, usbback_hotplug) hotplug_q;struct usbback_stub ports[USBBACK_MAXPORTS ];struct usbback_stub *addr_table[USB_DEV_ADDR_SIZE ];QEMUBH *bh;
hw/watchdog/watchdog.c +1 -1
@@ -32,7 +32,7 @@#include "qemu/help_option.h" static WatchdogAction watchdog_action =WATCHDOG_ACTION_RESET ; -static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; +static QLIST_HEAD(, WatchdogTimerModel) watchdog_list;void watchdog_add_model (WatchdogTimerModel *model) {
hw/xen/xen_pvdev.c +2 -2
@@ -31,10 +31,10 @@ struct xs_dirs {QTAILQ_ENTRY (xs_dirs) list; }; -static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup = +static QTAILQ_HEAD(, xs_dirs) xs_cleanup =QTAILQ_HEAD_INITIALIZER (xs_cleanup); -static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = +static QTAILQ_HEAD(, XenDevice) xendevs =QTAILQ_HEAD_INITIALIZER (xendevs);/* ------------------------------------------------------------- */
include/exec/memory.h +2 -2
@@ -379,9 +379,9 @@ struct MemoryRegion {MemoryRegion *alias;hwaddr alias_offset;int32_t priority; - QTAILQ_HEAD(subregions, MemoryRegion) subregions; + QTAILQ_HEAD(, MemoryRegion) subregions;QTAILQ_ENTRY (MemoryRegion) subregions_link; - QTAILQ_HEAD(coalesced_ranges, CoalescedMemoryRange) coalesced; + QTAILQ_HEAD(, CoalescedMemoryRange) coalesced;const char *name;unsigned ioeventfd_nb;MemoryRegionIoeventfd *ioeventfds;
include/hw/vfio/vfio-platform.h +1 -1
@@ -53,7 +53,7 @@ typedef struct VFIOPlatformDevice {VFIORegion **regions; QLIST_HEAD(, VFIOINTp) intp_list; /* list of IRQs *//* queue of pending IRQs */ - QSIMPLEQ_HEAD(pending_intp_queue, VFIOINTp) pending_intp_queue; + QSIMPLEQ_HEAD(, VFIOINTp) pending_intp_queue;char *compat;/* DT compatible values, separated by NUL */ unsigned int num_compat;/* number of compatible values */ uint32_t mmap_timeout;/* delay to re-enable mmaps after interrupt */
include/qom/cpu.h +2 -2
@@ -375,9 +375,9 @@ struct CPUState {QTAILQ_ENTRY (CPUState) node;/* ice debug support */ - QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; + QTAILQ_HEAD(, CPUBreakpoint) breakpoints; - QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; + QTAILQ_HEAD(, CPUWatchpoint) watchpoints;CPUWatchpoint *watchpoint_hit;void *opaque;
include/sysemu/kvm.h +0 -2
@@ -412,8 +412,6 @@ struct kvm_sw_breakpoint {QTAILQ_ENTRY (kvm_sw_breakpoint) entry; }; -QTAILQ_HEAD (kvm_sw_breakpoint_head, kvm_sw_breakpoint); -struct kvm_sw_breakpoint *kvm_find_sw_breakpoint (CPUState *cpu,target_ulong pc);
include/sysemu/rng.h +1 -1
@@ -57,7 +57,7 @@ struct RngBackend/*< protected >*/ bool opened; - QSIMPLEQ_HEAD(requests, RngRequest) requests; + QSIMPLEQ_HEAD(, RngRequest) requests; };
linux-user/elfload.c +1 -1
@@ -2844,7 +2844,7 @@ struct elf_note_info {struct target_elf_prstatus *prstatus;/* NT_PRSTATUS */ struct target_elf_prpsinfo *psinfo;/* NT_PRPSINFO */ - QTAILQ_HEAD(thread_list_head, elf_thread_status) thread_list; + QTAILQ_HEAD(, elf_thread_status) thread_list;#if 0 /* * Current version of ELF coredump doesn't support
memory.c +1 -1
@@ -2795,7 +2795,7 @@ struct MemoryRegionList {QTAILQ_ENTRY (MemoryRegionList) mrqueue; }; -typedef QTAILQ_HEAD(mrqueue, MemoryRegionList) MemoryRegionListHead; +typedef QTAILQ_HEAD(, MemoryRegionList) MemoryRegionListHead;#define MR_SIZE (size) (int128_nz(size) ? (hwaddr)int128_get64( \ int128_sub((size), int128_one())) : 0)
migration/block-dirty-bitmap.c +1 -1
@@ -116,7 +116,7 @@ typedef struct DirtyBitmapMigBitmapState { } DirtyBitmapMigBitmapState; typedef struct DirtyBitmapMigState { - QSIMPLEQ_HEAD(dbms_list, DirtyBitmapMigBitmapState) dbms_list; + QSIMPLEQ_HEAD(, DirtyBitmapMigBitmapState) dbms_list; bool bulk_completed; bool no_bitmaps;
migration/block.c +2 -2
@@ -93,12 +93,12 @@ typedef struct BlkMigBlock { } BlkMigBlock; typedef struct BlkMigState { - QSIMPLEQ_HEAD(bmds_list, BlkMigDevState) bmds_list; + QSIMPLEQ_HEAD(, BlkMigDevState) bmds_list; int64_t total_sector_sum; bool zero_blocks; /* Protected by lock. */ - QSIMPLEQ_HEAD(blk_list, BlkMigBlock) blk_list; + QSIMPLEQ_HEAD(, BlkMigBlock) blk_list; int submitted; int read_done;
migration/ram.c +1 -1
@@ -322,7 +322,7 @@ struct RAMState {RAMBlock *last_req_rb;/* Queue of outstanding page requests from the destination */ QemuMutex src_page_req_mutex; - QSIMPLEQ_HEAD(src_page_requests, RAMSrcPageRequest) src_page_requests; + QSIMPLEQ_HEAD(, RAMSrcPageRequest) src_page_requests; };typedef struct RAMState RAMState ;
monitor.c +2 -2
@@ -266,11 +266,11 @@ typedef struct QMPRequest QMPRequest;/* Protects mon_list, monitor_qapi_event_state. */ static QemuMutex monitor_lock;static GHashTable *monitor_qapi_event_state; -static QTAILQ_HEAD(mon_list, Monitor) mon_list; +static QTAILQ_HEAD(, Monitor) mon_list;/* Protects mon_fdsets */ static QemuMutex mon_fdsets_lock; -static QLIST_HEAD(mon_fdsets, MonFdset) mon_fdsets; +static QLIST_HEAD(, MonFdset) mon_fdsets;static int mon_refcount;
net/queue.c +1 -1
@@ -55,7 +55,7 @@ struct NetQueue {uint32_t nq_count;NetQueueDeliverFunc *deliver; - QTAILQ_HEAD(packets, NetPacket) packets; + QTAILQ_HEAD(, NetPacket) packets; unsigned delivering : 1; };
net/slirp.c +1 -1
@@ -85,7 +85,7 @@ typedef struct SlirpState { } SlirpState;static struct slirp_config_str *slirp_configs; -static QTAILQ_HEAD(slirp_stacks, SlirpState) slirp_stacks = +static QTAILQ_HEAD(, SlirpState) slirp_stacks =QTAILQ_HEAD_INITIALIZER (slirp_stacks);static int slirp_hostfwd (SlirpState *s,const char *redir_str,Error **errp);
slirp/slirp.c +1 -1
@@ -47,7 +47,7 @@ static const uint8_t special_ethaddr[ETH_ALEN] = {u_int curtime; -static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances = +static QTAILQ_HEAD(, Slirp) slirp_instances =QTAILQ_HEAD_INITIALIZER (slirp_instances);static struct in_addr dns_addr;
target/arm/kvm.c +1 -1
@@ -206,7 +206,7 @@ typedef struct KVMDevice {int dev_fd; } KVMDevice; -static QSLIST_HEAD(kvm_devices_head, KVMDevice) kvm_devices_head; +static QSLIST_HEAD(, KVMDevice) kvm_devices_head;static void kvm_arm_devlistener_add (MemoryListener *listener,MemoryRegionSection *section)
target/i386/hax-mem.c +1 -1
@@ -56,7 +56,7 @@ typedef struct HAXMapping {* send to the kernel only the removal of the pages from the MMIO hole after * having computed locally the result of the deletion and additions. */ -static QTAILQ_HEAD(HAXMappingListHead, HAXMapping) mappings = +static QTAILQ_HEAD(, HAXMapping) mappings =QTAILQ_HEAD_INITIALIZER (mappings);/**
tcg/tcg.h +1 -1
@@ -704,7 +704,7 @@ struct TCGContext {/* These structures are private to tcg-target.inc.c. */ #ifdef TCG_TARGET_NEED_LDST_LABELS - QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels; + QSIMPLEQ_HEAD(, TCGLabelQemuLdst) ldst_labels;#endif #ifdef TCG_TARGET_NEED_POOL_LABELS struct TCGLabelPoolData *pool_labels;
tests/test-rcu-list.c +1 -1
@@ -108,7 +108,7 @@ static void reclaim_list_el(struct rcu_head *prcu) }#if TEST_LIST_TYPE ==1 -static QLIST_HEAD(q_list_head, list_element) Q_list_head; +static QLIST_HEAD(, list_element) Q_list_head;#define TEST_NAME "qlist"#define TEST_LIST_REMOVE_RCU QLIST_REMOVE_RCU
vl.c +1 -1
@@ -1529,7 +1529,7 @@ struct vm_change_state_entry {QLIST_ENTRY (vm_change_state_entry) entries; }; -static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head; +static QLIST_HEAD(, vm_change_state_entry) vm_change_state_head;VMChangeStateEntry *qemu_add_vm_change_state_handler (VMChangeStateHandler *cb,void *opaque)
Signature · 1 line
2.19.2
PATCH v2 4/8 qemu/queue.h: typedef QTAILQ heads
In reply to Paolo BonziniThis will be needed when we change the QTAILQ head and elem structs to unions. However, it is also consistent with the usage elsewhere in QEMU for other list head structs (see for example FsMountList).
Note that most QTAILQs only need their name in order to do backwards walks. Those do not break with the struct->union change, and anyway the change will also remove the need to name heads when doing backwards walks, so those are not touched here.
--- exec.c | 3 ++- hw/vfio/common.c | 2 +- include/hw/vfio/vfio-common.h | 3 ++- include/qom/cpu.h | 5 +++-- ui/input.c | 14 ++++++++------ 5 files changed, 16 insertions(+), 11 deletions(-)
exec.c +2 -1
@@ -94,7 +94,8 @@ int target_page_bits;bool target_page_bits_decided;#endif -struct CPUTailQ cpus =QTAILQ_HEAD_INITIALIZER (cpus); +CPUTailQ cpus =QTAILQ_HEAD_INITIALIZER (cpus); +/* current CPU in the current thread. It is only valid inside cpu_exec() */ __threadCPUState *current_cpu;
hw/vfio/common.c +1 -1
@@ -37,7 +37,7 @@#include "trace.h" #include "qapi/error.h" -struct vfio_group_head vfio_group_list = +VFIOGroupList vfio_group_list =QLIST_HEAD_INITIALIZER (vfio_group_list); static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =QLIST_HEAD_INITIALIZER (vfio_address_spaces);
include/hw/vfio/vfio-common.h +2 -1
@@ -180,7 +180,8 @@ int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vbasedev, Error **errp);extern const MemoryRegionOps vfio_region_ops; -extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list; +typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; +extern VFIOGroupList vfio_group_list;#ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index,
include/qom/cpu.h +3 -2
@@ -435,8 +435,9 @@ struct CPUState {GArray *iommu_notifiers; }; -QTAILQ_HEAD (CPUTailQ, CPUState); -extern struct CPUTailQ cpus; +typedef QTAILQ_HEAD(CPUTailQ, CPUState) CPUTailQ; +extern CPUTailQ cpus; +#define first_cpu QTAILQ_FIRST_RCU(&cpus)#define CPU_NEXT (cpu) QTAILQ_NEXT_RCU(cpu, node)#define CPU_FOREACH (cpu) QTAILQ_FOREACH_RCU(cpu, &cpus, node)
ui/input.c +8 -6
@@ -19,6 +19,9 @@ struct QemuInputHandlerState { };typedef struct QemuInputEventQueue QemuInputEventQueue ; +typedef QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) +QemuInputEventQueueHead ; +struct QemuInputEventQueue {enum {QEMU_INPUT_QUEUE_DELAY =1 ,
@@ -37,8 +40,7 @@ static QTAILQ_HEAD(, QemuInputHandlerState) handlers =static NotifierList mouse_mode_notifiers =NOTIFIER_LIST_INITIALIZER (mouse_mode_notifiers); -static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue = -QTAILQ_HEAD_INITIALIZER (kbd_queue); +static QemuInputEventQueueHead kbd_queue =QTAILQ_HEAD_INITIALIZER (kbd_queue);static QEMUTimer *kbd_timer;static uint32_t kbd_default_delay_ms =10 ;static uint32_t queue_count;
@@ -257,7 +259,7 @@ static void qemu_input_event_trace(QemuConsole *src, InputEvent *evt)static void qemu_input_queue_process (void *opaque) { -struct QemuInputEventQueueHead *queue = opaque; +QemuInputEventQueueHead *queue = opaque;QemuInputEventQueue *item;g_assert (!QTAILQ_EMPTY (queue));
@@ -288,7 +290,7 @@ static void qemu_input_queue_process(void *opaque) } } -static void qemu_input_queue_delay (struct QemuInputEventQueueHead *queue, +static void qemu_input_queue_delay (QemuInputEventQueueHead *queue,QEMUTimer *timer,uint32_t delay_ms) {QemuInputEventQueue *item =g_new0 (QemuInputEventQueue,1 );
@@ -306,7 +308,7 @@ static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue, } } -static void qemu_input_queue_event (struct QemuInputEventQueueHead *queue, +static void qemu_input_queue_event (QemuInputEventQueueHead *queue,QemuConsole *src,InputEvent *evt) {QemuInputEventQueue *item =g_new0 (QemuInputEventQueue,1 );
@@ -318,7 +320,7 @@ static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue, queue_count++; } -static void qemu_input_queue_sync (struct QemuInputEventQueueHead *queue) +static void qemu_input_queue_sync (QemuInputEventQueueHead *queue) {QemuInputEventQueue *item =g_new0 (QemuInputEventQueue,1 );
Signature · 1 line
2.19.2
PATCH v2 5/8 qemu/queue.h: remove Q_TAILQ_{HEAD, ENTRY}
In reply to Paolo BonziniThese are not present for other kinds of queue, and unused. Zap them before more changes are made to the QTAILQ implementation.
--- include/qemu/queue.h | 14 ++++++-------- scripts/cocci-macro-file.h | 10 ---------- 2 files changed, 6 insertions(+), 18 deletions(-)
include/qemu/queue.h +6 -8
@@ -350,22 +350,20 @@ struct { \/* * Tail queue definitions. */ -#define Q_TAILQ_HEAD(name, type, qual) \ +#define QTAILQ_HEAD (name, type) \ struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last;/* addr of last next element */ \ + type *tqh_first;/* first element */ \ +type **tqh_last;/* addr of last next element */ \ } -#define QTAILQ_HEAD (name, type) Q_TAILQ_HEAD(name, struct type,)#define QTAILQ_HEAD_INITIALIZER (head) \ { NULL, &(head).tqh_first } -#define Q_TAILQ_ENTRY(type, qual) \ +#define QTAILQ_ENTRY (type) \ struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev; /* address of previous next element */\ + type *tqe_next;/* next element */ \ +type **tqe_prev;/* address of previous next element */ \ } -#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,)/* * Tail queue functions.
scripts/cocci-macro-file.h +0 -10
@@ -93,11 +93,6 @@ struct { \/* * Tail queue definitions. */ -#define Q_TAILQ_HEAD(name, type, qual) \ -struct name { \ - qual type *tqh_first; /* first element */ \ - qual type *qual *tqh_last;/* addr of last next element */ \ -}#define QTAILQ_HEAD (name, type) \ struct name { \ type *tqh_first;/* first element */ \
@@ -107,11 +102,6 @@ struct name { \#define QTAILQ_HEAD_INITIALIZER (head) \ { NULL, &(head).tqh_first } -#define Q_TAILQ_ENTRY(type, qual) \ -struct { \ - qual type *tqe_next; /* next element */ \ - qual type *qual *tqe_prev;/* address of previous next element */ \ -}#define QTAILQ_ENTRY (type) \ struct { \ type *tqe_next;/* next element */ \
Signature · 1 line
2.19.2
PATCH v2 6/8 qemu/queue.h: reimplement QTAILQ without pointer-to-pointers
In reply to Paolo BonziniQTAILQ is a doubly linked list, with a pointer-to-pointer to the last element from the head, and the previous element from each node.
But if you squint enough, QTAILQ becomes a combination of a singly-linked forwards list, and another singly-linked list which goes backwards and is circular. This is the idea that lets QTAILQ implement reverse
iteration: only, because the backwards list points inside the node, accessing the previous element needs to go two steps back and one forwards.
What this patch does is implement it in these terms, without actually changing the in-memory layout at all. The coexistence of the two lists is realized by making QTAILQ_HEAD and QTAILQ_ENTRY unions of the forwards pointer and a generic QTailQLink node. Thq QTailQLink can walk the list in both directions; the union is needed so that the forwards pointer can have the correct type, as a sort of poor man's template. While there are other ways to get the same layout without a union, this one has the advantage of simpler operation in the debugger, because the fields tqh_first and tqe_next still exist as before the patch. Those fields are also used by scripts/qemugdb/mtree.py, so it's a good idea to preserve them.
The advantage of the new representation is that the two-back-one-forward dance done by backwards accesses can be done all while operating on QTailQLinks. No casting to the head struct is needed anymore because, even though the QTailQLink's forward pointer is a void *, we can use typeof to recover the correct type. This patch only changes the implementation, not the interface. The next patch will remove the head struct name from the backwards visit macros.
--- include/qemu/queue.h | 139 ++++++++++++++++--------------------- include/qemu/rcu_queue.h | 45 ++++++------ scripts/cocci-macro-file.h | 14 ++-- 3 files changed, 92 insertions(+), 106 deletions(-)
include/qemu/queue.h +61 -78
@@ -346,23 +346,28 @@ struct { \#define QSIMPLEQ_FIRST (head) ((head)->sqh_first)#define QSIMPLEQ_NEXT (elm, field) ((elm)->field.sqe_next) +typedef struct QTailQLink { +void *tql_next; +struct QTailQLink *tql_prev; +}QTailQLink ;/* -* Tail queue definitions. +* Tail queue definitions. The union acts as a poor man template, as if +* it were QTailQLink<type>. */ #define QTAILQ_HEAD (name, type) \ -struct name { \ - type *tqh_first;/* first element */ \ -type **tqh_last;/* addr of last next element */ \ +union name { \ + struct type *tqh_first;/* first element */ \ +QTailQLink tqh_circ;/* link for circular backwards list */ \ }#define QTAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).tqh_first } + { .tqh_circ = { NULL, &(head).tqh_circ } }#define QTAILQ_ENTRY (type) \ -struct { \ - type *tqe_next;/* next element */ \ -type **tqe_prev;/* address of previous next element */ \ +union { \ + struct type *tqe_next;/* next element */ \ +QTailQLink tqe_circ;/* link for circular backwards list */ \ }/*
@@ -370,51 +375,51 @@ struct { \*/ #define QTAILQ_INIT(head) do { \ (head)->tqh_first = NULL; \ - (head)->tqh_last = &(head)->tqh_first; \ + (head)->tqh_circ.tql_prev = &(head)->tqh_circ; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ - (head)->tqh_first->field.tqe_prev = \ - &(elm)->field.tqe_next; \ + (head)->tqh_first->field.tqe_circ.tql_prev = \ + &(elm)->field.tqe_circ; \ else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ (head)->tqh_first = (elm); \ - (elm)->field.tqe_prev = &(head)->tqh_first; \ + (elm)->field.tqe_circ.tql_prev = &(head)->tqh_circ; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.tqe_next = NULL; \ - (elm)->field.tqe_prev = (head)->tqh_last; \ - *(head)->tqh_last = (elm); \ - (head)->tqh_last = &(elm)->field.tqe_next; \ + (elm)->field.tqe_circ.tql_prev = (head)->tqh_circ.tql_prev; \ + (head)->tqh_circ.tql_prev->tql_next = (elm); \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ } while (/*CONSTCOND*/0) #define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ - (elm)->field.tqe_next->field.tqe_prev = \ - &(elm)->field.tqe_next; \ + (elm)->field.tqe_next->field.tqe_circ.tql_prev = \ + &(elm)->field.tqe_circ; \ else \ - (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_circ.tql_prev = &(elm)->field.tqe_circ; \ (listelm)->field.tqe_next = (elm); \ - (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ + (elm)->field.tqe_circ.tql_prev = &(listelm)->field.tqe_circ; \ } while (/*CONSTCOND*/0) -#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ - (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ - (elm)->field.tqe_next = (listelm); \ - *(listelm)->field.tqe_prev = (elm); \ - (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_circ.tql_prev = (listelm)->field.tqe_circ.tql_prev; \ + (elm)->field.tqe_next = (listelm); \ + (listelm)->field.tqe_circ.tql_prev->tql_next = (elm); \ + (listelm)->field.tqe_circ.tql_prev = &(elm)->field.tqe_circ; \ } while (/*CONSTCOND*/0) #define QTAILQ_REMOVE(head, elm, field) do { \ if (((elm)->field.tqe_next) != NULL) \ - (elm)->field.tqe_next->field.tqe_prev = \ - (elm)->field.tqe_prev; \ + (elm)->field.tqe_next->field.tqe_circ.tql_prev = \ + (elm)->field.tqe_circ.tql_prev; \ else \ - (head)->tqh_last = (elm)->field.tqe_prev; \ - *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ - (elm)->field.tqe_prev = NULL; \ + (head)->tqh_circ.tql_prev = (elm)->field.tqe_circ.tql_prev; \ + (elm)->field.tqe_circ.tql_prev->tql_next = (elm)->field.tqe_next; \ + (elm)->field.tqe_circ.tql_prev = NULL; \ } while (/*CONSTCOND*/0)#define QTAILQ_FOREACH (var, head, field) \
@@ -428,13 +433,13 @@ struct { \ (var) = (next_var))#define QTAILQ_FOREACH_REVERSE (var, head, headname, field) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ + for ((var) = QTAILQ_LAST(head, headname); \ (var); \ - (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) + (var) = QTAILQ_PREV(var, headname, field))#define QTAILQ_FOREACH_REVERSE_SAFE (var, head, headname, field, prev_var) \ - for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ - (var) && ((prev_var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last)), 1); \ + for ((var) = QTAILQ_LAST(head, headname); \ + (var) && ((prev_var) = QTAILQ_PREV(var, headname, field)); \ (var) = (prev_var))/*
@@ -443,71 +448,49 @@ struct { \#define QTAILQ_EMPTY (head) ((head)->tqh_first == NULL)#define QTAILQ_FIRST (head) ((head)->tqh_first)#define QTAILQ_NEXT (elm, field) ((elm)->field.tqe_next) -#define QTAILQ_IN_USE (elm, field) ((elm)->field.tqe_prev != NULL) +#define QTAILQ_IN_USE (elm, field) ((elm)->field.tqe_circ.tql_prev != NULL) +#define QTAILQ_LINK_PREV (link) \ + ((link).tql_prev->tql_prev->tql_next)#define QTAILQ_LAST (head, headname) \ - (*(((struct headname *)((head)->tqh_last))->tqh_last)) + ((typeof((head)->tqh_first)) QTAILQ_LINK_PREV((head)->tqh_circ))#define QTAILQ_PREV (elm, headname, field) \ - (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) + ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))#define field_at_offset (base, offset, type) \ - ((type) (((char *) (base)) + (offset))) - -typedef struct DUMMY_Q_ENTRY DUMMY_Q_ENTRY ; -typedef struct DUMMY_Q DUMMY_Q ; - -struct DUMMY_Q_ENTRY { -QTAILQ_ENTRY (DUMMY_Q_ENTRY) next; -}; - -struct DUMMY_Q { - QTAILQ_HEAD(DUMMY_Q_HEAD, DUMMY_Q_ENTRY) head; -}; - -#define dummy_q ((DUMMY_Q *) 0) -#define dummy_qe ((DUMMY_Q_ENTRY *) 0) + ((type *) (((char *) (base)) + (offset)))/* -* Offsets of layout of a tail queue head. -*/ -#define QTAILQ_FIRST_OFFSET (offsetof(typeof(dummy_q->head), tqh_first)) -#define QTAILQ_LAST_OFFSET (offsetof(typeof(dummy_q->head), tqh_last)) -/* -* Raw access of elements of a tail queue +* Raw access of elements of a tail queue head. Offsets are all zero +* because it's a union. */ #define QTAILQ_RAW_FIRST (head) \ - (*field_at_offset(head, QTAILQ_FIRST_OFFSET, void **)) -#define QTAILQ_RAW_TQH_LAST (head) \ - (*field_at_offset(head, QTAILQ_LAST_OFFSET, void ***)) - -/* -* Offsets of layout of a tail queue element. -*/ -#define QTAILQ_NEXT_OFFSET (offsetof(typeof(dummy_qe->next), tqe_next)) -#define QTAILQ_PREV_OFFSET (offsetof(typeof(dummy_qe->next), tqe_prev)) + field_at_offset(head, 0, void *) +#define QTAILQ_RAW_TQH_CIRC (head) \ + field_at_offset(head, 0, QTailQLink)/* * Raw access of elements of a tail entry */ #define QTAILQ_RAW_NEXT (elm, entry) \ - (*field_at_offset(elm, entry + QTAILQ_NEXT_OFFSET, void **)) -#define QTAILQ_RAW_TQE_PREV (elm, entry) \ - (*field_at_offset(elm, entry + QTAILQ_PREV_OFFSET, void ***)) + field_at_offset(elm, entry, void *) +#define QTAILQ_RAW_TQE_CIRC (elm, entry) \ + field_at_offset(elm, entry, QTailQLink)/* -* Tail queue tranversal using pointer arithmetic. +* Tail queue traversal using pointer arithmetic. */ #define QTAILQ_RAW_FOREACH (elm, head, entry) \ - for ((elm) = QTAILQ_RAW_FIRST(head); \ + for ((elm) = *QTAILQ_RAW_FIRST(head); \ (elm); \ - (elm) = QTAILQ_RAW_NEXT(elm, entry)) + (elm) = *QTAILQ_RAW_NEXT(elm, entry))/* * Tail queue insertion using pointer arithmetic. */ -#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do { \ - QTAILQ_RAW_NEXT(elm, entry) = NULL; \ - QTAILQ_RAW_TQE_PREV(elm, entry) = QTAILQ_RAW_TQH_LAST(head); \ - *QTAILQ_RAW_TQH_LAST(head) = (elm); \ - QTAILQ_RAW_TQH_LAST(head) = &QTAILQ_RAW_NEXT(elm, entry); \ +#define QTAILQ_RAW_INSERT_TAIL(head, elm, entry) do { \ + *QTAILQ_RAW_NEXT(elm, entry) = NULL; \ + QTAILQ_RAW_TQE_CIRC(elm, entry)->tql_prev = QTAILQ_RAW_TQH_CIRC(head)->tql_prev; \ + QTAILQ_RAW_TQH_CIRC(head)->tql_prev->tql_next = (elm); \ + QTAILQ_RAW_TQH_CIRC(head)->tql_prev = QTAILQ_RAW_TQE_CIRC(elm, entry); \ } while (/*CONSTCOND*/0)#endif /* QEMU_SYS_QUEUE_H */
include/qemu/rcu_queue.h +24 -21
71 lines not on this page · raw message
scripts/cocci-macro-file.h +7 -7
@@ -94,18 +94,18 @@ struct { \* Tail queue definitions. */ #define QTAILQ_HEAD (name, type) \ -struct name { \ - type *tqh_first;/* first element */ \ -type **tqh_last;/* addr of last next element */ \ +union name { \ + struct type *tqh_first;/* first element */ \ +QTailQLink tqh_circ;/* link for last element */ \ }#define QTAILQ_HEAD_INITIALIZER (head) \ - { NULL, &(head).tqh_first } + { .tqh_circ = { NULL, &(head).tqh_circ } }#define QTAILQ_ENTRY (type) \ -struct { \ - type *tqe_next;/* next element */ \ -type **tqe_prev;/* address of previous next element */ \ +union { \ + struct type *tqe_next;/* next element */ \ +QTailQLink tqe_circ;/* link for prev element */ \ }/* From glib */
Signature · 1 line
2.19.2
PATCH v2 8/8 checkpatch: warn about qemu/queue.h head structs that are not typedef-ed
In reply to Paolo BonziniThese are just like any other struct or union, so they should have CamelCase typedefs.
--- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+)
scripts/checkpatch.pl +5 -0
@@ -2263,6 +2263,11 @@ sub process { } } + if ($line =~ /^.\s*(Q(?:S?LIST|SIMPLEQ|TAILQ)_HEAD)\s*\(\s*[^,]/ && + $line !~ /^.typedef/) { + ERROR("named $1 should be typedefed separately\n" . $herecurr); + } + # Need a space before open parenthesis after if, while etc if ($line=~/\b(if|while|for|switch)\(/) { ERROR("space required before the open parenthesis '('\n" . $herecurr);
Signature · 1 line
2.19.2
PATCH v2 7/8 qemu/queue.h: simplify reverse access to QTAILQ
In reply to Paolo BonziniThe new definition of QTAILQ does not require passing the headname, remove it.
--- cpus-common.c | 2 +- dump.c | 2 +- hw/core/qdev.c | 4 ++-- hw/scsi/scsi-bus.c | 2 +- hw/usb/combined-packet.c | 2 +- hw/usb/dev-mtp.c | 4 ++-- hw/usb/hcd-ehci.c | 2 +- hw/usb/hcd-ehci.h | 2 +- hw/usb/hcd-uhci.c | 4 ++-- include/exec/memory.h | 2 +- include/hw/qdev-core.h | 2 +- include/hw/usb.h | 2 +- include/net/net.h | 2 +- include/qemu/option_int.h | 2 +- include/qemu/queue.h | 16 ++++++++-------- include/sysemu/memory_mapping.h | 2 +- memory.c | 17 ++++++----------- memory_mapping.c | 2 +- net/filter.c | 2 +- net/net.c | 2 +- qga/commands-posix.c | 2 +- tcg/tcg.c | 2 +- tcg/tcg.h | 4 ++-- tests/libqos/malloc.c | 2 +- tests/test-vmstate.c | 8 ++++---- ui/console.c | 4 ++-- util/qemu-option.c | 4 ++-- 27 files changed, 48 insertions(+), 53 deletions(-)
cpus-common.c +1 -1
@@ -99,7 +99,7 @@ void cpu_list_remove(CPUState *cpu)return ; } -assert (!(cpu_index_auto_assigned && cpu !=QTAILQ_LAST (&cpus, CPUTailQ))); +assert (!(cpu_index_auto_assigned && cpu !=QTAILQ_LAST (&cpus)));QTAILQ_REMOVE_RCU (&cpus, cpu, node); cpu->cpu_index =UNASSIGNED_CPU_INDEX ;
dump.c +1 -1
@@ -1557,7 +1557,7 @@ static void get_max_mapnr(DumpState *s) {GuestPhysBlock *last_block; - last_block =QTAILQ_LAST (&s->guest_phys_blocks.head, GuestPhysBlockHead); + last_block =QTAILQ_LAST (&s->guest_phys_blocks.head); s->max_mapnr =dump_paddr_to_pfn (s, last_block->target_end); }
hw/core/qdev.c +2 -2
@@ -158,7 +158,7 @@ DeviceState *qdev_try_create(BusState *bus, const char *type)return dev; } -static QTAILQ_HEAD(device_listeners, DeviceListener) device_listeners +static QTAILQ_HEAD(, DeviceListener) device_listeners =QTAILQ_HEAD_INITIALIZER (device_listeners);enum ListenerDirection { Forward, Reverse };
@@ -177,7 +177,7 @@ enum ListenerDirection { Forward, Reverse };break ; \case Reverse: \QTAILQ_FOREACH_REVERSE (_listener, &device_listeners, \ - device_listeners, link) { \ + link) { \if (_listener->_callback) { \ _listener->_callback(_listener, ##_args); \ } \
hw/scsi/scsi-bus.c +1 -1
@@ -1554,7 +1554,7 @@ SCSIDevice *scsi_device_find(SCSIBus *bus, int channel, int id, int lun)BusChild *kid;SCSIDevice *target_dev =NULL ; - QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, ChildrenHead, sibling) { + QTAILQ_FOREACH_REVERSE(kid, &bus->qbus.children, sibling) {DeviceState *qdev = kid->child;SCSIDevice *dev =SCSI_DEVICE (qdev);
hw/usb/combined-packet.c +1 -1
@@ -64,7 +64,7 @@ void usb_combined_input_packet_complete(USBDevice *dev, USBPacket *p) status = combined->first->status; actual_length = combined->first->actual_length; - short_not_ok =QTAILQ_LAST (&combined->packets, packets_head)->short_not_ok; + short_not_ok =QTAILQ_LAST (&combined->packets)->short_not_ok; QTAILQ_FOREACH_SAFE(p, &combined->packets, combined_entry, next) {if (!done) {
hw/usb/dev-mtp.c +2 -2
@@ -191,7 +191,7 @@ struct MTPState {#ifdef CONFIG_INOTIFY1 /* inotify descriptor */ int inotifyfd; - QTAILQ_HEAD(events, MTPMonEntry) events; + QTAILQ_HEAD(, MTPMonEntry) events;#endif /* Responder is expecting a write operation */ bool write_pending;
@@ -1982,7 +1982,7 @@ static void usb_mtp_handle_data(USBDevice *dev, USBPacket *p)case EP_EVENT :#ifdef CONFIG_INOTIFY1 if (!QTAILQ_EMPTY (&s->events)) { -struct MTPMonEntry *e =QTAILQ_LAST (&s->events, events); +struct MTPMonEntry *e =QTAILQ_LAST (&s->events);uint32_t handle;int len =sizeof (container) +sizeof (uint32_t );
hw/usb/hcd-ehci.c +1 -1
@@ -1815,7 +1815,7 @@ static int ehci_state_fetchqtd(EHCIQueue *q)break ;case EHCI_ASYNC_INFLIGHT :/* Check if the guest has added new tds to the queue */ - again =ehci_fill_queue (QTAILQ_LAST (&q->packets, pkts_head)); + again =ehci_fill_queue (QTAILQ_LAST (&q->packets));/* Unfinished async handled packet, go horizontal */ ehci_set_state (q->ehci, q->async,EST_HORIZONTALQH );break ;
hw/usb/hcd-ehci.h +1 -1
@@ -247,7 +247,7 @@ struct EHCIQueue {uint32_t qtdaddr;/* address QTD read from */ int last_pid;/* pid of last packet executed */ USBDevice *dev; - QTAILQ_HEAD(pkts_head, EHCIPacket) packets; + QTAILQ_HEAD(, EHCIPacket) packets; }; typedef QTAILQ_HEAD(EHCIQueueHead, EHCIQueue) EHCIQueueHead;
hw/usb/hcd-uhci.c +2 -2
@@ -99,7 +99,7 @@ struct UHCIQueue {UHCIState *uhci;USBEndpoint *ep;QTAILQ_ENTRY (UHCIQueue) next; - QTAILQ_HEAD(asyncs_head, UHCIAsync) asyncs; + QTAILQ_HEAD(, UHCIAsync) asyncs;int8_t valid; };
@@ -837,7 +837,7 @@ static int uhci_handle_td(UHCIState *s, UHCIQueue *q, uint32_t qh_addr, }if (!async->done) {UHCI_TD last_td; -UHCIAsync *last =QTAILQ_LAST (&async->queue->asyncs, asyncs_head); +UHCIAsync *last =QTAILQ_LAST (&async->queue->asyncs);/* * While we are waiting for the current td to complete, the guest * may have added more tds to the queue. Note we re-read the td
include/exec/memory.h +1 -1
@@ -445,7 +445,7 @@ struct AddressSpace {int ioeventfd_nb;struct MemoryRegionIoeventfd *ioeventfds; - QTAILQ_HEAD(memory_listeners_as, MemoryListener) listeners; + QTAILQ_HEAD(, MemoryListener) listeners;QTAILQ_ENTRY (AddressSpace) address_spaces_link; };
include/hw/qdev-core.h +1 -1
@@ -206,7 +206,7 @@ struct BusState {HotplugHandler *hotplug_handler;int max_index;bool realized; - QTAILQ_HEAD(ChildrenHead, BusChild) children; + QTAILQ_HEAD(, BusChild) children;QLIST_ENTRY (BusState) sibling; };
include/hw/usb.h +1 -1
@@ -408,7 +408,7 @@ struct USBPacket {struct USBCombinedPacket {USBPacket *first; - QTAILQ_HEAD(packets_head, USBPacket) packets; + QTAILQ_HEAD(, USBPacket) packets;QEMUIOVector iov; };
include/net/net.h +1 -1
@@ -97,7 +97,7 @@ struct NetClientState { unsigned rxfilter_notify_enabled:1;int vring_enable;int vnet_hdr_len; - QTAILQ_HEAD(NetFilterHead, NetFilterState) filters; + QTAILQ_HEAD(, NetFilterState) filters; }; typedef struct NICState {
include/qemu/option_int.h +1 -1
@@ -47,7 +47,7 @@ struct QemuOpts {char *id;QemuOptsList *list;Location loc; - QTAILQ_HEAD(QemuOptHead, QemuOpt) head; + QTAILQ_HEAD(, QemuOpt) head;QTAILQ_ENTRY (QemuOpts) next; };
include/qemu/queue.h +8 -8
@@ -432,14 +432,14 @@ union { \ (var) && ((next_var) = ((var)->field.tqe_next),1 ); \ (var) = (next_var)) -#define QTAILQ_FOREACH_REVERSE (var, head, headname, field) \ - for ((var) = QTAILQ_LAST(head, headname); \ +#define QTAILQ_FOREACH_REVERSE (var, head, field) \ + for ((var) = QTAILQ_LAST(head); \ (var); \ - (var) = QTAILQ_PREV(var, headname, field)) + (var) = QTAILQ_PREV(var, field)) -#define QTAILQ_FOREACH_REVERSE_SAFE (var, head, headname, field, prev_var) \ - for ((var) = QTAILQ_LAST(head, headname); \ - (var) && ((prev_var) = QTAILQ_PREV(var, headname, field)); \ +#define QTAILQ_FOREACH_REVERSE_SAFE (var, head, field, prev_var) \ + for ((var) = QTAILQ_LAST(head); \ + (var) && ((prev_var) = QTAILQ_PREV(var, field)); \ (var) = (prev_var))/*
@@ -452,9 +452,9 @@ union { \#define QTAILQ_LINK_PREV (link) \ ((link).tql_prev->tql_prev->tql_next) -#define QTAILQ_LAST (head, headname) \ +#define QTAILQ_LAST (head) \ ((typeof((head)->tqh_first)) QTAILQ_LINK_PREV((head)->tqh_circ)) -#define QTAILQ_PREV (elm, headname, field) \ +#define QTAILQ_PREV (elm, field) \ ((typeof((elm)->field.tqe_next)) QTAILQ_LINK_PREV((elm)->field.tqe_circ))#define field_at_offset (base, offset, type) \
include/sysemu/memory_mapping.h +1 -1
@@ -36,7 +36,7 @@ typedef struct GuestPhysBlock {/* point-in-time snapshot of guest-visible physical mappings */ typedef struct GuestPhysBlockList {unsigned num; - QTAILQ_HEAD(GuestPhysBlockHead, GuestPhysBlock) head; + QTAILQ_HEAD(, GuestPhysBlock) head; }GuestPhysBlockList ;/* The physical and virtual address in the memory mapping are contiguous. */
memory.c +6 -11
@@ -39,7 +39,7 @@ static bool memory_region_update_pending;static bool ioeventfd_update_pending;static bool global_dirty_log = false; -static QTAILQ_HEAD(memory_listeners, MemoryListener) memory_listeners +static QTAILQ_HEAD(, MemoryListener) memory_listeners =QTAILQ_HEAD_INITIALIZER (memory_listeners); static QTAILQ_HEAD(, AddressSpace) address_spaces
@@ -113,8 +113,7 @@ enum ListenerDirection { Forward, Reverse }; } \break ; \case Reverse: \ -QTAILQ_FOREACH_REVERSE (_listener, &memory_listeners, \ - memory_listeners, link) { \ + QTAILQ_FOREACH_REVERSE(_listener, &memory_listeners, link) { \if (_listener->_callback) { \ _listener->_callback(_listener, ##_args); \ } \
@@ -128,19 +127,17 @@ enum ListenerDirection { Forward, Reverse }; #define MEMORY_LISTENER_CALL(_as, _callback, _direction, _section, _args...) \ do { \ MemoryListener *_listener; \ - struct memory_listeners_as *list = &(_as)->listeners; \ \ switch (_direction) { \ case Forward: \ - QTAILQ_FOREACH(_listener, list, link_as) { \ + QTAILQ_FOREACH(_listener, &(_as)->listeners, link_as) { \ if (_listener->_callback) { \ _listener->_callback(_listener, _section, ##_args); \ } \ } \ break; \ case Reverse: \ - QTAILQ_FOREACH_REVERSE(_listener, list, memory_listeners_as, \ - link_as) { \ + QTAILQ_FOREACH_REVERSE(_listener, &(_as)->listeners, link_as) { \ if (_listener->_callback) { \ _listener->_callback(_listener, _section, ##_args); \ } \
@@ -2691,8 +2688,7 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as) listener->address_space = as;if (QTAILQ_EMPTY (&memory_listeners) - || listener->priority >=QTAILQ_LAST (&memory_listeners, - memory_listeners)->priority) { + || listener->priority >=QTAILQ_LAST (&memory_listeners)->priority) {QTAILQ_INSERT_TAIL (&memory_listeners, listener, link); }else { QTAILQ_FOREACH(other, &memory_listeners, link) {
@@ -2704,8 +2700,7 @@ void memory_listener_register(MemoryListener *listener, AddressSpace *as) }if (QTAILQ_EMPTY (&as->listeners) - || listener->priority >=QTAILQ_LAST (&as->listeners, - memory_listeners)->priority) { + || listener->priority >=QTAILQ_LAST (&as->listeners)->priority) {QTAILQ_INSERT_TAIL (&as->listeners, listener, link_as); }else { QTAILQ_FOREACH(other, &as->listeners, link_as) {
memory_mapping.c +1 -1
@@ -223,7 +223,7 @@ static void guest_phys_blocks_region_add(MemoryListener *listener,if (!QTAILQ_EMPTY (&g->list->head)) {hwaddr predecessor_size; - predecessor =QTAILQ_LAST (&g->list->head, GuestPhysBlockHead); + predecessor =QTAILQ_LAST (&g->list->head); predecessor_size = predecessor->target_end - predecessor->target_start;/* the memory API guarantees monotonically increasing traversal */
net/filter.c +1 -1
@@ -55,7 +55,7 @@ static NetFilterState *netfilter_next(NetFilterState *nf, next =QTAILQ_NEXT (nf, next); }else {/* reverse order */ - next =QTAILQ_PREV (nf, NetFilterHead, next); + next =QTAILQ_PREV (nf, next); }return next;
net/net.c +1 -1
@@ -563,7 +563,7 @@ static ssize_t filter_receive_iov(NetClientState *nc, } } }else { - QTAILQ_FOREACH_REVERSE(nf, &nc->filters, NetFilterHead, next) { + QTAILQ_FOREACH_REVERSE(nf, &nc->filters, next) { ret =qemu_netfilter_receive (nf, direction, sender, flags, iov, iovcnt, sent_cb);if (ret) {
qga/commands-posix.c +1 -1
@@ -1291,7 +1291,7 @@ int64_t qmp_guest_fsfreeze_freeze_list(bool has_mountpoints,/* cannot risk guest agent blocking itself on a write in this state */ ga_set_frozen (ga_state); - QTAILQ_FOREACH_REVERSE(mount, &mounts, FsMountList, next) { + QTAILQ_FOREACH_REVERSE(mount, &mounts, next) {/* To issue fsfreeze in the reverse order of mounts, check if the * mount is listed in the list here */ if (has_mountpoints) {
tcg/tcg.c +1 -1
@@ -2269,7 +2269,7 @@ static void liveness_pass_1(TCGContext *s)tcg_la_func_end (s); - QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, TCGOpHead, link, op_prev) { + QTAILQ_FOREACH_REVERSE_SAFE(op, &s->ops, link, op_prev) {int i, nb_iargs, nb_oargs;TCGOpcode opc_new, opc_new2;bool have_opc_new2;
tcg/tcg.h +2 -2
@@ -715,7 +715,7 @@ struct TCGContext {TCGTempSet free_temps[TCG_TYPE_COUNT *2 ];TCGTemp temps[TCG_MAX_TEMPS ];/* globals first, temps after */ - QTAILQ_HEAD(TCGOpHead, TCGOp) ops, free_ops; + QTAILQ_HEAD(, TCGOp) ops, free_ops;/* Tells which temporary holds a given register. It does not take into account fixed registers */
@@ -843,7 +843,7 @@ static inline void tcg_set_insn_start_param(TCGOp *op, int arg, target_ulong v)/* The last op that was emitted. */ static inline TCGOp *tcg_last_op (void ) { -return QTAILQ_LAST (&tcg_ctx->ops, TCGOpHead); +return QTAILQ_LAST (&tcg_ctx->ops); }/* Test for whether to terminate the TB for using too many opcodes. */
tests/libqos/malloc.c +1 -1
@@ -104,7 +104,7 @@ static void mlist_coalesce(MemList *head, MemBlock *node) do { merge = 0; - left = QTAILQ_PREV(node, MemList, MLIST_ENTNAME); + left = QTAILQ_PREV(node, MLIST_ENTNAME); right = QTAILQ_NEXT(node, MLIST_ENTNAME); /* clowns to the left of me */
tests/test-vmstate.c +4 -4
@@ -630,7 +630,7 @@ struct TestQtailqElement {typedef struct TestQtailq {int16_t i16; - QTAILQ_HEAD(TestQtailqHead, TestQtailqElement) q; + QTAILQ_HEAD(, TestQtailqElement) q;int32_t i32; }TestQtailq ;
@@ -735,9 +735,9 @@ static void test_load_q(void) g_assert_cmpint(eof, ==, QEMU_VM_EOF);TestQtailqElement *qele_from =QTAILQ_FIRST (&obj_q.q); -TestQtailqElement *qlast_from =QTAILQ_LAST (&obj_q.q, TestQtailqHead); +TestQtailqElement *qlast_from =QTAILQ_LAST (&obj_q.q);TestQtailqElement *qele_to =QTAILQ_FIRST (&tgt.q); -TestQtailqElement *qlast_to =QTAILQ_LAST (&tgt.q, TestQtailqHead); +TestQtailqElement *qlast_to =QTAILQ_LAST (&tgt.q);while (1 ) { g_assert_cmpint(qele_to->b, ==, qele_from->b);
@@ -755,7 +755,7 @@ static void test_load_q(void)/* clean up */ TestQtailqElement *qele;while (!QTAILQ_EMPTY (&tgt.q)) { - qele =QTAILQ_LAST (&tgt.q, TestQtailqHead); + qele =QTAILQ_LAST (&tgt.q);QTAILQ_REMOVE (&tgt.q, qele, next);free (qele); qele =NULL ;
ui/console.c +2 -2
@@ -182,7 +182,7 @@ struct DisplayState {static DisplayState *display_state;static QemuConsole *active_console; -static QTAILQ_HEAD(consoles_head, QemuConsole) consoles = +static QTAILQ_HEAD(, QemuConsole) consoles =QTAILQ_HEAD_INITIALIZER (consoles);static bool cursor_visible_phase;static QEMUTimer *cursor_timer;
@@ -1303,7 +1303,7 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type, s->index =0 ;QTAILQ_INSERT_TAIL (&consoles, s, next); }else if (console_type !=GRAPHIC_CONSOLE || qdev_hotplug) { -QemuConsole *last =QTAILQ_LAST (&consoles, consoles_head); +QemuConsole *last =QTAILQ_LAST (&consoles); s->index = last->index +1 ;QTAILQ_INSERT_TAIL (&consoles, s, next); }else {
util/qemu-option.c +2 -2
@@ -280,7 +280,7 @@ QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) {QemuOpt *opt; - QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) { + QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) {if (strcmp (opt->name, name) !=0 )continue ;return opt;
@@ -379,7 +379,7 @@ bool qemu_opt_has_help_opt(QemuOpts *opts) {QemuOpt *opt; - QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) { + QTAILQ_FOREACH_REVERSE(opt, &opts->head, next) {if (is_help_option (opt->name)) {return true; }
Signature · 1 line
2.19.2
Re: [Qemu-devel] [PATCH 2/8] vfio: make vfio_address_spaces static
In reply to Paolo BonziniQuoted 9 lines · On Mon, 10 Dec 2018 19:28:10 +0100 Paolo Bonzini <[email protected]> wrote:
It is not used outside
hw/vfio/common.c, so it does not need to be extern.Cc Alex Williamson <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- hw/vfio/common.c | 2 +- include/hw/vfio/vfio-common.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
Quoted 25 lines
hw/vfio/common.c +1
-1@@ -39,7 +39,7 @@struct vfio_group_head vfio_group_list =QLIST_HEAD_INITIALIZER (vfio_group_list); -struct vfio_as_head vfio_address_spaces = +static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces =QLIST_HEAD_INITIALIZER (vfio_address_spaces);#ifdef CONFIG_KVM include/hw/vfio/vfio-common.h +0
-1@@ -181,7 +181,6 @@ int vfio_get_device(VFIOGroup *group, const char *name,extern const MemoryRegionOps vfio_region_ops; extern QLIST_HEAD(vfio_group_head, VFIOGroup) vfio_group_list; -extern QLIST_HEAD(vfio_as_head, VFIOAddressSpace) vfio_address_spaces;#ifdef CONFIG_LINUX int vfio_get_region_info(VFIODevice *vbasedev, int index,
[Qemu-devel] valgrind errors (was: [PATCH 7/8] qemu/queue.h: simplify reverse access to QTAILQ)
In reply to Paolo BonziniQuoted 2 lines · Paolo Bonzini
The new definition of QTAILQ does not require passing the headname, remove it.
Hi Paolo,
when running current QEMU master branch with valgrind, I get "Conditional jump or move depends on uninitialised value" errors. I've bisected it to your patch series here. Everything is still fine and calm with f481ee2d5e3d77c12a4c9a7756b8c2612aad84c6 ("qemu/queue.h: typedef QTAILQ heads"), but starting with commit eae3eb3e185028d6e862db747e3b7397600d6762 ("qemu/queue.h: simplify reverse access to QTAILQ"), I now get:
==14580== Thread 3:
==14580== Conditional jump or move depends on uninitialised value(s)
==14580== at 0x40C267: tcg_reg_alloc (tcg.c:3123) ==14580== by 0x40F8FB: tcg_reg_alloc_op (tcg.c:3506) ==14580== by 0x40F8FB: tcg_gen_code (tcg.c:3948) ==14580== by 0x47FAFF: tb_gen_code (translate-all.c:1748) ==14580== by 0x47E153: tb_find (cpu-exec.c:404) ==14580== by 0x47E153: cpu_exec (cpu-exec.c:724) ==14580== by 0x43D981: tcg_cpu_exec (cpus.c:1429) ==14580== by 0x43FB4F: qemu_tcg_cpu_thread_fn (cpus.c:1733) ==14580== by 0x879075: qemu_thread_start (qemu-thread-posix.c:502) ==14580== by 0xB528DD4: start_thread (in /usr/lib64/libpthread-2.17.so) ==14580== by 0xB83BB3C: clone (in /usr/lib64/libc-2.17.so)
Unfortunately, the commits in between do not compile, so I can not determine the exact commit that introduced the problem, but it definitely seems to happen due to your queue rework. Could you please have a look?
Thanks,
Thomas
Re: [Qemu-devel] valgrind errors (was: [PATCH 7/8] qemu/queue.h: simplify reverse access to QTAILQ)
Quoted 7 lines · Thomas Huth
when running current QEMU master branch with valgrind, I get "Conditional jump or move depends on uninitialised value" errors. I've bisected it to your patch series here. Everything is still fine and calm with
f481ee2d5e3d77c12a4c9a7756b8c2612aad84c6("qemu/queue.h: typedef QTAILQ heads"), but starting with commiteae3eb3e185028d6e862db747e3b7397600d6762("qemu/queue.h: simplify reverse access to QTAILQ"), I now get:
After fixing compilation with
memory.c +0 -0
@@ -128,7 +128,7 @@ enum ListenerDirection { Forward, Reverse }; #define MEMORY_LISTENER_CALL(_as, _callback, _direction, _section,
_args...) \
do { \
MemoryListener *_listener; \
- struct memory_listeners_as *list = &(_as)->listeners; \
+ union memory_listeners_as *list = &(_as)->listeners; \
\
switch (_direction) { \
case Forward: \I bisected it (not unexpectedly) to 7274f01bb8b81ffe8f13f463b6b0f3b9246c5387. It's a stupid stupid bug, and I'm sending a patch soon.
Paolo