qemu-barrier: Fix compilation on i386 hosts

Commit 1d31fca470648ec66afd8743491bfb5846306341 tried to fix bug
introduced by 610b823ef66b993660f1ab1447a769f190e4f3b3 by including
qemu-common.h, which breaks the build further.

Include compiler.h instead, as suggested by Blue Swirl.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
qemu-option: opt_set(): split it up into more functions

The new functions are opts_accepts_any() and find_desc_by_name(), which
are also going to be used by qemu_opts_validate() (see next commit).

This also makes opt_set() slightly more readable.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
qemu-option: qemu_opts_validate(): fix duplicated code

Use opts_accepts_any() and find_desc_by_name().

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
qemu-option: qemu_opt_set_bool(): fix code duplication

It will set opt->str in qemu_opt_set_bool, without opt->str, there
will be some potential bugs.

These are uses of opt->str, and what happens when it isn't set:

* qemu_opt_get(): returns NULL, which means "not set".  Bug can bite
  when value isn't the default value.

* qemu_opt_parse(): passes NULL to parse_option_bool(), which treats it
  like "on".  Wrong if the value is actually false.  Bug can bite when
  qemu_opts_validate() runs after qemu_opt_set_bool().

* qemu_opt_del(): passes NULL to g_free(), which is just fine.

* qemu_opt_foreach(): passes NULL to the callback, which is unlikely to
  be prepared for it.

* qemu_opts_print(): prints NULL, which crashes on some systems.

* qemu_opts_to_qdict(): passes NULL to qstring_from_str(), which
  crashes.

It also makes qemu_opt_set_bool more readable by using find_desc_by_name
and opts_accepts_any.

It is based on Luiz's patch and uses Markus's comments. Discussions can
be found at:
http://lists.nongnu.org/archive/html/qemu-devel/2012-07/msg02716.html

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
introduce qemu_opts_create_nofail function

While id is NULL, qemu_opts_create can not fail, so ignore
errors is fine.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
use qemu_opts_create_nofail

We will use qemu_opts_create_nofail function, it can make code
more readable.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
create new function: qemu_opt_set_number

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
add def_value and use it in qemu_opts_print.

qemu_opts_print has no user now, so I re-write it and use it in
qemu-img.c.

qemu_opts_print will be used while using "qemu-img create", it will
produce the same output as previous code.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Create four opts list related functions

This patch will create 4 functions, count_opts_list, append_opts_list,
free_opts_list and print_opts_list, they will used in following commits.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Use QemuOpts support in block layer

This patch will use QemuOpts related functions in block layer, add
a member bdrv_create_options to BlockDriver struct, it will return
a QemuOptsList pointer, which includes the image format's create
options.

And create options's primary consumer is block creating related functions,
so modify them together.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
remove QEMUOptionParameter related functions and struct

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
add-cow docs v12

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
add-cow docs v13

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
make path_has_protocol non static

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
make qed_read_string bdrv_read_string

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
rename qcow2-cache.c to block-cache.c

We will re-use qcow2-cache as block layer common cache code,
so change its name and made some changes, define a struct named
BlockTableType, pass BlockTableType and table size parameters to
block cache initialization function.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
add BITMAP suport

We will use BLOCK_TABLE_BITMAP to identify add-cow file's cache,
so add its support for block-cache.c.
add-cow file format core code

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
qemu-iotests: add add-cow iotests support

This patch will use qemu-iotests to test add-cow file format.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
aaA