]> git.ipfire.org Git - thirdparty/qemu.git/log
thirdparty/qemu.git
8 years agoUpdate version for v2.6.0-rc0 release v2.6.0-rc0
Peter Maydell [Wed, 30 Mar 2016 18:25:40 +0000 (19:25 +0100)] 
Update version for v2.6.0-rc0 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160330-1' into...
Peter Maydell [Wed, 30 Mar 2016 16:32:11 +0000 (17:32 +0100)] 
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160330-1' into staging

target-arm queue:
 * virt: fix the virtual power button by adding a modelled
   "key press for 100ms" device
 * various improvements to m25p80 flash devices
 * implement new QMP query-gic-capability command to let the
   management layer know what versions of GIC we support

# gpg: Signature made Wed 30 Mar 2016 17:30:51 BST using RSA key ID 14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"

* remotes/pmaydell/tags/pull-target-arm-20160330-1:
  arm: implement query-gic-capabilities
  kvm: add kvm_device_supported() helper function
  arm: enhance kvm_arm_create_scratch_host_vcpu
  arm: qmp: add query-gic-capabilities interface
  block: m25p80: at25128a/at25256a models
  block: m25p80: n25q256a/n25q512a models
  block: m25p80: Implemented FSR register
  block: m25p80: Fast read and 4bytes commands
  block: m25p80: Dummy cycles for N25Q256/512
  block: m25p80: Add configuration registers
  block: m25p80: 4byte address mode
  block: m25p80: Extend address mode
  block: m25p80: Widen flags variable
  block: m25p80: RESET_ENABLE and RESET_MEMORY commands
  block: m25p80: Removed unused variable
  ARM: Virt: Use gpio_key for power button
  hw/gpio: Add the emulation of gpio_key

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoarm: implement query-gic-capabilities
Peter Xu [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
arm: implement query-gic-capabilities

For emulated GIC capabilities, currently only gicv2 is supported. We
need to add gicv3 in when emulated gicv3 ready. For KVM accelerated ARM
VM, we detect the capability bits by creating a scratch VM.

Signed-off-by: Peter Xu <peterx@redhat.com>
Acked-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1458788142-17509-5-git-send-email-peterx@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agokvm: add kvm_device_supported() helper function
Peter Xu [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
kvm: add kvm_device_supported() helper function

This can be used when probing whether KVM support specific device. Here,
a raw vmfd is used.

Signed-off-by: Peter Xu <peterx@redhat.com>
Acked-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1458788142-17509-4-git-send-email-peterx@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoarm: enhance kvm_arm_create_scratch_host_vcpu
Peter Xu [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
arm: enhance kvm_arm_create_scratch_host_vcpu

Support passing NULL for the first parameter (with the same effect
as passing an empty array) and for the third parameter (meaning
that we should not attempt to init the vcpu).

Signed-off-by: Peter Xu <peterx@redhat.com>
Acked-by: Sergey Fedorov <serge.fdrv@gmail.com>
Message-id: 1458788142-17509-3-git-send-email-peterx@redhat.com
[PMM: tweaked commit message, comment]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoarm: qmp: add query-gic-capabilities interface
Peter Xu [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
arm: qmp: add query-gic-capabilities interface

This patch add "query-gic-capabilities" but does not implement it. The
command is ARM-only. The command will return a list of GICCapability
structs that describes all GIC versions that current QEMU and system
support.

Libvirt is possibly the first consumer of this new command.

Before this patch, a libvirt user can successfully configure all kinds
of GIC devices for ARM guests, no matter whether current QEMU/kernel
supports them. If the specified GIC version/type is not supported, the
user will get an ambiguous "QEMU boot failure" error when trying to start
the VM. This is not user-friendly.

With this patch, libvirt should be able to query which type (and which
version) of GIC device is supported. Using this information, libvirt
can warn the user during configuration of guests when specified GIC
device type is not supported. Or better, we can just list those versions
that we support, and filter out the unsupported ones.

For example, if we got the query result:

{"return": [{"emulated": false, "version": 3, "kernel": true},
            {"emulated": true, "version": 2, "kernel": false}]}

then it means that we support emulated GIC version 2 using:

  qemu-system-aarch64 -M virt,accel=tcg,gic-version=2 ...

or KVM-accelerated GIC version 3 using:

  qemu-system-aarch64 -M virt,accel=kvm,gic-version=3 ...

If we specify other explicit GIC versions rather than the above, QEMU
will not be able to boot.

The community is working on a more generic way to query these kinds of
information about valid values of machine properties. However, due to
the importance of supporting this specific use case, weecided to first
implement this ad-hoc one; then when the generic method is ready, we
can move on to that one smoothly.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-id: 1458788142-17509-2-git-send-email-peterx@redhat.com
[PMM: tweaked commit message a bit; monitor.o is CONFIG_SOFTMMU only]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: at25128a/at25256a models
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
block: m25p80: at25128a/at25256a models

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-12-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: n25q256a/n25q512a models
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:24 +0000 (17:27 +0100)] 
block: m25p80: n25q256a/n25q512a models

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-11-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Implemented FSR register
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: Implemented FSR register

Implements FSR register, it is used for busy waits.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-10-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Fast read and 4bytes commands
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: Fast read and 4bytes commands

Adds fast read and 4bytes commands family.
This work is based on Pawel Lenkow patch from v1.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-9-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Dummy cycles for N25Q256/512
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: Dummy cycles for N25Q256/512

Use the setting from the volatile cfg register to correctly
set the number of dummy cycles.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-8-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Add configuration registers
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: Add configuration registers

This patch adds both volatile and non volatile configuration registers
and commands to allow modify them. It is needed for proper handling
dummy cycles. Initialization of those registers and flash state
has been included as well.
Some of this registers are used by kernel.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Acked-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-7-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: 4byte address mode
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: 4byte address mode

This patch adds only 4byte address mode (does not cover dummy cycles).
This mode is needed to access more than 16 MiB of flash.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-6-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Extend address mode
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:23 +0000 (17:27 +0100)] 
block: m25p80: Extend address mode

Extend address mode allows to switch flash 16 MiB banks,
allowing user to access all flash sectors.
This access mode is used by u-boot.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-5-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Widen flags variable
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:22 +0000 (17:27 +0100)] 
block: m25p80: Widen flags variable

Extend the width of the flags variable to support the already existing
(but unused) WR_1 flag, which is above the range of 8 bits.
This allows support of EEPROM emulation which requires the WR_1 feature.

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-4-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: RESET_ENABLE and RESET_MEMORY commands
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:22 +0000 (17:27 +0100)] 
block: m25p80: RESET_ENABLE and RESET_MEMORY commands

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-3-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoblock: m25p80: Removed unused variable
Marcin Krzeminski [Wed, 30 Mar 2016 16:27:22 +0000 (17:27 +0100)] 
block: m25p80: Removed unused variable

Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1458719789-29868-2-git-send-email-marcin.krzeminski@nokia.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoARM: Virt: Use gpio_key for power button
Shannon Zhao [Wed, 30 Mar 2016 16:27:22 +0000 (17:27 +0100)] 
ARM: Virt: Use gpio_key for power button

