virtio-scsi: Fix subtle (guest) endian bug

The virtio-scsi config space is, by specification, in guest endian (which
is ill-defined, but there you go).  In virtio_scsi_get_config() we set up
all the fields in there, using stl_raw().  Which is a problem for the
max_channel and max_target fields, which are 16-bit, not 32-bit.  For
little-endian targets we get away with it by accident, since the first
two bytes will still be correct, and the extra two bytes written (with
zeroes) will be overwritten correctly by the next store.

But for big-endian guests, this means the max_target field ends up as zero,
which means the guest will only recognize a single disk on the virtio-scsi
bus.  This patch fixes the problem.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul 'Rusty' Russell <rusty@rustcorp.com.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 file changed
tree: f45340e864acdc041069a7b99508504372754546
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. default-configs/
  6. docs/
  7. fpu/
  8. fsdev/
  9. gdb-xml/
  10. hw/
  11. include/
  12. libcacard/
  13. linux-headers/
  14. linux-user/
  15. net/
  16. pc-bios/
  17. qapi/
  18. qga/
  19. QMP/
  20. qom/
  21. roms/
  22. scripts/
  23. slirp/
  24. stubs/
  25. sysconfigs/
  26. target-alpha/
  27. target-arm/
  28. target-cris/
  29. target-i386/
  30. target-lm32/
  31. target-m68k/
  32. target-microblaze/
  33. target-mips/
  34. target-openrisc/
  35. target-ppc/
  36. target-s390x/
  37. target-sh4/
  38. target-sparc/
  39. target-unicore32/
  40. target-xtensa/
  41. tcg/
  42. tests/
  43. trace/
  44. ui/
  45. .exrc
  46. .gitignore
  47. .gitmodules
  48. .mailmap
  49. a.out.h
  50. acl.c
  51. acl.h
  52. aes.c
  53. aes.h
  54. aio-posix.c
  55. aio-win32.c
  56. alpha-dis.c
  57. alpha.ld
  58. arch_init.c
  59. arch_init.h
  60. arm-dis.c
  61. arm.ld
  62. async.c
  63. balloon.c
  64. balloon.h
  65. bitmap.c
  66. bitmap.h
  67. bitops.c
  68. bitops.h
  69. block-migration.c
  70. block-migration.h
  71. block.c
  72. block.h
  73. block_int.h
  74. blockdev-nbd.c
  75. blockdev.c
  76. blockdev.h
  77. blockjob.c
  78. blockjob.h
  79. bswap.h
  80. bt-host.c
  81. bt-host.h
  82. bt-vhci.c
  83. buffered_file.c
  84. buffered_file.h
  85. cache-utils.c
  86. cache-utils.h
  87. Changelog
  88. cmd.c
  89. cmd.h
  90. CODING_STYLE
  91. compatfd.c
  92. compatfd.h
  93. compiler.h
  94. config.h
  95. configure
  96. console.c
  97. console.h
  98. COPYING
  99. COPYING.LIB
  100. coroutine-gthread.c
  101. coroutine-sigaltstack.c
  102. coroutine-ucontext.c
  103. coroutine-win32.c
  104. cpu-all.h
  105. cpu-common.h
  106. cpu-defs.h
  107. cpu-exec.c
  108. cpus.c
  109. cpus.h
  110. cputlb.c
  111. cputlb.h
  112. cris-dis.c
  113. cursor.c
  114. cursor_hidden.xpm
  115. cursor_left_ptr.xpm
  116. cutils.c
  117. def-helper.h
  118. device_tree.c
  119. device_tree.h
  120. dis-asm.h
  121. disas.c
  122. disas.h
  123. dma-helpers.c
  124. dma.h
  125. dump-stub.c
  126. dump.c
  127. dump.h
  128. elf.h
  129. envlist.c
  130. envlist.h
  131. error.c
  132. error.h
  133. event_notifier-posix.c
  134. event_notifier-win32.c
  135. event_notifier.h
  136. exec-all.h
  137. exec-memory.h
  138. exec.c
  139. gdbstub.c
  140. gdbstub.h
  141. gen-icount.h
  142. HACKING
  143. hmp-commands.hx
  144. hmp.c
  145. hmp.h
  146. host-utils.c
  147. host-utils.h
  148. hppa-dis.c
  149. hppa.ld
  150. hwaddr.h
  151. i386-dis.c
  152. i386.ld
  153. ia64-dis.c
  154. ia64.ld
  155. input.c
  156. int128.h
  157. iohandler.c
  158. ioport.c
  159. ioport.h
  160. iorange.h
  161. iov.c
  162. iov.h
  163. json-lexer.c
  164. json-lexer.h
  165. json-parser.c
  166. json-parser.h
  167. json-streamer.c
  168. json-streamer.h
  169. kvm-all.c
  170. kvm-stub.c
  171. kvm.h
  172. libfdt_env.h
  173. LICENSE
  174. lm32-dis.c
  175. m68k-dis.c
  176. m68k.ld
  177. main-loop.c
  178. main-loop.h
  179. MAINTAINERS
  180. Makefile
  181. Makefile.dis
  182. Makefile.objs
  183. Makefile.target
  184. Makefile.user
  185. memory-internal.h
  186. memory.c
  187. memory.h
  188. memory_mapping-stub.c
  189. memory_mapping.c
  190. memory_mapping.h
  191. microblaze-dis.c
  192. migration-exec.c
  193. migration-fd.c
  194. migration-tcp.c
  195. migration-unix.c
  196. migration.c
  197. migration.h
  198. mips-dis.c
  199. mips.ld
  200. module.c
  201. module.h
  202. monitor.c
  203. monitor.h
  204. nbd.c
  205. nbd.h
  206. net.c
  207. net.h
  208. notify.c
  209. notify.h
  210. os-posix.c
  211. os-win32.c
  212. osdep.c
  213. osdep.h
  214. oslib-posix.c
  215. oslib-win32.c
  216. page_cache.c
  217. path.c
  218. pci-ids.txt
  219. poison.h
  220. ppc-dis.c
  221. ppc.ld
  222. ppc64.ld
  223. qapi-schema-guest.json
  224. qapi-schema-test.json
  225. qapi-schema.json
  226. qbool.c
  227. qbool.h
  228. qdict-test-data.txt
  229. qdict.c
  230. qdict.h
  231. qemu-aio.h
  232. qemu-barrier.h
  233. qemu-bridge-helper.c
  234. qemu-char.c
  235. qemu-char.h
  236. qemu-common.h
  237. qemu-config.c
  238. qemu-config.h
  239. qemu-coroutine-int.h
  240. qemu-coroutine-io.c
  241. qemu-coroutine-lock.c
  242. qemu-coroutine-sleep.c
  243. qemu-coroutine.c
  244. qemu-coroutine.h
  245. qemu-doc.texi
  246. qemu-error.c
  247. qemu-error.h
  248. qemu-file.h
  249. qemu-ga.c
  250. qemu-img-cmds.hx
  251. qemu-img.c
  252. qemu-img.texi
  253. qemu-io.c
  254. qemu-lock.h
  255. qemu-log.c
  256. qemu-log.h
  257. qemu-nbd.c
  258. qemu-nbd.texi
  259. qemu-objects.h
  260. qemu-option-internal.h
  261. qemu-option.c
  262. qemu-option.h
  263. qemu-options-wrapper.h
  264. qemu-options.h
  265. qemu-options.hx
  266. qemu-os-posix.h
  267. qemu-os-win32.h
  268. qemu-pixman.c
  269. qemu-pixman.h
  270. qemu-progress.c
  271. qemu-queue.h
  272. qemu-seccomp.c
  273. qemu-seccomp.h
  274. qemu-sockets.c
  275. qemu-tech.texi
  276. qemu-thread-posix.c
  277. qemu-thread-posix.h
  278. qemu-thread-win32.c
  279. qemu-thread-win32.h
  280. qemu-thread.h
  281. qemu-timer-common.c
  282. qemu-timer.c
  283. qemu-timer.h
  284. qemu-tls.h
  285. qemu-tool.c
  286. qemu-user.c
  287. qemu-x509.h
  288. qemu-xattr.h
  289. qemu.sasl
  290. qemu_socket.h
  291. qerror.c
  292. qerror.h
  293. qfloat.c
  294. qfloat.h
  295. qint.c
  296. qint.h
  297. qjson.c
  298. qjson.h
  299. qlist.c
  300. qlist.h
  301. qmp-commands.hx
  302. qmp.c
  303. qobject.h
  304. qstring.c
  305. qstring.h
  306. qtest.c
  307. qtest.h
  308. range.h
  309. readline.c
  310. readline.h
  311. README
  312. rules.mak
  313. s390-dis.c
  314. s390.ld
  315. savevm.c
  316. sh4-dis.c
  317. softmmu-semi.h
  318. softmmu_defs.h
  319. softmmu_exec.h
  320. softmmu_header.h
  321. softmmu_template.h
  322. sparc-dis.c
  323. sparc.ld
  324. sparc64.ld
  325. spice-qemu-char.c
  326. sysemu.h
  327. tcg-runtime.c
  328. tci-dis.c
  329. tci.c
  330. thread-pool.c
  331. thread-pool.h
  332. thunk.c
  333. thunk.h
  334. TODO
  335. trace-events
  336. translate-all.c
  337. uboot_image.h
  338. uri.c
  339. uri.h
  340. user-exec.c
  341. VERSION
  342. version.rc
  343. vgafont.h
  344. vl.c
  345. vmstate.h
  346. x86_64.ld
  347. xen-all.c
  348. xen-mapcache.c
  349. xen-mapcache.h
  350. xen-stub.c