]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
8 years agonvdimm acpi: build ACPI nvdimm devices
Xiao Guangrong [Wed, 2 Dec 2015 07:20:59 +0000 (15:20 +0800)]
nvdimm acpi: build ACPI nvdimm devices

NVDIMM devices is defined in ACPI 6.0 9.20 NVDIMM Devices

There is a root device under \_SB and specified NVDIMM devices are under the
root device. Each NVDIMM device has _ADR which returns its handle used to
associate MEMDEV structure in NFIT

Currently, we do not support any function on _DSM, that means, NVDIMM
label data has not been supported yet

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm acpi: build ACPI NFIT table
Xiao Guangrong [Wed, 2 Dec 2015 07:20:58 +0000 (15:20 +0800)]
nvdimm acpi: build ACPI NFIT table

NFIT is defined in ACPI 6.0: 5.2.25 NVDIMM Firmware Interface Table (NFIT)

Currently, we only support PMEM mode. Each device has 3 structures:
- SPA structure, defines the PMEM region info

- MEM DEV structure, it has the @handle which is used to associate specified
  ACPI NVDIMM  device we will introduce in later patch.
  Also we can happily ignored the memory device's interleave, the real
  nvdimm hardware access is hidden behind host

- DCR structure, it defines vendor ID used to associate specified vendor
  nvdimm driver. Since we only implement PMEM mode this time, Command
  window and Data window are not needed

The NVDIMM functionality is controlled by the parameter, 'nvdimm', which
is introduced for the machine, there is a example to enable it:
-machine pc,nvdimm -m 8G,maxmem=100G,slots=100  -object \
memory-backend-file,id=mem1,share,mem-path=/tmp/nvdimm1,size=10G -device \
nvdimm,memdev=mem1,id=nv1

It is disabled on default

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoacpi: support specified oem table id for build_header
Xiao Guangrong [Wed, 2 Dec 2015 07:20:57 +0000 (15:20 +0800)]
acpi: support specified oem table id for build_header

Let build_header() support specified OEM table id so that we can build
multiple SSDT later

If the oem table id is not specified (aka, NULL), we use the default id
instead as the previous behavior

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agonvdimm: implement NVDIMM device abstract
Xiao Guangrong [Wed, 2 Dec 2015 07:20:56 +0000 (15:20 +0800)]
nvdimm: implement NVDIMM device abstract

Introduce "nvdimm" device which is based on pc-dimm device type

Currently, nothing is specific for nvdimm but hotplug is disabled

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agodocs/pci_expander_bridge: fix typo
Cao jin [Tue, 22 Dec 2015 12:00:43 +0000 (20:00 +0800)]
docs/pci_expander_bridge: fix typo

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agohw/compat.h: Change indentation of HW_COMPAT_* to 4 spaces
Eduardo Habkost [Mon, 30 Nov 2015 14:56:38 +0000 (12:56 -0200)]
hw/compat.h: Change indentation of HW_COMPAT_* to 4 spaces

Cosmetic change only.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Change indentation of PC_COMPAT_* to 4 spaces
Eduardo Habkost [Mon, 30 Nov 2015 14:56:37 +0000 (12:56 -0200)]
pc: Change indentation of PC_COMPAT_* to 4 spaces

Cosmetic change only.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Add pc-*-2.6 machine classes
Eduardo Habkost [Mon, 30 Nov 2015 14:56:36 +0000 (12:56 -0200)]
pc: Add pc-*-2.6 machine classes

Add pc-i440fx-2.6 and pc-q35-2.6 machine classes.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agopc: Remove redundant code from pc-*-2.3 machine classes
Eduardo Habkost [Mon, 30 Nov 2015 14:56:35 +0000 (12:56 -0200)]
pc: Remove redundant code from pc-*-2.3 machine classes

Remove the redundant 'alias = NULL' and 'is_default = 0' lines
from older machine-types. pc_*_2_4_machine_options() already
clear those fields, so they don't need to be cleared by
pc_*_2_3_machine_options().

Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
8 years agoq35: skip q35-acpi-dsdt.aml load if not needed
Gerd Hoffmann [Thu, 17 Dec 2015 10:40:49 +0000 (11:40 +0100)]
q35: skip q35-acpi-dsdt.aml load if not needed

Only old machine types which don't use the acpi builder (qemu 1.7 + older)
have to load that file for proper acpi support.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a force off function
Corey Minyard [Thu, 17 Dec 2015 18:50:19 +0000 (12:50 -0600)]
ipmi: Add a force off function

Allow the IPMI interface to request a forced power off.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add firmware registration to the ISA interface
Corey Minyard [Thu, 17 Dec 2015 18:50:13 +0000 (12:50 -0600)]
ipmi: Add firmware registration to the ISA interface

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a firmware configuration repository
Corey Minyard [Thu, 17 Dec 2015 18:50:12 +0000 (12:50 -0600)]
ipmi: Add a firmware configuration repository

Add a way for IPMI devices to register their firmware information
with the IPMI subsystem so that various firmware entities can pull
that information later for adding to firmware tables.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add migration capability to the IPMI devices.
Corey Minyard [Thu, 17 Dec 2015 18:50:11 +0000 (12:50 -0600)]
ipmi: Add migration capability to the IPMI devices.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add documentation
Corey Minyard [Thu, 17 Dec 2015 18:50:10 +0000 (12:50 -0600)]
ipmi: Add documentation

