fix -net user checks by reordering checks

reorder slirp config options. first check the dns-server-address,
then check the first-dhcp-address. the original code was comparing
the first-dhcp-address with the default dns-server-address, not
the configured dns-server-address.

Signed-off-by: Bas van Sisseren <bas@quarantainenet.nl>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
make user networking hostfwd work with restrict=y

This patch allows the hostfwd option to override the restrict=y setting in
the user network stack, as explicitly stated in the documentation on the
restrict option:

     restrict=on|off
         If this option is enabled, the guest will be isolated, i.e. it
         will not be able to contact the host and no guest IP packets
         will be routed over the host to the outside. This option does
         not affect any explicitly set forwarding rules.

Qemu bug tracker:
https://bugs.launchpad.net/qemu/+bug/829455

Signed-off-by: Gertjan Halkes <qemu@ghalkes.nl>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Merge remote-tracking branch 'kiszka/queues/slirp' into staging

# By Bas van Sisseren (1) and Gertjan Halkes (1)
# Via Jan Kiszka
* kiszka/queues/slirp:
  make user networking hostfwd work with restrict=y
  fix -net user checks by reordering checks

Message-id: cover.1371638848.git.jan.kiszka@siemens.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Merge remote-tracking branch 'bonzini/iommu-for-anthony' into staging

# By Paolo Bonzini (12) and others
# Via Paolo Bonzini
* bonzini/iommu-for-anthony: (25 commits)
  memory: render_memory_region: factor out fr constant setters
  memory: as_update_topology_pass: Improve comments
  memory: Fix comment typo
  memory: give name to every AddressSpace
  dma: eliminate DMAContext
  spapr_vio: take care of creating our own AddressSpace/DMAContext
  pci: use memory core for iommu support
  dma: eliminate old-style IOMMU support
  spapr: use memory core for iommu support
  spapr: make IOMMU translation go through IOMMUTLBEntry
  spapr: convert TCE API to use an opaque type
  vfio: abort if an emulated iommu is used
  memory: Add iommu map/unmap notifiers
  memory: iommu support
  memory: make section size a 128-bit integer
  exec: reorganize mem_add to match Int128 version
  Revert "s390x: reduce TARGET_PHYS_ADDR_SPACE_BITS to 62"
  Revert "memory: limit sections in the radix tree to the actual address space size"
  exec: return MemoryRegion from address_space_translate
  exec: Implement subpage_read/write via address_space_rw
  ...

Message-id: 1371739493-10187-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
cow: make reads go at a decent speed

Do not do two reads for each sector; load each sector of the bitmap
and use bitmap operations to process it.

Writes are still dog slow!

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cow: make writes go at a less indecent speed

Only sync once per write, rather than once per sector.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
cow: do not call bdrv_co_is_allocated

The next patches will make it a bit slower by calling bs->file.  It is
still appropriate for online jobs, but not for reads/writes.  Call the
internal function instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: make bdrv_co_is_allocated static

bdrv_is_allocated can detect coroutine context and go through a fast
path, similar to other block layer functions.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: remove bdrv_is_allocated_above/bdrv_co_is_allocated_above distinction

Now that bdrv_is_allocated detects coroutine context, the two can
use the same code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: introduce bdrv_get_block_status API

For now, bdrv_get_block_status is just another name for bdrv_is_allocated.
The next patches will add more flags.

This also touches all block drivers with a mostly mechanical rename.  The
sole exception is cow; because it calls cow_co_is_allocated from the read
code, we keep that function and make cow_co_get_block_status a wrapper.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: make bdrv_has_zero_init return false for copy-on-write-images

This helps implementing is_allocated on top of get_block_status.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: define get_block_status return value

Define the return value of get_block_status.  Bits 0, 1, 2 and 8-62
are valid; bit 63 (the sign bit) is reserved for errors.  Bits 3-7
are left for future extensions.

The return code is compatible with the old is_allocated API: returning
just 0 or 1 (aka BDRV_BLOCK_DATA) will not cause any behavioral change
in clients of is_allocated.  We will return more precise information
in the next patches.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: use bdrv_has_zero_init to return BDRV_BLOCK_ZERO

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: return get_block_status data and flags for formats

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
raw-posix: return get_block_status data and flags

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
raw-posix: detect XFS unwritten extents

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: add default get_block_status implementation for protocols

Protocols return raw data, so you can assume the offsets to pass
through unchanged.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
block: look for zero blocks in bs->file

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>