virtio-scsi: Add wwpn and tgpt properties

A vhost-scsi device must be bound to a tcm_vhost target port.  This will
be done by issuing an ioctl to the device with the wwpn and tgpt.  This
patch adds these properties to the virtio-scsi-pci device:

  qemu -device virtio-scsi-pci,wwpn=$TARGET_WWN,tgpt=$TPGT

Future patches will open /dev/vhost-scsi and issue the ioctl.

This patch also moves the virtio_scsi_init() prototype to
hw/virtio-scsi.h where the VirtIOSCSIConf structure is defined.  I think
this is cleaner than defining it in hw/virtio.h.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vhost: Pass device path to vhost_dev_init()

The path to /dev/vhost-net is currently hardcoded in vhost_dev_init().
This needs to be changed so that /dev/vhost-scsi can be used.  Pass in
the device path instead of hardcoding it.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio-scsi: Add vhost_vring_target ioctl struct

The vhost-scsi device is associated with a tcm_vhost target using the
VHOST_SCSI_SET_ENDPOINT and VHOST_SCSI_CLEAR_ENDPOINT ioctls that take a
wwpn and tpgt.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio-scsi: Open and initialize /dev/vhost-scsi

Begin adding vhost support by opening /dev/vhost-scsi.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
virtio-scsi: Start/stop vhost

This patch starts and stops vhost as the virtio device transitions
through its status phases.  Vhost can only be started once the guest
reports its driver has successfully initialized, which means the
virtqueues have been set up by the guest.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
notifier: add validity check and notify function

Event notifiers that have not had the event_notifier_init() function
called on them are invalid.  The event_notifier_valid() function checks
whether or not an event notifier is valild.  This can be used to check
whether a notifier is in use or not.

It sometimes useful to notify the event notifier, for example when vhost
is on the receiving end of the event notifier and qemu needs to notify
it.  The event_notifier_notify() function will signal the eventfd and
increment it by one.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio-pci: support host notifiers in TCG mode

Normally host notifiers are only used together with vhost-net in KVM
mode.  It is occassionally useful to use vhost with TCG mode, mainly for
testing and development.  This isn't hard to achieve, simply fall back
to notifying the host notifier manually from qemu if KVM mode is
disabled.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio-pci: check that event notification worked

For sanity assert that event notification succeeds.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
vhost-scsi: add -vhost-scsi host device

This patch adds a new type of host device that drives the vhost_scsi
device.  The syntax to add vhost-scsi is:

  qemu -vhost-scsi id=vhost-scsi0,wwpn=...,tpgt=123

The virtio-scsi emulated device will make use of vhost-scsi to process
virtio-scsi requests inside the kernel and hand them to the in-kernel
SCSI target stack.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
virtio-scsi: use the vhost-scsi host device

The vhost-scsi code was originally part of the virtio-scsi emulation.
This code has since been factored out and should be used instead.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
virtio-scsi: add VHOST_SCSI_SET_ENDPOINT call

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vhost-scsi: enable vhost notifiers for multiple queues

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
vhost-scsi: clear endpoint on stopped

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>