Add some basic documentation for the IPMI device.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add tests
Corey Minyard [Thu, 17 Dec 2015 18:50:09 +0000 (12:50 -0600)]
ipmi: Add tests

Test the KCS interface with a local BMC and a BT interface with an
external BMC.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a BT low-level interface
Corey Minyard [Thu, 17 Dec 2015 18:50:08 +0000 (12:50 -0600)]
ipmi: Add a BT low-level interface

This provides the simulation of the BT hardware interface for
IPMI.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add an ISA KCS low-level interface
Corey Minyard [Thu, 17 Dec 2015 18:50:07 +0000 (12:50 -0600)]
ipmi: Add an ISA KCS low-level interface

This provides the simulation of the KCS hardware interface.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add an external connection simulation interface
Corey Minyard [Thu, 17 Dec 2015 18:50:06 +0000 (12:50 -0600)]
ipmi: Add an external connection simulation interface

This adds an interface for IPMI that connects to a remote
BMC over a chardev (generally a TCP socket).  The OpenIPMI
lanserv simulator describes this interface, see that for
interface details.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoipmi: Add a local BMC simulation
Corey Minyard [Thu, 17 Dec 2015 18:50:05 +0000 (12:50 -0600)]
ipmi: Add a local BMC simulation

This provides a minimal local BMC, basically enough to comply with the
spec and provide a complete watchdog timer (including a sensor, SDR,
and event).

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoAdd a base IPMI interface
Corey Minyard [Thu, 17 Dec 2015 18:50:04 +0000 (12:50 -0600)]
Add a base IPMI interface

Add the basic IPMI types and infrastructure to QEMU.  Low-level
interfaces and simulation interfaces will register with this; it's
kind of the go-between to tie them together.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Group and document related PCMachineState/PCMachineclass fields
Eduardo Habkost [Fri, 11 Dec 2015 18:42:21 +0000 (16:42 -0200)]
pc: Group and document related PCMachineState/PCMachineclass fields

Group related PCMachineState and PCMachineClass fields into
sections, and move existing field descriptions to doc comments.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agoq35: Remove MCHPCIState.guest_info field
Eduardo Habkost [Fri, 11 Dec 2015 18:42:20 +0000 (16:42 -0200)]
q35: Remove MCHPCIState.guest_info field

The field is not used for anything.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agohw/i386: extend pxb query for all PC machines
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:28 +0000 (18:00 +0200)]
hw/i386: extend pxb query for all PC machines

Add bus property to PC machines and use it when looking
for primary PCI root bus (bus 0).

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
8 years agohw/pxb: introduce pxb-pcie expander for PCIe machines
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:27 +0000 (18:00 +0200)]
hw/pxb: introduce pxb-pcie expander for PCIe machines

The pxb-pcie is the counterpart of pxb for PCI express machines.
The new device re-uses the pxb code, but appears to the guests
as a different device. The pxb-pcie device does not have an internal
pci-pci bridge and exposes a PCIe root bus instead of a PCI one.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agohw/acpi: merge pxb adjacent memory/IO ranges
Marcel Apfelbaum [Thu, 26 Nov 2015 16:00:26 +0000 (18:00 +0200)]
hw/acpi: merge pxb adjacent memory/IO ranges

A generic PCI Bus Expander doesn't necessary have a built-in PCI bridge.
Int this case the ACPI will include IO/MEM ranges per device. Try to merge
adjacent resources to reduce the ACPI tables length.

Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:08 +0000 (20:58 -0200)]
pc: Move option_rom_has_mr/rom_file_has_mr globals to MachineClass

This way, these settings can be simply set on the corresponding
machine_options() function, instead of requiring code in
pc_compat_*() functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Remove enforce-aligned-dimm QOM property
Eduardo Habkost [Tue, 1 Dec 2015 22:58:07 +0000 (20:58 -0200)]
pc: Remove enforce-aligned-dimm QOM property

The property is read-only and not used for anything.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move enforce_aligned_dimm to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:06 +0000 (20:58 -0200)]
pc: Move enforce_aligned_dimm to PCMachineClass

enforce_aligned_dimm never changes after the machine is
initialized, so it can be simply set in PCMachineClass like all
the other compat fields.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agopc: Move acpi_data_size global to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:05 +0000 (20:58 -0200)]
pc: Move acpi_data_size global to PCMachineClass

This way we don't need code in pc_compat_*() functions to set the legacy
acpi_data_size value.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Move legacy_acpi_table_size global to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:04 +0000 (20:58 -0200)]
pc: Move legacy_acpi_table_size global to PCMachineClass

This way we can set legacy_acpi_table_size on the machine_options()
functions, instead of requirng code in pc_compat_*() functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agopc: Move compat boolean globals to PCMachineClass
Eduardo Habkost [Tue, 1 Dec 2015 22:58:03 +0000 (20:58 -0200)]
pc: Move compat boolean globals to PCMachineClass

This way the compat flags can be initialized in the machine_options()
function. This will help us to eventually eliminate the pc_compat_*()
functions.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
8 years agommap-alloc: tweak a comment on ppc64
Michael S. Tsirkin [Thu, 3 Dec 2015 08:35:31 +0000 (10:35 +0200)]
mmap-alloc: tweak a comment on ppc64

The comment I put in mmap-alloc to document the ppc64 rules
refers to the previous revision of the patch:
we don't look at memory alignment anymore, we check
the fs from which the fd is mapped, instead.

