vfio-pci: Fix debug build

Stray variable from before MSI-X rework

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio-pci: Mark non-migratable

We haven't magically fixed this yet.  Toss in a description too.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
memory: Make eventfd adhere to device endianness

Our memory API MMIO regions know the concept of device endianness. This
is used to automatically swap endianness between devices and host CPU,
depending on whether buses in between would swizzle the bits.

The ioeventfd value comparison does not adhere to that semantic though.
Probably because nobody has been running ioeventfd on a BE platform and
the only device implementing ioeventfd right now is LE (PCI) based.

So add swizzling to ioeventfd registration / deletion to make the rest
of the code as consistent as possible.

Thanks a lot to Michael Tsirkin to point me towards the right direction.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
i440fx: avoid destroying memory regions within a transaction

Calling memory_region_destroy() within a transaction is illegal, since
the memory API is allowed to continue to dispatch to a region until the
transaction commits.  440fx does that however when managing PAM registers.

This bug is benign, since the regions are all aliases (which the memory
core tends to throw anyway), and since we don't do concurrent dispatch yet,
but instead of relying on that, tighten ship ahead of the coming concurrency
storm.

Fix by having a predefined set of regions, of which one will be enabled at
any time.

Signed-off-by: Avi Kivity <avi@redhat.com>
memory: abort if a memory region is destroyed during a transaction

Destroying a memory region is illegal within a transaction, as until
the transaction is committed, the memory core may hold references to
the region.  Add an assert to check for violations of this rule.

Signed-off-by: Avi Kivity <avi@redhat.com>
Rename target_phys_addr_t to hwaddr

target_phys_addr_t is unwieldly, violates the C standard (_t suffixes are
reserved) and its purpose doesn't match the name (most target_phys_addr_t
addresses are not target specific).  Replace it with a finger-friendly,
standards conformant hwaddr.

Outstanding patchsets can be fixed up with the command

  git rebase -i --exec 'find -name "*.[ch]"
                        | xargs s/target_phys_addr_t/hwaddr/g' origin

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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>
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>
docs: document for add-cow file format

Document for add-cow format, the usage and spec of add-cow are introduced.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
docs v14
rename optional to compatible in docs
make path_has_protocol non static

We will use path_has_protocol outside block.c, so just make it public.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>