There is a problem for power button that it will not work if an early
system_powerdown request happens before guest gpio driver loads.

Fix this problem by using gpio_key.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1458221140-15232-3-git-send-email-zhaoshenglong@huawei.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agohw/gpio: Add the emulation of gpio_key
Shannon Zhao [Wed, 30 Mar 2016 16:27:22 +0000 (17:27 +0100)] 
hw/gpio: Add the emulation of gpio_key

This will be used by ARM virt machine as a power button.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Message-id: 1458221140-15232-2-git-send-email-zhaoshenglong@huawei.com
[PMM: Use hyphen rather than underscore in type names;
 add a comment briefly describing what the device does]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/lalrae/tags/mips-20160329-2' into staging
Peter Maydell [Wed, 30 Mar 2016 15:06:44 +0000 (16:06 +0100)] 
Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160329-2' into staging

MIPS patches 2016-03-29

Changes:
* add initial MIPS CPS support
* implement ITU block
* implement MAAR

# gpg: Signature made Wed 30 Mar 2016 09:27:01 BST using RSA key ID 0B29DA6B
# gpg: Good signature from "Leon Alrae <leon.alrae@imgtec.com>"

* remotes/lalrae/tags/mips-20160329-2: (21 commits)
  target-mips: add MAAR, MAARI register
  target-mips: use CP0_CHECK for gen_m{f|t}hc0
  hw/mips/cps: enable ITU for multithreading processors
  target-mips: make ITC Configuration Tags accessible to the CPU
  target-mips: check CP0 enabled for CACHE instruction also in R6
  hw/mips: implement ITC Storage - Bypass View
  hw/mips: implement ITC Storage - P/V Sync and Try Views
  hw/mips: implement ITC Storage - Empty/Full Sync and Try Views
  hw/mips: implement ITC Storage - Control View
  hw/mips: implement ITC Configuration Tags and Storage Cells
  target-mips: enable CM GCR in MIPS64R6-generic CPU
  hw/mips_malta: add CPS to Malta board
  hw/mips_malta: move CPU creation to a separate function
  hw/mips_malta: remove redundant irq and clock init
  hw/mips_malta: remove CPUMIPSState from the write_bootloader()
  hw/mips/cps: create CPC block inside CPS
  hw/mips: add initial Cluster Power Controller support
  hw/mips/cps: create GCR block inside CPS
  hw/mips: add initial Global Config Register support
  target-mips: add CMGCRBase register
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-03-30-1' into...
Peter Maydell [Wed, 30 Mar 2016 14:04:08 +0000 (15:04 +0100)] 
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-2016-03-30-1' into staging

Merge qcrypto fixes 2016/03/30 v1

# gpg: Signature made Wed 30 Mar 2016 14:59:19 BST using RSA key ID 15104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>"
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>"

* remotes/berrange/tags/pull-qcrypto-2016-03-30-1:
  crypto: do an explicit check for nettle pbkdf functions

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agocrypto: do an explicit check for nettle pbkdf functions
Daniel P. Berrange [Tue, 29 Mar 2016 14:47:51 +0000 (15:47 +0100)] 
crypto: do an explicit check for nettle pbkdf functions

Support for the PBKDF functions in nettle was not introduced
until version 2.6. Some distros QEMU targets have older
versions and thus lack PBKDF support. Address this by doing
a check in configure for the desired function and then skipping
compilation of the nettle-pbkdf.o module

Reported-by: Wen Congyang <wency@cn.fujitsu.com>
Tested-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Wed, 30 Mar 2016 12:43:04 +0000 (13:43 +0100)] 
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

# gpg: Signature made Wed 30 Mar 2016 11:57:54 BST using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (48 commits)
  iotests: Test qemu-img convert -S 0 behavior
  block/null-{co,aio}: Implement get_block_status()
  block/null-{co,aio}: Allow reading zeroes
  qemu-img: Fix preallocation with -S 0 for convert
  block: Remove bdrv_(set_)enable_write_cache()
  block: Remove BDRV_O_CACHE_WB
  block: Remove bdrv_parse_cache_flags()
  qemu-io: Use bdrv_parse_cache_mode() in reopen_f()
  block: Use bdrv_parse_cache_mode() in drive_init()
  raw: Support BDRV_REQ_FUA
  nbd: Support BDRV_REQ_FUA
  iscsi: Support BDRV_REQ_FUA
  block: Introduce bdrv_co_writev_flags()
  block/qapi: Use blk_enable_write_cache()
  block: Move enable_write_cache to BB level
  block: Handle flush error in bdrv_pwrite_sync()
  block: Always set writeback mode in blk_new_open()
  block: blockdev_init(): Call blk_set_enable_write_cache() explicitly
  xen_disk: Call blk_set_enable_write_cache() explicitly
  qemu-img: Call blk_set_enable_write_cache() explicitly
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging
Peter Maydell [Wed, 30 Mar 2016 11:30:38 +0000 (12:30 +0100)] 
Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into staging

# gpg: Signature made Wed 30 Mar 2016 02:07:15 BST using RSA key ID 398D6211
# gpg: Good signature from "Jason Wang (Jason Wang on RedHat) <jasowang@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 215D 46F4 8246 689E C77F  3562 EF04 965B 398D 6211

* remotes/jasowang/tags/net-pull-request:
  Revert "e1000: fix hang of win2k12 shutdown with flood ping"
  e1000: Fixing interrupts pace.
  tests/test-filter-redirector: Add unit test for filter-redirector
  net/filter-mirror: implement filter-redirector
  net/filter-mirror: Change filter_mirror_send interface
  tests/test-filter-mirror:add filter-mirror unit test
  net/filter-mirror:Add filter-mirror

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoiotests: Test qemu-img convert -S 0 behavior
Max Reitz [Thu, 24 Mar 2016 22:34:00 +0000 (23:34 +0100)] 
iotests: Test qemu-img convert -S 0 behavior

Passing -S 0 to qemu-img convert should result in all source data being
copied to the output, even if that source data is known to be 0. The
output image should therefore have exactly the same size on disk as an
image which we explicitly filled with data.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/null-{co,aio}: Implement get_block_status()
Max Reitz [Thu, 24 Mar 2016 22:33:59 +0000 (23:33 +0100)] 
block/null-{co,aio}: Implement get_block_status()

Signed-off-by: Max Reitz <mreitz@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/null-{co,aio}: Allow reading zeroes
Max Reitz [Thu, 24 Mar 2016 22:33:58 +0000 (23:33 +0100)] 
block/null-{co,aio}: Allow reading zeroes

This is optional so that it does not impede the null block driver's
performance unless this behavior is desired.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-img: Fix preallocation with -S 0 for convert
Max Reitz [Thu, 24 Mar 2016 22:33:57 +0000 (23:33 +0100)] 
qemu-img: Fix preallocation with -S 0 for convert