It's also not clear what does "in this case" refer
to, rearrange text to make it clearer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging
Peter Maydell [Tue, 22 Dec 2015 14:21:42 +0000 (14:21 +0000)]
Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging

# gpg: Signature made Tue 22 Dec 2015 08:52:55 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg:                 aka "Stefan Hajnoczi <stefanha@gmail.com>"

* remotes/stefanha/tags/block-pull-request:
  sdhci: add optional quirk property to disable card insertion/removal interrupts
  sdhci: don't raise a command index error for an unexpected response
  sd: sdhci: Delete over-zealous power check
  scripts/gdb: Fix a python exception in mtree.py
  parallels: add format spec
  block/mirror: replace IOV_MAX with blk_get_max_iov()
  block: replace IOV_MAX with BlockLimits.max_iov
  block-backend: add blk_get_max_iov()
  block: add BlockLimits.max_iov field
  virtio-blk: trivial code optimization

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agosdhci: add optional quirk property to disable card insertion/removal interrupts
Andrew Baumann [Mon, 21 Dec 2015 22:47:49 +0000 (14:47 -0800)]
sdhci: add optional quirk property to disable card insertion/removal interrupts

This is needed for a quirk of the Raspberry Pi (bcm2835/6) MMC
controller, where the card insert bit is documented as unimplemented
(always reads zero, doesn't generate interrupts) but is in fact
observed on hardware as set at power on, but is cleared (and remains
clear) on subsequent controller resets.

Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1450738069-18664-4-git-send-email-Andrew.Baumann@microsoft.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agosdhci: don't raise a command index error for an unexpected response
Andrew Baumann [Mon, 21 Dec 2015 22:47:48 +0000 (14:47 -0800)]
sdhci: don't raise a command index error for an unexpected response

This deletes a block of code that raised a command index error if a
command returned response data, but the guest did not set the
appropriate bits in the response register to handle such a response. I
cannot find any documentation that suggests the controller should
behave in this way, the error code doesn't make sense (command index
error is defined for the case where the index in a response does not
match that of the issued command), and in at least one case (CMD23
issued by UEFI on Raspberry Pi 2), actual hardware does not do this.

Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Message-id: 1450738069-18664-3-git-send-email-Andrew.Baumann@microsoft.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agosd: sdhci: Delete over-zealous power check
Peter Crosthwaite [Mon, 21 Dec 2015 22:47:47 +0000 (14:47 -0800)]
sd: sdhci: Delete over-zealous power check

This check was conditionalising SD card operation on the card being
powered by the SDHCI host controller. It is however possible
(particularly in embedded systems) for the power control of the SD card
to be managed outside of SDHCI. This can be as trivial as hard-wiring
the SD slot VCC to a constant power-rail.

This means the guest SDHCI can validly opt-out of the SDHCI power
control feature while still using the card. So delete this check to
allow operation of the card with SDHCI power control.

This is needed for at least Xilinx Zynq and Raspberry Pi, and
also makes Freescale i.MX25 work for me. The digilent Zybo board
has a public schematic which shows SD VCC hardwiring:

http://digilentinc.com/Data/Products/ZYBO/ZYBO_sch_VB.3.pdf
bottom of page 3.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Reviewed-by: Sai Pavan Boddu <saipava@xilinx.com>
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Message-id: 1450738069-18664-2-git-send-email-Andrew.Baumann@microsoft.com
[AB: Add Pi to list of devices fixed in commit message]
Signed-off-by: Andrew Baumann <Andrew.Baumann@microsoft.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoscripts/gdb: Fix a python exception in mtree.py
Yang Wei [Sat, 5 Dec 2015 11:52:20 +0000 (19:52 +0800)]
scripts/gdb: Fix a python exception in mtree.py

The following exception is threw:
Python Exception <class 'NameError'> name 'long' is not defined:
Error occurred in Python command: name 'long' is not defined

Python 2.4+, int()/long() have been unified, so replace long
with int.

Signed-off-by: Yang Wei <w90p710@gmail.com>
Message-id: 1449316340-4030-1-git-send-email-w90p710@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoparallels: add format spec
Vladimir Sementsov-Ogievskiy [Fri, 27 Nov 2015 12:20:06 +0000 (15:20 +0300)]
parallels: add format spec

This specifies Parallels image format as implemented in Parallels Cloud
Server 6.10

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Message-id: 1448626806-17591-1-git-send-email-den@openvz.org
CC: Eric Blake <eblake@redhat.com>
CC: John Snow <jsnow@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock/mirror: replace IOV_MAX with blk_get_max_iov()
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:47 +0000 (10:56 +0100)]
block/mirror: replace IOV_MAX with blk_get_max_iov()

Use blk_get_max_iov() instead of hardcoding IOV_MAX, which may not apply
to all BlockDrivers.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock: replace IOV_MAX with BlockLimits.max_iov
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:46 +0000 (10:56 +0100)]
block: replace IOV_MAX with BlockLimits.max_iov

Request merging must not result in a huge request that exceeds the
maximum number of iovec elements.  Use BlockLimits.max_iov instead of
hardcoding IOV_MAX.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock-backend: add blk_get_max_iov()
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:45 +0000 (10:56 +0100)]
block-backend: add blk_get_max_iov()

Add a function to query BlockLimits.max_iov.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoblock: add BlockLimits.max_iov field
Stefan Hajnoczi [Thu, 9 Jul 2015 09:56:44 +0000 (10:56 +0100)]
block: add BlockLimits.max_iov field

