CA-134745: read device-type and mode on physical-device callback

This is how blkback does it.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-134745: don't write info on physical-device callback

This write appears redundant as we already do so when connecting to the
front-end (connect_frontend), just like blktap does.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-134745: simplify and clarify reconnect logic

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-134745: ensure frontend() is called before physdev/hotplug.

Functions physical_device_changed() and hotplug_status_changed() require the
front-end path in the VBD to have been initialised, this patch ensures
that frontend() has been called before any of these functions are
called.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Acked-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Merge branch 'CA-134745' into xs64bit

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #85 on xapi-project/blktap
CA-135969: disable verbose messages in tapback

They seem to significantly delay tapback's execution.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
CA-135969: don't log to separate file, use syslog instead

Not logging to syslog leads to nasty lock ups and long delays.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Mate Lakat <mate.lakat@citrix.com>
Merge branch 'CA-135969' into xs64bit

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #90 on xapi-project/blktap
Revert "Merge branch 'CA-135969' into xs64bit"

This reverts commit b1ea896f36e6c2c0bca8496fcb668a95411c09cb, reversing
changes made to 246b35670f68410c1f589c99bbddc69858f59032. Revert required
to fix BVT.
CA-137830: enable memory caching for the VHD cache in IntelliCache

This patch enables memory caching for the VHD file acting as the cache
in IntelliCache, despite the fact that it is opened in R/W mode. Without
this, read caching interacts badly with IntelliCahce. This is safe to do
so as the cache file is always thrown away.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
CA-137830: change behaviour of vhd_cache_enabled

vhd_cache_enabled must return true not only if the VHD_CACHED_ENABLED
bit is set, but also if the VHD file in opened in read only mode
(VHD_OPEN_RDWR is not set). This ensures that if the leaf is opened R/W
and for buffered I/O (which is the case for IntelliCache), the parent
chain is is not considered 'cached'.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
CA-137830: don't pass TD_OPEN_NO_O_DIRECT to parent in IntelliCache

If IntelliCache is used, TD_OPEN_NO_O_DIRECT must not be passed to the
parent otherwise tapdisk will perform buffered I/O to the parent, and
this is meaningless as each block read from the parent is only read
once.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Merge branch 'CA-137830' into xs64bit

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #94 on xapi-project/blktap
CAR-1442: Allow 'tap-ctl create' to disable O_DIRECT

Signed-off-by: Germano Percossi <germano.percossi@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>

GitHub: closes #86 on xapi-project/blktap
Revert "Revert "Merge branch 'CA-135969' into xs64bit""

This reverts commit 0ef84c6b7c3a6f43e9e7315bbae5aec029f04e0d.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
CA-135969: block all other signals

And use sigaction for handling signals.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Chandrika Srinivasan <chandrika.srinivasan@citrix.com>
Merge branch 'CA-135969' into xs64bit

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>

GitHub: closes #95 on xapi-project/blktap
CA-138289: produce ring statistics in /dev/shm

blkback maintains shared ring statistics in a file in sysfs
(vbd-domid-devid/io_ring). This patch implements the same functionality
in tapdisk: tapdisk exports the same information under a new file in
/dev/shm (e.g /dev/shm/vbd3-domid-devid/io_ring), once every thirty
seconds for performance improvements. NB we don't deal with other
processes touching these files.

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Siddharth Vinothkumar <siddharth.vinothkumar@citrix.com>

GitHub: closes #93 on xapi-project/blktap
CA-138331: properly fail write I/O barrier requests

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Germano Percossi <germano.percossi@citrix.com>

GitHub: closes #96 on xapi-project/blktap
CA-139357: ignore SIGCHLD in master tapback

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>
Reviewed-by: Frediano Ziglio <frediano.ziglio@citrix.com>