When passing -S 0 to qemu-img convert, the target image is supposed to
be fully allocated. Right now, this is not the case if the source image
contains areas which bdrv_get_block_status() reports as being zero.

This patch changes a zeroed area's status from BLK_ZERO to BLK_DATA
before invoking convert_write() if -S 0 has been specified. In addition,
the check whether convert_read() actually needs to do anything
(basically only if the current area is a BLK_DATA area) is pulled out of
that function to the caller.

If -S 0 has been specified, zeroed areas need to be written as data to
the output, thus they then have to be accounted when calculating the
progress made.

This patch changes the reference output for iotest 122; contrary to what
it assumed, -S 0 really should allocate everything in the output, not
just areas that are filled with zeros (as opposed to being zeroed).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Remove bdrv_(set_)enable_write_cache()
Kevin Wolf [Fri, 18 Mar 2016 18:01:41 +0000 (19:01 +0100)] 
block: Remove bdrv_(set_)enable_write_cache()

The only remaining users were block jobs (mirror and backup) which
unconditionally enabled WCE on the BlockBackend of the target image. As
these block jobs don't go through BlockBackend for their I/O requests,
they aren't affected by this setting anyway but always get a writeback
mode, so that call can be removed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Remove BDRV_O_CACHE_WB
Kevin Wolf [Fri, 18 Mar 2016 16:46:45 +0000 (17:46 +0100)] 
block: Remove BDRV_O_CACHE_WB

The previous patches have successively made blk->enable_write_cache the
true source for the information whether a writethrough mode must be
implemented. The corresponding BDRV_O_CACHE_WB is only useless baggage
we're carrying around, so now's the time to remove it.

At the same time, we remove the 'cache.writeback' option parsing on the
BDS level as the only effect was setting the BDRV_O_CACHE_WB flag.

This change requires test cases that explicitly enabled the option to
drop it. Other than that and the change of the error message when
writethrough is enabled on the BDS level (from "Can't set writethrough
mode" to "doesn't support the option"), there should be no change in
behaviour.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Remove bdrv_parse_cache_flags()
Kevin Wolf [Fri, 18 Mar 2016 14:36:58 +0000 (15:36 +0100)] 
block: Remove bdrv_parse_cache_flags()

All users are converted to bdrv_parse_cache_mode() now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-io: Use bdrv_parse_cache_mode() in reopen_f()
Kevin Wolf [Fri, 18 Mar 2016 14:36:31 +0000 (15:36 +0100)] 
qemu-io: Use bdrv_parse_cache_mode() in reopen_f()

We must forbid changing the WCE flag in bdrv_reopen() in the same patch,
as otherwise the behaviour would change so that the flag takes
precedence over the explicitly specified option.

The correct value of the WCE flag depends on the BlockBackend user (e.g.
guest device) and isn't a decision that the QMP client makes, so this
change is what we want.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Use bdrv_parse_cache_mode() in drive_init()
Kevin Wolf [Fri, 18 Mar 2016 14:35:51 +0000 (15:35 +0100)] 
block: Use bdrv_parse_cache_mode() in drive_init()

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoraw: Support BDRV_REQ_FUA
Kevin Wolf [Thu, 10 Mar 2016 12:46:04 +0000 (13:46 +0100)] 
raw: Support BDRV_REQ_FUA

Pass through the FUA flag to the lower layer so that the separate flush
can be saved in practically relevant cases where a (raw) format driver
sits on top of the protocol driver.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agonbd: Support BDRV_REQ_FUA
Kevin Wolf [Thu, 10 Mar 2016 13:01:31 +0000 (14:01 +0100)] 
nbd: Support BDRV_REQ_FUA

The NBD server already used to send a FUA flag when the writethrough
mode was set. This code was a remnant from the times where protocol
drivers actually had to implement writethrough modes. Since nowadays the
block layer sends flushes in writethrough mode and non-root nodes are
always writeback, this was mostly dead code - only mostly because if NBD
was configured to be used without a format, we sent _both_ FUA and an
explicit flush afterwards, which makes the code not technically dead,
but useless overhead.

This patch changes the code so that the block layer's FUA flag is
recognised and translated into a NBD FUA flag. The additional flush is
avoided now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoiscsi: Support BDRV_REQ_FUA
Kevin Wolf [Thu, 10 Mar 2016 12:55:50 +0000 (13:55 +0100)] 
iscsi: Support BDRV_REQ_FUA

This replaces the existing hack in the iscsi driver that sent the FUA
bit in writethrough mode and ignored the following flush in order to
optimise the number of roundtrips (see commit 73b5394e).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Introduce bdrv_co_writev_flags()
Kevin Wolf [Thu, 10 Mar 2016 12:39:55 +0000 (13:39 +0100)] 
block: Introduce bdrv_co_writev_flags()

This function will allow drivers to implement BDRV_REQ_FUA natively
instead of sending a separate flush after the write.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock/qapi: Use blk_enable_write_cache()
Kevin Wolf [Thu, 3 Mar 2016 10:37:48 +0000 (11:37 +0100)] 
block/qapi: Use blk_enable_write_cache()

Now that WCE is handled on the BlockBackend level, the flag is
meaningless for BDSes. As the schema requires us to fill the field,
we return an enabled write cache for them.

Note that this means that querying the BlockBackend name may return
writethrough as the cache information, whereas querying the node-name of
the root of that same BlockBackend will return writeback.

This may appear odd at first, but it actually makes sense because it
correctly repesents the layer that implements the WCE handling. This
becomes more apparent when you consider nodes that are the root node of
multiple BlockBackends, where each BB can have its own WCE setting.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Move enable_write_cache to BB level
Kevin Wolf [Fri, 4 Mar 2016 13:28:01 +0000 (14:28 +0100)] 
block: Move enable_write_cache to BB level

Whether a write cache is used or not is a decision that concerns the
user (e.g. the guest device) rather than the backend. It was already
logically part of the BB level as bdrv_move_feature_fields() always kept
it on top of the BDS tree; with this patch, the core of it (the actual
flag and the additional flushes) is also implemented there.

Direct callers of bdrv_open() must pass BDRV_O_CACHE_WB now if bs
doesn't have a BlockBackend attached.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Handle flush error in bdrv_pwrite_sync()
Kevin Wolf [Fri, 4 Mar 2016 13:16:51 +0000 (14:16 +0100)] 
block: Handle flush error in bdrv_pwrite_sync()

We don't want to silently ignore a flush error.

Also, there is little point in avoiding the flush for writethrough modes
and once WCE is moved to the BB layer, we definitely need the flush here
because bdrv_pwrite() won't involve one any more.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Always set writeback mode in blk_new_open()
Kevin Wolf [Tue, 15 Mar 2016 13:34:37 +0000 (14:34 +0100)] 
block: Always set writeback mode in blk_new_open()

All callers of blk_new_open() either don't rely on the WCE bit set after
blk_new_open() because they explicitly set it anyway, or they pass
BDRV_O_CACHE_WB unconditionally.

This patch changes blk_new_open() so that it always enables writeback
mode and asserts that BDRV_O_CACHE_WB is clear. For those callers that
used to pass BDRV_O_CACHE_WB unconditionally, the flag is removed now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: blockdev_init(): Call blk_set_enable_write_cache() explicitly
Kevin Wolf [Tue, 15 Mar 2016 14:39:42 +0000 (15:39 +0100)] 
block: blockdev_init(): Call blk_set_enable_write_cache() explicitly

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoxen_disk: Call blk_set_enable_write_cache() explicitly
Kevin Wolf [Tue, 15 Mar 2016 12:38:43 +0000 (13:38 +0100)] 
xen_disk: Call blk_set_enable_write_cache() explicitly

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-img: Call blk_set_enable_write_cache() explicitly
Kevin Wolf [Tue, 15 Mar 2016 12:01:04 +0000 (13:01 +0100)] 
qemu-img: Call blk_set_enable_write_cache() explicitly

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-img: Expand all BDRV_O_FLAGS uses
Kevin Wolf [Tue, 15 Mar 2016 12:03:11 +0000 (13:03 +0100)] 
qemu-img: Expand all BDRV_O_FLAGS uses

It always only set the BDRV_O_CACHE_WB flag, which is going to go away.
In order to make the next changes more local for better reviewability
this patches expands the macro.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-io: Call blk_set_enable_write_cache() explicitly
Kevin Wolf [Tue, 15 Mar 2016 11:52:30 +0000 (12:52 +0100)] 
qemu-io: Call blk_set_enable_write_cache() explicitly

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-nbd: Call blk_set_enable_write_cache() explicitly
Kevin Wolf [Mon, 14 Mar 2016 10:43:28 +0000 (11:43 +0100)] 
qemu-nbd: Call blk_set_enable_write_cache() explicitly

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Add bdrv_parse_cache_mode()
Kevin Wolf [Mon, 14 Mar 2016 10:40:23 +0000 (11:40 +0100)] 
block: Add bdrv_parse_cache_mode()

It's like bdrv_parse_cache_flags(), except that writethrough mode isn't
included in the flags, but returned as a separate bool.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoreplay: introduce block devices record/replay
Pavel Dovgalyuk [Mon, 14 Mar 2016 07:45:10 +0000 (10:45 +0300)] 
replay: introduce block devices record/replay

This patch introduces block driver that implement recording
and replaying of block devices' operations.
All block completion operations are added to the queue.
Queue is flushed at checkpoints and information about processed requests
is recorded to the log. In replay phase the queue is matched with
events read from the log. Therefore block devices requests are processed
deterministically.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
[ kwolf: Rebased onto modified and already applied part of the series ]
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoreplay: fix error message
Pavel Dovgalyuk [Mon, 14 Mar 2016 07:45:04 +0000 (10:45 +0300)] 
replay: fix error message

This patch fixes error message in saving loop of the asynchronous events queue.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
[ kwolf: Fixed format string to use PRId64 instead of %d ]
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoreplay: bh scheduling fix
Pavel Dovgalyuk [Mon, 14 Mar 2016 07:44:59 +0000 (10:44 +0300)] 
replay: bh scheduling fix

This patch fixes scheduling of bottom halves when record/replay is enabled.
Now BH are not added to replay queue when asynchronous events are disabled.
This may happen in startup and loadvm/savevm phases of execution.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: add flush callback
Pavel Dovgalyuk [Mon, 14 Mar 2016 07:44:53 +0000 (10:44 +0300)] 
block: add flush callback

This patch adds callback for flush request. This callback is responsible
for flushing whole block devices stack. bdrv_flush function does not
proceed to underlying devices. It should be performed by this callback
function, if needed.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: an interoperability test for luks vs dm-crypt/cryptsetup
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:52 +0000 (14:11 +0000)] 
block: an interoperability test for luks vs dm-crypt/cryptsetup