The maximum number of struct iovec elements depends on the
BlockDriverState.  The raw-posix and iSCSI protocols have a maximum of
IOV_MAX but others could have different values.

Cc: Peter Lieven <pl@kamp.de>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agovirtio-blk: trivial code optimization
Gonglei [Wed, 11 Nov 2015 01:59:26 +0000 (09:59 +0800)]
virtio-blk: trivial code optimization

1. avoid possible superflous checking
2. make code more robustness

["make code more robustness" refers to avoiding integer
underflows/overflows.
--Stefan]

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Message-id: 1447207166-12612-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging
Peter Maydell [Fri, 18 Dec 2015 18:47:17 +0000 (18:47 +0000)]
Merge remote-tracking branch 'remotes/ehabkost/tags/numa-pull-request' into staging

NUMA queue, 2015-12-18

# gpg: Signature made Fri 18 Dec 2015 17:53:48 GMT using RSA key ID 984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"

* remotes/ehabkost/tags/numa-pull-request:
  numa: Clean up query-memdev error handling

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agonuma: Clean up query-memdev error handling
Markus Armbruster [Mon, 23 Nov 2015 08:35:31 +0000 (09:35 +0100)]
numa: Clean up query-memdev error handling

qmp_query_memdev() has two error paths:

* When object_get_objects_root() returns null.  It never does, so
  simply drop the useless error handling.

* When query_memdev() fails.  It leaks err then.  But any failure
  there is actually a programming error.  Switch it to &error_abort,
  and drop the useless error handling.

