From 297b044a7fccd1571cf94713a7caf2fc1a980841 Mon Sep 17 00:00:00 2001 From: Jarkko Lavinen Date: Tue, 28 Jun 2016 21:51:52 +0300 Subject: scsi-bus: Add SCSI scanner support Add support for missing scanner specific SCSI commands and their xfer lenghts as per ANSI spec section 15. Signed-off-by: Jarkko Lavinen Signed-off-by: Paolo Bonzini --- include/block/scsi.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/block/scsi.h b/include/block/scsi.h index a311341..8b966d7 100644 --- a/include/block/scsi.h +++ b/include/block/scsi.h @@ -48,13 +48,17 @@ #define ERASE 0x19 #define MODE_SENSE 0x1a #define LOAD_UNLOAD 0x1b +#define SCAN 0x1b #define START_STOP 0x1b #define RECEIVE_DIAGNOSTIC 0x1c #define SEND_DIAGNOSTIC 0x1d #define ALLOW_MEDIUM_REMOVAL 0x1e +#define SET_WINDOW 0x24 #define READ_CAPACITY_10 0x25 +#define GET_WINDOW 0x25 #define READ_10 0x28 #define WRITE_10 0x2a +#define SEND 0x2a #define SEEK_10 0x2b #define LOCATE_10 0x2b #define POSITION_TO_ELEMENT 0x2b @@ -62,10 +66,12 @@ #define VERIFY_10 0x2f #define SEARCH_HIGH 0x30 #define SEARCH_EQUAL 0x31 +#define OBJECT_POSITION 0x31 #define SEARCH_LOW 0x32 #define SET_LIMITS 0x33 #define PRE_FETCH 0x34 #define READ_POSITION 0x34 +#define GET_DATA_BUFFER_STATUS 0x34 #define SYNCHRONIZE_CACHE 0x35 #define LOCK_UNLOCK_CACHE 0x36 #define INITIALIZE_ELEMENT_STATUS_WITH_RANGE 0x37 -- cgit v1.1 From 6959e508c6de656015e0cd4fd21da34d6f08e8ac Mon Sep 17 00:00:00 2001 From: Jarkko Lavinen Date: Wed, 29 Jun 2016 03:11:46 +0300 Subject: scsi-bus: Use longer sense buffer with scanners Scanners can provide additional sense bytes beyond 18 bytes. VueScan uses 32 bytes alloc length with Request Sense command. Signed-off-by: Jarkko Lavinen Signed-off-by: Paolo Bonzini --- include/hw/scsi/scsi.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index 8acd3fa..94d7868 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -8,9 +8,10 @@ #define MAX_SCSI_DEVS 255 -#define SCSI_CMD_BUF_SIZE 16 -#define SCSI_SENSE_LEN 18 -#define SCSI_INQUIRY_LEN 36 +#define SCSI_CMD_BUF_SIZE 16 +#define SCSI_SENSE_LEN 18 +#define SCSI_SENSE_LEN_SCANNER 32 +#define SCSI_INQUIRY_LEN 36 typedef struct SCSIBus SCSIBus; typedef struct SCSIBusInfo SCSIBusInfo; -- cgit v1.1 From 1e13c01d2a4eadb9c498caa809a21e3b5672b411 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 7 Jul 2016 14:07:33 +0200 Subject: disas: avoid including everything in headers compiled from C++ disas/arm-a64.cc is careful to include only the bare minimum that it needs---qemu/osdep.h and disas/bfd.h. Unfortunately, disas/bfd.h then includes qemu-common.h, which brings in qemu/option.h and from there we get the kitchen sink. This causes problems because for example QEMU's atomic macros conflict with C++ atomic types. But really all that bfd.h needs is the fprintf_function typedef, so replace the inclusion of qemu-common.h with qemu/fprintf-fn.h. Reported-by: Sean Bruno Tested-by: Sean Bruno Cc: Peter Maydell Cc: Markus Armbruster Signed-off-by: Paolo Bonzini --- include/disas/bfd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/disas/bfd.h b/include/disas/bfd.h index a112e9c..a87b8a1 100644 --- a/include/disas/bfd.h +++ b/include/disas/bfd.h @@ -9,7 +9,7 @@ #ifndef DIS_ASM_H #define DIS_ASM_H -#include "qemu-common.h" +#include "qemu/fprintf-fn.h" typedef void *PTR; typedef uint64_t bfd_vma; -- cgit v1.1 From d27ba624aa1dfe5c07cc01200d95967ffce905d9 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Tue, 12 Jul 2016 14:48:33 +0800 Subject: util: Fix MIN_NON_ZERO MIN_NON_ZERO(1, 0) is evaluated to 0. Rewrite the macro to fix it. Reported-by: Miroslav Rezanina Signed-off-by: Fam Zheng Message-Id: <1468306113-847-1-git-send-email-famz@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- include/qemu/osdep.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index e63da28..e4c6ae6 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -151,7 +151,8 @@ extern int daemon(int, int); /* Minimum function that returns zero only iff both values are zero. * Intended for use with unsigned values only. */ #ifndef MIN_NON_ZERO -#define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b)) +#define MIN_NON_ZERO(a, b) ((a) == 0 ? (b) : \ + ((b) == 0 ? (a) : (MIN(a, b)))) #endif /* Round number down to multiple */ -- cgit v1.1 From aa5cb7f5e8bf2e6737d0cb36c118332ca26e7797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 4 Jul 2016 17:38:23 +0200 Subject: char: do not use atexit cleanup handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It turns out qemu is calling exit() in various places from various threads without taking much care of resources state. The atexit() cleanup handlers cannot easily destroy resources that are in use (by the same thread or other). Since c1111a24a3, TCG arm guests run into the following abort() when running tests, the chardev mutex is locked during the write, so qemu_mutex_destroy() returns an error: #0 0x00007fffdbb806f5 in raise () at /lib64/libc.so.6 #1 0x00007fffdbb822fa in abort () at /lib64/libc.so.6 #2 0x00005555557616fe in error_exit (err=, msg=msg@entry=0x555555c38c30 <__func__.14622> "qemu_mutex_destroy") at /home/drjones/code/qemu/util/qemu-thread-posix.c:39 #3 0x0000555555b0be20 in qemu_mutex_destroy (mutex=mutex@entry=0x5555566aa0e0) at /home/drjones/code/qemu/util/qemu-thread-posix.c:57 #4 0x00005555558aab00 in qemu_chr_free_common (chr=0x5555566aa0e0) at /home/drjones/code/qemu/qemu-char.c:4029 #5 0x00005555558b05f9 in qemu_chr_delete (chr=) at /home/drjones/code/qemu/qemu-char.c:4038 #6 0x00005555558b05f9 in qemu_chr_delete (chr=) at /home/drjones/code/qemu/qemu-char.c:4044 #7 0x00005555558b062c in qemu_chr_cleanup () at /home/drjones/code/qemu/qemu-char.c:4557 #8 0x00007fffdbb851e8 in __run_exit_handlers () at /lib64/libc.so.6 #9 0x00007fffdbb85235 in () at /lib64/libc.so.6 #10 0x00005555558d1b39 in testdev_write (testdev=0x5555566aa0a0) at /home/drjones/code/qemu/backends/testdev.c:71 #11 0x00005555558d1b39 in testdev_write (chr=, buf=0x7fffc343fd9a "", len=0) at /home/drjones/code/qemu/backends/testdev.c:95 #12 0x00005555558adced in qemu_chr_fe_write (s=0x5555566aa0e0, buf=buf@entry=0x7fffc343fd98 "0q", len=len@entry=2) at /home/drjones/code/qemu/qemu-char.c:282 Instead of using a atexit() handler, only run the chardev cleanup as initially proposed at the end of main(), where there are less chances (hic) of conflicts or other races. Signed-off-by: Marc-André Lureau Reported-by: Andrew Jones Message-Id: <20160704153823.16879-1-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini --- include/sysemu/char.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/sysemu/char.h b/include/sysemu/char.h index 57df10a..0ea9eac 100644 --- a/include/sysemu/char.h +++ b/include/sysemu/char.h @@ -152,6 +152,13 @@ CharDriverState *qemu_chr_new(const char *label, const char *filename, void qemu_chr_disconnect(CharDriverState *chr); /** + * @qemu_chr_cleanup: + * + * Delete all chardevs (when leaving qemu) + */ +void qemu_chr_cleanup(void); + +/** * @qemu_chr_new_noreplay: * * Create a new character backend from a URI. -- cgit v1.1 From 2aece63c8a9d2c3a8ff41d2febc4cdeff2633331 Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Wed, 13 Jul 2016 12:18:06 +0800 Subject: hostmem: detect host backend memory is being used properly Currently, we use memory_region_is_mapped() to detect if the host backend memory is being used. This works if the memory is directly mapped into guest's address space, however, it is not true for nvdimm as it uses aliased memory region to map the memory. This is why this bug can happen: https://bugzilla.redhat.com/show_bug.cgi?id=1352769 Fix it by introduce a new filed, is_mapped, to HostMemoryBackend, we set/clear this filed accordingly when the device link/unlink to host backend memory Signed-off-by: Xiao Guangrong Signed-off-by: Paolo Bonzini --- include/sysemu/hostmem.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 4d6617e..c903404 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -53,7 +53,7 @@ struct HostMemoryBackend { /* protected */ uint64_t size; bool merge, dump; - bool prealloc, force_prealloc; + bool prealloc, force_prealloc, is_mapped; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); HostMemPolicy policy; @@ -63,4 +63,6 @@ struct HostMemoryBackend { MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend, Error **errp); +void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped); +bool host_memory_backend_is_mapped(HostMemoryBackend *backend); #endif -- cgit v1.1