block: Change BDS parameter of bdrv_open() to **

Make bdrv_open() take a pointer to a BDS pointer, similarly to
bdrv_file_open(). If a pointer to a NULL pointer is given, bdrv_open()
will create a new BDS with an empty name; if the BDS pointer is not
NULL, that existing BDS will be reused (in the same way as bdrv_open()
already did).

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Add reference parameter to bdrv_open()

Allow bdrv_open() to handle references to existing block devices just as
bdrv_file_open() is already capable of.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Make bdrv_file_open() static

Add the bdrv_open() option BDRV_O_PROTOCOL which results in passing the
call to bdrv_file_open(). Additionally, make bdrv_file_open() static and
therefore bdrv_open() the only way to call it.

Consequently, all existing calls to bdrv_file_open() have to be adjusted
to use bdrv_open() with the BDRV_O_PROTOCOL flag instead.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Reuse NULL options check from bdrv_open()

Remove the check whether options is NULL form bdrv_file_open() and rely
on the one in bdrv_open() instead.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Reuse reference handling from bdrv_open()

Remove the reference parameter and the related handling code from
bdrv_file_open(), since it exists in bdrv_open() now as well.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Remove bdrv_new() from bdrv_file_open()

Change bdrv_file_open() to take a simple pointer to an already existing
BDS instead of an indirect one. The BDS will be created in bdrv_open()
if necessary.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Reuse fail path from bdrv_open()

The fail paths of bdrv_file_open() and bdrv_open() naturally exhibit
similarities, thus it is possible to reuse the one from bdrv_open() and
shorten the one in bdrv_file_open() accordingly.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Reuse bs->options setting from bdrv_open()

Setting bs->options in bdrv_file_open() is not necessary if it is
already done in bdrv_open().

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Reuse success path from bdrv_open()

The fail and success paths of bdrv_file_open() may be further shortened
by reusing code already existent in bdrv_open(). This includes
bdrv_file_open() not taking the reference to options which allows the
removal of QDECREF(options) in that function.

Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Remove bdrv_open_image()'s force_raw option

This option is now unnecessary since specifying BDRV_O_PROTOCOL as flag
will do exactly the same.

Signed-off-by: Max Reitz <mreitz@redhat.com>
quorum: Create quorum.c, add QuorumSingleAIOCB and QuorumAIOCB.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Create BDRVQuorumState and BlkDriver and do init.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_aio_writev and its dependencies.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
blkverify: Extract qemu_iovec_clone() and qemu_iovec_compare() from blkverify.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_aio_readv.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum mechanism.

Use gnutls's SHA-256 to compare versions.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_getlength().

Check that every bs file returns the same length.
Otherwize, return -EIO to disable the quorum and
avoid length discrepancy.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_invalidate_cache().

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_co_get_block_status.

Signed-off-by: Benoit Canet <benoit@irqsave.net>
quorum: Add quorum_co_flush().

Makes a vote to select error if any.

Signed-off-by: Benoit Canet <benoit@irqsave.net>