From 3d69f821616a578aeed569b3b56e157922819602 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Fri, 17 Mar 2017 14:14:46 +0800 Subject: virtio-scsi: Make virtio_scsi_acquire/release public They will be used in virtio-scsi-dataplane.c as well, so move them to header. Signed-off-by: Fam Zheng Message-Id: <20170317061447.16243-2-famz@redhat.com> Signed-off-by: Paolo Bonzini --- include/hw/virtio/virtio-scsi.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h index f536f77e68..8ae0acaa1f 100644 --- a/include/hw/virtio/virtio-scsi.h +++ b/include/hw/virtio/virtio-scsi.h @@ -121,6 +121,20 @@ typedef struct VirtIOSCSIReq { } req; } VirtIOSCSIReq; +static inline void virtio_scsi_acquire(VirtIOSCSI *s) +{ + if (s->ctx) { + aio_context_acquire(s->ctx); + } +} + +static inline void virtio_scsi_release(VirtIOSCSI *s) +{ + if (s->ctx) { + aio_context_release(s->ctx); + } +} + void virtio_scsi_common_realize(DeviceState *dev, Error **errp, VirtIOHandleOutput ctrl, VirtIOHandleOutput evt, VirtIOHandleOutput cmd); -- cgit v1.2.3 From 12f8def0e02232d7c6416ad9b66640f973c531d1 Mon Sep 17 00:00:00 2001 From: Andrey Shedel Date: Fri, 24 Mar 2017 15:01:41 -0700 Subject: win32: replace custom mutex and condition variable with native primitives The multithreaded TCG implementation exposed deadlocks in the win32 condition variables: as implemented, qemu_cond_broadcast waited on receivers, whereas the pthreads API it was intended to emulate does not. This was causing a deadlock because broadcast was called while holding the IO lock, as well as all possible waiters blocked on the same lock. This patch replaces all the custom synchronisation code for mutexes and condition variables with native Windows primitives (SRWlocks and condition variables) with the same semantics as their POSIX equivalents. To enable that, it requires a Windows Vista or newer host OS. Signed-off-by: Andrey Shedel [AB: edited commit message] Signed-off-by: Andrew Baumann Message-Id: <20170324220141.10104-1-Andrew.Baumann@microsoft.com> Signed-off-by: Paolo Bonzini --- include/qemu/thread-win32.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h index 5fb6541ae9..4c4a261cf4 100644 --- a/include/qemu/thread-win32.h +++ b/include/qemu/thread-win32.h @@ -4,8 +4,7 @@ #include struct QemuMutex { - CRITICAL_SECTION lock; - LONG owner; + SRWLOCK lock; }; typedef struct QemuRecMutex QemuRecMutex; @@ -19,9 +18,7 @@ int qemu_rec_mutex_trylock(QemuRecMutex *mutex); void qemu_rec_mutex_unlock(QemuRecMutex *mutex); struct QemuCond { - LONG waiters, target; - HANDLE sema; - HANDLE continue_event; + CONDITION_VARIABLE var; }; struct QemuSemaphore { -- cgit v1.2.3 From 5354edd286ea6e956b81da66c9dcc5e47028198e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 22 Mar 2017 13:12:18 +0100 Subject: Revert "apic: save apic_delivered flag" This reverts commit 07bfa354772f2de67008dc66c201b627acff0106. The global variable is only read as part of a apic_reset_irq_delivered(); qemu_irq_raise(s->irq); if (!apic_get_irq_delivered()) { sequence, so the value never matters at migration time. Reported-by: Dr. David Alan Gilbert Cc: Pavel Dovgalyuk Signed-off-by: Paolo Bonzini --- include/hw/i386/apic_internal.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 20ad28c95b..1209eb483a 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -189,8 +189,6 @@ struct APICCommonState { DeviceState *vapic; hwaddr vapic_paddr; /* note: persistence via kvmvapic */ bool legacy_instance_id; - - int apic_irq_delivered; /* for saving static variable */ }; typedef struct VAPICState { -- cgit v1.2.3