Messed up in commit 76b5d85 "qmp: add query-memdev".

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015...
Peter Maydell [Fri, 18 Dec 2015 17:04:15 +0000 (17:04 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-qcrypto-secrets-base-2015-12-18-1' into staging

Merge QCryptoSecret object support

# gpg: Signature made Fri 18 Dec 2015 16:51:21 GMT 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-secrets-base-2015-12-18-1:
  crypto: add support for loading encrypted x509 keys
  crypto: add QCryptoSecret object class for password/key handling
  qga: convert to use error checked base64 decode
  qemu-char: convert to use error checked base64 decode
  util: add base64 decoding function

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Fri, 18 Dec 2015 16:34:44 +0000 (16:34 +0000)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

# gpg: Signature made Fri 18 Dec 2015 13:41:03 GMT using RSA key ID C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"

* remotes/kevin/tags/for-upstream: (48 commits)
  block/qapi: allow best-effort query
  qemu-img: abort when full_backing_filename not present
  block/qapi: explicitly warn if !has_full_backing_filename
  block/qapi: always report full_backing_filename
  block/qapi: do not redundantly print "actual path"
  qemu-iotests: s390x: fix test 068
  qemu-iotests: s390x: fix test 051
  qemu-iotests: refine common.config
  block: fix bdrv_ioctl called from coroutine
  block: use drained section around bdrv_snapshot_delete
  iotests: Update comments for bdrv_swap() in 094
  block: Remove prototype of bdrv_swap from header
  raw-posix: Make aio=native option binding
  qcow2: insert assert into qcow2_get_specific_info()
  iotests: Extend test 112 for qemu-img amend
  qcow2: Point to amend function in check
  qcow2: Invoke refcount order amendment function
  qcow2: Add function for refcount order amendment
  qcow2: Use intermediate helper CB for amend
  qcow2: Split upgrade/downgrade paths for amend
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agocrypto: add support for loading encrypted x509 keys
Daniel P. Berrange [Thu, 15 Oct 2015 15:14:42 +0000 (16:14 +0100)]
crypto: add support for loading encrypted x509 keys

Make use of the QCryptoSecret object to support loading of
encrypted x509 keys. The optional 'passwordid' parameter
to the tls-creds-x509 object type, provides the ID of a
secret object instance that holds the decryption password
for the PEM file.

 # printf "123456" > mypasswd.txt
 # $QEMU \
    -object secret,id=sec0,filename=mypasswd.txt \
    -object tls-creds-x509,passwordid=sec0,id=creds0,\
            dir=/home/berrange/.pki/qemu,endpoint=server \
    -vnc :1,tls-creds=creds0

This requires QEMU to be linked to GNUTLS >= 3.1.11. If
GNUTLS is too old an error will be reported if an attempt
is made to pass a decryption password.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agocrypto: add QCryptoSecret object class for password/key handling
Daniel P. Berrange [Wed, 14 Oct 2015 08:58:38 +0000 (09:58 +0100)]
crypto: add QCryptoSecret object class for password/key handling

Introduce a new QCryptoSecret object class which will be used
for providing passwords and keys to other objects which need
sensitive credentials.

The new object can provide secret values directly as properties,
or indirectly via a file. The latter includes support for file
descriptor passing syntax on UNIX platforms. Ordinarily passing
secret values directly as properties is insecure, since they
are visible in process listings, or in log files showing the
CLI args / QMP commands. It is possible to use AES-256-CBC to
encrypt the secret values though, in which case all that is
visible is the ciphertext.  For ad hoc developer testing though,
it is fine to provide the secrets directly without encryption
so this is not explicitly forbidden.

The anticipated scenario is that libvirtd will create a random
master key per QEMU instance (eg /var/run/libvirt/qemu/$VMNAME.key)
and will use that key to encrypt all passwords it provides to
QEMU via '-object secret,....'.  This avoids the need for libvirt
(or other mgmt apps) to worry about file descriptor passing.

It also makes life easier for people who are scripting the
management of QEMU, for whom FD passing is significantly more
complex.

Providing data inline (insecure, only for ad hoc dev testing)

  $QEMU -object secret,id=sec0,data=letmein

Providing data indirectly in raw format

  printf "letmein" > mypasswd.txt
  $QEMU -object secret,id=sec0,file=mypasswd.txt

Providing data indirectly in base64 format

  $QEMU -object secret,id=sec0,file=mykey.b64,format=base64

Providing data with encryption

  $QEMU -object secret,id=master0,file=mykey.b64,format=base64 \
        -object secret,id=sec0,data=[base64 ciphertext],\
           keyid=master0,iv=[base64 IV],format=base64

Note that 'format' here refers to the format of the ciphertext
data. The decrypted data must always be in raw byte format.

More examples are shown in the updated docs.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqga: convert to use error checked base64 decode
Daniel P. Berrange [Mon, 23 Nov 2015 15:37:07 +0000 (15:37 +0000)]
qga: convert to use error checked base64 decode

Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoqemu-char: convert to use error checked base64 decode
Daniel P. Berrange [Mon, 23 Nov 2015 15:29:59 +0000 (15:29 +0000)]
qemu-char: convert to use error checked base64 decode

Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoutil: add base64 decoding function
Daniel P. Berrange [Mon, 23 Nov 2015 15:24:50 +0000 (15:24 +0000)]
util: add base64 decoding function

The standard glib provided g_base64_decode doesn't provide any
kind of sensible error checking on its input. Add a QEMU custom
wrapper qbase64_decode which can be used with untrustworthy
input that can contain invalid base64 characters, embedded
NUL characters, or not be NUL terminated at all.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoMerge remote-tracking branch 'remotes/berrange/tags/pull-io-channel-vnc-2015-12-18...
Peter Maydell [Fri, 18 Dec 2015 16:04:31 +0000 (16:04 +0000)]
Merge remote-tracking branch 'remotes/berrange/tags/pull-io-channel-vnc-2015-12-18-1' into staging

Merge VNC conversion to I/O channels

# gpg: Signature made Fri 18 Dec 2015 15:44:30 GMT 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-io-channel-vnc-2015-12-18-1:
  ui: convert VNC server to use QIOChannelWebsock
  ui: convert VNC server to use QIOChannelTLS
  ui: convert VNC server to use QIOChannelSocket

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoMerge remote-tracking branch 'remotes/sstabellini/tags/xsa155' into staging
Peter Maydell [Fri, 18 Dec 2015 15:32:32 +0000 (15:32 +0000)]
Merge remote-tracking branch 'remotes/sstabellini/tags/xsa155' into staging

XSA-155 fixes

# gpg: Signature made Fri 18 Dec 2015 15:16:18 GMT using RSA key ID 70E1AE90
# gpg: Good signature from "Stefano Stabellini <stefano.stabellini@eu.citrix.com>"

* remotes/sstabellini/tags/xsa155:
  xenfb: avoid reading twice the same fields from the shared page
  xen/blkif: Avoid double access to src->nr_segments

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8 years agoxenfb: avoid reading twice the same fields from the shared page
Stefano Stabellini [Fri, 18 Dec 2015 15:10:09 +0000 (15:10 +0000)]
xenfb: avoid reading twice the same fields from the shared page

Reading twice the same field could give the guest an attack of
opportunity. In the case of event->type, gcc could compile the switch
statement into a jump table, effectively ending up reading the type
field multiple times.

This is part of XSA-155.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
8 years agoxen/blkif: Avoid double access to src->nr_segments
Stefano Stabellini [Fri, 18 Dec 2015 15:09:58 +0000 (15:09 +0000)]
xen/blkif: Avoid double access to src->nr_segments

src is stored in shared memory and src->nr_segments is dereferenced
twice at the end of the function.  If a compiler decides to compile this
into two separate memory accesses then the size limitation could be
bypassed.

Fix it by removing the double access to src->nr_segments.

This is part of XSA-155.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
8 years agoui: convert VNC server to use QIOChannelWebsock
Daniel P. Berrange [Wed, 11 Mar 2015 15:53:49 +0000 (15:53 +0000)]
ui: convert VNC server to use QIOChannelWebsock

Remove custom websock handling code from the VNC server and use
the QIOChannelWebsock class instead.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoui: convert VNC server to use QIOChannelTLS
Daniel P. Berrange [Mon, 2 Mar 2015 19:01:05 +0000 (19:01 +0000)]
ui: convert VNC server to use QIOChannelTLS

Switch VNC server over to using the QIOChannelTLS object for
the TLS session. This removes all remaining VNC specific code
for dealing with TLS handshakes.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoui: convert VNC server to use QIOChannelSocket
Daniel P. Berrange [Fri, 27 Feb 2015 16:20:57 +0000 (16:20 +0000)]
ui: convert VNC server to use QIOChannelSocket

The minimal first step conversion to use QIOChannelSocket
classes instead of directly using POSIX sockets API. This
will later be extended to also cover the TLS, SASL and
websockets code.

Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoMerge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-12-18' into queue...
Kevin Wolf [Fri, 18 Dec 2015 13:40:35 +0000 (14:40 +0100)]
Merge remote-tracking branch 'mreitz/tags/pull-block-for-kevin-2015-12-18' into queue-block

block-next patches from before the 2.5.0 release.

# gpg: Signature made Fri Dec 18 14:38:44 2015 CET using RSA key ID E838ACAD
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"

* mreitz/tags/pull-block-for-kevin-2015-12-18:
  block/qapi: allow best-effort query
  qemu-img: abort when full_backing_filename not present
  block/qapi: explicitly warn if !has_full_backing_filename
  block/qapi: always report full_backing_filename
  block/qapi: do not redundantly print "actual path"
  qemu-iotests: s390x: fix test 068
  qemu-iotests: s390x: fix test 051
  qemu-iotests: refine common.config

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock/qapi: allow best-effort query
John Snow [Mon, 14 Dec 2015 19:55:16 +0000 (14:55 -0500)]
block/qapi: allow best-effort query

For more complex BDS trees that can be created under normal circumstances,
we lose the ability to issue query commands because of our inability to
re-construct the absolute filename.

Instead, omit this field when it is a problem and present as much information
as we can.

This will change the expected output in iotest 110, where we will now see a
json filename and the lack of an absolute filename instead of an error.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1450122916-4706-6-git-send-email-jsnow@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-img: abort when full_backing_filename not present
John Snow [Mon, 14 Dec 2015 19:55:15 +0000 (14:55 -0500)]
qemu-img: abort when full_backing_filename not present

...But only if we have the backing_filename. It means something Scary
happened and we can't really be quite exactly sure if we can trust the
backing_filename.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1450122916-4706-5-git-send-email-jsnow@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock/qapi: explicitly warn if !has_full_backing_filename
John Snow [Mon, 14 Dec 2015 19:55:14 +0000 (14:55 -0500)]
block/qapi: explicitly warn if !has_full_backing_filename

Disambiguate "Backing filename and full backing filename are equivalent"
from "full backing filename could not be determined."

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1450122916-4706-4-git-send-email-jsnow@redhat.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock/qapi: always report full_backing_filename
John Snow [Mon, 14 Dec 2015 19:55:13 +0000 (14:55 -0500)]
block/qapi: always report full_backing_filename

Always report full_backing_filename, even if it's the same as
backing_filename. In the next patch, full_backing_filename may be
omitted if it cannot be generated instead of allowing e.g. drive_query
to abort if it runs into this scenario.

The presence or absence of the "full" field becomes useful information.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1450122916-4706-3-git-send-email-jsnow@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock/qapi: do not redundantly print "actual path"
John Snow [Mon, 14 Dec 2015 19:55:12 +0000 (14:55 -0500)]
block/qapi: do not redundantly print "actual path"

If it happens to match the backing path, that was the actual path.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1450122916-4706-2-git-send-email-jsnow@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: s390x: fix test 068
Bo Tu [Thu, 3 Dec 2015 10:01:31 +0000 (18:01 +0800)]
qemu-iotests: s390x: fix test 068

Now, s390-virtio-ccw is default machine and s390-ccw.img is default boot
loader. If the s390-virtio-ccw machine finds no device to load from and
errors out, then emits a panic and exits the vm. This breaks test cases
068 for s390x.
Adding the parameter of "-no-shutdown" for s390-ccw-virtio will pause VM
before shutdown.

Acked-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
Message-id: 1449136891-26850-4-git-send-email-tubo@linux.vnet.ibm.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: s390x: fix test 051
Bo Tu [Thu, 3 Dec 2015 10:01:30 +0000 (18:01 +0800)]
qemu-iotests: s390x: fix test 051

The tests for ide device should only be tested for the pc
platform.
Set device_id to "drive0", and replace every "-drive file..."
by "-drive file=...,if=none,id=$device_id", then x86 and s390x
can get the common output in the test of "Snapshot mode".
Warning message expected for s390x when drive without device.
A x86 platform specific output file is also needed.

Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
Message-id: 1449136891-26850-3-git-send-email-tubo@linux.vnet.ibm.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: refine common.config
Bo Tu [Thu, 3 Dec 2015 10:01:29 +0000 (18:01 +0800)]
qemu-iotests: refine common.config

Replacing awk with sed, then it's easier to read.
Replacing "[ ! -z "$default_alias_machine" ]" with
"[[ $default_alias_machine ]]", then it's slightly shorter.

Reviewed-by: Max Reitz <mreitz@redhat.com>
Suggested-By: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Bo Tu <tubo@linux.vnet.ibm.com>
Message-id: 1449136891-26850-2-git-send-email-tubo@linux.vnet.ibm.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: fix bdrv_ioctl called from coroutine
Paolo Bonzini [Wed, 16 Dec 2015 18:33:47 +0000 (19:33 +0100)]
block: fix bdrv_ioctl called from coroutine

When called from a coroutine, bdrv_ioctl must be asynchronous just like
e.g. bdrv_flush.  The code was incorrectly making it synchronous, fix
it.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: use drained section around bdrv_snapshot_delete
Paolo Bonzini [Wed, 16 Dec 2015 18:33:45 +0000 (19:33 +0100)]
block: use drained section around bdrv_snapshot_delete

Do not use bdrv_drain, since by itself it does not guarantee
anything.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: Update comments for bdrv_swap() in 094
Fam Zheng [Fri, 18 Dec 2015 01:04:36 +0000 (09:04 +0800)]
iotests: Update comments for bdrv_swap() in 094

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Remove prototype of bdrv_swap from header
Fam Zheng [Fri, 18 Dec 2015 01:04:35 +0000 (09:04 +0800)]
block: Remove prototype of bdrv_swap from header

The function has gone.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoraw-posix: Make aio=native option binding
Kevin Wolf [Tue, 15 Dec 2015 10:35:36 +0000 (11:35 +0100)]
raw-posix: Make aio=native option binding

Traditionally, aio=native was treated as an advice that could simply be
ignored if an error occurs while initialising Linux AIO or the feature
wasn't compiled in. This behaviour was deprecated in commit 96518254
(qemu 2.3; error during init) and commit 1501ecc1 (qemu 2.5; not
compiled in).

This patch changes raw-posix to error out in these cases instead of
printing a deprecation warning.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8 years agoqcow2: insert assert into qcow2_get_specific_info()
Denis V. Lunev [Thu, 10 Dec 2015 09:55:48 +0000 (12:55 +0300)]
qcow2: insert assert into qcow2_get_specific_info()

s->qcow_version is always set to 2 or 3. Let's assert if this is wrong.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Max Reitz <mreitz@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoiotests: Extend test 112 for qemu-img amend
Max Reitz [Mon, 27 Jul 2015 15:51:40 +0000 (17:51 +0200)]
iotests: Extend test 112 for qemu-img amend

Add tests for conversion between different refcount widths.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Point to amend function in check
Max Reitz [Mon, 27 Jul 2015 15:51:39 +0000 (17:51 +0200)]
qcow2: Point to amend function in check

If a reference count is not representable with the current refcount
order, the image check should point to qemu-img amend for increasing the
refcount order. However, qemu-img amend needs write access to the image
which cannot be provided if the image is marked corrupt; and the image
check will not mark the image consistent unless everything actually is
consistent.

Therefore, if an image is marked corrupt and the image check encounters
a reference count overflow, it cannot be fixed by using qemu-img amend
to increase the refcount order. Instead, one has to use qemu-img convert
to create a completely new copy of the image in this case.

Alternatively, we may want to give the user a way of manually removing
the corrupt flag, maybe through qemu-img amend, but this is not part of
this patch.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Invoke refcount order amendment function
Max Reitz [Mon, 27 Jul 2015 15:51:38 +0000 (17:51 +0200)]
qcow2: Invoke refcount order amendment function

Make use of qcow2_change_refcount_order() to support changing the
refcount order with qemu-img amend.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Add function for refcount order amendment
Max Reitz [Mon, 27 Jul 2015 15:51:37 +0000 (17:51 +0200)]
qcow2: Add function for refcount order amendment

Add a function qcow2_change_refcount_order() which allows changing the
refcount order of a qcow2 image.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Use intermediate helper CB for amend
Max Reitz [Mon, 27 Jul 2015 15:51:36 +0000 (17:51 +0200)]
qcow2: Use intermediate helper CB for amend

If there is more than one time-consuming operation to be performed for
qcow2_amend_options(), we need an intermediate CB which coordinates the
progress of the individual operations and passes the result to the
original status callback.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Split upgrade/downgrade paths for amend
Max Reitz [Mon, 27 Jul 2015 15:51:35 +0000 (17:51 +0200)]
qcow2: Split upgrade/downgrade paths for amend

If the image version should be upgraded, that is the first we should do;
if it should be downgraded, that is the last we should do. So split the
version change block into an upgrade part at the start and a downgrade
part at the end.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Use abort() instead of assert(false)
Max Reitz [Mon, 27 Jul 2015 15:51:34 +0000 (17:51 +0200)]
qcow2: Use abort() instead of assert(false)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqcow2: Use error_report() in qcow2_amend_options()
Max Reitz [Mon, 27 Jul 2015 15:51:33 +0000 (17:51 +0200)]
qcow2: Use error_report() in qcow2_amend_options()

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoblock: Add opaque value to the amend CB
Max Reitz [Mon, 27 Jul 2015 15:51:32 +0000 (17:51 +0200)]
block: Add opaque value to the amend CB

Add an opaque value which is to be passed to the bdrv_amend_options()
status callback.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoprogress: Allow regressing progress
Max Reitz [Mon, 27 Jul 2015 15:51:31 +0000 (17:51 +0200)]
progress: Allow regressing progress

Progress may regress; this should be displayed correctly by
qemu_progress_print().

While touching that area of code, drop the redundant parentheses in the
same condition.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8 years agoqemu-iotests: Test reopen with node-name/driver options
Kevin Wolf [Fri, 8 May 2015 16:11:08 +0000 (18:11 +0200)]
qemu-iotests: Test reopen with node-name/driver options

'node-name' and 'driver' should not be changed during a reopen
operation. It is, however, valid to specify them with the same value as
they already had.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: Test cache mode option inheritance
Kevin Wolf [Fri, 8 May 2015 16:06:47 +0000 (18:06 +0200)]
qemu-iotests: Test cache mode option inheritance

This is doing a more complete test on setting cache modes both while
opening an image (i.e. in a -drive command line) and in reopen
situations. It checks that reopen can specify options for child nodes
and that cache modes are correctly inherited from parent nodes where
they are not specified.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: Try setting cache mode for children
Kevin Wolf [Fri, 8 May 2015 16:03:15 +0000 (18:03 +0200)]
qemu-iotests: Try setting cache mode for children

This is a basic test for specifying cache modes for child nodes on the
command line. It doesn't take much time and works without O_DIRECT
support.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblkdebug: Enable reopen
Kevin Wolf [Thu, 29 Oct 2015 14:22:27 +0000 (15:22 +0100)]
blkdebug: Enable reopen

Just reopening the children (as block.c does now) is enough.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
8 years agoblock: Move cache options into options QDict
Kevin Wolf [Fri, 8 May 2015 15:49:53 +0000 (17:49 +0200)]
block: Move cache options into options QDict

This adds the cache mode options to the QDict, so that they can be
specified for child nodes (e.g. backing.cache.direct=off).

The cache modes are not removed from the flags at this point; instead,
options and flags are kept in sync. If the user specifies both flags and
options, the options take precedence.

Child node inherit cache modes as options now, they don't use flags any
more.

Note that this forbids specifying the cache mode for empty drives. It
didn't make sense anyway to specify it there, because it didn't have any
effect. blockdev_init() considers the cache options now bdrv_open()
options and therefore doesn't create an empty drive any more but calls
into bdrv_open(). This in turn will fail with no driver and filename
specified.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: reopen: Extract QemuOpts for generic block layer options
Kevin Wolf [Fri, 8 May 2015 15:24:56 +0000 (17:24 +0200)]
block: reopen: Extract QemuOpts for generic block layer options

This patch adds a QemuOpts for generic block layer options to
bdrv_reopen_prepare(). The only two options that currently exist
(node-name and driver) cannot be changed, so the only thing we do is
putting them right back into the QDict so that we check at the end that
they are indeed unchanged.

We will add new options soon that can actually be changed.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoqemu-iotests: Remove cache mode test without medium
Kevin Wolf [Thu, 7 May 2015 12:41:30 +0000 (14:41 +0200)]
qemu-iotests: Remove cache mode test without medium

Specifying the cache mode for a driver without a medium is not a useful
thing to do: As long as there is no medium, the cache mode doesn't make
a difference, and once the 'change' command is used to insert a medium,
it ignores the old cache mode and makes the new medium use
cache=writethrough.

Later patches will make it an error to specify the cache mode for an
empty drive. Remove the corresponding test case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblockdev: Set 'format' indicates non-empty drive
Kevin Wolf [Fri, 13 Nov 2015 13:45:42 +0000 (14:45 +0100)]
blockdev: Set 'format' indicates non-empty drive

Creating an empty drive while specifying 'format' doesn't make sense.
The specified format driver would simply be ignored.

Make a set 'format' option an indication that a non-empty drive should
be created. This makes 'format' consistent with 'driver' and allows
using it with a block driver that doesn't need any other options (like
null-co/null-aio).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Introduce bs->explicit_options
Kevin Wolf [Fri, 8 May 2015 14:15:03 +0000 (16:15 +0200)]
block: Introduce bs->explicit_options

bs->options doesn't only contain options that the user explicitly
requested, but also option that were derived from flags, the filename or
inherited from the parent node.

For reopen, it is important to know the difference because reopening the
parent can change inherited values in child nodes, but it shouldn't
change any options that were explicitly specified for the child.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Split out parse_json_protocol()
Kevin Wolf [Thu, 29 Oct 2015 14:24:41 +0000 (15:24 +0100)]
block: Split out parse_json_protocol()

The next patch distinguishes options that were explicitly set and
options that were derived. bdrv_fill_option() added options of both
types: Options given by json: syntax should be counted as explicit, but
the rest is derived.

In preparation for the distinction, move json: parse to a separate
function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Add infrastructure for option inheritance
Kevin Wolf [Wed, 29 Apr 2015 15:29:39 +0000 (17:29 +0200)]
block: Add infrastructure for option inheritance

Options are not actually inherited from the parent node yet, but this
commit lays the grounds for doing so.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: reopen: Document option precedence and refactor accordingly
Kevin Wolf [Fri, 8 May 2015 15:07:31 +0000 (17:07 +0200)]
block: reopen: Document option precedence and refactor accordingly

The interesting part of reopening an image is from which sources the
effective options should be taken, i.e. which options take precedence
over which other options. This patch documents the precedence that will
be implemented in the following patches.

It also refactors bdrv_reopen_queue(), so that the top-level reopened
node is handled the same way as children are. Option/flag inheritance
from the parent becomes just one item in the list and is done at the
beginning of the function, similar to how the other items are/will be
handled.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Allow specifying child options in reopen
Kevin Wolf [Fri, 8 May 2015 13:14:15 +0000 (15:14 +0200)]
block: Allow specifying child options in reopen

If the child was defined in the same context (-drive argument or
blockdev-add QMP command) as its parent, a reopen of the parent should
work the same and allow changing options of the child.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
8 years agoblock: Keep "driver" in bs->options
Kevin Wolf [Fri, 24 Apr 2015 14:38:02 +0000 (16:38 +0200)]
block: Keep "driver" in bs->options

Instead of passing a separate drv argument to bdrv_open_common(), just
make sure that a "driver" option is set in the QDict. This also means
that a "driver" entry is consistently present in bs->options now.

This is another step towards keeping all options in the QDict (which is
the represenation of the blockdev-add QMP command).

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
8 years agoblock: Pass driver-specific options to .bdrv_refresh_filename()
Kevin Wolf [Mon, 27 Apr 2015 11:50:54 +0000 (13:50 +0200)]
block: Pass driver-specific options to .bdrv_refresh_filename()

In order to decide whether a blkdebug: filename can be produced or a
json: one is necessary, blkdebug checked whether bs->options had more
options than just "config", "x-image" or "image" (the latter including
nested options). That doesn't work well when generic block layer options
are present.

This patch passes an option QDict to the driver that contains only
driver-specific options, i.e. the options for the general block layer as
well as child nodes are already filtered out. Works much better this
way.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>