trace: fix bad interaction between debug mode, templates, ld, and 'asm goto'

A call to safe_load() when serializing a const char* trace argument
generates a reference to a label from .text.fixup to a template function
(safe_load()).  If this function is out-of-line, then ld can eliminate it,
as duplicate copies of templates are removed (except one).  This causes a
linker error.

Fix by marking the function (and template functions that call it) as always
inline.

Fixes #217.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
pci: Fix header type check

Header Type is 8-bit. The bit 7 is used to identify a multi-function
device. The lower bit 1 and bit 0 are used to identify the header type.

   00b is defined for Normal devices
   01b is defined for PCI-to-PCI bridges
   10b is defined for PC Card Standard

Fix the check by masking the lower 2 bits only.

This patch fixes the device probe on VMware Workstation.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Introduce scsi-common

Split the common scsi code from virtio-scsi.cc to scsi-common.cc. This way, we can share
code with other scsi driver, e.g., vmw-pvscsi.

Tested on local kvm and GCE.

Signed-off-by: Asias He <asias@cloudius-systems.com>
vmw-pvscsi: Initial support

This driver is for VMware's pvscsi disk. It has better performance than
using AHCI device in VMware. This driver uses the common scsi code in
scsi-common.

This driver is written from scratch. QEMU and Linux pvscsi drivers were
used as reference as there's no specification available.

Tested on QEMU's pvscsi implementation and VMware Workstation.

Signed-off-by: Asias He <asias@cloudius-systems.com>
virtio-scsi: Do not assert on response in req_done

req->response can be not zero when in some cases, for instance, when the
REPORT LUNS command send to a target which does not exist. Pass the
handling of req->response to command handling.

This allows us to probe multiple targets.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Introduce config.max_target

Use this to limit max number of target to scan.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Enable multiple target scan

Since we can handle non-exist target correctly now, we can enable
multiple target scan.

Signed-off-by: Asias He <asias@cloudius-systems.com>
vmw-pvscsi: Limit max number of LUNs per target to 1.

VMware supports only 1 lun per target. Limit the max_lun to speed up
probe.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Add scsi_common::handle_bio helper

This eliminates duplicated code in make_request() of scsi driver.

Signed-off-by: Asias He <asias@cloudius-systems.com>
scsi: Specify virtual keyword for the virtual functions

Avi suggested to add the virtual keyword to reduce possible confusion.

Signed-off-by: Asias He <asias@cloudius-systems.com>
Merge branch 'pvscsi' of https://github.com/asias/osv

VMware pvscsi support from Asias He.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>