sheep: remove master node

The current procedure to handle sheep join is as follows.

 1. The joining node sends a join request.
 2. The master node accepts the request.
 3. All the nodes update cluster members.

This procedure has some problems:

 - The master election is too complex to maintain.
   It is very difficult to make sure that the implementation is
   correct.

 - The master node can fail while it is accepting the joining node.
   The newly elected master has to take over the process, but it's
   usually difficult to implement because we have to know what the
   previous master did and what it did not before its failure.

This patch changes the sheep join procedure to the following.

 1. The joining node sends a join request.
 2. Some of the existing nodes accept the request.
 3. All the nodes update cluster members.

It is allowed for the multiple nodes to call sd_join_handler() against
the same join request, but at least one node must have to do it.  With
this change, we can eliminate a master, and node failure while
accepting node join is also allowed.

Removing a master from zookeeper is not easy since it doesn't expect
that multiple nodes send EVENT_ACCEPT.  I'll leave this for another
day.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
recovery: wait until getting the previous epoch's vdi bitmap

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
sheep: optimize getting vdi bitmap

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
util: add find_zero_blocks()

This adds a helper function which does the similar thing as
trim_zero_blocks() but doesn't update the given buffer.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
add sha1_from_buffer()

This adds a helper function to calculate a unique sha1 digest based on
the given buffer.

This also fixes a bug that we don't use an original buffer length to
calculate the hash value and the result is not unique.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: wait for recovery outside of _simulate_machine_down

Not all the users don't want to wait for recovery after network
failure emulation.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: add test for qemu reconnection

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
tests/functional: use kill_zk_session to _kill_sheep with zk

- fix kill_zk_session.c that if ZNONODE returns, we simply return success

In this way we don't blind sleep for _kill_sheep with zk driver. This fixes
some false failure of tests with SSD drive and also boost tests a little bit

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>