It is important that the QEMU luks implementation retains 100%
compatibility with the reference implementation provided by
the combination of the linux kernel dm-crypt module and cryptsetup
userspace tools.

There is a matrix of tests to be performed with different sets
of encryption settings. For each matrix entry, two tests will
be performed. One will create a LUKS image with the cryptsetup
tool and then do I/O with both cryptsetup & qemu-io. The other
will create the image with qemu-img and then again do I/O with
both cryptsetup and qemu-io.

The new I/O test 149 performs interoperability testing between
QEMU and the reference implementation. Such testing inherantly
requires elevated privileges, so to this this the user must have
configured passwordless sudo access. The test will automatically
skip if sudo is not available.

The test has to be run explicitly thus:

    cd tests/qemu-iotests
    ./check -luks 149

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: move encryption deprecation warning into qcow code
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:48 +0000 (14:11 +0000)] 
block: move encryption deprecation warning into qcow code

For a couple of releases we have been warning

  Encrypted images are deprecated
  Support for them will be removed in a future release.
  You can use 'qemu-img convert' to convert your image to an unencrypted one.

This warning was issued by system emulators, qemu-img, qemu-nbd
and qemu-io. Such a broad warning was issued because the original
intention was to rip out all the code for dealing with encryption
inside the QEMU block layer APIs.

The new block encryption framework used for the LUKS driver does
not rely on the unloved block layer API for encryption keys,
instead using the QOM 'secret' object type. It is thus no longer
appropriate to warn about encryption unconditionally.

When the qcow/qcow2 drivers are converted to use the new encryption
framework too, it will be practical to keep AES-CBC support present
for use in qemu-img, qemu-io & qemu-nbd to allow for interoperability
with older QEMU versions and liberation of data from existing encrypted
qcow2 files.

This change moves the warning out of the generic block code and
into the qcow/qcow2 drivers. Further, the warning is set to only
appear when running the system emulators, since qemu-img, qemu-io,
qemu-nbd are expected to support qcow2 encryption long term now that
the maint burden has been eliminated.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: add generic full disk encryption driver
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:47 +0000 (14:11 +0000)] 
block: add generic full disk encryption driver

Add a block driver that is capable of supporting any full disk
encryption format. This utilizes the previously added block
encryption code, and at this time supports the LUKS format.

The driver code is capable of supporting any format supported
by the QCryptoBlock module, so it registers one block driver
for each format. This patch only registers the "luks" driver
since the "qcow" driver is there only for back-compatibility
with existing qcow built-in encryption.

New LUKS compatible volumes can be formatted using qemu-img
with defaults for all settings.

$ qemu-img create --object secret,data=123456,id=sec0 \
      -f luks -o key-secret=sec0 demo.luks 10G

Alternatively the cryptographic settings can be explicitly
set

$ qemu-img create --object secret,data=123456,id=sec0 \
      -f luks -o key-secret=sec0,cipher-alg=aes-256,\
                 cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha256 \
      demo.luks 10G

And query its size

$ qemu-img info demo.img
image: demo.img
file format: luks
virtual size: 10G (10737418240 bytes)
disk size: 132K
encrypted: yes

Note that it was not necessary to provide the password
when querying info for the volume. The password is only
required when performing I/O on the volume

All volumes created by this new 'luks' driver should be
capable of being opened by the kernel dm-crypt driver.

The only algorithms listed in the LUKS spec that are
not currently supported by this impl are sha512 and
ripemd160 hashes and cast6 cipher.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
[ kwolf - Added #include to resolve conflict with da34e65c ]
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agotests: add output filter to python I/O tests helper
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:46 +0000 (14:11 +0000)] 
tests: add output filter to python I/O tests helper

Add a 'log' method to iotests.py which prints messages to
stdout, with optional filtering of data. Port over some
standard filters already present in the shell common.filter
code to be usable in python too.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agotests: refactor python I/O tests helper main method
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:45 +0000 (14:11 +0000)] 
tests: refactor python I/O tests helper main method

The iotests.py helper provides a main() method for running
tests via the python unit test framework. Not all tests
will want to use this, so refactor it to split the testing
of compatible formats and platforms into separate helper
methods

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agotests: redirect stderr to stdout for iotests
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:44 +0000 (14:11 +0000)] 
tests: redirect stderr to stdout for iotests

The python I/O tests helper for running qemu-img/qemu-io
setup stdout to be captured to a pipe, but left stderr
untouched. As a result, if something failed in qemu-img/
qemu-io, data written to stderr would get output directly
and not line up with data on the test stdout due to
buffering.  If we explicitly redirect stderr to the same
pipe as stdout, things are much clearer when they go
wrong.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-img/qemu-io: don't prompt for passwords if not required
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:43 +0000 (14:11 +0000)] 
qemu-img/qemu-io: don't prompt for passwords if not required

The qemu-img/qemu-io tools prompt for disk encryption passwords
regardless of whether any are actually required. Adding a check
on bdrv_key_required() avoids this prompt for disk formats which
have been converted to the QCryptoSecret APIs.

This is just a temporary hack to ensure the block I/O tests
continue to work after each patch, since the last patch will
completely delete all the password prompting code.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: add flag to indicate that no I/O will be performed
Daniel P. Berrange [Mon, 21 Mar 2016 14:11:42 +0000 (14:11 +0000)] 
block: add flag to indicate that no I/O will be performed

When opening an image it is useful to know whether the caller
intends to perform I/O on the image or not. In the case of
encrypted images this will allow the block driver to avoid
having to prompt for decryption keys when we merely want to
query header metadata about the image. eg qemu-img info

This flag is enforced at the top level only, since even if
we don't want todo I/O on the 'qcow2' file payload, the
underlying 'file' driver will still need todo I/O to read
the qcow2 header, for example.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/qapi: Pass bdrv_query_blk_stats() s->stats
Max Reitz [Wed, 2 Mar 2016 17:31:09 +0000 (18:31 +0100)] 
block/qapi: Pass bdrv_query_blk_stats() s->stats

bdrv_query_blk_stats() does not need access to all of BlockStats,
BlockDeviceStats is enough and is what this function is actually
supposed to fill.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/qapi: Set s->device in bdrv_query_stats()
Max Reitz [Wed, 2 Mar 2016 17:31:08 +0000 (18:31 +0100)] 
block/qapi: Set s->device in bdrv_query_stats()

This is the only instance of bdrv_query_blk_stats() accessing anything
in the BlockStats structure other than s->stats, so let us move it to
its caller (where it makes just as much sense) allowing us to make
bdrv_query_blk_stats() take a pointer to the BlockDeviceStats instead of
BlockStats.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/qapi: fix unbounded stack for dump_qdict
Peter Xu [Wed, 9 Mar 2016 05:56:37 +0000 (13:56 +0800)] 
block/qapi: fix unbounded stack for dump_qdict

Using heap instead of stack for better safety.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/qapi: make two printf() formats literal
Peter Xu [Wed, 9 Mar 2016 05:56:36 +0000 (13:56 +0800)] 
block/qapi: make two printf() formats literal

Fix two places to use literal printf format when possible.

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Remove blk_set_bs()
Kevin Wolf [Tue, 22 Mar 2016 12:54:08 +0000 (13:54 +0100)] 
block: Remove blk_set_bs()

The function is unused since commit f21d96d0 ('block: Use BdrvChild in
BlockBackend').

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoblock/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host
Programmingkid [Mon, 21 Mar 2016 15:41:28 +0000 (11:41 -0400)] 
block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host

Mac OS X can be picky when it comes to allowing the user
to use physical devices in QEMU. Most mounted volumes
appear to be off limits to QEMU. If an issue is detected,
a message is displayed showing the user how to unmount a
volume. Now QEMU uses both CD and DVD media.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Reject writethrough mode except at the root
Kevin Wolf [Mon, 14 Mar 2016 14:46:03 +0000 (15:46 +0100)] 
block: Reject writethrough mode except at the root

Writethrough mode is going to become a BlockBackend feature rather than
a BDS one, so forbid it in places where we won't be able to support it
when the code finally matches the envisioned design.

We only allowed setting the cache mode of non-root nodes after the 2.5
release, so we're still free to make this change.

The target of block jobs is now always opened in a writeback mode
because it doesn't have a BlockBackend attached. This makes more sense
anyway because block jobs know when to flush. If the graph is modified
on job completion, the original cache mode moves to the new root, so
for the guest device writethough always stays enabled if it was
configured this way.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoblock: Make backing files always writeback
Kevin Wolf [Fri, 4 Mar 2016 13:52:32 +0000 (14:52 +0100)] 
block: Make backing files always writeback

First of all, we're generally not writing to backing files, but when we
do, it's in the context of block jobs which know very well when to flush
the image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoblock: Remove cache.writeback from blockdev-add
Kevin Wolf [Mon, 14 Mar 2016 12:16:51 +0000 (13:16 +0100)] 
block: Remove cache.writeback from blockdev-add

The WCE bit is a frontend property and should not be part of the backend
configuration. This is especially important because the same BDS can be
used by different users with different WCE requirements.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Remove dirty bitmaps from bdrv_move_feature_fields()
Kevin Wolf [Mon, 29 Feb 2016 12:56:21 +0000 (13:56 +0100)] 
block: Remove dirty bitmaps from bdrv_move_feature_fields()

This patch changes dirty bitmaps from following a BlockBackend in graph
changes to sticking with the node they were created at. For the full
discussion, read the following mailing list thread:

  [Qemu-block] block: Dirty bitmaps and COR in bdrv_move_feature_fields()
  https://lists.nongnu.org/archive/html/qemu-block/2016-02/msg00745.html

In summary, the justification for this change is:

* When moving the dirty bitmap to the top of the tree was introduced in
  bdrv_append() in commit a9fc4408, it didn't actually have any effect
  because there could never be a bitmap in use when bdrv_append() was
  called (op blockers would prevent this). This is still true today for
  all internal uses of dirty bitmaps.

* Support for user-defined dirty bitmaps was introduced in 2.4, but we
  discouraged users from using it because we didn't consider it ready
  yet.

  Moreover, in 2.5, the bdrv_swap() removal introduced a bug that left
  dangling pointers if a dirty bitmap was present (the anchors of the
  dirty bitmap were swapped, but the back link in the first element
  wasn't updated), so it didn't even work correctly.

* block-dirty-bitmap-add takes an arbitrary node name, even if no
  BlockBackend is attached. This suggests that it is a node level
  operation and not a BlockBackend one. Consequently, there is no reason
  for dirty bitmaps to stay with a BlockBackend that was attached to the
  node they were created for.

* It was suggested that block-dirty-bitmap-add could track the node if a
  node name was specified, and track the BlockBackend if the device name
  was specified. This would however be inconsistent with other QMP
  commands. Commands that accept both device and node names currently
  interpret the device name just as an alias for the current root node
  of that BlockBackend.

* Dirty bitmaps have a name that is only unique amongst the bitmaps in a
  specific node. Moving bitmaps could lead to name clashes. Automatic
  renaming would involve too much magic.

* Persistent bitmaps are stored in a specific node. Moving them around
  automatically might be at least surprising, but it would probably also
  become a real problem because that would have to happen atomically
  without the management tool knowing of the operation.

At the end of the day it seems to be very clear that it was a mistake to
include dirty bitmaps in bdrv_move_feature_fields(). The functionality
of moving bitmaps and/or attaching them to a BlockBackend instead will
probably be needed, but it should be done with a new explicit QMP
command or option.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoblock: Remove copy-on-read from bdrv_move_feature_fields()
Kevin Wolf [Mon, 29 Feb 2016 12:12:26 +0000 (13:12 +0100)] 
block: Remove copy-on-read from bdrv_move_feature_fields()

Ever since we first introduced bdrv_append() in commit 8802d1fd ('qapi:
Introduce blockdev-group-snapshot-sync command'), the copy-on-read flag
was moved to the new top layer when taking a snapshot. The only problem
is that it doesn't make a whole lot of sense.

The use case for manually enabled CoR is to avoid reading data twice
from a slow remote image, so we want to save it to a local overlay, say
an ISO image accessed via HTTP to a local qcow2 overlay. When taking a
snapshot, we end up with a backing chain like this:

    http <- local.qcow2 <- snap_overlay.qcow2

There is no point in doing CoR from local.qcow2 into snap_overlay.qcow2,
we just want to keep copying data from the remote source into
local.qcow2.

The other use case of CoR is in the context of streaming, which isn't
very interesting for bdrv_move_feature_fields() because op blockers
prevent this combination.

This patch makes the copy-on-read flag stay on the image for which it
was originally set and prevents it from being propagated to the new
overlay. It is no longer intended to move CoR to the BlockBackend level.
In order for this to make sense, we also need to keep the respective
image read-write.

As a side effect of these changes, creating a live snapshot image (as
opposed to using an existing externally created one) on top of a COR
block device works now. It used to fail because it tried to open its
backing file both read-only and with COR.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
8 years agoblock: Remove bdrv_make_anon()
Kevin Wolf [Fri, 18 Mar 2016 09:46:57 +0000 (10:46 +0100)] 
block: Remove bdrv_make_anon()

The call in hmp_drive_del() is dead code because blk_remove_bs() is
called a few lines above. The only other remaining user is
bdrv_delete(), which only abuses bdrv_make_anon() to remove it from the
named nodes list. This path inlines the list entry removal into
bdrv_delete() and removes bdrv_make_anon().

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agotarget-mips: add MAAR, MAARI register
Yongbok Kim [Thu, 24 Mar 2016 15:49:58 +0000 (15:49 +0000)] 
target-mips: add MAAR, MAARI register

The MAAR register is a read/write register included in Release 5
of the architecture that defines the accessibility attributes of
physical address regions. In particular, MAAR defines whether an
instruction fetch or data load can speculatively access a memory
region within the physical address bounds specified by MAAR.

As QEMU doesn't do speculative access, hence this patch only
provides ability to access the registers.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agotarget-mips: use CP0_CHECK for gen_m{f|t}hc0
Yongbok Kim [Thu, 24 Mar 2016 15:49:59 +0000 (15:49 +0000)] 
target-mips: use CP0_CHECK for gen_m{f|t}hc0

Reuse CP0_CHECK macro for gen_m{f|t}hc0.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
Reviewed-by: Leon Alrae <leon.alrae@imgtec.com>
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips/cps: enable ITU for multithreading processors
Leon Alrae [Fri, 25 Mar 2016 13:49:37 +0000 (13:49 +0000)] 
hw/mips/cps: enable ITU for multithreading processors

Make ITU available in the system if CPU supports multithreading
and is part of CPS.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agotarget-mips: make ITC Configuration Tags accessible to the CPU
Leon Alrae [Fri, 25 Mar 2016 13:49:36 +0000 (13:49 +0000)] 
target-mips: make ITC Configuration Tags accessible to the CPU

Add CP0.ErrCtl register with WST, SPR and ITC bits. In 34K and interAptiv
processors these bits are used to enable CACHE instruction access to
different arrays. When WST=0, SPR=0 and ITC=1 the CACHE instruction will
access ITC tag values.

Generally we do not model caches and we have been treating the CACHE
instruction as NOP. But since CACHE can operate on ITC Tags new
MIPS_HFLAG_ITC_CACHE hflag is introduced to generate the helper only when
CACHE is in the ITC Access mode.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agotarget-mips: check CP0 enabled for CACHE instruction also in R6
Leon Alrae [Fri, 25 Mar 2016 13:49:35 +0000 (13:49 +0000)] 
target-mips: check CP0 enabled for CACHE instruction also in R6

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement ITC Storage - Bypass View
Leon Alrae [Fri, 25 Mar 2016 13:49:34 +0000 (13:49 +0000)] 
hw/mips: implement ITC Storage - Bypass View

Bypass View does not cause issuing thread to block and does not affect
any of the cells state bit.

Read from a FIFO cell returns the value of the oldest entry.
Store to a FIFO cell changes the value of the newest entry.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement ITC Storage - P/V Sync and Try Views
Leon Alrae [Fri, 25 Mar 2016 13:49:33 +0000 (13:49 +0000)] 
hw/mips: implement ITC Storage - P/V Sync and Try Views

P/V Synchronized and Try Views can be used to access Semaphore cells.
Load returns current value and post-decrements the value in the cell
(until it reaches zero). Stores increment the value (until it saturates
at 0xFFFF).

P/V Synchronized View causes the issuing thread to block on read if value
is 0. P/V Try View does not block the thread, it returns 0 in this case.

Cell's Empty and Full bits are not modified.

Trap bit (i.e. Gating Storage exceptions) not implemented.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement ITC Storage - Empty/Full Sync and Try Views
Leon Alrae [Fri, 25 Mar 2016 13:49:32 +0000 (13:49 +0000)] 
hw/mips: implement ITC Storage - Empty/Full Sync and Try Views

Empty/Full Synchronized and Try views can be used to access FIFO cells.
Store to the FIFO cell pushes the value into the queue, load pops the oldest
element from the queue. Cell's Full and Empty bits are automatically updated
to reflect new state of the cell.

Empty/Full Synchronized View causes the issuing thread to block when FIFO is
empty while thread is performing a read, or FIFO is full while thread is
performing a write.

Empty/Full Try View never blocks the thread. If cell is full then write is
ignored, if cell is empty then load returns 0.

Trap bit (i.e. Gating Storage exceptions) not implemented.
Store Conditional support for E/F Try View (i.e. indicate failure if FIFO
is full) not implemented.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement ITC Storage - Control View
Leon Alrae [Fri, 25 Mar 2016 13:49:31 +0000 (13:49 +0000)] 
hw/mips: implement ITC Storage - Control View

Control view is used to access the ITC Storage Cell Tags. It never causes
the issuing thread to block.

Guest can empty the FIFO cell by setting Empty bit to 1.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement ITC Configuration Tags and Storage Cells
Leon Alrae [Fri, 25 Mar 2016 13:49:30 +0000 (13:49 +0000)] 
hw/mips: implement ITC Configuration Tags and Storage Cells

Implement ITC as a single object consisting of two memory regions:

1) tag_io: ITC Configuration Tags (i.e. ITCAddressMap{0,1} registers) which
are accessible by the CPU via CACHE instruction. Also adding
MemoryRegion *itc_tag to the CPUMIPSState so that CACHE instruction will
dispatch reads/writes directly.

2) storage_io: memory-mapped ITC Storage whose address space is configurable
(i.e. enabled/remapped/resized) by writing to ITCAddressMap{0,1} registers.

ITC Storage contains FIFO and Semaphore cells. Read-only FIFO bit in the
ITC cell tag indicates the type of the cell. If the ITC Storage contains
both types of cells then FIFOs are located before Semaphores.

Since issuing thread can get blocked on the access to a cell (in E/F
Synchronized and P/V Synchronized Views) each cell has a bitmap to track
which threads are currently blocked.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agotarget-mips: enable CM GCR in MIPS64R6-generic CPU
Leon Alrae [Tue, 15 Mar 2016 09:59:36 +0000 (09:59 +0000)] 
target-mips: enable CM GCR in MIPS64R6-generic CPU

Indicate that in the MIPS64R6-generic CPU the memory-mapped
Global Configuration Register Space is implemented.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips_malta: add CPS to Malta board
Leon Alrae [Tue, 15 Mar 2016 09:59:35 +0000 (09:59 +0000)] 
hw/mips_malta: add CPS to Malta board

If the user specifies smp > 1 and the CPU with CM GCR support, then
create Coherent Processing System (which takes care of instantiating CPUs)
rather than CPUs directly and connect i8259 and cbus to the pins exposed by
CPS. However, there is no GIC yet, thus CPS exposes CPU's IRQ pins so use
the same pin numbers as before.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips_malta: move CPU creation to a separate function
Leon Alrae [Tue, 15 Mar 2016 09:59:34 +0000 (09:59 +0000)] 
hw/mips_malta: move CPU creation to a separate function

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips_malta: remove redundant irq and clock init
Leon Alrae [Tue, 15 Mar 2016 09:59:33 +0000 (09:59 +0000)] 
hw/mips_malta: remove redundant irq and clock init

Global smp_cpus is never zero (even if user provides -smp 0), thus clocks
and irqs are always initialized for each created CPU in the loop at the
beginning of mips_malta_init.

These two lines cause a leak of already allocated timer and irqs for the
first CPU - remove them.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips_malta: remove CPUMIPSState from the write_bootloader()
Leon Alrae [Tue, 15 Mar 2016 09:59:32 +0000 (09:59 +0000)] 
hw/mips_malta: remove CPUMIPSState from the write_bootloader()

Remove CPUMIPSState from the write_bootloader() argument list as it
is not used in the function.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips/cps: create CPC block inside CPS
Leon Alrae [Tue, 15 Mar 2016 09:59:31 +0000 (09:59 +0000)] 
hw/mips/cps: create CPC block inside CPS

Create Cluster Power Controller and add a link to the CPC MemoryRegion
in GCR. Guest can enable / map CPC to any physical address by writing to
the memory-mapped GCR_CPC_BASE register.

Set vp-start-reset property to 1 to allow only first VP to run from reset.
Others are brought up by the guest via CPC memory-mapped registers.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: add initial Cluster Power Controller support
Leon Alrae [Tue, 15 Mar 2016 09:59:30 +0000 (09:59 +0000)] 
hw/mips: add initial Cluster Power Controller support

Cluster Power Controller (CPC) is responsible for power management in
multiprocessing system. It provides registers to control the power and the
clock frequency of the individual elements in the system.

This patch implements only three registers that are used to control the
power state of each VP on a single core:
* VP Run is a write-only register used to set each VP to the run state
* VP Stop is a write-only register used to set each VP to the suspend state
* VP Running is a read-only register indicating the run state of each VP

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips/cps: create GCR block inside CPS
Leon Alrae [Tue, 15 Mar 2016 09:59:29 +0000 (09:59 +0000)] 
hw/mips/cps: create GCR block inside CPS

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: add initial Global Config Register support
Yongbok Kim [Tue, 15 Mar 2016 09:59:28 +0000 (09:59 +0000)] 
hw/mips: add initial Global Config Register support

Add initial GCR support to indicate number of VPs present in the system,
L2 bypass mode and revision number.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
[leon.alrae@imgtec.com:
 * removed GIC part,
 * changed commit message,
 * replaced %lx format spec. with PRIx64,
 * renamed mips_gcr.{c,h} to mips_cmgcr.{c,h},
 * replaced CONFIG_MIPS_GIC with CONFIG_MIPS_CPS]
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agotarget-mips: add CMGCRBase register
Yongbok Kim [Tue, 15 Mar 2016 09:59:27 +0000 (09:59 +0000)] 
target-mips: add CMGCRBase register

Physical base address for the memory-mapped Coherency Manager Global
Configuration Register space.
The MIPS default location for the GCR_BASE address is 0x1FBF_8.
This register only exists if Config3 CMGCR is set to one.

Signed-off-by: Yongbok Kim <yongbok.kim@imgtec.com>
[leon.alrae@imgtec.com: move CMGCR enabling to a separate patch]
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agohw/mips: implement generic MIPS Coherent Processing System container
Leon Alrae [Tue, 15 Mar 2016 09:59:26 +0000 (09:59 +0000)] 
hw/mips: implement generic MIPS Coherent Processing System container

Implement generic MIPS Coherent Processing System (CPS) which in this
commit just creates VPs, but it will serve as a container also for
other components like Global Configuration Registers and Cluster Power
Controller.

Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
8 years agoRevert "e1000: fix hang of win2k12 shutdown with flood ping"
Sameeh Jubran [Thu, 17 Mar 2016 07:37:58 +0000 (09:37 +0200)] 
Revert "e1000: fix hang of win2k12 shutdown with flood ping"

This reverts commit 9596ef7c7b8528bedb240792ea1fb598543ad3c4.

This workaround in order to fix endless interrupts is no
longer needed because it was superseded by the previous patch
(e1000: Fixing interrupt pace).

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agoe1000: Fixing interrupts pace.
Sameeh Jubran [Thu, 17 Mar 2016 07:37:57 +0000 (09:37 +0200)] 
e1000: Fixing interrupts pace.

This patch introduces an upper bound for number of interrupts
per second. Without this bound an interrupt storm can occur as
it has been observed on Windows 10 when disabling the device.

According to the SPEC - Intel PCI/PCI-X Family of Gigabit
Ethernet Controllers Software Developer's Manual, section
13.4.18 - the Ethernet controller guarantees a maximum
observable interrupt rate of 7813 interrupts/sec. If there is
no upper bound this could lead to an interrupt storm by e1000
(when mit_delay < 500) causing interrupts to fire at a very high
pace.
Thus if mit_delay < 500 then the delay should be set to the
minimum delay possible which is 500. This can be calculated
easily as follows:

Interval = 10^9 / (7813 * 256) = 500.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agotests/test-filter-redirector: Add unit test for filter-redirector
Zhang Chen [Thu, 17 Mar 2016 08:16:27 +0000 (16:16 +0800)] 
tests/test-filter-redirector: Add unit test for filter-redirector

In this unit test,we will test the filter redirector function.

Case 1, tx traffic flow:

qemu side              | test side
                       |
+---------+            |  +-------+
| backend <---------------+ sock0 |
+----+----+            |  +-------+
     |                 |
+----v----+  +-------+ |
|  rd0    +->+chardev| |
+---------+  +---+---+ |
                 |     |
+---------+      |     |
|  rd1    <------+     |
+----+----+            |
     |                 |
+----v----+            |  +-------+
|  rd2    +--------------->sock1  |
+---------+            |  +-------+
                       +

a. we(sock0) inject packet to qemu socket backend
b. backend pass packet to filter redirector0(rd0)
c. rd0 redirect packet to out_dev(chardev) which is connected with
filter redirector1's(rd1) in_dev
d. rd1 read this packet from in_dev, and pass to next filter redirector2(rd2)
e. rd2 redirect packet to rd2's out_dev which is connected with an opened socketed(sock1)
f. we read packet from sock1 and compare to what we inject

Start qemu with:

"-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=tx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=tx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=tx,outdev=redirector1 "

--------------------------------------
Case 2, rx traffic flow
qemu side              | test side
                       |
+---------+            |  +-------+
| backend +---------------> sock1 |
+----^----+            |  +-------+
     |                 |
+----+----+  +-------+ |
|  rd0    +<-+chardev| |
+---------+  +---+---+ |
                 ^     |
+---------+      |     |
|  rd1    +------+     |
+----^----+            |
     |                 |
+----+----+            |  +-------+
|  rd2    <---------------+sock0  |
+---------+            |  +-------+

a. we(sock0) insert packet to filter redirector2(rd2)
b. rd2 pass packet to filter redirector1(rd1)
c. rd1 redirect packet to out_dev(chardev) which is connected with
   filter redirector0's(rd0) in_dev
d. rd0 read this packet from in_dev, and pass ti to qemu backend which is
   connected with an opened socketed(sock1)
e. we read packet from sock1 and compare to what we inject

Start qemu with:

"-netdev socket,id=qtest-bn0,fd=%d "
"-device rtl8139,netdev=qtest-bn0,id=qtest-e0 "
"-chardev socket,id=redirector0,path=%s,server,nowait "
"-chardev socket,id=redirector1,path=%s,server,nowait "
"-chardev socket,id=redirector2,path=%s,nowait "
"-object filter-redirector,id=qtest-f0,netdev=qtest-bn0,"
"queue=rx,outdev=redirector0 "
"-object filter-redirector,id=qtest-f1,netdev=qtest-bn0,"
"queue=rx,indev=redirector2 "
"-object filter-redirector,id=qtest-f2,netdev=qtest-bn0,"
"queue=rx,outdev=redirector1 "

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agonet/filter-mirror: implement filter-redirector
Zhang Chen [Thu, 17 Mar 2016 08:16:26 +0000 (16:16 +0800)] 
net/filter-mirror: implement filter-redirector

Filter-redirector is a netfilter plugin.
It gives qemu the ability to redirect net packet.
redirector can redirect filter's net packet to outdev.
and redirect indev's packet to filter.

                      filter
                        +
            redirector  |
               +--------------+
               |        |     |
  indev +-----------+   +---------->  outdev
               |    |         |
               +--------------+
                    |
                    v
                  filter

usage:

-netdev user,id=hn0
-chardev socket,id=s0,host=ip_primary,port=X,server,nowait
-chardev socket,id=s1,host=ip_primary,port=Y,server,nowait
-filter-redirector,id=r0,netdev=hn0,queue=tx/rx/all,indev=s0,outdev=s1

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agonet/filter-mirror: Change filter_mirror_send interface
Zhang Chen [Tue, 15 Mar 2016 10:02:51 +0000 (18:02 +0800)] 
net/filter-mirror: Change filter_mirror_send interface

Change filter_mirror_send interface to make it easier
to used by other filter

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agotests/test-filter-mirror:add filter-mirror unit test
Zhang Chen [Tue, 15 Mar 2016 07:41:34 +0000 (15:41 +0800)] 
tests/test-filter-mirror:add filter-mirror unit test

In this unit test we will test the mirror function.

start qemu with:
      -netdev socket,id=qtest-bn0,fd=sockfd
      -device e1000,netdev=qtest-bn0,id=qtest-e0
      -chardev socket,id=mirror0,path=/tmp/filter-mirror-test.sock,server,nowait
      -object filter-mirror,id=qtest-f0,netdev=qtest-bn0,queue=tx,outdev=mirror0

We inject packet to netdev socket id = qtest-bn0,
filter-mirror will copy and mirror the packet to mirror0.
we read packet from mirror0 and then compare to what we injected.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
8 years agonet/filter-mirror:Add filter-mirror
Zhang Chen [Tue, 15 Mar 2016 07:41:33 +0000 (15:41 +0800)] 
net/filter-mirror:Add filter-mirror

Filter-mirror is a netfilter plugin.
It gives qemu the ability to mirror
packets to a chardev.

usage:

-netdev tap,id=hn0
-chardev socket,id=mirror0,host=ip_primary,port=X,server,nowait
-filter-mirror,id=m0,netdev=hn0,queue=tx/rx/all,outdev=mirror0

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Reviewed-by: Yang Hongyang <hongyang.yang@easystack.cn>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>