Re: [Qemu-devel] [PATCH v2 2/6] hw/i2c: Add a NULL check for i2c slave init callbacks

2016-11-30 Thread Cédric Le Goater
On 11/30/2016 06:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> Add a NULL check for i2c slave init callbacks, so that we no longer
> need to implement empty init functions.
> 
> Signed-off-by: Alastair D'Silva 

Reviewed-by:  Cédric Le Goater 

> ---
>  hw/arm/pxa2xx.c   | 9 +
>  hw/arm/tosa.c | 7 ---
>  hw/arm/z2.c   | 7 ---
>  hw/i2c/core.c | 6 +-
>  hw/timer/ds1338.c | 6 --
>  5 files changed, 6 insertions(+), 29 deletions(-)
> 
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index 21ea1d6..bdcf6bc 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -1449,17 +1449,10 @@ static const VMStateDescription vmstate_pxa2xx_i2c = {
>  }
>  };
>  
> -static int pxa2xx_i2c_slave_init(I2CSlave *i2c)
> -{
> -/* Nothing to do.  */
> -return 0;
> -}
> -
>  static void pxa2xx_i2c_slave_class_init(ObjectClass *klass, void *data)
>  {
>  I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> -k->init = pxa2xx_i2c_slave_init;
>  k->event = pxa2xx_i2c_event;
>  k->recv = pxa2xx_i2c_rx;
>  k->send = pxa2xx_i2c_tx;
> @@ -2070,7 +2063,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
>  }
>  if (!revision)
>  revision = "pxa270";
> -
> +
>  s->cpu = cpu_arm_init(revision);
>  if (s->cpu == NULL) {
>  fprintf(stderr, "Unable to find CPU definition\n");
> diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
> index 1ee12f4..39d9dbb 100644
> --- a/hw/arm/tosa.c
> +++ b/hw/arm/tosa.c
> @@ -202,12 +202,6 @@ static int tosa_dac_recv(I2CSlave *s)
>  return -1;
>  }
>  
> -static int tosa_dac_init(I2CSlave *i2c)
> -{
> -/* Nothing to do.  */
> -return 0;
> -}
> -
>  static void tosa_tg_init(PXA2xxState *cpu)
>  {
>  I2CBus *bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> @@ -275,7 +269,6 @@ static void tosa_dac_class_init(ObjectClass *klass, void 
> *data)
>  {
>  I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> -k->init = tosa_dac_init;
>  k->event = tosa_dac_event;
>  k->recv = tosa_dac_recv;
>  k->send = tosa_dac_send;
> diff --git a/hw/arm/z2.c b/hw/arm/z2.c
> index 68a92f3..b3a6bbd 100644
> --- a/hw/arm/z2.c
> +++ b/hw/arm/z2.c
> @@ -263,12 +263,6 @@ static int aer915_recv(I2CSlave *slave)
>  return retval;
>  }
>  
> -static int aer915_init(I2CSlave *i2c)
> -{
> -/* Nothing to do.  */
> -return 0;
> -}
> -
>  static VMStateDescription vmstate_aer915_state = {
>  .name = "aer915",
>  .version_id = 1,
> @@ -285,7 +279,6 @@ static void aer915_class_init(ObjectClass *klass, void 
> *data)
>  DeviceClass *dc = DEVICE_CLASS(klass);
>  I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> -k->init = aer915_init;
>  k->event = aer915_event;
>  k->recv = aer915_recv;
>  k->send = aer915_send;
> diff --git a/hw/i2c/core.c b/hw/i2c/core.c
> index abd4c4c..ae3ca94 100644
> --- a/hw/i2c/core.c
> +++ b/hw/i2c/core.c
> @@ -260,7 +260,11 @@ static int i2c_slave_qdev_init(DeviceState *dev)
>  I2CSlave *s = I2C_SLAVE(dev);
>  I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s);
>  
> -return sc->init(s);
> +if (sc->init) {
> +return sc->init(s);
> +} else {
> +return 0;
> +}
>  }
>  
>  DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr)
> diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
> index 0112949..f5d04dd 100644
> --- a/hw/timer/ds1338.c
> +++ b/hw/timer/ds1338.c
> @@ -198,11 +198,6 @@ static int ds1338_send(I2CSlave *i2c, uint8_t data)
>  return 0;
>  }
>  
> -static int ds1338_init(I2CSlave *i2c)
> -{
> -return 0;
> -}
> -
>  static void ds1338_reset(DeviceState *dev)
>  {
>  DS1338State *s = DS1338(dev);
> @@ -220,7 +215,6 @@ static void ds1338_class_init(ObjectClass *klass, void 
> *data)
>  DeviceClass *dc = DEVICE_CLASS(klass);
>  I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
>  
> -k->init = ds1338_init;
>  k->event = ds1338_event;
>  k->recv = ds1338_recv;
>  k->send = ds1338_send;
> 




Re: [Qemu-devel] [PATCH v2 4/6] hw/timer: Add Epson RX8900 RTC support

2016-11-30 Thread Cédric Le Goater
On 11/30/2016 06:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> This patch adds support for the Epson RX8900 I2C RTC.
> 
> The following chip features are implemented:
>  - RTC (wallclock based, ptimer 10x oversampling to pick up
>   wallclock transitions)
>  - Time update interrupt (per second/minute, wallclock based)
>  - Alarms (wallclock based)
>  - Temperature (set via a property)
>  - Countdown timer (emulated clock via ptimer)
>  - FOUT via GPIO (emulated clock via ptimer)
> 
> The following chip features are unimplemented:
>  - Low voltage detection
>  - i2c timeout
> 
> The implementation exports the following named GPIOs:
> rx8900-interrupt-out
> rx8900-fout-enable
> rx8900-fout
> 
> Signed-off-by: Alastair D'Silva 
> Signed-off-by: Chris Smart 

Reviewed-by:  Cédric Le Goater 


> ---
>  default-configs/arm-softmmu.mak |   1 +
>  hw/timer/Makefile.objs  |   2 +
>  hw/timer/rx8900.c   | 890 
> 
>  hw/timer/rx8900_regs.h  | 139 +++
>  hw/timer/trace-events   |  31 ++
>  5 files changed, 1063 insertions(+)
>  create mode 100644 hw/timer/rx8900.c
>  create mode 100644 hw/timer/rx8900_regs.h
> 
> diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
> index 6de3e16..adb600e 100644
> --- a/default-configs/arm-softmmu.mak
> +++ b/default-configs/arm-softmmu.mak
> @@ -29,6 +29,7 @@ CONFIG_SMC91C111=y
>  CONFIG_ALLWINNER_EMAC=y
>  CONFIG_IMX_FEC=y
>  CONFIG_DS1338=y
> +CONFIG_RX8900=y
>  CONFIG_PFLASH_CFI01=y
>  CONFIG_PFLASH_CFI02=y
>  CONFIG_MICRODRIVE=y
> diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs
> index 7ba8c23..fa028ac 100644
> --- a/hw/timer/Makefile.objs
> +++ b/hw/timer/Makefile.objs
> @@ -3,6 +3,7 @@ common-obj-$(CONFIG_ARM_MPTIMER) += arm_mptimer.o
>  common-obj-$(CONFIG_A9_GTIMER) += a9gtimer.o
>  common-obj-$(CONFIG_CADENCE) += cadence_ttc.o
>  common-obj-$(CONFIG_DS1338) += ds1338.o
> +common-obj-$(CONFIG_RX8900) += rx8900.o
>  common-obj-$(CONFIG_HPET) += hpet.o
>  common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
>  common-obj-$(CONFIG_M48T59) += m48t59.o
> @@ -17,6 +18,7 @@ common-obj-$(CONFIG_IMX) += imx_epit.o
>  common-obj-$(CONFIG_IMX) += imx_gpt.o
>  common-obj-$(CONFIG_LM32) += lm32_timer.o
>  common-obj-$(CONFIG_MILKYMIST) += milkymist-sysctl.o
> +common-obj-$(CONFIG_RX8900) += rx8900.o
>  
>  obj-$(CONFIG_EXYNOS4) += exynos4210_mct.o
>  obj-$(CONFIG_EXYNOS4) += exynos4210_pwm.o
> diff --git a/hw/timer/rx8900.c b/hw/timer/rx8900.c
> new file mode 100644
> index 000..e634819
> --- /dev/null
> +++ b/hw/timer/rx8900.c
> @@ -0,0 +1,890 @@
> +/*
> + * Epson RX8900SA/CE Realtime Clock Module
> + *
> + * Copyright (c) 2016 IBM Corporation
> + * Authors:
> + *  Alastair D'Silva 
> + *  Chris Smart 
> + *
> + * This code is licensed under the GPL version 2 or later.  See
> + * the COPYING file in the top-level directory.
> + *
> + * Datasheet available at:
> + *  https://support.epson.biz/td/api/doc_check.php?dl=app_RX8900CE&lang=en
> + *
> + * Not implemented:
> + *  Implement i2c timeout
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +#include "hw/i2c/i2c.h"
> +#include "hw/timer/rx8900_regs.h"
> +#include "hw/ptimer.h"
> +#include "qemu/main-loop.h"
> +#include "qemu/bcd.h"
> +#include "qemu/log.h"
> +#include "qapi/error.h"
> +#include "qapi/visitor.h"
> +#include "trace.h"
> +
> + #include 
> +
> + #include 
> +
> +#define TYPE_RX8900 "rx8900"
> +#define RX8900(obj) OBJECT_CHECK(RX8900State, (obj), TYPE_RX8900)
> +
> +typedef struct RX8900State {
> +I2CSlave parent_obj;
> +
> +ptimer_state *sec_timer; /* triggered once per second */
> +ptimer_state *fout_timer;
> +ptimer_state *countdown_timer;
> +bool fout;
> +int64_t offset;
> +uint8_t weekday; /* Saved for deferred offset calculation, 0-6 */
> +uint8_t wday_offset;
> +uint8_t nvram[RX8900_NVRAM_SIZE];
> +int32_t ptr; /* Wrapped to stay within RX8900_NVRAM_SIZE */
> +bool addr_byte;
> +uint8_t last_interrupt_seconds;
> +uint8_t last_update_interrupt_minutes;
> +double supply_voltage;
> +qemu_irq interrupt_pin;
> +qemu_irq fout_pin;
> +} RX8900State;
> +
> +static const VMStateDescription vmstate_rx8900 = {
> +.name = "rx8900",
> +.version_id = 2,
> +.minimum_version_id = 1,
> +.fields = (VMStateField[]) {
> +VMSTATE_I2C_SLAVE(parent_obj, RX8900State),
> +VMSTATE_PTIMER(sec_timer, RX8900State),
> +VMSTATE_PTIMER(fout_timer, RX8900State),
> +VMSTATE_PTIMER(countdown_timer, RX8900State),
> +VMSTATE_BOOL(fout, RX8900State),
> +VMSTATE_INT64(offset, RX8900State),
> +VMSTATE_UINT8_V(weekday, RX8900State, 2),
> +VMSTATE_UINT8_V(wday_offset, RX8900State, 2),
> +VMSTATE_UINT8_ARRAY(nvram, RX8900State, RX8900_NVRAM_SIZE),
> +VMSTATE_INT32(ptr, RX8900State),
> +VMSTATE_BOOL(addr_byte, RX8900State),
> +VM

Re: [Qemu-devel] [PATCH v2 6/6] arm: Add an RX8900 RTC to the ASpeed board

2016-11-30 Thread Cédric Le Goater
On 11/30/2016 06:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> Connect an RX8900 RTC to i2c12 of the AST2500 SOC at address 0x32
> 
> Signed-off-by: Alastair D'Silva 
> ---
>  hw/arm/aspeed.c | 12 
>  1 file changed, 12 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index c7206fd..8de95f2 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -166,7 +166,19 @@ static const TypeInfo palmetto_bmc_type = {
>  
>  static void ast2500_evb_init(MachineState *machine)
>  {
> +AspeedSoCState *soc;
> +I2CBus *i2c12;
> +DeviceState *rx8900;
> +
>  aspeed_board_init(machine, &aspeed_boards[AST2500_EVB]);
> +
> +soc = ASPEED_SOC(object_resolve_path_component(OBJECT(machine), "soc"));
> +
> +i2c12 = aspeed_i2c_get_bus((DeviceState *)&soc->i2c, 11);
> +rx8900 = i2c_create_slave(i2c12, "rx8900", 0x32);
> +
> +qdev_connect_gpio_out_named(rx8900, "rx8900-interrupt-out", 0,
> +qdev_get_gpio_in(DEVICE(&soc->vic), 22));
>  }
>  
>  static void ast2500_evb_class_init(ObjectClass *oc, void *data)
> 

I think it would be nicer to define a handler under AspeedBoardConfig,
something like : 

int (*i2c_init)(AspeedBoardState *bmc);

when a board needs I2C devices. The handler would be called 
from aspeed_board_init() directly. This is similar to what 
we do for the flash modules but we didn't have to add a 
specific handler for the flash.

Thoughts ?


C.






Re: [Qemu-devel] [PATCH v2 1/6] arm: Uniquely name imx25 I2C buses.

2016-11-30 Thread Cédric Le Goater
On 11/30/2016 06:36 AM, Alastair D'Silva wrote:
> From: Alastair D'Silva 
> 
> The imx25 chip provides 3 i2c buses, but they have all been named
> "i2c", which makes it difficult to predict which bus a device will
> be connected to when specified on the command line.
> 
> This patch addresses the issue by naming the buses uniquely:
>   i2c.0 i2c.1 i2c.2
> 
> Signed-off-by: Alastair D'Silva 
> ---
>  hw/arm/imx25_pdk.c | 4 +---
>  hw/i2c/imx_i2c.c   | 6 +-
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c
> index 025b608..c6f04d3 100644
> --- a/hw/arm/imx25_pdk.c
> +++ b/hw/arm/imx25_pdk.c
> @@ -138,9 +138,7 @@ static void imx25_pdk_init(MachineState *machine)
>   * We add it here (only on qtest usage) to be able to do a bit
>   * of simple qtest. See "make check" for details.
>   */
> -i2c_create_slave((I2CBus *)qdev_get_child_bus(DEVICE(&s->soc.i2c[0]),
> -  "i2c"),
> - "ds1338", 0x68);
> +i2c_create_slave(s->soc.i2c[0].bus, "ds1338", 0x68);
>  }
>  }
>  
> diff --git a/hw/i2c/imx_i2c.c b/hw/i2c/imx_i2c.c
> index 37e5a62..7be10fb 100644
> --- a/hw/i2c/imx_i2c.c
> +++ b/hw/i2c/imx_i2c.c
> @@ -305,12 +305,16 @@ static const VMStateDescription imx_i2c_vmstate = {
>  static void imx_i2c_realize(DeviceState *dev, Error **errp)
>  {
>  IMXI2CState *s = IMX_I2C(dev);
> +static int bus_count;

hmm, the static is ugly :/ 

Isn't there other ways to achieve this naming ? 

Thanks,

C.  

> +char name[16];
> +
> +snprintf(name, sizeof(name), "i2c.%d", bus_count++);
>  
>  memory_region_init_io(&s->iomem, OBJECT(s), &imx_i2c_ops, s, 
> TYPE_IMX_I2C,
>IMX_I2C_MEM_SIZE);
>  sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
>  sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
> -s->bus = i2c_init_bus(DEVICE(dev), "i2c");
> +s->bus = i2c_init_bus(DEVICE(dev), name);
>  }
>  
>  static void imx_i2c_class_init(ObjectClass *klass, void *data)
> 




Re: [Qemu-devel] [PATCH v7 RFC] block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support

2016-11-30 Thread Stefan Hajnoczi
On Wed, Nov 30, 2016 at 04:20:03AM +, Rakesh Ranjan wrote:
> > Why does the client have to know about failover if it's connected to
> >a server process on the same host?  I thought the server process
> >manages networking issues (like the actual protocol to speak to other
> >VxHS nodes and for failover).
> 
> Just to comment on this, the model being followed within HyperScale is to
> allow application I/O continuity (resiliency) in various cases as
> mentioned below. It really adds value for consumer/customer and tries to
> avoid culprits for single points of failure.
> 
> 1. HyperScale storage service failure (QNIO Server)
>   - Daemon managing local storage for VMs and runs on each compute node
>   - Daemon can run as a service on Hypervisor itself as well as within VSA
> (Virtual Storage Appliance or Virtual Machine running on the hypervisor),
> which depends on ecosystem where HyperScale is supported
>   - Daemon or storage service down/crash/crash-in-loop shouldn¹t lead to 
> an
> huge impact on all the VMs running on that hypervisor or compute node
> hence providing service level resiliency is very useful for
>   application I/O continuity in such case.
> 
>Solution:
>   - The service failure handling can be only done at the client side and
> not at the server side since service running as a server itself is down.
>   - Client detects an I/O error and depending on the logic, it does
> application I/O failover to another available/active QNIO server or
> HyperScale Storage service running on different compute node
> (reflection/replication node)
>   - Once the orig/old server comes back online, client gets/receives
> negotiated error (not a real application error) to do the application I/O
> failback to the original server or local HyperScale storage service to get
> better I/O performance.
>   
> 2. Local physical storage or media failure
>   - Once server or HyperScale storage service detects the media or local
> disk failure, depending on the vDisk (guest disk) configuration, if
> another storage copy is available
>   on different compute node then it internally handles the local
> fault and serves the application read and write requests otherwise
> application or client gets the fault.
>   - Client doesn¹t know about any I/O failure since Server or Storage
> service manages/handles the fault tolerance.
> - In such case, in order to get some I/O performance benefit, once
> client gets a negotiated error (not an application error) from local
> server or storage service,
>   client can initiate I/O failover and can directly send
> application I/O to another compute node where storage copy is available to
> serve the application need instead of sending it locally where media is
> faulted.   

Thanks for explaining the model.

The new information for me here is that the qnio server may run in a VM
instead of on the host and that the client will attempt to use a remote
qnio server if the local qnio server fails.

This means that although the discussion most recently focussed on local
I/O tap performance, there is a requirement for a network protocol too.
The local I/O tap stuff is just an optimization for when the local qnio
server can be used.

Stefan


signature.asc
Description: PGP signature


[Qemu-devel] [RFC Design Doc v3] Enable Shared Virtual Memory feature in pass-through scenarios

2016-11-30 Thread Liu, Yi L
What's changed from v2:
a) Detailed feature description
b) refine description in "Address translation in virtual SVM"
b) "Terms" is added

Content
===
1. Feature description
2. Why use it?
3. How to enable it
4. How to test
5. Terms

Details
===
1. Feature description
Shared virtual memory(SVM) is to let application program share its virtual
address with SVM capable devices. 

Shared virtual memory details:
a) SVM feature requires ATS/PRQ/PASID support on both device side and
IOMMU side.
b) SVM capable devices could send DMA requests with PASID, the address
in the request would be a virtual address within a program's virtual address
space.
c) IOMMU would use first level page table to translate the address in the
request.
d) First level page table is a HVA->HPA mapping on bare metal.

Shared Virtual Memory feature in pass-through scenarios is actually SVM
virtualization. It is to let application programs(running in guest)share their
virtual address with assigned device(e.g. graphics processors or accelerators).

In virtualization, SVM would be:
a) Require a vIOMMU exposed to guest
b) Assigned SVM capable device could send DMA requests with PASID, the
address in the request would be a virtual address within a guest
program's virtual address space(GVA).
c) Physical IOMMU needs to do GVA->GPA->HPA translation. Nested mode
would be enabled, first level page table would achieve GVA->GPA mapping,
while second level page table would achieve GPA->HPA translation.

For more SVM detail, you may want refer to section 2.5.1.1 of Intel VT-d spec
and section 5.6 of OpenCL spec. For details about SVM address translation,
pls refer to section 3 of Intel VT-d spec.
It's also welcomed to discuss directly in this thread.

Link to related specs:
http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf
https://www.khronos.org/registry/cl/specs/opencl-2.0.pdf


2. Why use it?
It is common to pass-through devices to guest and expect to achieve as
much similar performance as it is on host. With this feature enabled, 
the application programs in guest would be able to share data-structures
with assigned devices without unnecessary overheads.


3. How to enable it
As mentioned above, SVM virtualization requires a vIOMMU exposed to guest.
Since there is an existing IOMMU emulator in host user space(QEMU), it is
more acceptable to extend the IOMMU emulator to support SVM for assigned
devices. So far, the vIOMMU exposed to guest is only for emulated devices.
In this design, it would focus on virtual SVM for assigned devices. Virtual
IOVA and virtual interrupt remapping will not be included here.

The enabling work would include the following items.

a) IOMMU Register Access Emulation
Already existed in QEMU, need some extensions to support SVM. e.g. support
page request service related registers(PQA_REG).

b) vIOMMU Capability
Report SVM related capabilities(PASID,PRS,DT,PT,ECS etc.) in ex-capability
register and cache mode, DWD, DRD in capability register.

c) QI Handling Emulation
Already existed in QEMU, need to shadow the QIs related to assigned devices to
physical IOMMU.
i.  ex-context entry cache invalidation(nested mode setting, guest PASID 
table
pointer shadowing)
ii. 1st level translation cache invalidation
iii.Response for recoverable faults

d) Address translation in virtual SVM
In virtualization, for requests with PASID from assigned device, the address 
translation
would be subjected to first level page table and then second level page table, 
which is
named nested mode. Extended context mode should be supported on hardware. DMA
remapping in SVM virtualization would be:
i.  For requests with PASID, the related extended context entry should have
the NESTE bit set. 
ii. Guest PASID table pointer should be shadowed to host IOMMU driver.
The PASID table pointer field in extended context entry would be a GPA as
nested mode is on.

First level page table would be maintained by guest IOMMU driver. Second level
page table would be maintained by host IOMMU driver.

e) Recoverable Address Translation Faults Handling Emulation
It is serviced by page request when device support PRS. For assigned devices, 
host IOMMU driver would get page requests from pIOMMU. Here, we need a
mechanism to drain the page requests from devices which are assigned to a
guest. In this design it would be done through VFIO. Page request descriptors
would be propagated to user space and then exposed to guest IOMMU driver.
This requires following support:
i.  a mechanism to notify vIOMMU emulator to fetch PRQ descriptor
ii. a notify framework in QEMU to signal the PRQ descriptor fetching when
notified by pIOMMU

f) Non-Recoverable Address Translation Handling Emulation
The non-recoverable fault propagation is similar to recoverable faults. In
this design it would propagate fault data to user space

Re: [Qemu-devel] [PATCH 1/2] virtio-net rsc: support coalescing ipv4 tcp traffic

2016-11-30 Thread Wei Xu

On 2016年11月24日 12:17, Jason Wang wrote:



On 2016年11月01日 01:41, w...@redhat.com wrote:

From: Wei Xu 

All the data packets in a tcp connection are cached
to a single buffer in every receive interval, and will
be sent out via a timer, the 'virtio_net_rsc_timeout'
controls the interval, this value may impact the
performance and response time of tcp connection,
5(50us) is an experience value to gain a performance
improvement, since the whql test sends packets every 100us,
so '30(300us)' passes the test case, it is the default
value as well, tune it via the command line parameter
'rsc_interval' within 'virtio-net-pci' device, for example,
to launch a guest with interval set as '50':

'virtio-net-pci,netdev=hostnet1,bus=pci.0,id=net1,mac=00,rsc_interval=50'


The timer will only be triggered if the packets pool is not empty,
and it'll drain off all the cached packets.

'NetRscChain' is used to save the segments of IPv4/6 in a
VirtIONet device.

A new segment becomes a 'Candidate' as well as it passed sanity check,
the main handler of TCP includes TCP window update, duplicated
ACK check and the real data coalescing.

An 'Candidate' segment means:
1. Segment is within current window and the sequence is the expected one.
2. 'ACK' of the segment is in the valid window.

Sanity check includes:
1. Incorrect version in IP header
2. An IP options or IP fragment
3. Not a TCP packet
4. Sanity size check to prevent buffer overflow attack.
5. An ECN packet

Even though, there might more cases should be considered such as
ip identification other flags, while it breaks the test because
windows set it to the same even it's not a fragment.

Normally it includes 2 typical ways to handle a TCP control flag,
'bypass' and 'finalize', 'bypass' means should be sent out directly,
while 'finalize' means the packets should also be bypassed, but this
should be done after search for the same connection packets in the
pool and drain all of them out, this is to avoid out of order fragment.

All the 'SYN' packets will be bypassed since this always begin a new'
connection, other flags such 'URG/FIN/RST/CWR/ECE' will trigger a
finalization, because this normally happens upon a connection is going
to be closed, an 'URG' packet also finalize current coalescing unit.

Statistics can be used to monitor the basic coalescing status, the
'out of order' and 'out of window' means how many retransmitting packets,
thus describe the performance intuitively.

Signed-off-by: Wei Xu 
---
  hw/net/virtio-net.c | 602
++--
  include/hw/virtio/virtio-net.h  |   5 +-
  include/hw/virtio/virtio.h  |  76 
  include/net/eth.h   |   2 +
  include/standard-headers/linux/virtio_net.h |  14 +
  net/tap.c   |   3 +-
  6 files changed, 670 insertions(+), 32 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 06bfe4b..d1824d9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -15,10 +15,12 @@
  #include "qemu/iov.h"
  #include "hw/virtio/virtio.h"
  #include "net/net.h"
+#include "net/eth.h"
  #include "net/checksum.h"
  #include "net/tap.h"
  #include "qemu/error-report.h"
  #include "qemu/timer.h"
+#include "qemu/sockets.h"
  #include "hw/virtio/virtio-net.h"
  #include "net/vhost_net.h"
  #include "hw/virtio/virtio-bus.h"
@@ -43,6 +45,24 @@
  #define endof(container, field) \
  (offsetof(container, field) + sizeof(((container *)0)->field))
+#define VIRTIO_NET_IP4_ADDR_SIZE   8/* ipv4 saddr + daddr */


Only used once in the code, I don't see much value of this macro.


Just to keep it a bit readable.




+
+#define VIRTIO_NET_TCP_FLAG 0x3F
+#define VIRTIO_NET_TCP_HDR_LENGTH   0xF000
+
+/* IPv4 max payload, 16 bits in the header */
+#define VIRTIO_NET_MAX_IP4_PAYLOAD (65535 - sizeof(struct ip_header))
+#define VIRTIO_NET_MAX_TCP_PAYLOAD 65535
+
+/* header length value in ip header without option */
+#define VIRTIO_NET_IP4_HEADER_LENGTH 5
+
+/* Purge coalesced packets timer interval, This value affects the
performance
+   a lot, and should be tuned carefully, '30'(300us) is the
recommended
+   value to pass the WHQL test, '5' can gain 2x netperf
throughput with
+   tso/gso/gro 'off'. */
+#define VIRTIO_NET_RSC_INTERVAL  30


This should be a property for virito-net and the above comment can be
the description of the property.


This is a value for a property, actually I hadn't found a place to put
it.




+
  typedef struct VirtIOFeature {
  uint32_t flags;
  size_t end;
@@ -589,7 +609,12 @@ static uint64_t
virtio_net_guest_offloads_by_features(uint32_t features)
  (1ULL << VIRTIO_NET_F_GUEST_ECN)  |
  (1ULL << VIRTIO_NET_F_GUEST_UFO);
-return guest_offloads_mask & features;
+if (features & VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) {
+return (guest_offloads_mask & features) |
+   (1ULL << VIRTIO_NET_F_GUEST_RSC

[Qemu-devel] [PATCH kernel v5 0/5] Extend virtio-balloon for fast (de)inflating & fast live migration

2016-11-30 Thread Liang Li
This patch set contains two parts of changes to the virtio-balloon.
 
One is the change for speeding up the inflating & deflating process,
the main idea of this optimization is to use bitmap to send the page
information to host instead of the PFNs, to reduce the overhead of
virtio data transmission, address translation and madvise(). This can
help to improve the performance by about 85%.
 
Another change is for speeding up live migration. By skipping process
guest's unused pages in the first round of data copy, to reduce needless
data processing, this can help to save quite a lot of CPU cycles and
network bandwidth. We put guest's unused page information in a bitmap
and send it to host with the virt queue of virtio-balloon. For an idle
guest with 8GB RAM, this can help to shorten the total live migration
time from 2Sec to about 500ms in 10Gbps network environment.
 
Changes from v4 to v5:
* Drop the code to get the max_pfn, use another way instead.
* Simplify the API to get the unused page information from mm. 

Changes from v3 to v4:
* Use the new scheme suggested by Dave Hansen to encode the bitmap.
* Add code which is missed in v3 to handle migrate page. 
* Free the memory for bitmap intime once the operation is done.
* Address some of the comments in v3.

Changes from v2 to v3:
* Change the name of 'free page' to 'unused page'.
* Use the scatter & gather bitmap instead of a 1MB page bitmap.
* Fix overwriting the page bitmap after kicking.
* Some of MST's comments for v2.
 
Changes from v1 to v2:
* Abandon the patch for dropping page cache.
* Put some structures to uapi head file.
* Use a new way to determine the page bitmap size.
* Use a unified way to send the free page information with the bitmap
* Address the issues referred in MST's comments

Liang Li (5):
  virtio-balloon: rework deflate to add page to a list
  virtio-balloon: define new feature bit and head struct
  virtio-balloon: speed up inflate/deflate process
  virtio-balloon: define flags and head for host request vq
  virtio-balloon: tell host vm's unused page info

 drivers/virtio/virtio_balloon.c | 539 
 include/linux/mm.h  |   3 +-
 include/uapi/linux/virtio_balloon.h |  41 +++
 mm/page_alloc.c |  72 +
 4 files changed, 607 insertions(+), 48 deletions(-)

-- 
1.8.3.1




[Qemu-devel] [PATCH kernel v5 1/5] virtio-balloon: rework deflate to add page to a list

2016-11-30 Thread Liang Li
When doing the inflating/deflating operation, the current virtio-balloon
implementation uses an array to save 256 PFNS, then send these PFNS to
host through virtio and process each PFN one by one. This way is not
efficient when inflating/deflating a large mount of memory because too
many times of the following operations:

1. Virtio data transmission
2. Page allocate/free
3. Address translation(GPA->HVA)
4. madvise

The over head of these operations will consume a lot of CPU cycles and
will take a long time to complete, it may impact the QoS of the guest as
well as the host. The overhead will be reduced a lot if batch processing
is used. E.g. If there are several pages whose address are physical
contiguous in the guest, these bulk pages can be processed in one
operation.

The main idea for the optimization is to reduce the above operations as
much as possible. And it can be achieved by using a bitmap instead of an
PFN array. Comparing with PFN array, for a specific size buffer, bitmap
can present more pages, which is very important for batch processing.

Using bitmap instead of PFN is not very helpful when inflating/deflating
a small mount of pages, in this case, using PFNs is better. But using
bitmap will not impact the QoS of guest or host heavily because the
operation will be completed very soon for a small mount of pages, and we
will use some methods to make sure the efficiency not drop too much.

This patch saves the deflated pages to a list instead of the PFN array,
which will allow faster notifications using a bitmap down the road.
balloon_pfn_to_page() can be removed because it's useless.

Signed-off-by: Liang Li 
Signed-off-by: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 22 --
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 181793f..f59cb4f 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -103,12 +103,6 @@ static u32 page_to_balloon_pfn(struct page *page)
return pfn * VIRTIO_BALLOON_PAGES_PER_PAGE;
 }
 
-static struct page *balloon_pfn_to_page(u32 pfn)
-{
-   BUG_ON(pfn % VIRTIO_BALLOON_PAGES_PER_PAGE);
-   return pfn_to_page(pfn / VIRTIO_BALLOON_PAGES_PER_PAGE);
-}
-
 static void balloon_ack(struct virtqueue *vq)
 {
struct virtio_balloon *vb = vq->vdev->priv;
@@ -181,18 +175,16 @@ static unsigned fill_balloon(struct virtio_balloon *vb, 
size_t num)
return num_allocated_pages;
 }
 
-static void release_pages_balloon(struct virtio_balloon *vb)
+static void release_pages_balloon(struct virtio_balloon *vb,
+struct list_head *pages)
 {
-   unsigned int i;
-   struct page *page;
+   struct page *page, *next;
 
-   /* Find pfns pointing at start of each page, get pages and free them. */
-   for (i = 0; i < vb->num_pfns; i += VIRTIO_BALLOON_PAGES_PER_PAGE) {
-   page = balloon_pfn_to_page(virtio32_to_cpu(vb->vdev,
-  vb->pfns[i]));
+   list_for_each_entry_safe(page, next, pages, lru) {
if (!virtio_has_feature(vb->vdev,
VIRTIO_BALLOON_F_DEFLATE_ON_OOM))
adjust_managed_page_count(page, 1);
+   list_del(&page->lru);
put_page(page); /* balloon reference */
}
 }
@@ -202,6 +194,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
unsigned num_freed_pages;
struct page *page;
struct balloon_dev_info *vb_dev_info = &vb->vb_dev_info;
+   LIST_HEAD(pages);
 
/* We can only do one array worth at a time. */
num = min(num, ARRAY_SIZE(vb->pfns));
@@ -215,6 +208,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
if (!page)
break;
set_page_pfns(vb, vb->pfns + vb->num_pfns, page);
+   list_add(&page->lru, &pages);
vb->num_pages -= VIRTIO_BALLOON_PAGES_PER_PAGE;
}
 
@@ -226,7 +220,7 @@ static unsigned leak_balloon(struct virtio_balloon *vb, 
size_t num)
 */
if (vb->num_pfns != 0)
tell_host(vb, vb->deflate_vq);
-   release_pages_balloon(vb);
+   release_pages_balloon(vb, &pages);
mutex_unlock(&vb->balloon_lock);
return num_freed_pages;
 }
-- 
1.8.3.1




[Qemu-devel] [PATCH kernel v5 5/5] virtio-balloon: tell host vm's unused page info

2016-11-30 Thread Liang Li
This patch contains two parts:

One is to add a new API to mm go get the unused page information.
The virtio balloon driver will use this new API added to get the
unused page info and send it to hypervisor(QEMU) to speed up live
migration. During sending the bitmap, some the pages may be modified
and are used by the guest, this inaccuracy can be corrected by the
dirty page logging mechanism.

One is to add support the request for vm's unused page information,
QEMU can make use of unused page information and the dirty page
logging mechanism to skip the transportation of some of these unused
pages, this is very helpful to reduce the network traffic and speed
up the live migration process.

Signed-off-by: Liang Li 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 126 +---
 include/linux/mm.h  |   3 +-
 mm/page_alloc.c |  72 +++
 3 files changed, 193 insertions(+), 8 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index c3ddec3..2626cc0 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -56,7 +56,7 @@
 
 struct virtio_balloon {
struct virtio_device *vdev;
-   struct virtqueue *inflate_vq, *deflate_vq, *stats_vq;
+   struct virtqueue *inflate_vq, *deflate_vq, *stats_vq, *req_vq;
 
/* The balloon servicing is delegated to a freezable workqueue. */
struct work_struct update_balloon_stats_work;
@@ -75,6 +75,8 @@ struct virtio_balloon {
void *resp_hdr;
/* Pointer to the start address of response data. */
unsigned long *resp_data;
+   /* Size of response data buffer. */
+   unsigned long resp_buf_size;
/* Pointer offset of the response data. */
unsigned long resp_pos;
/* Bitmap and bitmap count used to tell the host the pages */
@@ -83,6 +85,8 @@ struct virtio_balloon {
unsigned int nr_page_bmap;
/* Used to record the processed pfn range */
unsigned long min_pfn, max_pfn, start_pfn, end_pfn;
+   /* Request header */
+   struct virtio_balloon_req_hdr req_hdr;
/*
 * The pages we've told the Host we're not using are enqueued
 * at vb_dev_info->pages list.
@@ -551,6 +555,58 @@ static void update_balloon_stats(struct virtio_balloon *vb)
pages_to_bytes(available));
 }
 
+static void send_unused_pages_info(struct virtio_balloon *vb,
+   unsigned long req_id)
+{
+   struct scatterlist sg_in;
+   unsigned long pos = 0;
+   struct virtqueue *vq = vb->req_vq;
+   struct virtio_balloon_resp_hdr *hdr = vb->resp_hdr;
+   int ret, order;
+
+   mutex_lock(&vb->balloon_lock);
+
+   for (order = MAX_ORDER - 1; order >= 0; order--) {
+   pos = 0;
+   ret = get_unused_pages(vb->resp_data,
+vb->resp_buf_size / sizeof(unsigned long),
+order, &pos);
+   if (ret == -ENOSPC) {
+   void *new_resp_data;
+
+   new_resp_data = kmalloc(2 * vb->resp_buf_size,
+   GFP_KERNEL);
+   if (new_resp_data) {
+   kfree(vb->resp_data);
+   vb->resp_data = new_resp_data;
+   vb->resp_buf_size *= 2;
+   order++;
+   continue;
+   } else
+   dev_warn(&vb->vdev->dev,
+"%s: omit some %d order pages\n",
+__func__, order);
+   }
+
+   if (pos > 0) {
+   vb->resp_pos = pos;
+   hdr->cmd = BALLOON_GET_UNUSED_PAGES;
+   hdr->id = req_id;
+   if (order > 0)
+   hdr->flag = BALLOON_FLAG_CONT;
+   else
+   hdr->flag = BALLOON_FLAG_DONE;
+
+   send_resp_data(vb, vq, true);
+   }
+   }
+
+   mutex_unlock(&vb->balloon_lock);
+   sg_init_one(&sg_in, &vb->req_hdr, sizeof(vb->req_hdr));
+   virtqueue_add_inbuf(vq, &sg_in, 1, &vb->req_hdr, GFP_KERNEL);
+   virtqueue_kick(vq);
+}
+
 /*
  * While most virtqueues communicate guest-initiated requests to the 
hypervisor,
  * the stats queue operates in reverse.  The driver initializes the virtqueue
@@ -685,18 +741,56 @@ static void update_balloon_size_func(struct work_struct 
*work)
queue_work(system_freezable_wq, work);
 }
 
+static void misc_handle_rq(struct virtio_balloon *vb)
+{
+   struct virtio_balloon_req_hdr *ptr_hdr;
+

Re: [Qemu-devel] [PATCH v7 RFC] block/vxhs: Initial commit to add Veritas HyperScale VxHS block device support

2016-11-30 Thread Stefan Hajnoczi
On Mon, Nov 28, 2016 at 02:17:56PM +, Stefan Hajnoczi wrote:
> Please take a look at vhost-user-scsi, which folks from Nutanix are
> currently working on.  See "[PATCH v2 0/3] Introduce vhost-user-scsi and
> sample application" on qemu-devel.  It is a true zero-copy local I/O tap
> because it shares guest RAM.  This is more efficient than cross memory
> attach's single memory copy.  It does not require running the server as
> root.  This is the #1 thing you should evaluate for your final
> architecture.
> 
> vhost-user-scsi works on the virtio-scsi emulation level.  That means
> the server must implement the virtio-scsi vring and device emulation.
> It is not a block driver.  By hooking in at this level you can achieve
> the best performance but you lose all QEMU block layer functionality and
> need to implement your own SCSI target.  You also need to consider live
> migration.

To clarify why I think vhost-user-scsi is best suited to your
requirements for performance:

With vhost-user-scsi the qnio server would be notified by kvm.ko via
eventfd when the VM submits new I/O requests to the virtio-scsi HBA.
The QEMU process is completely bypassed for I/O request submission and
the qnio server processes the SCSI command instead.  This avoids the
context switch to QEMU and then to the qnio server.  With cross memory
attach QEMU first needs to process the I/O request and hand it to
libqnio before the qnio server can be scheduled.

The vhost-user-scsi qnio server has shared memory access to guest RAM
and is therefore able to do zero-copy I/O into guest buffers.  Cross
memory attach always incurs a memory copy.

Using this high-performance architecture requires significant changes
though.  vhost-user-scsi hooks into the stack at a different layer so a
QEMU block driver is not used at all.  QEMU also wouldn't use libqnio.
Instead everything will live in your qnio server process (not part of
QEMU).

You'd have to rethink the resiliency strategy because you currently rely
on the QEMU block driver connecting to a different qnio server if the
local qnio server fails.  In the vhost-user-scsi world it's more like
having a phyiscal SCSI adapter - redundancy and multipathing are used to
achieve resiliency.

For example, virtio-scsi HBA #1 would connect to the local qnio server
process.  virtio-scsi HBA #2 would connect to another local process
called the "proxy process" which forwards requests to a remote qnio
server (using libqnio?).  If HBA #1 fails then I/O is sent to HBA #2
instead.  The path can reset back to HBA #1 once that becomes
operational again.

If the qnio server is supposed to run in a VM instead of directly in the
host environment then it's worth looking at the vhost-pci work that Wei
Wang  is working on.  The email thread is called
"[PATCH v2 0/4] *** vhost-user spec extension for vhost-pci ***".  The
idea here is to allow inter-VM virtio device emulation so that instead
of terminating the virtio-scsi device in the qnio server process on the
host, you can terminate it inside another VM with good performance
characteristics.

Stefan


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH kernel v5 2/5] virtio-balloon: define new feature bit and head struct

2016-11-30 Thread Liang Li
Add a new feature which supports sending the page information with
a bitmap. The current implementation uses PFNs array, which is not
very efficient. Using bitmap can improve the performance of
inflating/deflating significantly

The page bitmap header will used to tell the host some information
about the page bitmap. e.g. the page size, page bitmap length and
start pfn.

Signed-off-by: Liang Li 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/uapi/linux/virtio_balloon.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/include/uapi/linux/virtio_balloon.h 
b/include/uapi/linux/virtio_balloon.h
index 343d7dd..1be4b1f 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -34,6 +34,7 @@
 #define VIRTIO_BALLOON_F_MUST_TELL_HOST0 /* Tell before reclaiming 
pages */
 #define VIRTIO_BALLOON_F_STATS_VQ  1 /* Memory Stats virtqueue */
 #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM2 /* Deflate balloon on OOM */
+#define VIRTIO_BALLOON_F_PAGE_BITMAP   3 /* Send page info with bitmap */
 
 /* Size of a PFN in the balloon interface. */
 #define VIRTIO_BALLOON_PFN_SHIFT 12
@@ -82,4 +83,22 @@ struct virtio_balloon_stat {
__virtio64 val;
 } __attribute__((packed));
 
+/* Response header structure */
+struct virtio_balloon_resp_hdr {
+   __le64 cmd : 8; /* Distinguish different requests type */
+   __le64 flag: 8; /* Mark status for a specific request type */
+   __le64 id : 16; /* Distinguish requests of a specific type */
+   __le64 data_len: 32; /* Length of the following data, in bytes */
+};
+
+/* Page bitmap header structure */
+struct virtio_balloon_bmap_hdr {
+   struct {
+   __le64 start_pfn : 52; /* start pfn for the bitmap */
+   __le64 page_shift : 6; /* page shift width, in bytes */
+   __le64 bmap_len : 6;  /* bitmap length, in bytes */
+   } head;
+   __le64 bmap[0];
+};
+
 #endif /* _LINUX_VIRTIO_BALLOON_H */
-- 
1.8.3.1




[Qemu-devel] [PATCH kernel v5 3/5] virtio-balloon: speed up inflate/deflate process

2016-11-30 Thread Liang Li
The implementation of the current virtio-balloon is not very
efficient, the time spends on different stages of inflating
the balloon to 7GB of a 8GB idle guest:

a. allocating pages (6.5%)
b. sending PFNs to host (68.3%)
c. address translation (6.1%)
d. madvise (19%)

It takes about 4126ms for the inflating process to complete.
Debugging shows that the bottle neck are the stage b and stage d.

If using a bitmap to send the page info instead of the PFNs, we
can reduce the overhead in stage b quite a lot. Furthermore, we
can do the address translation and call madvise() with a bulk of
RAM pages, instead of the current page per page way, the overhead
of stage c and stage d can also be reduced a lot.

This patch is the kernel side implementation which is intended to
speed up the inflating & deflating process by adding a new feature
to the virtio-balloon device. With this new feature, inflating the
balloon to 7GB of a 8GB idle guest only takes 590ms, the
performance improvement is about 85%.

TODO: optimize stage a by allocating/freeing a chunk of pages
instead of a single page at a time.

Signed-off-by: Liang Li 
Suggested-by: Michael S. Tsirkin 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 drivers/virtio/virtio_balloon.c | 395 +---
 1 file changed, 367 insertions(+), 28 deletions(-)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index f59cb4f..c3ddec3 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -42,6 +42,10 @@
 #define OOM_VBALLOON_DEFAULT_PAGES 256
 #define VIRTBALLOON_OOM_NOTIFY_PRIORITY 80
 
+#define BALLOON_BMAP_SIZE  (8 * PAGE_SIZE)
+#define PFNS_PER_BMAP  (BALLOON_BMAP_SIZE * BITS_PER_BYTE)
+#define BALLOON_BMAP_COUNT 32
+
 static int oom_pages = OOM_VBALLOON_DEFAULT_PAGES;
 module_param(oom_pages, int, S_IRUSR | S_IWUSR);
 MODULE_PARM_DESC(oom_pages, "pages to free on OOM");
@@ -67,6 +71,18 @@ struct virtio_balloon {
 
/* Number of balloon pages we've told the Host we're not using. */
unsigned int num_pages;
+   /* Pointer to the response header. */
+   void *resp_hdr;
+   /* Pointer to the start address of response data. */
+   unsigned long *resp_data;
+   /* Pointer offset of the response data. */
+   unsigned long resp_pos;
+   /* Bitmap and bitmap count used to tell the host the pages */
+   unsigned long *page_bitmap[BALLOON_BMAP_COUNT];
+   /* Number of split page bitmaps */
+   unsigned int nr_page_bmap;
+   /* Used to record the processed pfn range */
+   unsigned long min_pfn, max_pfn, start_pfn, end_pfn;
/*
 * The pages we've told the Host we're not using are enqueued
 * at vb_dev_info->pages list.
@@ -110,20 +126,228 @@ static void balloon_ack(struct virtqueue *vq)
wake_up(&vb->acked);
 }
 
-static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
+static inline void init_bmap_pfn_range(struct virtio_balloon *vb)
 {
-   struct scatterlist sg;
+   vb->min_pfn = ULONG_MAX;
+   vb->max_pfn = 0;
+}
+
+static inline void update_bmap_pfn_range(struct virtio_balloon *vb,
+struct page *page)
+{
+   unsigned long balloon_pfn = page_to_balloon_pfn(page);
+
+   vb->min_pfn = min(balloon_pfn, vb->min_pfn);
+   vb->max_pfn = max(balloon_pfn, vb->max_pfn);
+}
+
+static void extend_page_bitmap(struct virtio_balloon *vb,
+   unsigned long nr_pfn)
+{
+   int i, bmap_count;
+   unsigned long bmap_len;
+
+   bmap_len = ALIGN(nr_pfn, BITS_PER_LONG) / BITS_PER_BYTE;
+   bmap_len = ALIGN(bmap_len, BALLOON_BMAP_SIZE);
+   bmap_count = min((int)(bmap_len / BALLOON_BMAP_SIZE),
+BALLOON_BMAP_COUNT);
+
+   for (i = 1; i < bmap_count; i++) {
+   vb->page_bitmap[i] = kmalloc(BALLOON_BMAP_SIZE, GFP_KERNEL);
+   if (vb->page_bitmap[i])
+   vb->nr_page_bmap++;
+   else
+   break;
+   }
+}
+
+static void free_extended_page_bitmap(struct virtio_balloon *vb)
+{
+   int i, bmap_count = vb->nr_page_bmap;
+
+
+   for (i = 1; i < bmap_count; i++) {
+   kfree(vb->page_bitmap[i]);
+   vb->page_bitmap[i] = NULL;
+   vb->nr_page_bmap--;
+   }
+}
+
+static void kfree_page_bitmap(struct virtio_balloon *vb)
+{
+   int i;
+
+   for (i = 0; i < vb->nr_page_bmap; i++)
+   kfree(vb->page_bitmap[i]);
+}
+
+static void clear_page_bitmap(struct virtio_balloon *vb)
+{
+   int i;
+
+   for (i = 0; i < vb->nr_page_bmap; i++)
+   memset(vb->page_bitmap[i], 0, BALLOON_BMAP_SIZE);
+}
+
+static unsigned long do_set_resp_bitmap(struct virtio_balloon *vb,
+   unsigned long *bitmap,  unsigned long base_pfn,
+   unsigned long pos, int nr_page)
+
+{
+   s

Re: [Qemu-devel] qemu-system-sh4 vs qemu-system-arm/i386 default behavior

2016-11-30 Thread Aurelien Jarno
On 2016-11-30 08:33, Thomas Huth wrote:
> On 30.11.2016 02:01, Tom Rini wrote:
> > Hey all,
> > 
> > I'm trying to make use of the r2d platform for U-Boot testing via QEMU.
> > After applying a series[1] I can use the kernel.org sh4 toolchain to get
> > a u-boot.bin that runs, mostly.  I say mostly as first of all I have to
> > pass "-monitor null -serial null -serial stdio -nographic" to
> > qemu-system-sh4 and in that order for me to get output from U-Boot on
> > the prompt.  On other platforms such as arm and vexpress or i386 and the
> > 'pc' machine I do not need to do this.  Does anyone have any idea why
> > this might be and where to start poking in the code to fix this?

The reason is that u-boot and the linux kernel do not have the same way
to number the serial port than the physical hardware. Therefore u-boot
and the Linux kernel use the second physical serial port .The question is
whether we should number our ports from the software (or part of the
sofrware) or hardware point of view.

> The "-serial" parameter is related to the serial_hds[] array in the
> code, so you could search for that one.
> 
> The following line in hw/sh4/r2d.c looks somewhat suspicious:
> 
> sm501_init(address_space_mem, 0x1000, SM501_VRAM_SIZE,
>irq[SM501], serial_hds[2]);
> 
> Why is this machine always using serial_hds[2] and not a lower index?
> ... Maybe the maintainer of the board (Magnus) knows the answer here...

The third serial port is provided by the graphic chipset. The first two
serial ports are provided by the SH7750 CPU, see in hw/sh4/sh7750.c.

Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH kernel v5 4/5] virtio-balloon: define flags and head for host request vq

2016-11-30 Thread Liang Li
Define the flags and head struct for a new host request virtual
queue. Guest can get requests from host and then responds to them on
this new virtual queue.
Host can make use of this virtual queue to request the guest do some
operations, e.g. drop page cache, synchronize file system, etc.
And the hypervisor can get some of guest's runtime information
through this virtual queue too, e.g. the guest's unused page
information, which can be used for live migration optimization.

Signed-off-by: Liang Li 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: Michael S. Tsirkin 
Cc: Paolo Bonzini 
Cc: Cornelia Huck 
Cc: Amit Shah 
Cc: Dave Hansen 
---
 include/uapi/linux/virtio_balloon.h | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/include/uapi/linux/virtio_balloon.h 
b/include/uapi/linux/virtio_balloon.h
index 1be4b1f..5ac3a40 100644
--- a/include/uapi/linux/virtio_balloon.h
+++ b/include/uapi/linux/virtio_balloon.h
@@ -35,6 +35,7 @@
 #define VIRTIO_BALLOON_F_STATS_VQ  1 /* Memory Stats virtqueue */
 #define VIRTIO_BALLOON_F_DEFLATE_ON_OOM2 /* Deflate balloon on OOM */
 #define VIRTIO_BALLOON_F_PAGE_BITMAP   3 /* Send page info with bitmap */
+#define VIRTIO_BALLOON_F_HOST_REQ_VQ   4 /* Host request virtqueue */
 
 /* Size of a PFN in the balloon interface. */
 #define VIRTIO_BALLOON_PFN_SHIFT 12
@@ -101,4 +102,25 @@ struct virtio_balloon_bmap_hdr {
__le64 bmap[0];
 };
 
+enum virtio_balloon_req_id {
+   /* Get unused page information */
+   BALLOON_GET_UNUSED_PAGES,
+};
+
+enum virtio_balloon_flag {
+   /* Have more data for a request */
+   BALLOON_FLAG_CONT,
+   /* No more data for a request */
+   BALLOON_FLAG_DONE,
+};
+
+struct virtio_balloon_req_hdr {
+   /* Used to distinguish different requests */
+   __le16 cmd;
+   /* Reserved */
+   __le16 reserved[3];
+   /* Request parameter */
+   __le64 param;
+};
+
 #endif /* _LINUX_VIRTIO_BALLOON_H */
-- 
1.8.3.1




Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Andrew Jones
On Wed, Nov 30, 2016 at 07:19:12AM +, Peter Maydell wrote:
> On 29 November 2016 at 19:38, Andrew Jones  wrote:
> > Thanks for making me look, I was simply assuming we were in the while
> > loops above.
> >
> > I couldn't get the problem to reproduce with access to the monitor,
> > but by adding '-d exec' I was able to see cpu0 was on the wfe in
> > smp_boot_secondary. It should only stay there until cpu1 executes the
> > sev in secondary_cinit, but it looks like TCG doesn't yet implement sev
> >
> >  $ grep SEV target-arm/translate.c
> > /* TODO: Implement SEV, SEVL and WFE.  May help SMP performance.
> 
> Yes, we currently NOP SEV. We only implement WFE as "yield back
> to TCG top level loop", though, so this is fine. The idea is
> that WFE gets used in busy loops so it's a helpful hint to
> try running some other TCG vCPU instead of just spinning in
> the guest on this one. Implementing SEV as a NOP and WFE as
> a more-or-less NOP is architecturally permitted (guest code
> is required to cope with WFE returning "early"). If something
> is not working correctly then it's either buggy guest code
> or a problem with the generic TCG scheduling of CPUs.

The problem is indeed with the scheduling. The way it currently works
is to depend on the iothread to kick a reschedule once in a while, or
a cpu to issue an instruction that does so (wfe/wfi). However if
there's no io and a cpu never issues a scheduling instruction, then it
won't happen. We either need a sched tick or to never have an infinite
iothread ppoll timeout (basically using the ppoll timeout as a tick).

As for being buggy guest code, I don't think so. Here's another
unit test that illustrates the issue taking wfe/sev out.

 #include 
 void secondary(void) {
 printf("secondary running\n");
 asm("yield");

 /* A "real" guest cpu shouldn't do this, but even if it
  * does, that shouldn't stop other cpus from running.
  */
 while(1);
 }
 int main(void) {
 smp_boot_secondary(1, secondary);
 printf("primary running\n");
 asm("yield");
 return 0;
 }

With that test we get the two print statements, but it never exits.

Now that I understand the problem much better, I think I may be
coming full circle and advocating the iothread's ppoll never be
allowed to have an infinite timeout again, but now only for tcg.
Something like

 if (timeout < 0 && tcg_enabled())
timeout = TCG_SCHED_TICK;

Thanks,
drew



Re: [Qemu-devel] qemu-system-sh4 vs qemu-system-arm/i386 default behavior

2016-11-30 Thread Thomas Huth
On 30.11.2016 09:02, Aurelien Jarno wrote:
> On 2016-11-30 08:33, Thomas Huth wrote:
>> On 30.11.2016 02:01, Tom Rini wrote:
>>> Hey all,
>>>
>>> I'm trying to make use of the r2d platform for U-Boot testing via QEMU.
>>> After applying a series[1] I can use the kernel.org sh4 toolchain to get
>>> a u-boot.bin that runs, mostly.  I say mostly as first of all I have to
>>> pass "-monitor null -serial null -serial stdio -nographic" to
>>> qemu-system-sh4 and in that order for me to get output from U-Boot on
>>> the prompt.  On other platforms such as arm and vexpress or i386 and the
>>> 'pc' machine I do not need to do this.  Does anyone have any idea why
>>> this might be and where to start poking in the code to fix this?
> 
> The reason is that u-boot and the linux kernel do not have the same way
> to number the serial port than the physical hardware. Therefore u-boot
> and the Linux kernel use the second physical serial port .The question is
> whether we should number our ports from the software (or part of the
> sofrware) or hardware point of view.

OK, thanks for the explanation, that makes sense now. ... maybe we
should put this information on a SH4 machine page under
http://qemu-project.org/Documentation/Platforms so that users have a
possibility to understand this serial port numbering?

 Thomas




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v7 0/5] IOMMU: intel_iommu support map and unmap notifications

2016-11-30 Thread Peter Xu
On Mon, Nov 28, 2016 at 05:51:50PM +0200, Aviv B.D wrote:
> * intel_iommu's replay op is not implemented yet (May come in different patch 
>   set).
>   The replay function is required for hotplug vfio device and to move devices 
>   between existing domains.

I am thinking about this replay thing recently and now I start to
doubt whether the whole vt-d vIOMMU framework suites this...

Generally speaking, current work is throwing away the IOMMU "domain"
layer here. We maintain the mapping only per device, and we don't care
too much about which domain it belongs. This seems problematic.

A simplest wrong case for this is (let's assume cache-mode is
enabled): if we have two assigned devices A and B, both belong to the
same domain 1. Meanwhile, in domain 1 assume we have one mapping which
is the first page (iova range 0-0xfff). Then, if guest wants to
invalidate the page, it'll notify VT-d vIOMMU with an invalidation
message. If we do this invalidation per-device, we'll need to UNMAP
the region twice - once for A, once for B (if we have more devices, we
will unmap more times), and we can never know we have done duplicated
work since we don't keep domain info, so we don't know they are using
the same address space. The first unmap will work, and then we'll
possibly get some errors on the rest of dma unmap failures.

Looks like we just cannot live without knowing this domain layer.
Because the address space is binded to the domain. If we want to sync
the address space (here to setup a correct shadow page table), we need
to do it per-domain.

What I can think of as a solution is that we introduce this "domain"
layer - like a memory region per domain. When invalidation happens,
it's per-domain, not per-device any more (actually I guess that's what
current vt-d iommu driver in kernel is doing, we just ignored it - we
fetch the devices that matches the domain ID). We can/need to maintain
something different, like sid <-> domain mappings (we can do this as
long as we are notified when context entries changed), per-domain
mappings (just like per-device mappings that we are trying to build in
this series, but what we really need is IMHO per domain one), etc.
When device switches domain, we switch the IOMMU memory region
accordingly.

Does this make any sense? Comments are greatly welcomed (especially
from AlexW and DavidG).

Thanks,

-- peterx



Re: [Qemu-devel] [PATCH] net: mcf: check receive buffer size register value

2016-11-30 Thread Jason Wang



On 2016年11月29日 03:08, P J P wrote:

From: Prasad J Pandit 

ColdFire Fast Ethernet Controller uses a receive buffer size
register(EMRBR) to hold maximum size of all receive buffers.
It is set by a user before any operation. If it was set to be
zero, ColdFire emulator would go into an infinite loop while
receiving data in mcf_fec_receive. Add check to avoid it.

Reported-by: Wjjzhang 
Signed-off-by: Prasad J Pandit 
---
  hw/net/mcf_fec.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 0ee8ad9..13631e0 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -392,7 +392,7 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
  s->tx_descriptor = s->etdsr;
  break;
  case 0x188:
-s->emrbr = value & 0x7f0;
+s->emrbr = value > 0 ? value & 0x7F0 : 0x7F0;
  break;
  default:
  hw_error("mcf_fec_write Bad address 0x%x\n", (int)addr);


Applied, thanks.



Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Peter Maydell
On 30 November 2016 at 09:05, Andrew Jones  wrote:
> The problem is indeed with the scheduling. The way it currently works
> is to depend on the iothread to kick a reschedule once in a while, or
> a cpu to issue an instruction that does so (wfe/wfi). However if
> there's no io and a cpu never issues a scheduling instruction, then it
> won't happen. We either need a sched tick or to never have an infinite
> iothread ppoll timeout (basically using the ppoll timeout as a tick).

Ah yes, that one. I thought Alex had a patch which added
a timer to ensure that we don't allow a single guest
TCG vCPU to hog the execution thread, but maybe I'm
misremembering.

thanks
-- PMM



[Qemu-devel] [RFC for-2.9 00/11] Move target-* CPU file into a target/ folder

2016-11-30 Thread Thomas Huth
We've currently got 18 architectures in QEMU, and thus 18 target-xxx
folders in the root folder of the QEMU source tree. More architectures
(e.g. RISC-V, AVR) are likely to be included soon, too, so the main
folder of the QEMU sources slowly gets quite overcrowded with the
target-xxx folders.
Thus I'd like to suggest that we move the target-xxx folders into
a dedicated target/ folder, so that target-xxx/ simply becomes
target/xxx/ instead.

The first patch is the most important one here, it prepares the
build system to be able to deal with both, target-xxx and target/xxx
folders. Once that has been applied, each target architecture
could be moved to the target/ folder when it is convenient for the
subsytem maintainer to do the move (i.e. we do not have to move all
files immediately in one go). So if we agree to do this change and
the first patch has been committed, I could rather send the following
patches step by step to the maintainers so they can queue the patch
for their subsystem for a good point in time. And new architectures
like RISC-V and AVR could start in the target/ folder immediately
instead.

So please provide some feedback: Is this a good idea? Or do you
consider this rather just as unnecessary code churn instead?

(Note: This patch series does also not contain all targets yet,
I first would like to get some feedback before continuing this work)

Thomas Huth (11):
  Makefile: Allow CPU targets to reside in target/ folder, too
  tilegx: Move CPU files to target/ folder
  m68k: Move CPU files to target/ folder
  alpha: Move CPU files to target/ folder
  arm: Move CPU files to target/ folder
  ppc: Move CPU files to target/ folder
  i386: Move CPU files to target/ folder
  microblaze: Move CPU files to target/ folder
  mips: Move CPU files to target/ folder
  s390x: Move CPU files to target/ folder
  sparc: Move CPU files to target/ folder

 MAINTAINERS| 32 +++---
 Makefile.objs  | 10 +++
 Makefile.target| 10 +--
 hw/alpha/alpha_sys.h   |  2 +-
 hw/arm/strongarm.h |  2 +-
 hw/arm/virt-acpi-build.c   |  2 +-
 hw/i386/acpi-build.c   |  2 +-
 hw/i386/kvm/apic.c |  2 +-
 hw/intc/ioapic.c   |  2 +-
 hw/misc/hyperv_testdev.c   |  2 +-
 hw/ppc/fdt.c   |  2 +-
 hw/ppc/pnv.c   |  2 +-
 hw/ppc/pnv_core.c  |  2 +-
 hw/ppc/pnv_lpc.c   |  2 +-
 hw/ppc/pnv_xscom.c |  2 +-
 hw/ppc/spapr_cpu_core.c|  6 ++--
 include/hw/arm/arm.h   |  2 +-
 include/hw/arm/exynos4210.h|  2 +-
 include/hw/arm/omap.h  |  2 +-
 include/hw/arm/pxa.h   |  2 +-
 include/hw/m68k/mcf.h  |  2 +-
 include/hw/mips/cpudevs.h  |  2 +-
 include/hw/ppc/fdt.h   |  2 +-
 include/hw/ppc/ppc.h   |  2 +-
 include/hw/ppc/spapr_cpu_core.h|  2 +-
 scripts/analyze-inclusions |  6 ++--
 {target-alpha => target/alpha}/Makefile.objs   |  0
 {target-alpha => target/alpha}/STATUS  |  0
 {target-alpha => target/alpha}/cpu-qom.h   |  0
 {target-alpha => target/alpha}/cpu.c   |  0
 {target-alpha => target/alpha}/cpu.h   |  0
 {target-alpha => target/alpha}/fpu_helper.c|  0
 {target-alpha => target/alpha}/gdbstub.c   |  0
 {target-alpha => target/alpha}/helper.c|  0
 {target-alpha => target/alpha}/helper.h|  0
 {target-alpha => target/alpha}/int_helper.c|  0
 {target-alpha => target/alpha}/machine.c   |  0
 {target-alpha => target/alpha}/mem_helper.c|  0
 {target-alpha => target/alpha}/sys_helper.c|  0
 {target-alpha => target/alpha}/translate.c |  0
 {target-alpha => target/alpha}/vax_helper.c|  0
 {target-arm => target/arm}/Makefile.objs   |  0
 {target-arm => target/arm}/arch_dump.c |  0
 {target-arm => target/arm}/arm-powerctl.c  |  0
 {target-arm => target/arm}/arm-powerctl.h  |  0
 {target-arm => target/arm}/arm-semi.c  |  0
 {target-arm => target/arm}/arm_ldst.h  |  0
 {target-arm => target/arm}/cpu-qom.h   |  0
 {target-arm => target/arm}/cpu.c   |  0
 {target-arm => target/arm}/cpu.h   |  0
 {target-arm => target/arm}/cpu64.c |  0
 {target-arm => target/arm}/crypto_helper.c |  0
 {target-arm => target/arm}/gdbstub.c 

[Qemu-devel] [RFC for-2.9 09/11] mips: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 4 ++--
 include/hw/mips/cpudevs.h | 2 +-
 {target-mips => target/mips}/Makefile.objs| 0
 {target-mips => target/mips}/TODO | 0
 {target-mips => target/mips}/cpu-qom.h| 0
 {target-mips => target/mips}/cpu.c| 0
 {target-mips => target/mips}/cpu.h| 0
 {target-mips => target/mips}/dsp_helper.c | 0
 {target-mips => target/mips}/gdbstub.c| 0
 {target-mips => target/mips}/helper.c | 0
 {target-mips => target/mips}/helper.h | 0
 {target-mips => target/mips}/kvm.c| 0
 {target-mips => target/mips}/kvm_mips.h   | 0
 {target-mips => target/mips}/lmi_helper.c | 0
 {target-mips => target/mips}/machine.c| 0
 {target-mips => target/mips}/mips-defs.h  | 0
 {target-mips => target/mips}/mips-semi.c  | 0
 {target-mips => target/mips}/msa_helper.c | 0
 {target-mips => target/mips}/op_helper.c  | 0
 {target-mips => target/mips}/translate.c  | 0
 {target-mips => target/mips}/translate_init.c | 0
 21 files changed, 3 insertions(+), 3 deletions(-)
 rename {target-mips => target/mips}/Makefile.objs (100%)
 rename {target-mips => target/mips}/TODO (100%)
 rename {target-mips => target/mips}/cpu-qom.h (100%)
 rename {target-mips => target/mips}/cpu.c (100%)
 rename {target-mips => target/mips}/cpu.h (100%)
 rename {target-mips => target/mips}/dsp_helper.c (100%)
 rename {target-mips => target/mips}/gdbstub.c (100%)
 rename {target-mips => target/mips}/helper.c (100%)
 rename {target-mips => target/mips}/helper.h (100%)
 rename {target-mips => target/mips}/kvm.c (100%)
 rename {target-mips => target/mips}/kvm_mips.h (100%)
 rename {target-mips => target/mips}/lmi_helper.c (100%)
 rename {target-mips => target/mips}/machine.c (100%)
 rename {target-mips => target/mips}/mips-defs.h (100%)
 rename {target-mips => target/mips}/mips-semi.c (100%)
 rename {target-mips => target/mips}/msa_helper.c (100%)
 rename {target-mips => target/mips}/op_helper.c (100%)
 rename {target-mips => target/mips}/translate.c (100%)
 rename {target-mips => target/mips}/translate_init.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index c7b1a3f..fb6c3a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,7 +161,7 @@ MIPS
 M: Aurelien Jarno 
 M: Yongbok Kim 
 S: Maintained
-F: target-mips/
+F: target/mips/
 F: hw/mips/
 F: hw/misc/mips_*
 F: hw/intc/mips_gic.c
@@ -274,7 +274,7 @@ F: target/arm/kvm.c
 MIPS
 M: James Hogan 
 S: Maintained
-F: target-mips/kvm.c
+F: target/mips/kvm.c
 
 PPC
 M: Alexander Graf 
diff --git a/include/hw/mips/cpudevs.h b/include/hw/mips/cpudevs.h
index 8673daa..31f5319 100644
--- a/include/hw/mips/cpudevs.h
+++ b/include/hw/mips/cpudevs.h
@@ -1,7 +1,7 @@
 #ifndef HW_MIPS_CPUDEVS_H
 #define HW_MIPS_CPUDEVS_H
 
-#include "target-mips/cpu-qom.h"
+#include "cpu-qom.h"
 
 /* Definitions for MIPS CPU internal devices.  */
 
diff --git a/target-mips/Makefile.objs b/target/mips/Makefile.objs
similarity index 100%
rename from target-mips/Makefile.objs
rename to target/mips/Makefile.objs
diff --git a/target-mips/TODO b/target/mips/TODO
similarity index 100%
rename from target-mips/TODO
rename to target/mips/TODO
diff --git a/target-mips/cpu-qom.h b/target/mips/cpu-qom.h
similarity index 100%
rename from target-mips/cpu-qom.h
rename to target/mips/cpu-qom.h
diff --git a/target-mips/cpu.c b/target/mips/cpu.c
similarity index 100%
rename from target-mips/cpu.c
rename to target/mips/cpu.c
diff --git a/target-mips/cpu.h b/target/mips/cpu.h
similarity index 100%
rename from target-mips/cpu.h
rename to target/mips/cpu.h
diff --git a/target-mips/dsp_helper.c b/target/mips/dsp_helper.c
similarity index 100%
rename from target-mips/dsp_helper.c
rename to target/mips/dsp_helper.c
diff --git a/target-mips/gdbstub.c b/target/mips/gdbstub.c
similarity index 100%
rename from target-mips/gdbstub.c
rename to target/mips/gdbstub.c
diff --git a/target-mips/helper.c b/target/mips/helper.c
similarity index 100%
rename from target-mips/helper.c
rename to target/mips/helper.c
diff --git a/target-mips/helper.h b/target/mips/helper.h
similarity index 100%
rename from target-mips/helper.h
rename to target/mips/helper.h
diff --git a/target-mips/kvm.c b/target/mips/kvm.c
similarity index 100%
rename from target-mips/kvm.c
rename to target/mips/kvm.c
diff --git a/target-mips/kvm_mips.h b/target/mips/kvm_mips.h
similarity index 100%
rename from target-mips/kvm_mips.h
rename to target/mips/kvm_mips.h
diff --git a/target-mips/lmi_helper.c b/target/mips/lmi_helper.c
similarity index 100%
rename from target-mips/lmi_helper.c
rename to target/mips/lmi_helper.c
diff --git a/target-mips/machine.c b/target/mips/machine.c
similarity index 100%
rename from target-mips/machine.c
rename to target/mips/machine.c
diff --git a/target-mips/mips-defs.h b/target/mips/mips-defs.h
similarity index 100%
rename from target-mips/mips-defs.h
rename to target/mips/mips-defs.h
di

[Qemu-devel] [RFC for-2.9 03/11] m68k: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 2 +-
 include/hw/m68k/mcf.h  | 2 +-
 {target-m68k => target/m68k}/Makefile.objs | 0
 {target-m68k => target/m68k}/cpu-qom.h | 0
 {target-m68k => target/m68k}/cpu.c | 0
 {target-m68k => target/m68k}/cpu.h | 0
 {target-m68k => target/m68k}/gdbstub.c | 0
 {target-m68k => target/m68k}/helper.c  | 0
 {target-m68k => target/m68k}/helper.h  | 0
 {target-m68k => target/m68k}/m68k-semi.c   | 0
 {target-m68k => target/m68k}/op_helper.c   | 0
 {target-m68k => target/m68k}/qregs.def | 0
 {target-m68k => target/m68k}/translate.c   | 0
 13 files changed, 2 insertions(+), 2 deletions(-)
 rename {target-m68k => target/m68k}/Makefile.objs (100%)
 rename {target-m68k => target/m68k}/cpu-qom.h (100%)
 rename {target-m68k => target/m68k}/cpu.c (100%)
 rename {target-m68k => target/m68k}/cpu.h (100%)
 rename {target-m68k => target/m68k}/gdbstub.c (100%)
 rename {target-m68k => target/m68k}/helper.c (100%)
 rename {target-m68k => target/m68k}/helper.h (100%)
 rename {target-m68k => target/m68k}/m68k-semi.c (100%)
 rename {target-m68k => target/m68k}/op_helper.c (100%)
 rename {target-m68k => target/m68k}/qregs.def (100%)
 rename {target-m68k => target/m68k}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4a60579..ce1ee35 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -147,7 +147,7 @@ F: tests/tcg/lm32/
 M68K
 M: Laurent Vivier 
 S: Maintained
-F: target-m68k/
+F: target/m68k/
 F: disas/m68k.c
 
 MicroBlaze
diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h
index 0f0d228..ef8963d 100644
--- a/include/hw/m68k/mcf.h
+++ b/include/hw/m68k/mcf.h
@@ -2,7 +2,7 @@
 #define HW_MCF_H
 /* Motorola ColdFire device prototypes.  */
 
-#include "target-m68k/cpu-qom.h"
+#include "cpu-qom.h"
 
 struct MemoryRegion;
 
diff --git a/target-m68k/Makefile.objs b/target/m68k/Makefile.objs
similarity index 100%
rename from target-m68k/Makefile.objs
rename to target/m68k/Makefile.objs
diff --git a/target-m68k/cpu-qom.h b/target/m68k/cpu-qom.h
similarity index 100%
rename from target-m68k/cpu-qom.h
rename to target/m68k/cpu-qom.h
diff --git a/target-m68k/cpu.c b/target/m68k/cpu.c
similarity index 100%
rename from target-m68k/cpu.c
rename to target/m68k/cpu.c
diff --git a/target-m68k/cpu.h b/target/m68k/cpu.h
similarity index 100%
rename from target-m68k/cpu.h
rename to target/m68k/cpu.h
diff --git a/target-m68k/gdbstub.c b/target/m68k/gdbstub.c
similarity index 100%
rename from target-m68k/gdbstub.c
rename to target/m68k/gdbstub.c
diff --git a/target-m68k/helper.c b/target/m68k/helper.c
similarity index 100%
rename from target-m68k/helper.c
rename to target/m68k/helper.c
diff --git a/target-m68k/helper.h b/target/m68k/helper.h
similarity index 100%
rename from target-m68k/helper.h
rename to target/m68k/helper.h
diff --git a/target-m68k/m68k-semi.c b/target/m68k/m68k-semi.c
similarity index 100%
rename from target-m68k/m68k-semi.c
rename to target/m68k/m68k-semi.c
diff --git a/target-m68k/op_helper.c b/target/m68k/op_helper.c
similarity index 100%
rename from target-m68k/op_helper.c
rename to target/m68k/op_helper.c
diff --git a/target-m68k/qregs.def b/target/m68k/qregs.def
similarity index 100%
rename from target-m68k/qregs.def
rename to target/m68k/qregs.def
diff --git a/target-m68k/translate.c b/target/m68k/translate.c
similarity index 100%
rename from target-m68k/translate.c
rename to target/m68k/translate.c
-- 
1.8.3.1




[Qemu-devel] [RFC for-2.9 08/11] microblaze: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 {target-microblaze => target/microblaze}/Makefile.objs   | 0
 {target-microblaze => target/microblaze}/cpu-qom.h   | 0
 {target-microblaze => target/microblaze}/cpu.c   | 0
 {target-microblaze => target/microblaze}/cpu.h   | 0
 {target-microblaze => target/microblaze}/gdbstub.c   | 0
 {target-microblaze => target/microblaze}/helper.c| 0
 {target-microblaze => target/microblaze}/helper.h| 0
 {target-microblaze => target/microblaze}/microblaze-decode.h | 0
 {target-microblaze => target/microblaze}/mmu.c   | 0
 {target-microblaze => target/microblaze}/mmu.h   | 0
 {target-microblaze => target/microblaze}/op_helper.c | 0
 {target-microblaze => target/microblaze}/translate.c | 0
 13 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-microblaze => target/microblaze}/Makefile.objs (100%)
 rename {target-microblaze => target/microblaze}/cpu-qom.h (100%)
 rename {target-microblaze => target/microblaze}/cpu.c (100%)
 rename {target-microblaze => target/microblaze}/cpu.h (100%)
 rename {target-microblaze => target/microblaze}/gdbstub.c (100%)
 rename {target-microblaze => target/microblaze}/helper.c (100%)
 rename {target-microblaze => target/microblaze}/helper.h (100%)
 rename {target-microblaze => target/microblaze}/microblaze-decode.h (100%)
 rename {target-microblaze => target/microblaze}/mmu.c (100%)
 rename {target-microblaze => target/microblaze}/mmu.h (100%)
 rename {target-microblaze => target/microblaze}/op_helper.c (100%)
 rename {target-microblaze => target/microblaze}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1b064ac..c7b1a3f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -153,7 +153,7 @@ F: disas/m68k.c
 MicroBlaze
 M: Edgar E. Iglesias 
 S: Maintained
-F: target-microblaze/
+F: target/microblaze/
 F: hw/microblaze/
 F: disas/microblaze.c
 
diff --git a/target-microblaze/Makefile.objs b/target/microblaze/Makefile.objs
similarity index 100%
rename from target-microblaze/Makefile.objs
rename to target/microblaze/Makefile.objs
diff --git a/target-microblaze/cpu-qom.h b/target/microblaze/cpu-qom.h
similarity index 100%
rename from target-microblaze/cpu-qom.h
rename to target/microblaze/cpu-qom.h
diff --git a/target-microblaze/cpu.c b/target/microblaze/cpu.c
similarity index 100%
rename from target-microblaze/cpu.c
rename to target/microblaze/cpu.c
diff --git a/target-microblaze/cpu.h b/target/microblaze/cpu.h
similarity index 100%
rename from target-microblaze/cpu.h
rename to target/microblaze/cpu.h
diff --git a/target-microblaze/gdbstub.c b/target/microblaze/gdbstub.c
similarity index 100%
rename from target-microblaze/gdbstub.c
rename to target/microblaze/gdbstub.c
diff --git a/target-microblaze/helper.c b/target/microblaze/helper.c
similarity index 100%
rename from target-microblaze/helper.c
rename to target/microblaze/helper.c
diff --git a/target-microblaze/helper.h b/target/microblaze/helper.h
similarity index 100%
rename from target-microblaze/helper.h
rename to target/microblaze/helper.h
diff --git a/target-microblaze/microblaze-decode.h 
b/target/microblaze/microblaze-decode.h
similarity index 100%
rename from target-microblaze/microblaze-decode.h
rename to target/microblaze/microblaze-decode.h
diff --git a/target-microblaze/mmu.c b/target/microblaze/mmu.c
similarity index 100%
rename from target-microblaze/mmu.c
rename to target/microblaze/mmu.c
diff --git a/target-microblaze/mmu.h b/target/microblaze/mmu.h
similarity index 100%
rename from target-microblaze/mmu.h
rename to target/microblaze/mmu.h
diff --git a/target-microblaze/op_helper.c b/target/microblaze/op_helper.c
similarity index 100%
rename from target-microblaze/op_helper.c
rename to target/microblaze/op_helper.c
diff --git a/target-microblaze/translate.c b/target/microblaze/translate.c
similarity index 100%
rename from target-microblaze/translate.c
rename to target/microblaze/translate.c
-- 
1.8.3.1




[Qemu-devel] [RFC for-2.9 04/11] alpha: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 hw/alpha/alpha_sys.h | 2 +-
 {target-alpha => target/alpha}/Makefile.objs | 0
 {target-alpha => target/alpha}/STATUS| 0
 {target-alpha => target/alpha}/cpu-qom.h | 0
 {target-alpha => target/alpha}/cpu.c | 0
 {target-alpha => target/alpha}/cpu.h | 0
 {target-alpha => target/alpha}/fpu_helper.c  | 0
 {target-alpha => target/alpha}/gdbstub.c | 0
 {target-alpha => target/alpha}/helper.c  | 0
 {target-alpha => target/alpha}/helper.h  | 0
 {target-alpha => target/alpha}/int_helper.c  | 0
 {target-alpha => target/alpha}/machine.c | 0
 {target-alpha => target/alpha}/mem_helper.c  | 0
 {target-alpha => target/alpha}/sys_helper.c  | 0
 {target-alpha => target/alpha}/translate.c   | 0
 {target-alpha => target/alpha}/vax_helper.c  | 0
 17 files changed, 2 insertions(+), 2 deletions(-)
 rename {target-alpha => target/alpha}/Makefile.objs (100%)
 rename {target-alpha => target/alpha}/STATUS (100%)
 rename {target-alpha => target/alpha}/cpu-qom.h (100%)
 rename {target-alpha => target/alpha}/cpu.c (100%)
 rename {target-alpha => target/alpha}/cpu.h (100%)
 rename {target-alpha => target/alpha}/fpu_helper.c (100%)
 rename {target-alpha => target/alpha}/gdbstub.c (100%)
 rename {target-alpha => target/alpha}/helper.c (100%)
 rename {target-alpha => target/alpha}/helper.h (100%)
 rename {target-alpha => target/alpha}/int_helper.c (100%)
 rename {target-alpha => target/alpha}/machine.c (100%)
 rename {target-alpha => target/alpha}/mem_helper.c (100%)
 rename {target-alpha => target/alpha}/sys_helper.c (100%)
 rename {target-alpha => target/alpha}/translate.c (100%)
 rename {target-alpha => target/alpha}/vax_helper.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index ce1ee35..37deb43 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -106,7 +106,7 @@ F: include/fpu/
 Alpha
 M: Richard Henderson 
 S: Maintained
-F: target-alpha/
+F: target/alpha/
 F: hw/alpha/
 F: tests/tcg/alpha/
 F: disas/alpha.c
diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h
index ed911f2..bdabf41 100644
--- a/hw/alpha/alpha_sys.h
+++ b/hw/alpha/alpha_sys.h
@@ -3,7 +3,7 @@
 #ifndef HW_ALPHA_SYS_H
 #define HW_ALPHA_SYS_H
 
-#include "target-alpha/cpu-qom.h"
+#include "cpu-qom.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
 #include "hw/ide.h"
diff --git a/target-alpha/Makefile.objs b/target/alpha/Makefile.objs
similarity index 100%
rename from target-alpha/Makefile.objs
rename to target/alpha/Makefile.objs
diff --git a/target-alpha/STATUS b/target/alpha/STATUS
similarity index 100%
rename from target-alpha/STATUS
rename to target/alpha/STATUS
diff --git a/target-alpha/cpu-qom.h b/target/alpha/cpu-qom.h
similarity index 100%
rename from target-alpha/cpu-qom.h
rename to target/alpha/cpu-qom.h
diff --git a/target-alpha/cpu.c b/target/alpha/cpu.c
similarity index 100%
rename from target-alpha/cpu.c
rename to target/alpha/cpu.c
diff --git a/target-alpha/cpu.h b/target/alpha/cpu.h
similarity index 100%
rename from target-alpha/cpu.h
rename to target/alpha/cpu.h
diff --git a/target-alpha/fpu_helper.c b/target/alpha/fpu_helper.c
similarity index 100%
rename from target-alpha/fpu_helper.c
rename to target/alpha/fpu_helper.c
diff --git a/target-alpha/gdbstub.c b/target/alpha/gdbstub.c
similarity index 100%
rename from target-alpha/gdbstub.c
rename to target/alpha/gdbstub.c
diff --git a/target-alpha/helper.c b/target/alpha/helper.c
similarity index 100%
rename from target-alpha/helper.c
rename to target/alpha/helper.c
diff --git a/target-alpha/helper.h b/target/alpha/helper.h
similarity index 100%
rename from target-alpha/helper.h
rename to target/alpha/helper.h
diff --git a/target-alpha/int_helper.c b/target/alpha/int_helper.c
similarity index 100%
rename from target-alpha/int_helper.c
rename to target/alpha/int_helper.c
diff --git a/target-alpha/machine.c b/target/alpha/machine.c
similarity index 100%
rename from target-alpha/machine.c
rename to target/alpha/machine.c
diff --git a/target-alpha/mem_helper.c b/target/alpha/mem_helper.c
similarity index 100%
rename from target-alpha/mem_helper.c
rename to target/alpha/mem_helper.c
diff --git a/target-alpha/sys_helper.c b/target/alpha/sys_helper.c
similarity index 100%
rename from target-alpha/sys_helper.c
rename to target/alpha/sys_helper.c
diff --git a/target-alpha/translate.c b/target/alpha/translate.c
similarity index 100%
rename from target-alpha/translate.c
rename to target/alpha/translate.c
diff --git a/target-alpha/vax_helper.c b/target/alpha/vax_helper.c
similarity index 100%
rename from target-alpha/vax_helper.c
rename to target/alpha/vax_helper.c
-- 
1.8.3.1




[Qemu-devel] [RFC for-2.9 01/11] Makefile: Allow CPU targets to reside in target/ folder, too

2016-11-30 Thread Thomas Huth
To be able to compile the CPU targets from within a subfolder
of the target/ folder, we've got to adapt the Makefile.target
a little bit first.

Signed-off-by: Thomas Huth 
---
 Makefile.target | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 7a5080e..90b25ae 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -7,11 +7,17 @@ include config-target.mak
 include config-devices.mak
 include $(SRC_PATH)/rules.mak
 
+ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
+TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
+else
+TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
+endif
+
 $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
 ifdef CONFIG_LINUX
 QEMU_CFLAGS += -I../linux-headers
 endif
-QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
+QEMU_CFLAGS += -I.. -I$(SRC_PATH)/$(TARGET_FOLDER) -DNEED_CPU_H
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/include
 
@@ -92,7 +98,7 @@ obj-$(CONFIG_TCG_INTERPRETER) += tci.o
 obj-y += tcg/tcg-common.o
 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
 obj-y += fpu/softfloat.o
-obj-y += target-$(TARGET_BASE_ARCH)/
+obj-y += $(TARGET_FOLDER)/
 obj-y += disas.o
 obj-y += tcg-runtime.o
 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
-- 
1.8.3.1




[Qemu-devel] [RFC for-2.9 06/11] ppc: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 4 ++--
 Makefile.objs   | 2 +-
 hw/ppc/fdt.c| 2 +-
 hw/ppc/pnv.c| 2 +-
 hw/ppc/pnv_core.c   | 2 +-
 hw/ppc/pnv_lpc.c| 2 +-
 hw/ppc/pnv_xscom.c  | 2 +-
 hw/ppc/spapr_cpu_core.c | 6 +++---
 include/hw/ppc/fdt.h| 2 +-
 include/hw/ppc/ppc.h| 2 +-
 include/hw/ppc/spapr_cpu_core.h | 2 +-
 {target-ppc => target/ppc}/Makefile.objs| 0
 {target-ppc => target/ppc}/STATUS   | 0
 {target-ppc => target/ppc}/arch_dump.c  | 0
 {target-ppc => target/ppc}/cpu-models.c | 0
 {target-ppc => target/ppc}/cpu-models.h | 0
 {target-ppc => target/ppc}/cpu-qom.h| 0
 {target-ppc => target/ppc}/cpu.h| 0
 {target-ppc => target/ppc}/dfp_helper.c | 0
 {target-ppc => target/ppc}/excp_helper.c| 0
 {target-ppc => target/ppc}/fpu_helper.c | 0
 {target-ppc => target/ppc}/gdbstub.c| 0
 {target-ppc => target/ppc}/helper.h | 0
 {target-ppc => target/ppc}/helper_regs.h| 0
 {target-ppc => target/ppc}/int_helper.c | 0
 {target-ppc => target/ppc}/internal.h   | 0
 {target-ppc => target/ppc}/kvm-stub.c   | 0
 {target-ppc => target/ppc}/kvm.c| 0
 {target-ppc => target/ppc}/kvm_ppc.h| 0
 {target-ppc => target/ppc}/machine.c| 0
 {target-ppc => target/ppc}/mem_helper.c | 0
 {target-ppc => target/ppc}/mfrom_table.c| 0
 {target-ppc => target/ppc}/mfrom_table_gen.c| 0
 {target-ppc => target/ppc}/misc_helper.c| 0
 {target-ppc => target/ppc}/mmu-hash32.c | 0
 {target-ppc => target/ppc}/mmu-hash32.h | 0
 {target-ppc => target/ppc}/mmu-hash64.c | 0
 {target-ppc => target/ppc}/mmu-hash64.h | 0
 {target-ppc => target/ppc}/mmu_helper.c | 0
 {target-ppc => target/ppc}/monitor.c| 0
 {target-ppc => target/ppc}/timebase_helper.c| 0
 {target-ppc => target/ppc}/trace-events | 2 +-
 {target-ppc => target/ppc}/translate.c  | 0
 {target-ppc => target/ppc}/translate/dfp-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/dfp-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/fp-impl.inc.c  | 0
 {target-ppc => target/ppc}/translate/fp-ops.inc.c   | 0
 {target-ppc => target/ppc}/translate/spe-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/spe-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/vmx-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/vmx-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/vsx-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/vsx-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate_init.c | 0
 {target-ppc => target/ppc}/user_only_helper.c   | 0
 55 files changed, 15 insertions(+), 15 deletions(-)
 rename {target-ppc => target/ppc}/Makefile.objs (100%)
 rename {target-ppc => target/ppc}/STATUS (100%)
 rename {target-ppc => target/ppc}/arch_dump.c (100%)
 rename {target-ppc => target/ppc}/cpu-models.c (100%)
 rename {target-ppc => target/ppc}/cpu-models.h (100%)
 rename {target-ppc => target/ppc}/cpu-qom.h (100%)
 rename {target-ppc => target/ppc}/cpu.h (100%)
 rename {target-ppc => target/ppc}/dfp_helper.c (100%)
 rename {target-ppc => target/ppc}/excp_helper.c (100%)
 rename {target-ppc => target/ppc}/fpu_helper.c (100%)
 rename {target-ppc => target/ppc}/gdbstub.c (100%)
 rename {target-ppc => target/ppc}/helper.h (100%)
 rename {target-ppc => target/ppc}/helper_regs.h (100%)
 rename {target-ppc => target/ppc}/int_helper.c (100%)
 rename {target-ppc => target/ppc}/internal.h (100%)
 rename {target-ppc => target/ppc}/kvm-stub.c (100%)
 rename {target-ppc => target/ppc}/kvm.c (100%)
 rename {target-ppc => target/ppc}/kvm_ppc.h (100%)
 rename {target-ppc => target/ppc}/machine.c (100%)
 rename {target-ppc => target/ppc}/mem_helper.c (100%)
 rename {target-ppc => target/ppc}/mfrom_table.c (100%)
 rename {target-ppc => target/ppc}/mfrom_table_gen.c (100%)
 rename {target-ppc => target/ppc}/misc_helper.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash32.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash32.h (100%)
 rename {target-ppc => target/ppc}/mmu-hash64.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash64.h (100%)
 rename {target-ppc => target/ppc}/mmu_helper.c (100%)
 rename {target-ppc => target/ppc}/monitor.c (100%)
 rename {target-ppc => target/ppc}/timebase_helper.c (100%)
 rename {target-ppc => target/ppc}/trace-events (92%)
 rename {target-ppc => target/ppc}/translate.c (100%)
 rename 

[Qemu-devel] [RFC for-2.9 02/11] tilegx: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 {target-tilegx => target/tilegx}/Makefile.objs   | 0
 {target-tilegx => target/tilegx}/cpu.c   | 0
 {target-tilegx => target/tilegx}/cpu.h   | 0
 {target-tilegx => target/tilegx}/helper.c| 0
 {target-tilegx => target/tilegx}/helper.h| 0
 {target-tilegx => target/tilegx}/opcode_tilegx.h | 0
 {target-tilegx => target/tilegx}/simd_helper.c   | 0
 {target-tilegx => target/tilegx}/spr_def_64.h| 0
 {target-tilegx => target/tilegx}/translate.c | 0
 9 files changed, 0 insertions(+), 0 deletions(-)
 rename {target-tilegx => target/tilegx}/Makefile.objs (100%)
 rename {target-tilegx => target/tilegx}/cpu.c (100%)
 rename {target-tilegx => target/tilegx}/cpu.h (100%)
 rename {target-tilegx => target/tilegx}/helper.c (100%)
 rename {target-tilegx => target/tilegx}/helper.h (100%)
 rename {target-tilegx => target/tilegx}/opcode_tilegx.h (100%)
 rename {target-tilegx => target/tilegx}/simd_helper.c (100%)
 rename {target-tilegx => target/tilegx}/spr_def_64.h (100%)
 rename {target-tilegx => target/tilegx}/translate.c (100%)

diff --git a/target-tilegx/Makefile.objs b/target/tilegx/Makefile.objs
similarity index 100%
rename from target-tilegx/Makefile.objs
rename to target/tilegx/Makefile.objs
diff --git a/target-tilegx/cpu.c b/target/tilegx/cpu.c
similarity index 100%
rename from target-tilegx/cpu.c
rename to target/tilegx/cpu.c
diff --git a/target-tilegx/cpu.h b/target/tilegx/cpu.h
similarity index 100%
rename from target-tilegx/cpu.h
rename to target/tilegx/cpu.h
diff --git a/target-tilegx/helper.c b/target/tilegx/helper.c
similarity index 100%
rename from target-tilegx/helper.c
rename to target/tilegx/helper.c
diff --git a/target-tilegx/helper.h b/target/tilegx/helper.h
similarity index 100%
rename from target-tilegx/helper.h
rename to target/tilegx/helper.h
diff --git a/target-tilegx/opcode_tilegx.h b/target/tilegx/opcode_tilegx.h
similarity index 100%
rename from target-tilegx/opcode_tilegx.h
rename to target/tilegx/opcode_tilegx.h
diff --git a/target-tilegx/simd_helper.c b/target/tilegx/simd_helper.c
similarity index 100%
rename from target-tilegx/simd_helper.c
rename to target/tilegx/simd_helper.c
diff --git a/target-tilegx/spr_def_64.h b/target/tilegx/spr_def_64.h
similarity index 100%
rename from target-tilegx/spr_def_64.h
rename to target/tilegx/spr_def_64.h
diff --git a/target-tilegx/translate.c b/target/tilegx/translate.c
similarity index 100%
rename from target-tilegx/translate.c
rename to target/tilegx/translate.c
-- 
1.8.3.1




[Qemu-devel] [RFC for-2.9 05/11] arm: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 4 ++--
 Makefile.objs  | 2 +-
 hw/arm/strongarm.h | 2 +-
 hw/arm/virt-acpi-build.c   | 2 +-
 include/hw/arm/arm.h   | 2 +-
 include/hw/arm/exynos4210.h| 2 +-
 include/hw/arm/omap.h  | 2 +-
 include/hw/arm/pxa.h   | 2 +-
 {target-arm => target/arm}/Makefile.objs   | 0
 {target-arm => target/arm}/arch_dump.c | 0
 {target-arm => target/arm}/arm-powerctl.c  | 0
 {target-arm => target/arm}/arm-powerctl.h  | 0
 {target-arm => target/arm}/arm-semi.c  | 0
 {target-arm => target/arm}/arm_ldst.h  | 0
 {target-arm => target/arm}/cpu-qom.h   | 0
 {target-arm => target/arm}/cpu.c   | 0
 {target-arm => target/arm}/cpu.h   | 0
 {target-arm => target/arm}/cpu64.c | 0
 {target-arm => target/arm}/crypto_helper.c | 0
 {target-arm => target/arm}/gdbstub.c   | 0
 {target-arm => target/arm}/gdbstub64.c | 0
 {target-arm => target/arm}/helper-a64.c| 0
 {target-arm => target/arm}/helper-a64.h| 0
 {target-arm => target/arm}/helper.c| 0
 {target-arm => target/arm}/helper.h| 0
 {target-arm => target/arm}/internals.h | 0
 {target-arm => target/arm}/iwmmxt_helper.c | 0
 {target-arm => target/arm}/kvm-consts.h| 0
 {target-arm => target/arm}/kvm-stub.c  | 0
 {target-arm => target/arm}/kvm.c   | 0
 {target-arm => target/arm}/kvm32.c | 0
 {target-arm => target/arm}/kvm64.c | 0
 {target-arm => target/arm}/kvm_arm.h   | 0
 {target-arm => target/arm}/machine.c   | 0
 {target-arm => target/arm}/monitor.c   | 0
 {target-arm => target/arm}/neon_helper.c   | 0
 {target-arm => target/arm}/op_addsub.h | 0
 {target-arm => target/arm}/op_helper.c | 0
 {target-arm => target/arm}/psci.c  | 0
 {target-arm => target/arm}/trace-events| 2 +-
 {target-arm => target/arm}/translate-a64.c | 0
 {target-arm => target/arm}/translate.c | 0
 {target-arm => target/arm}/translate.h | 0
 43 files changed, 10 insertions(+), 10 deletions(-)
 rename {target-arm => target/arm}/Makefile.objs (100%)
 rename {target-arm => target/arm}/arch_dump.c (100%)
 rename {target-arm => target/arm}/arm-powerctl.c (100%)
 rename {target-arm => target/arm}/arm-powerctl.h (100%)
 rename {target-arm => target/arm}/arm-semi.c (100%)
 rename {target-arm => target/arm}/arm_ldst.h (100%)
 rename {target-arm => target/arm}/cpu-qom.h (100%)
 rename {target-arm => target/arm}/cpu.c (100%)
 rename {target-arm => target/arm}/cpu.h (100%)
 rename {target-arm => target/arm}/cpu64.c (100%)
 rename {target-arm => target/arm}/crypto_helper.c (100%)
 rename {target-arm => target/arm}/gdbstub.c (100%)
 rename {target-arm => target/arm}/gdbstub64.c (100%)
 rename {target-arm => target/arm}/helper-a64.c (100%)
 rename {target-arm => target/arm}/helper-a64.h (100%)
 rename {target-arm => target/arm}/helper.c (100%)
 rename {target-arm => target/arm}/helper.h (100%)
 rename {target-arm => target/arm}/internals.h (100%)
 rename {target-arm => target/arm}/iwmmxt_helper.c (100%)
 rename {target-arm => target/arm}/kvm-consts.h (100%)
 rename {target-arm => target/arm}/kvm-stub.c (100%)
 rename {target-arm => target/arm}/kvm.c (100%)
 rename {target-arm => target/arm}/kvm32.c (100%)
 rename {target-arm => target/arm}/kvm64.c (100%)
 rename {target-arm => target/arm}/kvm_arm.h (100%)
 rename {target-arm => target/arm}/machine.c (100%)
 rename {target-arm => target/arm}/monitor.c (100%)
 rename {target-arm => target/arm}/neon_helper.c (100%)
 rename {target-arm => target/arm}/op_addsub.h (100%)
 rename {target-arm => target/arm}/op_helper.c (100%)
 rename {target-arm => target/arm}/psci.c (100%)
 rename {target-arm => target/arm}/trace-events (96%)
 rename {target-arm => target/arm}/translate-a64.c (100%)
 rename {target-arm => target/arm}/translate.c (100%)
 rename {target-arm => target/arm}/translate.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 37deb43..2760146 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -115,7 +115,7 @@ ARM
 M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Maintained
-F: target-arm/
+F: target/arm/
 F: hw/arm/
 F: hw/cpu/a*mpcore.c
 F: include/hw/cpu/a*mpcore.h
@@ -269,7 +269,7 @@ ARM
 M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Maintained
-F: target-arm/kvm.c
+F: target/arm/kvm.c
 
 MIPS
 M: James Hogan 
diff --git a/Makefile.objs b/Makefile.objs
index 06f74b8..6d2b36e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -155,7 +155,7 @@ trace-events-y += hw/alpha/trace-events
 trace-events-y += ui/trace-events
 trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
-trace-events-y += target-arm/trace-events
+trace-events-y += target/arm/trace-events
 trace-events-y += target-i386/trace-events
 trace-events-y += target-sparc/trace-events
 trace-events-y += target-s390x/trace-events
diff --git a/hw/arm/stron

[Qemu-devel] [RFC for-2.9 07/11] i386: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 4 ++--
 Makefile.objs| 2 +-
 hw/i386/acpi-build.c | 2 +-
 hw/i386/kvm/apic.c   | 2 +-
 hw/intc/ioapic.c | 2 +-
 hw/misc/hyperv_testdev.c | 2 +-
 scripts/analyze-inclusions   | 6 +++---
 {target-i386 => target/i386}/Makefile.objs   | 0
 {target-i386 => target/i386}/TODO| 0
 {target-i386 => target/i386}/arch_dump.c | 0
 {target-i386 => target/i386}/arch_memory_mapping.c   | 0
 {target-i386 => target/i386}/bpt_helper.c| 0
 {target-i386 => target/i386}/cc_helper.c | 0
 {target-i386 => target/i386}/cc_helper_template.h| 0
 {target-i386 => target/i386}/cpu-qom.h   | 0
 {target-i386 => target/i386}/cpu.c   | 0
 {target-i386 => target/i386}/cpu.h   | 0
 {target-i386 => target/i386}/excp_helper.c   | 0
 {target-i386 => target/i386}/fpu_helper.c| 0
 {target-i386 => target/i386}/gdbstub.c   | 0
 {target-i386 => target/i386}/helper.c| 0
 {target-i386 => target/i386}/helper.h| 0
 {target-i386 => target/i386}/hyperv.c| 0
 {target-i386 => target/i386}/hyperv.h| 0
 {target-i386 => target/i386}/int_helper.c| 0
 {target-i386 => target/i386}/kvm-stub.c  | 0
 {target-i386 => target/i386}/kvm.c   | 0
 {target-i386 => target/i386}/kvm_i386.h  | 0
 {target-i386 => target/i386}/machine.c   | 0
 {target-i386 => target/i386}/mem_helper.c| 0
 {target-i386 => target/i386}/misc_helper.c   | 0
 {target-i386 => target/i386}/monitor.c   | 0
 {target-i386 => target/i386}/mpx_helper.c| 0
 {target-i386 => target/i386}/ops_sse.h   | 0
 {target-i386 => target/i386}/ops_sse_header.h| 0
 {target-i386 => target/i386}/seg_helper.c| 0
 {target-i386 => target/i386}/shift_helper_template.h | 0
 {target-i386 => target/i386}/smm_helper.c| 0
 {target-i386 => target/i386}/svm.h   | 0
 {target-i386 => target/i386}/svm_helper.c| 0
 {target-i386 => target/i386}/trace-events| 2 +-
 {target-i386 => target/i386}/translate.c | 0
 42 files changed, 11 insertions(+), 11 deletions(-)
 rename {target-i386 => target/i386}/Makefile.objs (100%)
 rename {target-i386 => target/i386}/TODO (100%)
 rename {target-i386 => target/i386}/arch_dump.c (100%)
 rename {target-i386 => target/i386}/arch_memory_mapping.c (100%)
 rename {target-i386 => target/i386}/bpt_helper.c (100%)
 rename {target-i386 => target/i386}/cc_helper.c (100%)
 rename {target-i386 => target/i386}/cc_helper_template.h (100%)
 rename {target-i386 => target/i386}/cpu-qom.h (100%)
 rename {target-i386 => target/i386}/cpu.c (100%)
 rename {target-i386 => target/i386}/cpu.h (100%)
 rename {target-i386 => target/i386}/excp_helper.c (100%)
 rename {target-i386 => target/i386}/fpu_helper.c (100%)
 rename {target-i386 => target/i386}/gdbstub.c (100%)
 rename {target-i386 => target/i386}/helper.c (100%)
 rename {target-i386 => target/i386}/helper.h (100%)
 rename {target-i386 => target/i386}/hyperv.c (100%)
 rename {target-i386 => target/i386}/hyperv.h (100%)
 rename {target-i386 => target/i386}/int_helper.c (100%)
 rename {target-i386 => target/i386}/kvm-stub.c (100%)
 rename {target-i386 => target/i386}/kvm.c (100%)
 rename {target-i386 => target/i386}/kvm_i386.h (100%)
 rename {target-i386 => target/i386}/machine.c (100%)
 rename {target-i386 => target/i386}/mem_helper.c (100%)
 rename {target-i386 => target/i386}/misc_helper.c (100%)
 rename {target-i386 => target/i386}/monitor.c (100%)
 rename {target-i386 => target/i386}/mpx_helper.c (100%)
 rename {target-i386 => target/i386}/ops_sse.h (100%)
 rename {target-i386 => target/i386}/ops_sse_header.h (100%)
 rename {target-i386 => target/i386}/seg_helper.c (100%)
 rename {target-i386 => target/i386}/shift_helper_template.h (100%)
 rename {target-i386 => target/i386}/smm_helper.c (100%)
 rename {target-i386 => target/i386}/svm.h (100%)
 rename {target-i386 => target/i386}/svm_helper.c (100%)
 rename {target-i386 => target/i386}/trace-events (94%)
 rename {target-i386 => target/i386}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index da65284..1b064ac 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -235,7 +235,7 @@ M: Paolo Bonzini 
 M: Richard Henderson 
 M: Eduardo Habkost 
 S: Maintained
-F: target-i386/
+F: target/i386/
 F: hw/i386/
 F: disas/i386.c
 
@@ -301,7 +301,7 @@ M: Paolo Bonzini 
 M: Marcelo Tosatti 
 L: k...@vger.kernel.org
 S: Supported
-F: target-i386/kvm.c
+F: target/i386/kvm.c
 
 Guest CPU Cores (Xen):
 --
diff --git a/Makefile.objs b/Mak

Re: [Qemu-devel] [RFC for-2.9 00/11] Move target-* CPU file into a target/ folder

2016-11-30 Thread Christian Borntraeger
On 11/30/2016 10:47 AM, Thomas Huth wrote:
> We've currently got 18 architectures in QEMU, and thus 18 target-xxx
> folders in the root folder of the QEMU source tree. More architectures
> (e.g. RISC-V, AVR) are likely to be included soon, too, so the main
> folder of the QEMU sources slowly gets quite overcrowded with the
> target-xxx folders.
> Thus I'd like to suggest that we move the target-xxx folders into
> a dedicated target/ folder, so that target-xxx/ simply becomes
> target/xxx/ instead.
> 
> The first patch is the most important one here, it prepares the
> build system to be able to deal with both, target-xxx and target/xxx
> folders. Once that has been applied, each target architecture
> could be moved to the target/ folder when it is convenient for the
> subsytem maintainer to do the move (i.e. we do not have to move all
> files immediately in one go). So if we agree to do this change and
> the first patch has been committed, I could rather send the following
> patches step by step to the maintainers so they can queue the patch
> for their subsystem for a good point in time. And new architectures
> like RISC-V and AVR could start in the target/ folder immediately
> instead.
> 
> So please provide some feedback: Is this a good idea? Or do you
> consider this rather just as unnecessary code churn instead?

Given the low amount of manpower for the stable work, I think this will
cause more harm than it helps. So my gut feeling is to keep it as
is.

Christian




[Qemu-devel] [RFC for-2.9 10/11] s390x: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 8 
 Makefile.objs | 2 +-
 {target-s390x => target/s390x}/Makefile.objs  | 2 +-
 {target-s390x => target/s390x}/arch_dump.c| 0
 {target-s390x => target/s390x}/cc_helper.c| 0
 {target-s390x => target/s390x}/cpu-qom.h  | 0
 {target-s390x => target/s390x}/cpu.c  | 0
 {target-s390x => target/s390x}/cpu.h  | 0
 {target-s390x => target/s390x}/cpu_features.c | 0
 {target-s390x => target/s390x}/cpu_features.h | 0
 {target-s390x => target/s390x}/cpu_features_def.h | 0
 {target-s390x => target/s390x}/cpu_models.c   | 0
 {target-s390x => target/s390x}/cpu_models.h   | 0
 {target-s390x => target/s390x}/fpu_helper.c   | 0
 {target-s390x => target/s390x}/gdbstub.c  | 0
 {target-s390x => target/s390x}/gen-features.c | 0
 {target-s390x => target/s390x}/helper.c   | 0
 {target-s390x => target/s390x}/helper.h   | 0
 {target-s390x => target/s390x}/insn-data.def  | 0
 {target-s390x => target/s390x}/insn-format.def| 0
 {target-s390x => target/s390x}/int_helper.c   | 0
 {target-s390x => target/s390x}/interrupt.c| 0
 {target-s390x => target/s390x}/ioinst.c   | 0
 {target-s390x => target/s390x}/kvm.c  | 0
 {target-s390x => target/s390x}/machine.c  | 0
 {target-s390x => target/s390x}/mem_helper.c   | 0
 {target-s390x => target/s390x}/misc_helper.c  | 0
 {target-s390x => target/s390x}/mmu_helper.c   | 0
 {target-s390x => target/s390x}/trace-events   | 8 
 {target-s390x => target/s390x}/translate.c| 0
 30 files changed, 10 insertions(+), 10 deletions(-)
 rename {target-s390x => target/s390x}/Makefile.objs (94%)
 rename {target-s390x => target/s390x}/arch_dump.c (100%)
 rename {target-s390x => target/s390x}/cc_helper.c (100%)
 rename {target-s390x => target/s390x}/cpu-qom.h (100%)
 rename {target-s390x => target/s390x}/cpu.c (100%)
 rename {target-s390x => target/s390x}/cpu.h (100%)
 rename {target-s390x => target/s390x}/cpu_features.c (100%)
 rename {target-s390x => target/s390x}/cpu_features.h (100%)
 rename {target-s390x => target/s390x}/cpu_features_def.h (100%)
 rename {target-s390x => target/s390x}/cpu_models.c (100%)
 rename {target-s390x => target/s390x}/cpu_models.h (100%)
 rename {target-s390x => target/s390x}/fpu_helper.c (100%)
 rename {target-s390x => target/s390x}/gdbstub.c (100%)
 rename {target-s390x => target/s390x}/gen-features.c (100%)
 rename {target-s390x => target/s390x}/helper.c (100%)
 rename {target-s390x => target/s390x}/helper.h (100%)
 rename {target-s390x => target/s390x}/insn-data.def (100%)
 rename {target-s390x => target/s390x}/insn-format.def (100%)
 rename {target-s390x => target/s390x}/int_helper.c (100%)
 rename {target-s390x => target/s390x}/interrupt.c (100%)
 rename {target-s390x => target/s390x}/ioinst.c (100%)
 rename {target-s390x => target/s390x}/kvm.c (100%)
 rename {target-s390x => target/s390x}/machine.c (100%)
 rename {target-s390x => target/s390x}/mem_helper.c (100%)
 rename {target-s390x => target/s390x}/misc_helper.c (100%)
 rename {target-s390x => target/s390x}/mmu_helper.c (100%)
 rename {target-s390x => target/s390x}/trace-events (91%)
 rename {target-s390x => target/s390x}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index fb6c3a6..48b0a7b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -202,7 +202,7 @@ S390
 M: Richard Henderson 
 M: Alexander Graf 
 S: Maintained
-F: target-s390x/
+F: target/s390x/
 F: hw/s390x/
 F: disas/s390.c
 
@@ -286,9 +286,9 @@ M: Christian Borntraeger 
 M: Cornelia Huck 
 M: Alexander Graf 
 S: Maintained
-F: target-s390x/kvm.c
-F: target-s390x/ioinst.[ch]
-F: target-s390x/machine.c
+F: target/s390x/kvm.c
+F: target/s390x/ioinst.[ch]
+F: target/s390x/machine.c
 F: hw/intc/s390_flic.c
 F: hw/intc/s390_flic_kvm.c
 F: include/hw/s390x/s390_flic.h
diff --git a/Makefile.objs b/Makefile.objs
index 91a24c5..c5ebb80 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -158,7 +158,7 @@ trace-events-y += net/trace-events
 trace-events-y += target/arm/trace-events
 trace-events-y += target/i386/trace-events
 trace-events-y += target-sparc/trace-events
-trace-events-y += target-s390x/trace-events
+trace-events-y += target/s390x/trace-events
 trace-events-y += target/ppc/trace-events
 trace-events-y += qom/trace-events
 trace-events-y += linux-user/trace-events
diff --git a/target-s390x/Makefile.objs b/target/s390x/Makefile.objs
similarity index 94%
rename from target-s390x/Makefile.objs
rename to target/s390x/Makefile.objs
index 6b02b17..c573633 100644
--- a/target-s390x/Makefile.objs
+++ b/target/s390x/Makefile.objs
@@ -5,7 +5,7 @@ obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o 
mmu_helper.o
 obj-$(CONFIG_KVM) += kvm.o
 
 # build and run feature list generator
-feat-src = $(SRC_PATH)/target-$(TARGET_BASE_ARCH)/
+feat-src = $(SRC_PATH)/target/$(TA

[Qemu-devel] [RFC for-2.9 11/11] sparc: Move CPU files to target/ folder

2016-11-30 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 2 +-
 Makefile.objs | 2 +-
 {target-sparc => target/sparc}/Makefile.objs  | 0
 {target-sparc => target/sparc}/TODO   | 0
 {target-sparc => target/sparc}/asi.h  | 0
 {target-sparc => target/sparc}/cc_helper.c| 0
 {target-sparc => target/sparc}/cpu-qom.h  | 0
 {target-sparc => target/sparc}/cpu.c  | 0
 {target-sparc => target/sparc}/cpu.h  | 0
 {target-sparc => target/sparc}/fop_helper.c   | 0
 {target-sparc => target/sparc}/gdbstub.c  | 0
 {target-sparc => target/sparc}/helper.c   | 0
 {target-sparc => target/sparc}/helper.h   | 0
 {target-sparc => target/sparc}/int32_helper.c | 0
 {target-sparc => target/sparc}/int64_helper.c | 0
 {target-sparc => target/sparc}/ldst_helper.c  | 0
 {target-sparc => target/sparc}/machine.c  | 0
 {target-sparc => target/sparc}/mmu_helper.c   | 0
 {target-sparc => target/sparc}/monitor.c  | 0
 {target-sparc => target/sparc}/trace-events   | 8 
 {target-sparc => target/sparc}/translate.c| 0
 {target-sparc => target/sparc}/vis_helper.c   | 0
 {target-sparc => target/sparc}/win_helper.c   | 0
 23 files changed, 6 insertions(+), 6 deletions(-)
 rename {target-sparc => target/sparc}/Makefile.objs (100%)
 rename {target-sparc => target/sparc}/TODO (100%)
 rename {target-sparc => target/sparc}/asi.h (100%)
 rename {target-sparc => target/sparc}/cc_helper.c (100%)
 rename {target-sparc => target/sparc}/cpu-qom.h (100%)
 rename {target-sparc => target/sparc}/cpu.c (100%)
 rename {target-sparc => target/sparc}/cpu.h (100%)
 rename {target-sparc => target/sparc}/fop_helper.c (100%)
 rename {target-sparc => target/sparc}/gdbstub.c (100%)
 rename {target-sparc => target/sparc}/helper.c (100%)
 rename {target-sparc => target/sparc}/helper.h (100%)
 rename {target-sparc => target/sparc}/int32_helper.c (100%)
 rename {target-sparc => target/sparc}/int64_helper.c (100%)
 rename {target-sparc => target/sparc}/ldst_helper.c (100%)
 rename {target-sparc => target/sparc}/machine.c (100%)
 rename {target-sparc => target/sparc}/mmu_helper.c (100%)
 rename {target-sparc => target/sparc}/monitor.c (100%)
 rename {target-sparc => target/sparc}/trace-events (94%)
 rename {target-sparc => target/sparc}/translate.c (100%)
 rename {target-sparc => target/sparc}/vis_helper.c (100%)
 rename {target-sparc => target/sparc}/win_helper.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 48b0a7b..f8959d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -218,7 +218,7 @@ SPARC
 M: Mark Cave-Ayland 
 M: Artyom Tarasenko 
 S: Maintained
-F: target-sparc/
+F: target/sparc/
 F: hw/sparc/
 F: hw/sparc64/
 F: disas/sparc.c
diff --git a/Makefile.objs b/Makefile.objs
index c5ebb80..e59b979 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -157,7 +157,7 @@ trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
 trace-events-y += target/arm/trace-events
 trace-events-y += target/i386/trace-events
-trace-events-y += target-sparc/trace-events
+trace-events-y += target/sparc/trace-events
 trace-events-y += target/s390x/trace-events
 trace-events-y += target/ppc/trace-events
 trace-events-y += qom/trace-events
diff --git a/target-sparc/Makefile.objs b/target/sparc/Makefile.objs
similarity index 100%
rename from target-sparc/Makefile.objs
rename to target/sparc/Makefile.objs
diff --git a/target-sparc/TODO b/target/sparc/TODO
similarity index 100%
rename from target-sparc/TODO
rename to target/sparc/TODO
diff --git a/target-sparc/asi.h b/target/sparc/asi.h
similarity index 100%
rename from target-sparc/asi.h
rename to target/sparc/asi.h
diff --git a/target-sparc/cc_helper.c b/target/sparc/cc_helper.c
similarity index 100%
rename from target-sparc/cc_helper.c
rename to target/sparc/cc_helper.c
diff --git a/target-sparc/cpu-qom.h b/target/sparc/cpu-qom.h
similarity index 100%
rename from target-sparc/cpu-qom.h
rename to target/sparc/cpu-qom.h
diff --git a/target-sparc/cpu.c b/target/sparc/cpu.c
similarity index 100%
rename from target-sparc/cpu.c
rename to target/sparc/cpu.c
diff --git a/target-sparc/cpu.h b/target/sparc/cpu.h
similarity index 100%
rename from target-sparc/cpu.h
rename to target/sparc/cpu.h
diff --git a/target-sparc/fop_helper.c b/target/sparc/fop_helper.c
similarity index 100%
rename from target-sparc/fop_helper.c
rename to target/sparc/fop_helper.c
diff --git a/target-sparc/gdbstub.c b/target/sparc/gdbstub.c
similarity index 100%
rename from target-sparc/gdbstub.c
rename to target/sparc/gdbstub.c
diff --git a/target-sparc/helper.c b/target/sparc/helper.c
similarity index 100%
rename from target-sparc/helper.c
rename to target/sparc/helper.c
diff --git a/target-sparc/helper.h b/target/sparc/helper.h
similarity index 100%
rename from target-sparc/helper.h
rename to target/sparc/helper.h
diff --git a/target-sparc/int32_helper.c b/target/sparc/int32_helper.c
similarity index 100%
rename from target-sparc/int32_helper.c

[Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Laszlo Ersek
Recent git releases support the diff.orderFile permanent setting. (In
older releases, the -O option had to be specified on the command line,
or in aliases, for the same effect, which was quite inconvenient.) From
git-diff(1):

   -O
   Output the patch in the order specified in the ,
   which has one shell glob pattern per line. This overrides
   the diff.orderFile configuration variable (see git-
   config(1)). To cancel diff.orderFile, use -O/dev/null.

In my experience, an order file such as:

configure
*Makefile*
*.json
*.txt
*.h
*.c

that is, a priority order that goes from
descriptive/declarative/abstract to imperative/specific works wonders
for reviewing.

Randomly picked example:

[Qemu-devel] [PATCH] virtio-gpu: track and limit host memory allocations
http://lists.nongnu.org/archive/html/qemu-devel/2016-11/msg05144.html

This patch adds several fields to several structures first, and then it
does things with those new fields. If you think about what the English
verb "to declare" means, it's clear you want to see the declaration
first (same as the compiler), and only then how the field is put to use.

Thanks!
Laszlo



[Qemu-devel] [RFC v3 2/3] vhost-net: Notify the backend about the host MTU

2016-11-30 Thread Maxime Coquelin
This patch provides a way for virtio-net to notify the
backend about the host MTU set by the user.

Cc: Michael S. Tsirkin 
Cc: Aaron Conole 
Signed-off-by: Maxime Coquelin 
---
 hw/net/vhost_net.c  | 22 ++
 include/net/vhost_net.h |  2 ++
 2 files changed, 24 insertions(+)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index f2d49ad..d7c13d4 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -51,6 +51,7 @@ static const int kernel_feature_bits[] = {
 VIRTIO_RING_F_EVENT_IDX,
 VIRTIO_NET_F_MRG_RXBUF,
 VIRTIO_F_VERSION_1,
+VIRTIO_NET_F_MTU,
 VHOST_INVALID_FEATURE_BIT
 };
 
@@ -74,6 +75,7 @@ static const int user_feature_bits[] = {
 VIRTIO_NET_F_HOST_ECN,
 VIRTIO_NET_F_HOST_UFO,
 VIRTIO_NET_F_MRG_RXBUF,
+VIRTIO_NET_F_MTU,
 
 /* This bit implies RARP isn't sent by QEMU out of band */
 VIRTIO_NET_F_GUEST_ANNOUNCE,
@@ -435,6 +437,22 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
 return 0;
 }
 
+int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
+{
+const VhostOps *vhost_ops = net->dev.vhost_ops;
+int ret;
+
+if (!vhost_ops->vhost_net_set_mtu) {
+return -ENOSYS;
+}
+
+ret = vhost_ops->vhost_net_set_mtu(&net->dev, mtu);
+if (ret < 0) {
+return -errno;
+}
+return 0;
+}
+
 #else
 uint64_t vhost_net_get_max_queues(VHostNetState *net)
 {
@@ -501,4 +519,8 @@ int vhost_set_vring_enable(NetClientState *nc, int enable)
 {
 return 0;
 }
+
+int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu)
+{
+}
 #endif
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 5a08eff..afc1499 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -35,4 +35,6 @@ int vhost_set_vring_enable(NetClientState * nc, int enable);
 
 uint64_t vhost_net_get_acked_features(VHostNetState *net);
 
+int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu);
+
 #endif
-- 
2.9.3




Re: [Qemu-devel] [RFC for-2.9 00/11] Move target-* CPU file into a target/ folder

2016-11-30 Thread Laurent Vivier
Le 30/11/2016 à 10:47, Thomas Huth a écrit :
> We've currently got 18 architectures in QEMU, and thus 18 target-xxx
> folders in the root folder of the QEMU source tree. More architectures
> (e.g. RISC-V, AVR) are likely to be included soon, too, so the main
> folder of the QEMU sources slowly gets quite overcrowded with the
> target-xxx folders.
> Thus I'd like to suggest that we move the target-xxx folders into
> a dedicated target/ folder, so that target-xxx/ simply becomes
> target/xxx/ instead.
> 
> The first patch is the most important one here, it prepares the
> build system to be able to deal with both, target-xxx and target/xxx
> folders. Once that has been applied, each target architecture
> could be moved to the target/ folder when it is convenient for the
> subsytem maintainer to do the move (i.e. we do not have to move all
> files immediately in one go). So if we agree to do this change and
> the first patch has been committed, I could rather send the following
> patches step by step to the maintainers so they can queue the patch
> for their subsystem for a good point in time. And new architectures
> like RISC-V and AVR could start in the target/ folder immediately
> instead.
> 
> So please provide some feedback: Is this a good idea? Or do you
> consider this rather just as unnecessary code churn instead?
> 

IMHO, it seems a good idea.

Nevertheless, I'm not sure to be able to manage both in the makefile is
a good idea: it can become a little bit messy.

Thanks,
Laurent




[Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature

2016-11-30 Thread Maxime Coquelin
This series implements Virtio spec update from Aaron Conole which
defines a way for the host to expose its max MTU to the guest.

This third version re-desings how MTU value is provided to QEMU.
Now, host_mtu parameter is added to provide QEMU with the MTU value,
and the backend, if supported, gets notified of the MTU value when the
MTU feature neogotiation succeeds.

Only user backend currently supports MTU notification. A new protocol
feature has been implemented for sending MTU value to the backend.
Aaron, Kevin, Flavio, do you confirm this works for OVS if DPDK vhost lib
adds needed API to get the MTU value?

For kernel backend, it is expected the management tool also configures
the tap/macvtap interface with same MTU value.
Daniel, I would be interrested about your feedback on this implementation
from management tool point of view.

Changes since RFC v2:
-
 - host_mtu propoerty is now used to specify the MTU value
 - update vhost-user spec with MTU additions

Changes since RFC v1:
-
 - Rebased on top of v2.8.0-rc0 (2.7.90)
 - Write MTU unconditionnaly in netcfg to avoid memory leak (Paolo)
 - Add host_mtu property to be able to disable the feature from QEMU

Maxime Coquelin (3):
  vhost-user: Add MTU protocol feature and op
  vhost-net: Notify the backend about the host MTU
  virtio-net: Add MTU feature support

 docs/specs/vhost-user.txt | 13 +
 hw/net/vhost_net.c| 22 ++
 hw/net/virtio-net.c   | 13 +
 hw/virtio/vhost-user.c| 13 +
 include/hw/virtio/vhost-backend.h |  2 ++
 include/hw/virtio/virtio-net.h|  1 +
 include/net/vhost_net.h   |  2 ++
 7 files changed, 66 insertions(+)

-- 
2.9.3




Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Stefan Hajnoczi
On Wed, Nov 30, 2016 at 01:42:14PM +0800, Fam Zheng wrote:
> On Tue, 11/29 20:43, Stefan Hajnoczi wrote:
> > On Tue, Nov 29, 2016 at 1:24 PM, Fam Zheng  wrote:
> > > On Tue, 11/29 12:17, Paolo Bonzini wrote:
> > >> On 29/11/2016 11:32, Fam Zheng wrote:
> > >> * it still needs a system call before polling is entered.  Ideally, QEMU
> > >> could run without any system call while in polling mode.
> > >>
> > >> Another possibility is to add a system call for single_task_running().
> > >> It should be simple enough that you can implement it in the vDSO and
> > >> avoid a context switch.  There are convenient hooking points in
> > >> add_nr_running and sub_nr_running.
> > >
> > > That sounds good!
> > 
> > With this solution QEMU can either poll virtqueues or the host kernel
> > can poll NIC and storage controller descriptor rings, but not both at
> > the same time in one thread.  This is one of the reasons why I think
> > exploring polling in the kernel makes more sense.
> 
> That's true. I have one question though: controller rings are in a different
> layer in the kernel, I wonder what the syscall interface looks like to ask
> kernel to poll both hardware rings and memory locations in the same loop? It's
> not obvious to me after reading your eventfd patch.

Current descriptor ring polling in select(2)/poll(2) is supported for
network sockets.  Take a look at the POLL_BUSY_LOOP flag in
fs/select.c:do_poll().  If the .poll() callback sets the flag then it
indicates that the fd supports busy loop polling.

The way this is implemented for network sockets is that the socket looks
up the napi index and is able to use the NIC driver to poll the rx ring.
Then it checks whether the socket's receive queue contains data after
the rx ring was processed.

The virtio_net.ko driver supports this interface, for example.  See
drivers/net/virtio_net.c:virtnet_busy_poll().

Busy loop polling isn't supported for block I/O yet.  There is currently
a completely independent code path for O_DIRECT synchronous I/O where
NVMe can poll for request completion.  But it doesn't work together with
asynchronous I/O (e.g. Linux AIO using eventfd with select(2)/poll(2)).

> > The disadvantage of the kernel approach is that you must make the
> > ppoll(2)/epoll_wait(2) syscall even for polling, and you probably need
> > to do eventfd reads afterwards so the minimum event loop iteration
> > latency is higher than doing polling in userspace.
> 
> And userspace drivers powered by dpdk or vfio will still want to do polling in
> userspace anyway, we may want to take that into account as well.

vfio supports interrupts so it can definitely be integrated with
adaptive kernel polling (i.e. poll for a little while and then wait for
an interrupt if there was no event).

Does dpdk ever use interrupts?

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [RFC for-2.9 00/11] Move target-* CPU file into a target/ folder

2016-11-30 Thread Thomas Huth
On 30.11.2016 11:10, Laurent Vivier wrote:
> Le 30/11/2016 à 10:47, Thomas Huth a écrit :
>> We've currently got 18 architectures in QEMU, and thus 18 target-xxx
>> folders in the root folder of the QEMU source tree. More architectures
>> (e.g. RISC-V, AVR) are likely to be included soon, too, so the main
>> folder of the QEMU sources slowly gets quite overcrowded with the
>> target-xxx folders.
>> Thus I'd like to suggest that we move the target-xxx folders into
>> a dedicated target/ folder, so that target-xxx/ simply becomes
>> target/xxx/ instead.
>>
>> The first patch is the most important one here, it prepares the
>> build system to be able to deal with both, target-xxx and target/xxx
>> folders. Once that has been applied, each target architecture
>> could be moved to the target/ folder when it is convenient for the
>> subsytem maintainer to do the move (i.e. we do not have to move all
>> files immediately in one go). So if we agree to do this change and
>> the first patch has been committed, I could rather send the following
>> patches step by step to the maintainers so they can queue the patch
>> for their subsystem for a good point in time. And new architectures
>> like RISC-V and AVR could start in the target/ folder immediately
>> instead.
>>
>> So please provide some feedback: Is this a good idea? Or do you
>> consider this rather just as unnecessary code churn instead?
>>
> 
> IMHO, it seems a good idea.
> 
> Nevertheless, I'm not sure to be able to manage both in the makefile is
> a good idea: it can become a little bit messy.

That's of course only a temporary solution. Once all targets have been
moved, the Makefile should be changed to only look into the target/xxx
folders.

 Thomas




[Qemu-devel] [RFC v3 1/3] vhost-user: Add MTU protocol feature and op

2016-11-30 Thread Maxime Coquelin
This patch implements VHOST_USER_PROTOCOL_F_MTU protocol
feature and VHOST_USER_SET_MTU request so that the backend
gets notified of the user defined host MTU.

Vhost-net driver sends this request through a new
vhost_net_set_mtu vhost_ops entry.

Cc: Michael S. Tsirkin 
Cc: Aaron Conole 
Signed-off-by: Maxime Coquelin 
---
 docs/specs/vhost-user.txt | 13 +
 hw/virtio/vhost-user.c| 13 +
 include/hw/virtio/vhost-backend.h |  2 ++
 3 files changed, 28 insertions(+)

diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 7890d71..1740baa 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -259,6 +259,7 @@ Protocol features
 #define VHOST_USER_PROTOCOL_F_LOG_SHMFD  1
 #define VHOST_USER_PROTOCOL_F_RARP   2
 #define VHOST_USER_PROTOCOL_F_REPLY_ACK  3
+#define VHOST_USER_PROTOCOL_F_MTU4
 
 Message types
 -
@@ -470,6 +471,18 @@ Message types
   The first 6 bytes of the payload contain the mac address of the guest to
   allow the vhost user backend to construct and broadcast the fake RARP.
 
+ * VHOST_USER_SET_MTU
+
+  Id: 20
+ Equivalent ioctl: N/A
+ Master payload: u64
+
+ Set host MTU value exposed to the guest.
+ This request should be sent only when VIRTIO_NET_F_MTU feature has 
been
+ successfully negotiated, VHOST_USER_F_PROTOCOL_FEATURES is present in
+ VHOST_USER_GET_FEATURES and protocol feature bit 
VHOST_USER_PROTOCOL_F_MTU
+ is present in VHOST_USER_GET_PROTOCOL_FEATURES.
+
 VHOST_USER_PROTOCOL_F_REPLY_ACK:
 ---
 The original vhost-user specification only demands replies for certain
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 7ee92b3..86e8255 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -32,6 +32,7 @@ enum VhostUserProtocolFeature {
 VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,
 VHOST_USER_PROTOCOL_F_RARP = 2,
 VHOST_USER_PROTOCOL_F_REPLY_ACK = 3,
+VHOST_USER_PROTOCOL_F_MTU = 4,
 
 VHOST_USER_PROTOCOL_F_MAX
 };
@@ -59,6 +60,7 @@ typedef enum VhostUserRequest {
 VHOST_USER_GET_QUEUE_NUM = 17,
 VHOST_USER_SET_VRING_ENABLE = 18,
 VHOST_USER_SEND_RARP = 19,
+VHOST_USER_SET_MTU = 20,
 VHOST_USER_MAX
 } VhostUserRequest;
 
@@ -186,6 +188,7 @@ static bool vhost_user_one_time_request(VhostUserRequest 
request)
 case VHOST_USER_RESET_OWNER:
 case VHOST_USER_SET_MEM_TABLE:
 case VHOST_USER_GET_QUEUE_NUM:
+case VHOST_USER_SET_MTU:
 return true;
 default:
 return false;
@@ -685,6 +688,15 @@ static bool vhost_user_can_merge(struct vhost_dev *dev,
 return mfd == rfd;
 }
 
+static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)
+{
+if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MTU)) {
+return vhost_user_set_u64(dev, VHOST_USER_SET_MTU, (uint64_t)mtu);
+}
+
+return -1;
+}
+
 const VhostOps user_ops = {
 .backend_type = VHOST_BACKEND_TYPE_USER,
 .vhost_backend_init = vhost_user_init,
@@ -708,4 +720,5 @@ const VhostOps user_ops = {
 .vhost_requires_shm_log = vhost_user_requires_shm_log,
 .vhost_migration_done = vhost_user_migration_done,
 .vhost_backend_can_merge = vhost_user_can_merge,
+.vhost_net_set_mtu = vhost_user_net_set_mtu,
 };
diff --git a/include/hw/virtio/vhost-backend.h 
b/include/hw/virtio/vhost-backend.h
index 6e90703..30abc11 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -32,6 +32,7 @@ typedef int (*vhost_backend_memslots_limit)(struct vhost_dev 
*dev);
 
 typedef int (*vhost_net_set_backend_op)(struct vhost_dev *dev,
 struct vhost_vring_file *file);
+typedef int (*vhost_net_set_mtu_op)(struct vhost_dev *dev, uint16_t mtu);
 typedef int (*vhost_scsi_set_endpoint_op)(struct vhost_dev *dev,
   struct vhost_scsi_target *target);
 typedef int (*vhost_scsi_clear_endpoint_op)(struct vhost_dev *dev,
@@ -83,6 +84,7 @@ typedef struct VhostOps {
 vhost_backend_cleanup vhost_backend_cleanup;
 vhost_backend_memslots_limit vhost_backend_memslots_limit;
 vhost_net_set_backend_op vhost_net_set_backend;
+vhost_net_set_mtu_op vhost_net_set_mtu;
 vhost_scsi_set_endpoint_op vhost_scsi_set_endpoint;
 vhost_scsi_clear_endpoint_op vhost_scsi_clear_endpoint;
 vhost_scsi_get_abi_version_op vhost_scsi_get_abi_version;
-- 
2.9.3




[Qemu-devel] [RFC v3 3/3] virtio-net: Add MTU feature support

2016-11-30 Thread Maxime Coquelin
This patch allows advising guest with host MTU's by setting
host_mtu parameter.

If VIRTIO_NET_F_MTU has been successfully negotiated, MTU
value is passed to the backend.

Cc: Michael S. Tsirkin 
Cc: Aaron Conole 
---
 hw/net/virtio-net.c| 13 +
 include/hw/virtio/virtio-net.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5009533..5225e9b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -55,6 +55,8 @@ static VirtIOFeature feature_sizes[] = {
  .end = endof(struct virtio_net_config, status)},
 {.flags = 1 << VIRTIO_NET_F_MQ,
  .end = endof(struct virtio_net_config, max_virtqueue_pairs)},
+{.flags = 1 << VIRTIO_NET_F_MTU,
+ .end = endof(struct virtio_net_config, mtu)},
 {}
 };
 
@@ -81,6 +83,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t 
*config)
 
 virtio_stw_p(vdev, &netcfg.status, n->status);
 virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues);
+virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu);
 memcpy(netcfg.mac, n->mac, ETH_ALEN);
 memcpy(config, &netcfg, n->config_size);
 }
@@ -152,6 +155,10 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t 
status)
 qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
 }
 
+if (virtio_has_feature(vdev->guest_features, VIRTIO_NET_F_MTU)) {
+vhost_net_set_mtu(get_vhost_net(nc->peer), n->net_conf.mtu);
+}
+
 n->vhost_started = 1;
 r = vhost_net_start(vdev, n->nic->ncs, queues);
 if (r < 0) {
@@ -1695,6 +1702,7 @@ static void virtio_net_set_config_size(VirtIONet *n, 
uint64_t host_features)
 {
 int i, config_size = 0;
 virtio_add_feature(&host_features, VIRTIO_NET_F_MAC);
+
 for (i = 0; feature_sizes[i].flags != 0; i++) {
 if (host_features & feature_sizes[i].flags) {
 config_size = MAX(feature_sizes[i].end, config_size);
@@ -1724,6 +1732,10 @@ static void virtio_net_device_realize(DeviceState *dev, 
Error **errp)
 NetClientState *nc;
 int i;
 
+if (n->net_conf.mtu) {
+n->host_features |= (0x1 << VIRTIO_NET_F_MTU);
+}
+
 virtio_net_set_config_size(n, n->host_features);
 virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size);
 
@@ -1922,6 +1934,7 @@ static Property virtio_net_properties[] = {
 DEFINE_PROP_STRING("tx", VirtIONet, net_conf.tx),
 DEFINE_PROP_UINT16("rx_queue_size", VirtIONet, net_conf.rx_queue_size,
VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE),
+DEFINE_PROP_UINT16("host_mtu", VirtIONet, net_conf.mtu, 0),
 DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 0ced975..8ea56a8 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -36,6 +36,7 @@ typedef struct virtio_net_conf
 int32_t txburst;
 char *tx;
 uint16_t rx_queue_size;
+uint16_t mtu;
 } virtio_net_conf;
 
 /* Maximum packet size we can receive from tap device: header + 64k */
-- 
2.9.3




Re: [Qemu-devel] [RFC v3 1/3] vhost-user: Add MTU protocol feature and op

2016-11-30 Thread Yuanhan Liu
On Wed, Nov 30, 2016 at 11:10:15AM +0100, Maxime Coquelin wrote:
> +#define VHOST_USER_PROTOCOL_F_MTU4
>  
>  Message types
>  -
> @@ -470,6 +471,18 @@ Message types
>The first 6 bytes of the payload contain the mac address of the guest 
> to
>allow the vhost user backend to construct and broadcast the fake RARP.
>  
> + * VHOST_USER_SET_MTU

One thing I have just thought of is that, though we currently have one
vhost-user driver (net), SPDK here (James cc'ed) is proposing vhost-user
for other devices, say SCSI.

So maybe it's better to add some type prefix here, like VHOST_USER_NET_SET_MTU?

--yliu



Re: [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature

2016-11-30 Thread no-reply
Hi,

Your series failed automatic build test. Please find the testing commands and
their output below. If you have docker installed, you can probably reproduce it
locally.

Subject: [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature
Type: series
Message-id: 20161130101017.13382-1-maxime.coque...@redhat.com

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=16
make docker-test-quick@centos6
make docker-test-mingw@fedora
make docker-test-build@min-glib
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]  patchew/20161130053629.23340-1-alast...@au1.ibm.com -> 
patchew/20161130053629.23340-1-alast...@au1.ibm.com
 * [new tag] patchew/20161130101017.13382-1-maxime.coque...@redhat.com 
-> patchew/20161130101017.13382-1-maxime.coque...@redhat.com
Switched to a new branch 'test'
593935f virtio-net: Add MTU feature support
93e38c6 vhost-net: Notify the backend about the host MTU
aaeb227 vhost-user: Add MTU protocol feature and op

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 'dtc'...
Submodule path 'dtc': checked out '65cc4d2748a2c2e6f27f1cf39e07a5dbabd80ebf'
  BUILD   centos6
make[1]: Entering directory `/var/tmp/patchew-tester-tmp-bde91o6k/src'
  ARCHIVE qemu.tgz
  ARCHIVE dtc.tgz
  COPYRUNNER
RUN test-quick in qemu:centos6 
Packages installed:
SDL-devel-1.2.14-7.el6_7.1.x86_64
ccache-3.1.6-2.el6.x86_64
epel-release-6-8.noarch
gcc-4.4.7-17.el6.x86_64
git-1.7.1-4.el6_7.1.x86_64
glib2-devel-2.28.8-5.el6.x86_64
libfdt-devel-1.4.0-1.el6.x86_64
make-3.81-23.el6.x86_64
package g++ is not installed
pixman-devel-0.32.8-1.el6.x86_64
tar-1.23-15.el6_8.x86_64
zlib-devel-1.2.3-29.el6.x86_64

Environment variables:
PACKAGES=libfdt-devel ccache tar git make gcc g++ zlib-devel 
glib2-devel SDL-devel pixman-devel epel-release
HOSTNAME=34156d7170a9
TERM=xterm
MAKEFLAGS= -j16
HISTSIZE=1000
J=16
USER=root
CCACHE_DIR=/var/tmp/ccache
EXTRA_CONFIGURE_OPTS=
V=
SHOW_ENV=1
MAIL=/var/spool/mail/root
PATH=/usr/lib/ccache:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
LANG=en_US.UTF-8
TARGET_LIST=
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TEST_DIR=/tmp/qemu-test
LOGNAME=root
LESSOPEN=||/usr/bin/lesspipe.sh %s
FEATURES= dtc
DEBUG=
G_BROKEN_FILENAMES=1
CCACHE_HASHDIR=
_=/usr/bin/env

Configure options:
--enable-werror --target-list=x86_64-softmmu,aarch64-softmmu 
--prefix=/var/tmp/qemu-build/install
No C++ compiler available; disabling C++ specific optional code
Install prefix/var/tmp/qemu-build/install
BIOS directory/var/tmp/qemu-build/install/share/qemu
binary directory  /var/tmp/qemu-build/install/bin
library directory /var/tmp/qemu-build/install/lib
module directory  /var/tmp/qemu-build/install/lib/qemu
libexec directory /var/tmp/qemu-build/install/libexec
include directory /var/tmp/qemu-build/install/include
config directory  /var/tmp/qemu-build/install/etc
local state directory   /var/tmp/qemu-build/install/var
Manual directory  /var/tmp/qemu-build/install/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path   /tmp/qemu-test/src
C compilercc
Host C compiler   cc
C++ compiler  
Objective-C compiler cc
ARFLAGS   rv
CFLAGS-O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g 
QEMU_CFLAGS   -I/usr/include/pixman-1-pthread -I/usr/include/glib-2.0 
-I/usr/lib64/glib-2.0/include   -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes 
-Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes 
-fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wmissing-include-dirs 
-Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self 
-Wignored-qualifiers -Wold-style-declaration -Wold-style-definition 
-Wtype-limits -fstack-protector-all
LDFLAGS   -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g 
make  make
install   install
pythonpython -B
smbd  /usr/sbin/smbd
module supportno
host CPU  x86_64
host big endian   no
target list   x86_64-softmmu aarch64-softmmu
tcg debug enabled no
gprof enabled no
sparse enabledno
strip binariesyes
profiler  no
static build  no
pixmansystem
SDL support   yes (1.2.14)
GTK support   no 
GTK GL supportno
VTE support   no 
TLS priority  NORMAL
GNUTLS supportno
GNUTLS rndno
libgcrypt no
libgcrypt kdf no
nettleno 
nettle kdfno
libtasn1  no
curses supportno
virgl support no
curl support  no
mingw32 support   no
Audio drivers oss
Block whitelist (rw) 
Block whitelist (ro) 
VirtFS supportno
VNC support   yes
VNC SASL support  no
VNC JPEG support  no
VNC PNG support   no
xen sup

Re: [Qemu-devel] [PATCH 2/2] fsl_etsec: Fix various small problems in hexdump code

2016-11-30 Thread Jason Wang



On 2016年11月29日 02:13, Andrey Smirnov wrote:

Fix various small problems in hexdump code, such as:
 - Reference to non-existing field etsec->nic->nc.name is replaced
 with nc->name

 - Type mismatch warnings

Signed-off-by: Andrey Smirnov 
---
  hw/net/fsl_etsec/etsec.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index b5c777f..1093d8b 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -348,8 +348,8 @@ static ssize_t etsec_receive(NetClientState *nc,
  eTSEC *etsec = qemu_get_nic_opaque(nc);
  
  #if defined(HEX_DUMP)

-fprintf(stderr, "%s receive size:%d\n", etsec->nic->nc.name, size);
-qemu_hexdump(buf, stderr, "", size);
+fprintf(stderr, "%s receive size:%zd\n", nc->name, size);
+qemu_hexdump((void *)buf, stderr, "", size);
  #endif
  /* Flush is unnecessary as are already in receiving path */
  etsec->need_flush = false;


Applied, thanks.



Re: [Qemu-devel] [PATCH 1/2] fsl_etsec: Pad short payloads with zeros

2016-11-30 Thread Jason Wang



On 2016年11月29日 02:13, Andrey Smirnov wrote:

Depending on QEMU network setup it is possible for us to receive a
complete Ethernet packet that is less 64 bytes long. One such example is
when QEMU is configured to use a standalone TAP device (not set to be a
part of any bridge) receives and ARP packet. In cases like that we need
to add more than just 4-bytes of CRC padding and ensure that our payload
is at least 60 bytes long, such that, when combined with CRC padding
bytes the resulting size is at least 802.3 minimum MTU bytes
long (64). Failing to do that results in code in etsec_walk_rx_ring()
setting BD_RX_SH which, in turn, makes corresponding Linux driver of
emulated host to reject buffer as a runt packet

Signed-off-by: Andrey Smirnov 
---
  hw/net/fsl_etsec/rings.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 79d2f14..1434c91 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -474,6 +474,13 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t 
*buf, size_t size)
  /* CRC padding (We don't have to compute the CRC) */
  etsec->rx_padding = 4;
  
+/*

+ * Ensure that payload length + CRC length is at least 802.3
+ * minimum MTU size bytes long (64)
+ */
+if (etsec->rx_buffer_len < 60)
+etsec->rx_padding += 60 - etsec->rx_buffer_len;
+
  etsec->rx_first_in_frame = 1;
  etsec->rx_remaining_data = etsec->rx_buffer_len;
  RING_DEBUG("%s: rx_buffer_len:%u rx_padding+crc:%u\n", __func__,


Applied, thanks.



Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Fam Zheng
On Wed, 11/30 09:38, Stefan Hajnoczi wrote:
> On Wed, Nov 30, 2016 at 01:42:14PM +0800, Fam Zheng wrote:
> > On Tue, 11/29 20:43, Stefan Hajnoczi wrote:
> > > On Tue, Nov 29, 2016 at 1:24 PM, Fam Zheng  wrote:
> > > > On Tue, 11/29 12:17, Paolo Bonzini wrote:
> > > >> On 29/11/2016 11:32, Fam Zheng wrote:
> > > >> * it still needs a system call before polling is entered.  Ideally, 
> > > >> QEMU
> > > >> could run without any system call while in polling mode.
> > > >>
> > > >> Another possibility is to add a system call for single_task_running().
> > > >> It should be simple enough that you can implement it in the vDSO and
> > > >> avoid a context switch.  There are convenient hooking points in
> > > >> add_nr_running and sub_nr_running.
> > > >
> > > > That sounds good!
> > > 
> > > With this solution QEMU can either poll virtqueues or the host kernel
> > > can poll NIC and storage controller descriptor rings, but not both at
> > > the same time in one thread.  This is one of the reasons why I think
> > > exploring polling in the kernel makes more sense.
> > 
> > That's true. I have one question though: controller rings are in a different
> > layer in the kernel, I wonder what the syscall interface looks like to ask
> > kernel to poll both hardware rings and memory locations in the same loop? 
> > It's
> > not obvious to me after reading your eventfd patch.
> 
> Current descriptor ring polling in select(2)/poll(2) is supported for
> network sockets.  Take a look at the POLL_BUSY_LOOP flag in
> fs/select.c:do_poll().  If the .poll() callback sets the flag then it
> indicates that the fd supports busy loop polling.
> 
> The way this is implemented for network sockets is that the socket looks
> up the napi index and is able to use the NIC driver to poll the rx ring.
> Then it checks whether the socket's receive queue contains data after
> the rx ring was processed.
> 
> The virtio_net.ko driver supports this interface, for example.  See
> drivers/net/virtio_net.c:virtnet_busy_poll().
> 
> Busy loop polling isn't supported for block I/O yet.  There is currently
> a completely independent code path for O_DIRECT synchronous I/O where
> NVMe can poll for request completion.  But it doesn't work together with
> asynchronous I/O (e.g. Linux AIO using eventfd with select(2)/poll(2)).

This makes perfect sense now, thanks for the pointers!

> 
> > > The disadvantage of the kernel approach is that you must make the
> > > ppoll(2)/epoll_wait(2) syscall even for polling, and you probably need
> > > to do eventfd reads afterwards so the minimum event loop iteration
> > > latency is higher than doing polling in userspace.
> > 
> > And userspace drivers powered by dpdk or vfio will still want to do polling 
> > in
> > userspace anyway, we may want to take that into account as well.
> 
> vfio supports interrupts so it can definitely be integrated with
> adaptive kernel polling (i.e. poll for a little while and then wait for
> an interrupt if there was no event).
> 
> Does dpdk ever use interrupts?

Yes, interrupt mode is supported there. For example see the intx/msix init code
in drivers/net/ixgbe/ixgbe_ethdev.c:ixgbe_dev_start().

Fam




Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Gerd Hoffmann
On Mi, 2016-11-30 at 11:08 +0100, Laszlo Ersek wrote:
> Recent git releases support the diff.orderFile permanent setting.

Cool.

> configure
> *Makefile*
> *.json
> *.txt
> *.h
> *.c

I'd put *.txt to the head so doc updates come first.
Otherwise the order looks good to me.

Want sent a patch?

Can this be automatically enabled per repo, like .gitignore, so it works
without everybody tweaking its local git config?

cheers,
  Gerd




Re: [Qemu-devel] [Nbd] [PATCH v3] doc: Add NBD_CMD_BLOCK_STATUS extension

2016-11-30 Thread Sergey Talantov
Hi, Wouter!

> Actually, come to think of that. What is the exact use case for this thing? I 
> understand you're trying to create incremental backups of things, which would 
> imply you don't write from the client that is getting the ?
> block status thingies, right?

Overall, the most desired use case for this NBD extension is to allow 3-rd 
party software to make incremental backups.
Acronis (vendor of backup solutions) would support qemu backup if block status 
is provided.


-Original Message-
From: Wouter Verhelst [mailto:w...@uter.be] 
Sent: Sunday, November 27, 2016 22:17
To: Vladimir Sementsov-Ogievskiy 
Cc: nbd-gene...@lists.sourceforge.net; kw...@redhat.com; qemu-devel@nongnu.org; 
pborzen...@virtuozzo.com; stefa...@redhat.com; pbonz...@redhat.com; 
m...@pengutronix.de; d...@openvz.org
Subject: Re: [Nbd] [PATCH v3] doc: Add NBD_CMD_BLOCK_STATUS extension

Hi Vladimir,

Quickly: the reason I haven't merged this yes is twofold:
- I wasn't thrilled with the proposal at the time. It felt a bit
  hackish, and bolted onto NBD so you could use it, but without defining
  everything in the NBD protocol. "We're reading some data, but it's not
  about you". That didn't feel right
- There were a number of questions still unanswered (you're answering a
  few below, so that's good).

For clarity, I have no objection whatsoever to adding more commands if they're 
useful, but I would prefer that they're also useful with NBD on its own, i.e., 
without requiring an initiation or correlation of some state through another 
protocol or network connection or whatever. If that's needed, that feels like I 
didn't do my job properly, if you get my point.

On Fri, Nov 25, 2016 at 02:28:16PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> With the availability of sparse storage formats, it is often needed to 
> query status of a particular range and read only those blocks of data 
> that are actually present on the block device.
> 
> To provide such information, the patch adds the BLOCK_STATUS extension 
> with one new NBD_CMD_BLOCK_STATUS command, a new structured reply 
> chunk format, and a new transmission flag.
> 
> There exists a concept of data dirtiness, which is required during, 
> for example, incremental block device backup. To express this concept 
> via NBD protocol, this patch also adds a flag to NBD_CMD_BLOCK_STATUS 
> to request dirtiness information rather than provisioning information; 
> however, with the current proposal, data dirtiness is only useful with 
> additional coordination outside of the NBD protocol (such as a way to 
> start and stop the server from tracking dirty sectors).  Future NBD 
> extensions may add commands to control dirtiness through NBD.
> 
> Since NBD protocol has no notion of block size, and to mimic SCSI "GET 
> LBA STATUS" command more closely, it has been chosen to return a list 
> of extents in the response of NBD_CMD_BLOCK_STATUS command, instead of 
> a bitmap.
> 
> CC: Pavel Borzenkov 
> CC: Denis V. Lunev 
> CC: Wouter Verhelst 
> CC: Paolo Bonzini 
> CC: Kevin Wolf 
> CC: Stefan Hajnoczi 
> Signed-off-by: Eric Blake 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
> 
> v3:
> 
> Hi all. This is almost a resend of v2 (by Eric Blake), The only change 
> is removing the restriction, that sum of status descriptor lengths 
> must be equal to requested length. I.e., let's permit the server to 
> replay with less data than required if it wants.

Reasonable, yes. The length that the client requests should be a maximum (i.e.
"I'm interested in this range"), not an exact request.

> Also, bit of NBD_FLAG_SEND_BLOCK_STATUS is changed to 9, as 8 is now  
> NBD_FLAG_CAN_MULTI_CONN in master branch.

Right.

> And, finally, I've rebased this onto current state of 
> extension-structured-reply branch (which itself should be rebased on 
> master IMHO).

Probably a good idea, given the above.

> By this resend I just want to continue the diqussion, started about 
> half a year ago. Here is a summary of some questions and ideas from v2
> diqussion:
> 
> 1. Q: Synchronisation. Is such data (dirty/allocated) reliable? 
>A: This all is for read-only disks, so the data is static and unchangeable.

I think we should declare that it's up to the client to ensure no other writes 
happen without its knowledge. This may be because the client and server 
communicate out of band about state changes, or because the client somehow 
knows that it's the only writer, or whatever.

We can easily do that by declaring that the result of that command only talks 
about *current* state, and that concurrent writes by different clients may 
invalidate the state. This is true for NBD in general (i.e., concurrent read or 
write commands from other clients may confuse file systems on top of NBD), so 
it doesn't change expectations in any way.

> 2. Q: different granularities of dirty/allocated bitmaps. Any problems?
>A: 1: server replies with status descriptors of any size, granularity
> 

Re: [Qemu-devel] [PATCH] virtio-scsi: introduce virtio_scsi_acquire/release

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 04:37:01PM +0100, Paolo Bonzini wrote:
> These will be used more as soon as the acquire/release is pushed down to
> the ioeventfd handlers.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  hw/scsi/virtio-scsi.c | 27 ++-
>  1 file changed, 18 insertions(+), 9 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v4 1/1] crypto: add virtio-crypto driver

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 08:48:14PM +0800, Gonglei wrote:
> diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c 
> b/drivers/crypto/virtio/virtio_crypto_algs.c
> new file mode 100644
> index 000..08b077f
> --- /dev/null
> +++ b/drivers/crypto/virtio/virtio_crypto_algs.c
> @@ -0,0 +1,518 @@
> + /* Algorithms supported by virtio crypto device
> +  *
> +  * Authors: Gonglei 
> +  *
> +  * Copyright 2016 HUAWEI TECHNOLOGIES CO., LTD.
> +  *
> +  * This program is free software; you can redistribute it and/or modify
> +  * it under the terms of the GNU General Public License as published by
> +  * the Free Software Foundation; either version 2 of the License, or
> +  * (at your option) any later version.
> +  *
> +  * This program is distributed in the hope that it will be useful,
> +  * but WITHOUT ANY WARRANTY; without even the implied warranty of
> +  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +  * GNU General Public License for more details.
> +  *
> +  * You should have received a copy of the GNU General Public License
> +  * along with this program; if not, see .
> +  */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include "virtio_crypto_common.h"
> +
> +static DEFINE_MUTEX(algs_lock);

Did you run checkpatch.pl?  I think it encourages you to document what
the lock protects.

> +static int virtio_crypto_alg_ablkcipher_init_session(
> + struct virtio_crypto_ablkcipher_ctx *ctx,
> + uint32_t alg, const uint8_t *key,
> + unsigned int keylen,
> + int encrypt)
> +{
> + struct scatterlist outhdr, key_sg, inhdr, *sgs[3];
> + unsigned int tmp;
> + struct virtio_crypto *vcrypto = ctx->vcrypto;
> + int op = encrypt ? VIRTIO_CRYPTO_OP_ENCRYPT : VIRTIO_CRYPTO_OP_DECRYPT;
> + int err;
> + unsigned int num_out = 0, num_in = 0;
> +
> + /*
> +  * Avoid to do DMA from the stack, switch to using
> +  * dynamically-allocated for the key
> +  */
> + uint8_t *cipher_key = kmalloc(keylen, GFP_ATOMIC);
> +
> + if (!cipher_key)
> + return -ENOMEM;
> +
> + memcpy(cipher_key, key, keylen);

Are there any rules on handling key material in the kernel?  This buffer
is just kfreed later.  Do you need to zero it out before freeing it?

> +
> + spin_lock(&vcrypto->ctrl_lock);

The QAT accelerator driver doesn't spin while talking to the device in
virtio_crypto_alg_ablkcipher_init_session().  I didn't find any other
driver examples in the kernel tree, but this function seems like a
weakness in the virtio-crypto device.

While QEMU is servicing the create session command this vcpu is blocked.
The QEMU global mutex is held so no other vcpu can enter QEMU and the
QMP monitor is also blocked.

This is a scalability and performance problem.  Can you look at how QAT
avoids this synchronous session setup?


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 1/2] virtio-net rsc: support coalescing ipv4 tcp traffic

2016-11-30 Thread Jason Wang



On 2016年11月30日 16:55, Wei Xu wrote:

On 2016年11月24日 12:17, Jason Wang wrote:



On 2016年11月01日 01:41, w...@redhat.com wrote:

From: Wei Xu 

All the data packets in a tcp connection are cached
to a single buffer in every receive interval, and will
be sent out via a timer, the 'virtio_net_rsc_timeout'
controls the interval, this value may impact the
performance and response time of tcp connection,
5(50us) is an experience value to gain a performance
improvement, since the whql test sends packets every 100us,
so '30(300us)' passes the test case, it is the default
value as well, tune it via the command line parameter
'rsc_interval' within 'virtio-net-pci' device, for example,
to launch a guest with interval set as '50':

'virtio-net-pci,netdev=hostnet1,bus=pci.0,id=net1,mac=00,rsc_interval=50' 




The timer will only be triggered if the packets pool is not empty,
and it'll drain off all the cached packets.

'NetRscChain' is used to save the segments of IPv4/6 in a
VirtIONet device.

A new segment becomes a 'Candidate' as well as it passed sanity check,
the main handler of TCP includes TCP window update, duplicated
ACK check and the real data coalescing.

An 'Candidate' segment means:
1. Segment is within current window and the sequence is the expected 
one.

2. 'ACK' of the segment is in the valid window.

Sanity check includes:
1. Incorrect version in IP header
2. An IP options or IP fragment
3. Not a TCP packet
4. Sanity size check to prevent buffer overflow attack.
5. An ECN packet

Even though, there might more cases should be considered such as
ip identification other flags, while it breaks the test because
windows set it to the same even it's not a fragment.

Normally it includes 2 typical ways to handle a TCP control flag,
'bypass' and 'finalize', 'bypass' means should be sent out directly,
while 'finalize' means the packets should also be bypassed, but this
should be done after search for the same connection packets in the
pool and drain all of them out, this is to avoid out of order fragment.

All the 'SYN' packets will be bypassed since this always begin a new'
connection, other flags such 'URG/FIN/RST/CWR/ECE' will trigger a
finalization, because this normally happens upon a connection is going
to be closed, an 'URG' packet also finalize current coalescing unit.

Statistics can be used to monitor the basic coalescing status, the
'out of order' and 'out of window' means how many retransmitting 
packets,

thus describe the performance intuitively.

Signed-off-by: Wei Xu 
---
  hw/net/virtio-net.c | 602
++--
  include/hw/virtio/virtio-net.h  |   5 +-
  include/hw/virtio/virtio.h  |  76 
  include/net/eth.h   |   2 +
  include/standard-headers/linux/virtio_net.h |  14 +
  net/tap.c   |   3 +-
  6 files changed, 670 insertions(+), 32 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 06bfe4b..d1824d9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -15,10 +15,12 @@
  #include "qemu/iov.h"
  #include "hw/virtio/virtio.h"
  #include "net/net.h"
+#include "net/eth.h"
  #include "net/checksum.h"
  #include "net/tap.h"
  #include "qemu/error-report.h"
  #include "qemu/timer.h"
+#include "qemu/sockets.h"
  #include "hw/virtio/virtio-net.h"
  #include "net/vhost_net.h"
  #include "hw/virtio/virtio-bus.h"
@@ -43,6 +45,24 @@
  #define endof(container, field) \
  (offsetof(container, field) + sizeof(((container *)0)->field))
+#define VIRTIO_NET_IP4_ADDR_SIZE   8/* ipv4 saddr + daddr */


Only used once in the code, I don't see much value of this macro.


Just to keep it a bit readable.


Then you may want to replace this with sizeof(struct ...).






+
+#define VIRTIO_NET_TCP_FLAG 0x3F
+#define VIRTIO_NET_TCP_HDR_LENGTH   0xF000
+
+/* IPv4 max payload, 16 bits in the header */
+#define VIRTIO_NET_MAX_IP4_PAYLOAD (65535 - sizeof(struct ip_header))
+#define VIRTIO_NET_MAX_TCP_PAYLOAD 65535
+
+/* header length value in ip header without option */
+#define VIRTIO_NET_IP4_HEADER_LENGTH 5
+
+/* Purge coalesced packets timer interval, This value affects the
performance
+   a lot, and should be tuned carefully, '30'(300us) is the
recommended
+   value to pass the WHQL test, '5' can gain 2x netperf
throughput with
+   tso/gso/gro 'off'. */
+#define VIRTIO_NET_RSC_INTERVAL  30


This should be a property for virito-net and the above comment can be
the description of the property.


This is a value for a property, actually I hadn't found a place to put
it.


There's a description filed of PropertyInfo, but for virtio properties 
may need more work. So we can leave this as is now.







+
  typedef struct VirtIOFeature {
  uint32_t flags;
  size_t end;
@@ -589,7 +609,12 @@ static uint64_t
virtio_net_guest_offloads_by_features(uint32_t features)
  (1ULL << VIRTIO_NET_F_GUEST_ECN)  |

Re: [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature

2016-11-30 Thread Jason Wang



On 2016年11月30日 18:10, Maxime Coquelin wrote:

This series implements Virtio spec update from Aaron Conole which
defines a way for the host to expose its max MTU to the guest.

This third version re-desings how MTU value is provided to QEMU.
Now, host_mtu parameter is added to provide QEMU with the MTU value,
and the backend, if supported, gets notified of the MTU value when the
MTU feature neogotiation succeeds.

Only user backend currently supports MTU notification. A new protocol
feature has been implemented for sending MTU value to the backend.
Aaron, Kevin, Flavio, do you confirm this works for OVS if DPDK vhost lib
adds needed API to get the MTU value?

For kernel backend, it is expected the management tool also configures
the tap/macvtap interface with same MTU value.
Daniel, I would be interrested about your feedback on this implementation
from management tool point of view.


I believe we want management tool to configure both kernel and user 
backends.




Changes since RFC v2:
-
  - host_mtu propoerty is now used to specify the MTU value
  - update vhost-user spec with MTU additions

Changes since RFC v1:
-
  - Rebased on top of v2.8.0-rc0 (2.7.90)
  - Write MTU unconditionnaly in netcfg to avoid memory leak (Paolo)
  - Add host_mtu property to be able to disable the feature from QEMU

Maxime Coquelin (3):
   vhost-user: Add MTU protocol feature and op
   vhost-net: Notify the backend about the host MTU
   virtio-net: Add MTU feature support

  docs/specs/vhost-user.txt | 13 +
  hw/net/vhost_net.c| 22 ++
  hw/net/virtio-net.c   | 13 +
  hw/virtio/vhost-user.c| 13 +
  include/hw/virtio/vhost-backend.h |  2 ++
  include/hw/virtio/virtio-net.h|  1 +
  include/net/vhost_net.h   |  2 ++
  7 files changed, 66 insertions(+)






Re: [Qemu-devel] [RFC v3 3/3] virtio-net: Add MTU feature support

2016-11-30 Thread Jason Wang



On 2016年11月30日 18:10, Maxime Coquelin wrote:

This patch allows advising guest with host MTU's by setting
host_mtu parameter.

If VIRTIO_NET_F_MTU has been successfully negotiated, MTU
value is passed to the backend.

Cc: Michael S. Tsirkin 
Cc: Aaron Conole 
---
  hw/net/virtio-net.c| 13 +
  include/hw/virtio/virtio-net.h |  1 +
  2 files changed, 14 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5009533..5225e9b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -55,6 +55,8 @@ static VirtIOFeature feature_sizes[] = {
   .end = endof(struct virtio_net_config, status)},
  {.flags = 1 << VIRTIO_NET_F_MQ,
   .end = endof(struct virtio_net_config, max_virtqueue_pairs)},
+{.flags = 1 << VIRTIO_NET_F_MTU,
+ .end = endof(struct virtio_net_config, mtu)},
  {}
  };
  
@@ -81,6 +83,7 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
  
  virtio_stw_p(vdev, &netcfg.status, n->status);

  virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues);
+virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu);
  memcpy(netcfg.mac, n->mac, ETH_ALEN);
  memcpy(config, &netcfg, n->config_size);
  }
@@ -152,6 +155,10 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t 
status)
  qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
  }
  
+if (virtio_has_feature(vdev->guest_features, VIRTIO_NET_F_MTU)) {

+vhost_net_set_mtu(get_vhost_net(nc->peer), n->net_conf.mtu);
+}


We'd better not ignore errors here and that's why we need management 
tool (who can make sure the mtu is set correctly before launching qemu).



+
  n->vhost_started = 1;
  r = vhost_net_start(vdev, n->nic->ncs, queues);
  if (r < 0) {
@@ -1695,6 +1702,7 @@ static void virtio_net_set_config_size(VirtIONet *n, 
uint64_t host_features)
  {
  int i, config_size = 0;
  virtio_add_feature(&host_features, VIRTIO_NET_F_MAC);
+
  for (i = 0; feature_sizes[i].flags != 0; i++) {
  if (host_features & feature_sizes[i].flags) {
  config_size = MAX(feature_sizes[i].end, config_size);
@@ -1724,6 +1732,10 @@ static void virtio_net_device_realize(DeviceState *dev, 
Error **errp)
  NetClientState *nc;
  int i;
  
+if (n->net_conf.mtu) {

+n->host_features |= (0x1 << VIRTIO_NET_F_MTU);
+}
+
  virtio_net_set_config_size(n, n->host_features);
  virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size);
  
@@ -1922,6 +1934,7 @@ static Property virtio_net_properties[] = {

  DEFINE_PROP_STRING("tx", VirtIONet, net_conf.tx),
  DEFINE_PROP_UINT16("rx_queue_size", VirtIONet, net_conf.rx_queue_size,
 VIRTIO_NET_RX_QUEUE_DEFAULT_SIZE),
+DEFINE_PROP_UINT16("host_mtu", VirtIONet, net_conf.mtu, 0),
  DEFINE_PROP_END_OF_LIST(),
  };
  
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h

index 0ced975..8ea56a8 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -36,6 +36,7 @@ typedef struct virtio_net_conf
  int32_t txburst;
  char *tx;
  uint16_t rx_queue_size;
+uint16_t mtu;
  } virtio_net_conf;
  
  /* Maximum packet size we can receive from tap device: header + 64k */





Re: [Qemu-devel] [PATCH v2 4/5] slirp: VMStatify socket level

2016-11-30 Thread Dr. David Alan Gilbert
* Samuel Thibault (samuel.thiba...@gnu.org) wrote:
> Hello,
> 
> Dr. David Alan Gilbert, on Mon 28 Nov 2016 09:08:16 +, wrote:
> > Hmm, I don't really know IPv6 but I'm thinking this code will become 
> > something like
> > the following (says he not knowing whether a scope-id or a flowinfo
> > is something that needs migrating) (untested):
> > 
> > 
> > static const VMStateDescription vmstate_slirp_socket_addr = {
> > .name = "slirp-socket-addr",
> > .version_id = 4,
> > .fields = (VMStateField[]) {
> > VMSTATE_UINT16(ss.ss_family, union slirp_sockaddr),
> > VMSTATE_UINT32_TEST(sin.sin_addr.s_addr, union slirp_sockaddr,
> > slirp_family_inet),
> > VMSTATE_UINT16_TEST(sin.sin_port, union slirp_sockaddr,
> > slirp_family_inet),
> > 
> > VMSTATE_BUFFER_TEST(sin6.sin6_addr, union slirp_sockaddr,
> > slirp_family_inet6),
> > VMSTATE_UINT16_TEST(sin6.sin6_port, union slirp_sockaddr,
> > slirp_family_inet6),
> > VMSTATE_UINT32_TEST(sin6.sin6_flowinfo, union slirp_sockaddr,
> > slirp_family_inet6),
> > VMSTATE_UINT32_TEST(sin6.sin6_scope_id, union slirp_sockaddr,
> > slirp_family_inet6),
> > 
> > VMSTATE_END_OF_LIST()
> > }
> > };
> 
> Ok, that looks good :)
> 
> > So to me that looks pretty clean, we need to add another slirp_family_inet6
> > test function, but then we just add the extra fields for the IPv6 stuff.
> 
> Yes, now I see.
> 
> > Can you suggest an IPv6 command line for testing that ?
> 
> Well, it doesn't exist yet, that's the problem. And applying your patch
> would have made it to exist even harder, so that's why I was afraid.
> 
> I would say that your patch should contain these IPv6 lines, but as
> comments since they are untested, for the person who will at some point
> want to implement the IPv6 case here.

OK, yes I can just add them as a comment and let someone who fixes
the rest of the IPv6 code turn it on.

Dave

> Samuel
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



Re: [Qemu-devel] [PATCH v2 0/6] Add support for the Epson RX8900 RTC to the aspeed board

2016-11-30 Thread Alastair D'Silva
On Wed, 2016-11-30 at 16:36 +1100, Alastair D'Silva wrote:
> 
> This patch series adds support for the Epson RX8900 RTC to the
> Aspeed board.
> 
> The tests use the existing imx25 infrastructure, and some minor
> changes have been made to uniquely identify the I2C buses.
> 
> A NULL check have been added to eliminate empty i2cslave init
> functions.
> 
> Support for named interrupts has been implemented in qtest to
> facilitate testing.

Sorry, I missed a changelog...

Changelog:
v2:
 - Avoid using error_report
 - Fix TIE behaviour
 - Move temperature init out of reset, it should not change
   on a soft reset
 - Fix IRQ in test failures
 - Add a NULL check for i2c slave init callbacks, so that we
   no longer need to implement empty init functions.
 - Refactor to use the existing qemu trace infrastructure
 - Move the RX8900 definition into the aspeed machine init
 - It it possible for check_update_interrupt_seconds in the
   rx8900 test to return 6, depending on the alignment with
   the wall clock.
 - Support low voltage detection





Re: [Qemu-devel] Question about open() in qemu

2016-11-30 Thread Fam Zheng
On Wed, 11/30 19:11, morgenlette madeBy wrote:
> Hello
> 
> I am studnet studying QEMU.
> 
> I have a question open in QEMU.
> 
> In  function handle_aiocb_rw_linear() in block/raw-posix.c,
> 
> i tried to open my device driver(mydev).
> 
> this driver was confirmed safe operation by test program.
> 
> But in qemu, this driver was not opened returning -1.
> 
> errno is 1. 1 means 'Operation not permitted'
> 
> QEMU is not supporting open()???

Hi!

If you are asking a question about your modification to QEMU, could you include
the patch and describe the steps in detail? I cannot tell what you are trying to
achieve here.

Fam



[Qemu-devel] Question about open() in qemu

2016-11-30 Thread morgenlette madeBy
Hello

I am studnet studying QEMU.

I have a question open in QEMU.

In  function handle_aiocb_rw_linear() in block/raw-posix.c,

i tried to open my device driver(mydev).

this driver was confirmed safe operation by test program.

But in qemu, this driver was not opened returning -1.

errno is 1. 1 means 'Operation not permitted'

QEMU is not supporting open()???


Re: [Qemu-devel] [RFC v3 1/3] vhost-user: Add MTU protocol feature and op

2016-11-30 Thread Maxime Coquelin



On 11/30/2016 11:25 AM, Yuanhan Liu wrote:

On Wed, Nov 30, 2016 at 11:10:15AM +0100, Maxime Coquelin wrote:

+#define VHOST_USER_PROTOCOL_F_MTU4

 Message types
 -
@@ -470,6 +471,18 @@ Message types
   The first 6 bytes of the payload contain the mac address of the guest to
   allow the vhost user backend to construct and broadcast the fake RARP.

+ * VHOST_USER_SET_MTU


One thing I have just thought of is that, though we currently have one
vhost-user driver (net), SPDK here (James cc'ed) is proposing vhost-user
for other devices, say SCSI.

So maybe it's better to add some type prefix here, like VHOST_USER_NET_SET_MTU?

Good point, and it would be consistent with the op name.

Thanks,
Maxime



--yliu





Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Laszlo Ersek
On 11/30/16 11:55, Gerd Hoffmann wrote:
> On Mi, 2016-11-30 at 11:08 +0100, Laszlo Ersek wrote:
>> Recent git releases support the diff.orderFile permanent setting.
> 
> Cool.
> 
>> configure
>> *Makefile*
>> *.json
>> *.txt
>> *.h
>> *.c
> 
> I'd put *.txt to the head so doc updates come first.

Good idea, yes.

> Otherwise the order looks good to me.
> 
> Want sent a patch?

What file for? :)

I've considered modifying
, but that article is
humongous already.

Nonetheless, section "Make code motion patches easy to review" mentions
some diff.* settings, so I guess a new section after it ("Format
declarative and abstract changes near the top") would be appropriate, if
there's no disagreement.

> Can this be automatically enabled per repo, like .gitignore, so it works
> without everybody tweaking its local git config?

Not to my understanding.

Thanks!
Laszlo




Re: [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature

2016-11-30 Thread Maxime Coquelin



On 11/30/2016 12:23 PM, Jason Wang wrote:



On 2016年11月30日 18:10, Maxime Coquelin wrote:

This series implements Virtio spec update from Aaron Conole which
defines a way for the host to expose its max MTU to the guest.

This third version re-desings how MTU value is provided to QEMU.
Now, host_mtu parameter is added to provide QEMU with the MTU value,
and the backend, if supported, gets notified of the MTU value when the
MTU feature neogotiation succeeds.

Only user backend currently supports MTU notification. A new protocol
feature has been implemented for sending MTU value to the backend.
Aaron, Kevin, Flavio, do you confirm this works for OVS if DPDK vhost lib
adds needed API to get the MTU value?

For kernel backend, it is expected the management tool also configures
the tap/macvtap interface with same MTU value.
Daniel, I would be interrested about your feedback on this implementation
from management tool point of view.


I believe we want management tool to configure both kernel and user
backends.


Yes, I think you are right.

The vhost-user protocol feature would in this case be used to ensure
consistency.

Does that make sense, or we should just drop VHOST_USER_SET_MTU?

Thanks,
Maxime



Re: [Qemu-devel] [RFC v3 3/3] virtio-net: Add MTU feature support

2016-11-30 Thread Maxime Coquelin



On 11/30/2016 12:24 PM, Jason Wang wrote:



On 2016年11月30日 18:10, Maxime Coquelin wrote:

This patch allows advising guest with host MTU's by setting
host_mtu parameter.

If VIRTIO_NET_F_MTU has been successfully negotiated, MTU
value is passed to the backend.

Cc: Michael S. Tsirkin 
Cc: Aaron Conole 
---
  hw/net/virtio-net.c| 13 +
  include/hw/virtio/virtio-net.h |  1 +
  2 files changed, 14 insertions(+)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 5009533..5225e9b 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -55,6 +55,8 @@ static VirtIOFeature feature_sizes[] = {
   .end = endof(struct virtio_net_config, status)},
  {.flags = 1 << VIRTIO_NET_F_MQ,
   .end = endof(struct virtio_net_config, max_virtqueue_pairs)},
+{.flags = 1 << VIRTIO_NET_F_MTU,
+ .end = endof(struct virtio_net_config, mtu)},
  {}
  };
  @@ -81,6 +83,7 @@ static void virtio_net_get_config(VirtIODevice
*vdev, uint8_t *config)
virtio_stw_p(vdev, &netcfg.status, n->status);
  virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues);
+virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu);
  memcpy(netcfg.mac, n->mac, ETH_ALEN);
  memcpy(config, &netcfg, n->config_size);
  }
@@ -152,6 +155,10 @@ static void virtio_net_vhost_status(VirtIONet *n,
uint8_t status)
  qemu_net_queue_purge(qnc->incoming_queue, qnc->peer);
  }
  +if (virtio_has_feature(vdev->guest_features,
VIRTIO_NET_F_MTU)) {
+vhost_net_set_mtu(get_vhost_net(nc->peer), n->net_conf.mtu);
+}


We'd better not ignore errors here and that's why we need management
tool (who can make sure the mtu is set correctly before launching qemu).


Ok.
Currently, errors are reported if it failed to send the request
(protocol feature not present), maybe the request should require a
reply from the backend whether or not configured MTU is consistent
with what management tool set.

Make sense?

Thanks,
Maxime



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Fam Zheng
On Wed, 11/30 13:03, Laszlo Ersek wrote:
> On 11/30/16 11:55, Gerd Hoffmann wrote:
> > On Mi, 2016-11-30 at 11:08 +0100, Laszlo Ersek wrote:
> >> Recent git releases support the diff.orderFile permanent setting.
> > 
> > Cool.
> > 
> >> configure
> >> *Makefile*
> >> *.json
> >> *.txt
> >> *.h
> >> *.c
> > 
> > I'd put *.txt to the head so doc updates come first.
> 
> Good idea, yes.
> 
> > Otherwise the order looks good to me.
> > 
> > Want sent a patch?
> 
> What file for? :)

This is a nice feature, thanks!

Does it make sense to have a .gitpublish file (for Stefan's git-publish script)
in QEMU.git? That way we can add a new profile option to git-publish and let it
build the command line accordingly. This is going to be helpful for those who
already use git-publish.

> 
> I've considered modifying
> , but that article is
> humongous already.

And this sounds good too.

Fam

> 
> Nonetheless, section "Make code motion patches easy to review" mentions
> some diff.* settings, so I guess a new section after it ("Format
> declarative and abstract changes near the top") would be appropriate, if
> there's no disagreement.
> 
> > Can this be automatically enabled per repo, like .gitignore, so it works
> > without everybody tweaking its local git config?
> 
> Not to my understanding.
> 
> Thanks!
> Laszlo
> 
> 



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Gerd Hoffmann
  Hi,

> > Want sent a patch?
> 
> What file for? :)

create something like scripts/git.orderfile, so people have just to run
"git config diff.orderfile scripts/git.orderfile" to enable it, and we
can refine the config without having everybody update the orderfile
manually?

> I've considered modifying
> , but that article is
> humongous already.
> 
> Nonetheless, section "Make code motion patches easy to review" mentions
> some diff.* settings, so I guess a new section after it ("Format
> declarative and abstract changes near the top") would be appropriate, if
> there's no disagreement.

Yep, adding to the wiki sounds good too.

> > Can this be automatically enabled per repo, like .gitignore, so it works
> > without everybody tweaking its local git config?
> 
> Not to my understanding.

Too bad.

cheers,
  Gerd




Re: [Qemu-devel] [PATCH 01/10] aio: rename bh_lock to list_lock

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:46:58PM +0100, Paolo Bonzini wrote:
> diff --git a/include/block/aio.h b/include/block/aio.h
> index c7ae27c..eee3139 100644
> --- a/include/block/aio.h
> +++ b/include/block/aio.h
> @@ -90,7 +90,7 @@ struct AioContext {
>  uint32_t notify_me;
>  
>  /* lock to protect between bh's adders and deleter */
> -QemuMutex bh_lock;
> +QemuMutex list_lock;

Please update the comment.  Looks good otherwise:

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] qemu-system-sh4 vs qemu-system-arm/i386 default behavior

2016-11-30 Thread Tom Rini
On Wed, Nov 30, 2016 at 10:12:09AM +0100, Thomas Huth wrote:
> On 30.11.2016 09:02, Aurelien Jarno wrote:
> > On 2016-11-30 08:33, Thomas Huth wrote:
> >> On 30.11.2016 02:01, Tom Rini wrote:
> >>> Hey all,
> >>>
> >>> I'm trying to make use of the r2d platform for U-Boot testing via QEMU.
> >>> After applying a series[1] I can use the kernel.org sh4 toolchain to get
> >>> a u-boot.bin that runs, mostly.  I say mostly as first of all I have to
> >>> pass "-monitor null -serial null -serial stdio -nographic" to
> >>> qemu-system-sh4 and in that order for me to get output from U-Boot on
> >>> the prompt.  On other platforms such as arm and vexpress or i386 and the
> >>> 'pc' machine I do not need to do this.  Does anyone have any idea why
> >>> this might be and where to start poking in the code to fix this?
> > 
> > The reason is that u-boot and the linux kernel do not have the same way
> > to number the serial port than the physical hardware. Therefore u-boot
> > and the Linux kernel use the second physical serial port .The question is
> > whether we should number our ports from the software (or part of the
> > sofrware) or hardware point of view.
> 
> OK, thanks for the explanation, that makes sense now. ... maybe we
> should put this information on a SH4 machine page under
> http://qemu-project.org/Documentation/Platforms so that users have a
> possibility to understand this serial port numbering?

I'm still a bit confused, sorry.  Digging around a bit I guess what is
happening is that serial_hds[0] is being used, but Linux and U-Boot
expect to use serial_hds[1] and that's what the above combination of
arguments is getting me?  How would I go about saying in a more simple
form perhaps, to use the second described port not the first described
port?  Thanks!

-- 
Tom


signature.asc
Description: Digital signature


Re: [Qemu-devel] [PATCH 03/10] aio: make ctx->list_lock a QemuLockCnt, subsuming ctx->walking_bh

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:00PM +0100, Paolo Bonzini wrote:
> This will make it possible to walk the list of bottom halves without
> holding the AioContext lock---and in turn to call bottom half
> handlers without holding the lock.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  async.c | 35 ---
>  include/block/aio.h | 12 +---
>  2 files changed, 21 insertions(+), 26 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 02/10] qemu-thread: introduce QemuLockCnt

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:46:59PM +0100, Paolo Bonzini wrote:
> A QemuLockCnt comprises a counter and a mutex, with primitives
> to increment and decrement the counter, and to take and release the
> mutex.  It can be used to do lock-free visits to a data structure
> whenever mutexes would be too heavy-weight and the critical section
> is too long for RCU.
> 
> This could be implemented simply by protecting the counter with the
> mutex, but QemuLockCnt is harder to misuse and more efficient.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  docs/lockcnt.txt  | 343 
> ++
>  include/qemu/thread.h |  17 +++
>  util/Makefile.objs|   1 +
>  util/lockcnt.c| 113 +
>  4 files changed, 474 insertions(+)
>  create mode 100644 docs/lockcnt.txt
>  create mode 100644 util/lockcnt.c
> 
> diff --git a/docs/lockcnt.txt b/docs/lockcnt.txt
> new file mode 100644
> index 000..fc5d240
> --- /dev/null
> +++ b/docs/lockcnt.txt
> @@ -0,0 +1,343 @@
> +DOCUMENTATION FOR LOCKED COUNTERS (aka QemuLockCnt)
> +===

This file contains all the documentation but the header file has no doc
comments.  Could you move everything into the header file (like
include/qom/object.h)?


signature.asc
Description: PGP signature


Re: [Qemu-devel] [qemu patch V3 2/2] kvmclock: reduce kvmclock difference on migration

2016-11-30 Thread Eduardo Habkost
On Tue, Nov 29, 2016 at 09:54:29PM -0200, Marcelo Tosatti wrote:
> On Tue, Nov 29, 2016 at 10:34:05AM -0200, Eduardo Habkost wrote:
> > On Tue, Nov 29, 2016 at 08:56:00AM -0200, Marcelo Tosatti wrote:
> > > On Mon, Nov 28, 2016 at 03:12:01PM -0200, Eduardo Habkost wrote:
> > > > On Mon, Nov 28, 2016 at 02:45:24PM -0200, Marcelo Tosatti wrote:
> > > > > On Mon, Nov 28, 2016 at 12:13:22PM -0200, Eduardo Habkost wrote:
> > > > > > Sorry for not noticing the following issues on the previous
> > > > > > reviews. I was only paying attention to the vmstate and machine
> > > > > > code:
> > > > > > 
> > > > > > On Mon, Nov 21, 2016 at 08:50:04AM -0200, Marcelo Tosatti wrote:
> > > > > > > Check for KVM_CAP_ADJUST_CLOCK capability KVM_CLOCK_TSC_STABLE, 
> > > > > > > which
> > > > > > > indicates that KVM_GET_CLOCK returns a value as seen by the guest 
> > > > > > > at
> > > > > > > that moment.
> > > > > > > 
> > > > > > > For new machine types, use this value rather than reading 
> > > > > > > from guest memory.
> > > > > > > 
> > > > > > > This reduces kvmclock difference on migration from 5s to 0.1s
> > > > > > > (when max_downtime == 5s).
> > > > > > > 
> > > > > > > Signed-off-by: Marcelo Tosatti 
> > > > > > > 
> > > > > > > ---
> > > > > > >  hw/i386/kvm/clock.c|  107 
> > > > > > > ++---
> > > > > > >  include/hw/i386/pc.h   |5 ++
> > > > > > >  target-i386/kvm.c  |7 +++
> > > > > > >  target-i386/kvm_i386.h |1 
> > > > > > >  4 files changed, 106 insertions(+), 14 deletions(-)
> > > > > > > 
> > > > > > > v2: 
> > > > > > > - improve variable names (Juan)
> > > > > > > - consolidate code on kvm_get_clock function (Paolo)
> > > > > > > - return mach_use_reliable_get_clock from needed function (Paolo)
> > > > > > > v3: 
> > > > > > > - simplify check for src_use_reliable_get_clock (Eduardo)
> > > > > > > - move src_use_reliable_get_clock initialization to realize 
> > > > > > > (Eduardo)
> > > > > > > 
> > > > > > > 
> > > > > > > Index: qemu-mig-advance-clock/hw/i386/kvm/clock.c
> > > > > > > ===
> > > > > > > --- qemu-mig-advance-clock.orig/hw/i386/kvm/clock.c   
> > > > > > > 2016-11-17 15:07:11.220632761 -0200
> > > > > > > +++ qemu-mig-advance-clock/hw/i386/kvm/clock.c2016-11-17 
> > > > > > > 15:11:51.372048640 -0200
> > > > > > > @@ -36,6 +36,12 @@
> > > > > > >  
> > > > > > >  uint64_t clock;
> > > > > > >  bool clock_valid;
> > > > > > > +
> > > > > > > +/* whether machine supports reliable KVM_GET_CLOCK */
> > > > > > > +bool mach_use_reliable_get_clock;
> > > > > > > +
> > > > > > > +/* whether source host supported reliable KVM_GET_CLOCK */
> > > > > > > +bool src_use_reliable_get_clock;
> > > > > > >  } KVMClockState;
> > > > > > >  
> > > > > > >  struct pvclock_vcpu_time_info {
> > > > > > > @@ -81,6 +87,19 @@
> > > > > > >  return nsec + time.system_time;
> > > > > > >  }
> > > > > > >  
> > > > > > > +static uint64_t kvm_get_clock(void)
> > > > > > > +{
> > > > > > > +struct kvm_clock_data data;
> > > > > > > +int ret;
> > > > > > > +
> > > > > > > +ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data);
> > > > > > > +if (ret < 0) {
> > > > > > > +fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", 
> > > > > > > strerror(ret));
> > > > > > > +abort();
> > > > > > > +}
> > > > > > > +return data.clock;
> > > > > > > +}
> > > > > > > +
> > > > > > >  static void kvmclock_vm_state_change(void *opaque, int running,
> > > > > > >   RunState state)
> > > > > > >  {
> > > > > > > @@ -91,15 +110,36 @@
> > > > > > 
> > > > > > Can you please use "diff -p" on your patches?
> > > > > > 
> > > > > > >  
> > > > > > >  if (running) {
> > > > > > >  struct kvm_clock_data data = {};
> > > > > > > -uint64_t time_at_migration = kvmclock_current_nsec(s);
> > > > > > > +uint64_t pvclock_via_mem = 0;
> > > > > > >  
> > > > > > > -s->clock_valid = false;
> > > > > > > +/* local (running VM) restore */
> > > > > > > +if (s->clock_valid) {
> > > > > > > +/*
> > > > > > > + * if host does not support reliable KVM_GET_CLOCK,
> > > > > > > + * read kvmclock value from memory
> > > > > > > + */
> > > > > > > +if (!kvm_has_adjust_clock_stable()) {
> > > > > > 
> > > > > > Why not use src_use_reliable_get_clock here, too? (Maybe rename
> > > > > > it to simply clock_is_reliable?)
> > > > > 
> > > > > Because you end up mixing two mental ideas (one: whether the source
> > > > > has KVM_GET_CLOCK, second: whether the destination has KVM_GET_CLOCK 
> > > > > into one variable). I find it more confusing than not.
> > > > > Maybe its just my limited brain but i find it
> > > > > confusing.
> > > > 
> > > > I find it simpler and easier to reason about.
> > > 
> > > I disagree,

Re: [Qemu-devel] [PATCH 04/10] qemu-thread: optimize QemuLockCnt with futexes on Linux

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:01PM +0100, Paolo Bonzini wrote:
> diff --git a/include/qemu/futex.h b/include/qemu/futex.h
> new file mode 100644
> index 000..c3d1089
> --- /dev/null
> +++ b/include/qemu/futex.h
> @@ -0,0 +1,36 @@
> +/*
> + * Wrappers around Linux futex syscall
> + *
> + * Copyright Red Hat, Inc. 2015
> + *
> + * Author:
> + *  Paolo Bonzini 
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include 
> +#include 
> +
> +#define futex(...)  syscall(__NR_futex, __VA_ARGS__)
> +
> +static inline void futex_wake(void *f, int n)
> +{
> +futex(f, FUTEX_WAKE, n, NULL, NULL, 0);
> +}
> +
> +static inline void futex_wait(void *f, unsigned val)

Now that this is being promoted to an include/ API please use
qemu_futex(), qemu_futex_wake(), and qemu_futex_wait() names.  It's a
bit bold to use futex(), futex_wake(), and futex_wait().  We're relying
on the fact that no system headers will ever use those names.

I haven't reviewed this patch in detail but:
Acked-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:03PM +0100, Paolo Bonzini wrote:
> @@ -272,22 +275,32 @@ bool aio_prepare(AioContext *ctx)
>  bool aio_pending(AioContext *ctx)
>  {
>  AioHandler *node;
> +bool result = false;
>  
> -QLIST_FOREACH(node, &ctx->aio_handlers, node) {
> +/*
> + * We have to walk very carefully in case aio_set_fd_handler is
> + * called while we're walking.
> + */
> +qemu_lockcnt_inc(&ctx->list_lock);
> +
> +QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
>  int revents;
>  
>  revents = node->pfd.revents & node->pfd.events;
>  if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
>  aio_node_check(ctx, node->is_external)) {
> -return true;
> +result = true;
> +break;
>  }
>  if (revents & (G_IO_OUT | G_IO_ERR) && node->io_write &&
>  aio_node_check(ctx, node->is_external)) {
> -return true;
> +result = true;
> +break;
>  }
>  }
> +qemu_lockcnt_dec(&ctx->list_lock);
>  
> -return false;
> +return result;
>  }
>  
>  bool aio_dispatch(AioContext *ctx)
> @@ -308,13 +321,12 @@ bool aio_dispatch(AioContext *ctx)
>   * We have to walk very carefully in case aio_set_fd_handler is
>   * called while we're walking.
>   */
> -ctx->walking_handlers++;
> +qemu_lockcnt_inc(&ctx->list_lock);
>  
> -QLIST_FOREACH_SAFE(node, &ctx->aio_handlers, node, tmp) {
> +QLIST_FOREACH_SAFE_RCU(node, &ctx->aio_handlers, node, tmp) {
>  int revents;
>  
> -revents = node->pfd.revents & node->pfd.events;
> -node->pfd.revents = 0;
> +revents = atomic_xchg(&node->pfd.revents, 0) & node->pfd.events;

Why is node->pfd.revents accessed with atomic_*() here and in aio_poll()
but not in aio_pending()?


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 07/10] aio-win32: remove walking_handlers, protecting AioHandler list with list_lock

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:04PM +0100, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini 
> ---
>  aio-win32.c | 82 
> +
>  1 file changed, 50 insertions(+), 32 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PATCH 08/10] aio: document locking

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:05PM +0100, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini 
> ---
>  docs/multiple-iothreads.txt |  5 ++---
>  include/block/aio.h | 32 
>  2 files changed, 18 insertions(+), 19 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PATCH 09/10] aio: push aio_context_acquire/release down to dispatching

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:06PM +0100, Paolo Bonzini wrote:
> The AioContext data structures are now protected by list_lock and/or
> they are walked with FOREACH_RCU primitives.  There is no need anymore
> to acquire the AioContext for the entire duration of aio_dispatch.
> Instead, just acquire it before and after invoking the callbacks.
> The next step is then to push it further down.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  aio-posix.c | 15 ++-
>  aio-win32.c | 15 +++
>  async.c |  2 ++
>  3 files changed, 15 insertions(+), 17 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PATCH 10/10] async: optimize aio_bh_poll

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:07PM +0100, Paolo Bonzini wrote:
> Avoid entering the slow path of qemu_lockcnt_dec_and_lock if
> no bottom half has to be deleted.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  async.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 05/10] aio: tweak walking in dispatch phase

2016-11-30 Thread Stefan Hajnoczi
On Tue, Nov 29, 2016 at 12:47:02PM +0100, Paolo Bonzini wrote:
> Preparing for the following patch, use QLIST_FOREACH_SAFE and
> modify the placement of walking_handlers increment/decrement.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  aio-posix.c | 27 +--
>  aio-win32.c | 26 --
>  2 files changed, 25 insertions(+), 28 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PATCH 06/10] aio-posix: remove walking_handlers, protecting AioHandler list with list_lock

2016-11-30 Thread Paolo Bonzini


On 30/11/2016 14:31, Stefan Hajnoczi wrote:
> On Tue, Nov 29, 2016 at 12:47:03PM +0100, Paolo Bonzini wrote:
>> @@ -272,22 +275,32 @@ bool aio_prepare(AioContext *ctx)
>>  bool aio_pending(AioContext *ctx)
>>  {
>>  AioHandler *node;
>> +bool result = false;
>>  
>> -QLIST_FOREACH(node, &ctx->aio_handlers, node) {
>> +/*
>> + * We have to walk very carefully in case aio_set_fd_handler is
>> + * called while we're walking.
>> + */
>> +qemu_lockcnt_inc(&ctx->list_lock);
>> +
>> +QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
>>  int revents;
>>  
>>  revents = node->pfd.revents & node->pfd.events;
>>  if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
>>  aio_node_check(ctx, node->is_external)) {
>> -return true;
>> +result = true;
>> +break;
>>  }
>>  if (revents & (G_IO_OUT | G_IO_ERR) && node->io_write &&
>>  aio_node_check(ctx, node->is_external)) {
>> -return true;
>> +result = true;
>> +break;
>>  }
>>  }
>> +qemu_lockcnt_dec(&ctx->list_lock);
>>  
>> -return false;
>> +return result;
>>  }
>>  
>>  bool aio_dispatch(AioContext *ctx)
>> @@ -308,13 +321,12 @@ bool aio_dispatch(AioContext *ctx)
>>   * We have to walk very carefully in case aio_set_fd_handler is
>>   * called while we're walking.
>>   */
>> -ctx->walking_handlers++;
>> +qemu_lockcnt_inc(&ctx->list_lock);
>>  
>> -QLIST_FOREACH_SAFE(node, &ctx->aio_handlers, node, tmp) {
>> +QLIST_FOREACH_SAFE_RCU(node, &ctx->aio_handlers, node, tmp) {
>>  int revents;
>>  
>> -revents = node->pfd.revents & node->pfd.events;
>> -node->pfd.revents = 0;
>> +revents = atomic_xchg(&node->pfd.revents, 0) & node->pfd.events;
> 
> Why is node->pfd.revents accessed with atomic_*() here and in aio_poll()
> but not in aio_pending()?

It could use atomic_read there, indeed.

Paolo



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [RFC v3 0/3] virtio-net: Add support to MTU feature

2016-11-30 Thread Michael S. Tsirkin
On Wed, Nov 30, 2016 at 01:16:59PM +0100, Maxime Coquelin wrote:
> 
> 
> On 11/30/2016 12:23 PM, Jason Wang wrote:
> > 
> > 
> > On 2016年11月30日 18:10, Maxime Coquelin wrote:
> > > This series implements Virtio spec update from Aaron Conole which
> > > defines a way for the host to expose its max MTU to the guest.
> > > 
> > > This third version re-desings how MTU value is provided to QEMU.
> > > Now, host_mtu parameter is added to provide QEMU with the MTU value,
> > > and the backend, if supported, gets notified of the MTU value when the
> > > MTU feature neogotiation succeeds.
> > > 
> > > Only user backend currently supports MTU notification. A new protocol
> > > feature has been implemented for sending MTU value to the backend.
> > > Aaron, Kevin, Flavio, do you confirm this works for OVS if DPDK vhost lib
> > > adds needed API to get the MTU value?
> > > 
> > > For kernel backend, it is expected the management tool also configures
> > > the tap/macvtap interface with same MTU value.
> > > Daniel, I would be interrested about your feedback on this implementation
> > > from management tool point of view.
> > 
> > I believe we want management tool to configure both kernel and user
> > backends.
> 
> Yes, I think you are right.
> 
> The vhost-user protocol feature would in this case be used to ensure
> consistency.
> 
> Does that make sense, or we should just drop VHOST_USER_SET_MTU?
> 
> Thanks,
> Maxime


It doesn't hurt to have a feature and if set send mtu to backend,
to verify that it can support that mtu.
But we don't need to require that feature, if not supported
we can just assume mtu is correct.

-- 
MST



Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Paolo Bonzini


On 30/11/2016 10:46, Peter Maydell wrote:
>> > The problem is indeed with the scheduling. The way it currently works
>> > is to depend on the iothread to kick a reschedule once in a while, or
>> > a cpu to issue an instruction that does so (wfe/wfi). However if
>> > there's no io and a cpu never issues a scheduling instruction, then it
>> > won't happen. We either need a sched tick or to never have an infinite
>> > iothread ppoll timeout (basically using the ppoll timeout as a tick).
> Ah yes, that one. I thought Alex had a patch which added
> a timer to ensure that we don't allow a single guest
> TCG vCPU to hog the execution thread, but maybe I'm
> misremembering.

Yes, it's part of MTTCG.

Paolo



[Qemu-devel] [Bug 1186935] Re: [1.5] QEMU monitor gets overlapped by GTK menu bar

2016-11-30 Thread Thomas Huth
Can you still reproduce this issue with the latest version of QEMU / the
latest version of gtk?

** Changed in: qemu
   Status: Confirmed => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1186935

Title:
  [1.5] QEMU monitor gets overlapped by GTK menu bar

Status in QEMU:
  Incomplete

Bug description:
  The QEMU minitor gets partially hidden by the menu bar which was
  introduced in QEMU version 1.5.0.

  Steps to reproduce:

   1. Run `qemu-system-x86_64`
   2. Press Ctrl + Alt + 2 (or use the menu bar)
   3. Observe that the monitor output is partially shown, without the 
"compat_monitor0 console" and "QEMU 1.5.0 monitor - type 'help' for more 
information" lines.

  Attached is a screenshot of `qemu-system-x86_64` and `qemu-system-
  x86_64 -display sdl`.

  Version: 1.5.0
  Distribution: Arch Linux 64-bit

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1186935/+subscriptions



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Michael S. Tsirkin
On Wed, Nov 30, 2016 at 11:08:27AM +0100, Laszlo Ersek wrote:
> Recent git releases support the diff.orderFile permanent setting. (In
> older releases, the -O option had to be specified on the command line,
> or in aliases, for the same effect, which was quite inconvenient.) From
> git-diff(1):
> 
>-O
>Output the patch in the order specified in the ,
>which has one shell glob pattern per line. This overrides
>the diff.orderFile configuration variable (see git-
>config(1)). To cancel diff.orderFile, use -O/dev/null.
> 
> In my experience, an order file such as:
> 
> configure
> *Makefile*

Why add the * before Makefile? In fact, why * after it?

> *.json
> *.txt
> *.h
> *.c
> 
> that is, a priority order that goes from
> descriptive/declarative/abstract to imperative/specific works wonders
> for reviewing.
> 
> Randomly picked example:
> 
> [Qemu-devel] [PATCH] virtio-gpu: track and limit host memory allocations
> http://lists.nongnu.org/archive/html/qemu-devel/2016-11/msg05144.html
> 
> This patch adds several fields to several structures first, and then it
> does things with those new fields. If you think about what the English
> verb "to declare" means, it's clear you want to see the declaration
> first (same as the compiler), and only then how the field is put to use.
> 
> Thanks!
> Laszlo



Re: [Qemu-devel] [PATCH for-2.9 25/30] block: add a model option for MTD devices

2016-11-30 Thread Cédric Le Goater
On 11/29/2016 07:08 PM, Kevin Wolf wrote:
> Am 29.11.2016 um 18:30 hat Cédric Le Goater geschrieben:
>> On 11/29/2016 04:44 PM, Cédric Le Goater wrote:
>>> This could be used to define the flash model to use on some boards
>>> definitions.
>>
>> As this patch was part of a larger set, I did not send the whole 
>> set to qemu-block@ list. Could you please take a look at the proposal ? 
> 
> This is a device level option rather than a block backend one. We messed
> up -drive in its early days by including some device options, but we
> don't generally want to add to this.
> 
> The correct way would be to add a qdev property for this and specify it
> with -device or -global.

OK. I see. I should use something like this on the command line :

-drive file=flash-romulus-test,format=raw,if=mtd,id=bmc \
-device mx25l25635e,drive=bmc \
-drive file=flash-romulus-test2,format=raw,if=mtd,id=bmc2 \
-device mx25l25635e,drive=bmc2 \
-drive file=romulus.pnor,format=raw,if=mtd,id=pnor \
-device mx66l1g45g,drive=pnor 

and retrieve the attached m25p80 device from the drive with the 
routine blk_get_attached_dev(). That is changing a bit the way
the platform is initialized but it is cleaner as no default 
devices are automatically added.

Thanks,

C. 

> Kevin
> 
>>> Signed-off-by: Cédric Le Goater 
>>> Reviewed-by: Joel Stanley 
>>> ---
>>>  blockdev.c| 12 
>>>  include/sysemu/blockdev.h |  1 +
>>>  qemu-options.hx   |  4 +++-
>>>  3 files changed, 16 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/blockdev.c b/blockdev.c
>>> index 245e1e1d177a..bcc99365b86c 100644
>>> --- a/blockdev.c
>>> +++ b/blockdev.c
>>> @@ -742,6 +742,10 @@ QemuOptsList qemu_legacy_drive_opts = {
>>>  .type = QEMU_OPT_STRING,
>>>  .help = "pci address (virtio only)",
>>>  },{
>>> +.name = "model",
>>> +.type = QEMU_OPT_STRING,
>>> +.help = "flash model (mtd only)",
>>> +},{
>>>  .name = "serial",
>>>  .type = QEMU_OPT_STRING,
>>>  .help = "disk serial number",
>>> @@ -790,6 +794,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, 
>>> BlockInterfaceType block_default_type)
>>>  bool read_only = false;
>>>  bool copy_on_read;
>>>  const char *serial;
>>> +const char *model;
>>>  const char *filename;
>>>  Error *local_err = NULL;
>>>  int i;
>>> @@ -1076,6 +1081,12 @@ DriveInfo *drive_new(QemuOpts *all_opts, 
>>> BlockInterfaceType block_default_type)
>>>  qdict_put(bs_opts, "rerror", qstring_from_str(rerror));
>>>  }
>>>  
>>> +model = qemu_opt_get(legacy_opts, "model");
>>> +if (model && type != IF_MTD) {
>>> +error_report("model is not supported by this bus type");
>>> +goto fail;
>>> +}
>>> +
>>>  /* Actual block device init: Functionality shared with blockdev-add */
>>>  blk = blockdev_init(filename, bs_opts, &local_err);
>>>  bs_opts = NULL;
>>> @@ -1102,6 +1113,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, 
>>> BlockInterfaceType block_default_type)
>>>  dinfo->unit = unit_id;
>>>  dinfo->devaddr = devaddr;
>>>  dinfo->serial = g_strdup(serial);
>>> +dinfo->model = g_strdup(model);
>>>  
>>>  blk_set_legacy_dinfo(blk, dinfo);
>>>  
>>> diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
>>> index 16432f350805..10c66e5e86a4 100644
>>> --- a/include/sysemu/blockdev.h
>>> +++ b/include/sysemu/blockdev.h
>>> @@ -39,6 +39,7 @@ struct DriveInfo {
>>>  int cyls, heads, secs, trans;
>>>  QemuOpts *opts;
>>>  char *serial;
>>> +char *model;
>>>  QTAILQ_ENTRY(DriveInfo) next;
>>>  };
>>>  
>>> diff --git a/qemu-options.hx b/qemu-options.hx
>>> index 4a5b29f349f7..16add85bd0f5 100644
>>> --- a/qemu-options.hx
>>> +++ b/qemu-options.hx
>>> @@ -517,7 +517,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive,
>>>  "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
>>>  "   [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
>>>  "   
>>> [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
>>> -"   [,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
>>> +"   [,serial=s][,model=m][,addr=A][,rerror=ignore|stop|report]\n"
>>>  "   
>>> [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
>>>  "   [,readonly=on|off][,copy-on-read=on|off]\n"
>>>  "   [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
>>> @@ -570,6 +570,8 @@ the format.  Can be used to specify format=raw to avoid 
>>> interpreting
>>>  an untrusted format header.
>>>  @item serial=@var{serial}
>>>  This option specifies the serial number to assign to the device.
>>> +@item model=@var{model}
>>> +This option specifies the model to use to create a flash device (if=mtd 
>>> only).
>>>  @item addr=@var{addr}
>>>  Specify the controller's PCI address (if=virtio only).
>>>

Re: [Qemu-devel] Linux kernel polling for QEMU

2016-11-30 Thread Stefan Hajnoczi
On Wed, Nov 30, 2016 at 06:50:09PM +0800, Fam Zheng wrote:
> On Wed, 11/30 09:38, Stefan Hajnoczi wrote:
> > On Wed, Nov 30, 2016 at 01:42:14PM +0800, Fam Zheng wrote:
> > > On Tue, 11/29 20:43, Stefan Hajnoczi wrote:
> > > > On Tue, Nov 29, 2016 at 1:24 PM, Fam Zheng  wrote:
> > > > > On Tue, 11/29 12:17, Paolo Bonzini wrote:
> > > > >> On 29/11/2016 11:32, Fam Zheng wrote:
> > > > >> * it still needs a system call before polling is entered.  Ideally, 
> > > > >> QEMU
> > > > >> could run without any system call while in polling mode.
> > > > >>
> > > > >> Another possibility is to add a system call for 
> > > > >> single_task_running().
> > > > >> It should be simple enough that you can implement it in the vDSO and
> > > > >> avoid a context switch.  There are convenient hooking points in
> > > > >> add_nr_running and sub_nr_running.
> > > > >
> > > > > That sounds good!
> > > > 
> > > > With this solution QEMU can either poll virtqueues or the host kernel
> > > > can poll NIC and storage controller descriptor rings, but not both at
> > > > the same time in one thread.  This is one of the reasons why I think
> > > > exploring polling in the kernel makes more sense.
> > > 
> > > That's true. I have one question though: controller rings are in a 
> > > different
> > > layer in the kernel, I wonder what the syscall interface looks like to ask
> > > kernel to poll both hardware rings and memory locations in the same loop? 
> > > It's
> > > not obvious to me after reading your eventfd patch.
> > 
> > Current descriptor ring polling in select(2)/poll(2) is supported for
> > network sockets.  Take a look at the POLL_BUSY_LOOP flag in
> > fs/select.c:do_poll().  If the .poll() callback sets the flag then it
> > indicates that the fd supports busy loop polling.
> > 
> > The way this is implemented for network sockets is that the socket looks
> > up the napi index and is able to use the NIC driver to poll the rx ring.
> > Then it checks whether the socket's receive queue contains data after
> > the rx ring was processed.
> > 
> > The virtio_net.ko driver supports this interface, for example.  See
> > drivers/net/virtio_net.c:virtnet_busy_poll().
> > 
> > Busy loop polling isn't supported for block I/O yet.  There is currently
> > a completely independent code path for O_DIRECT synchronous I/O where
> > NVMe can poll for request completion.  But it doesn't work together with
> > asynchronous I/O (e.g. Linux AIO using eventfd with select(2)/poll(2)).
> 
> This makes perfect sense now, thanks for the pointers!
> 
> > 
> > > > The disadvantage of the kernel approach is that you must make the
> > > > ppoll(2)/epoll_wait(2) syscall even for polling, and you probably need
> > > > to do eventfd reads afterwards so the minimum event loop iteration
> > > > latency is higher than doing polling in userspace.
> > > 
> > > And userspace drivers powered by dpdk or vfio will still want to do 
> > > polling in
> > > userspace anyway, we may want to take that into account as well.
> > 
> > vfio supports interrupts so it can definitely be integrated with
> > adaptive kernel polling (i.e. poll for a little while and then wait for
> > an interrupt if there was no event).
> > 
> > Does dpdk ever use interrupts?
> 
> Yes, interrupt mode is supported there. For example see the intx/msix init 
> code
> in drivers/net/ixgbe/ixgbe_ethdev.c:ixgbe_dev_start().

If the application wants to poll 100% of the time then userspace polling
is the right solution.  Userspace polling also makes sense when all
event sources can be polled from userspace - it's faster than using
kernel polling.

But I think in adaptive polling + wait use cases or when there are a
mixture of userspace and kernel event sources to poll, then it makes
sense to use kernel polling.

In QEMU we have the latter so I think we need to contribute to kernel
polling.

Stefan


signature.asc
Description: PGP signature


[Qemu-devel] [Bug 1336194] Re: Errors reporting in do_delvm caused a crash

2016-11-30 Thread Thomas Huth
Looks like this had been fixed here:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=ba2b22888c43f

** Changed in: qemu
   Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1336194

Title:
  Errors reporting in do_delvm caused a crash

Status in QEMU:
  Fix Released

Bug description:
  In case of multiple errors, it leads to a crash.

  Typical back trace:
  #0   in __GI_raise (sig=sig@entry=6) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:56
  #1   in __GI_abort () at abort.c:90
  #2   in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry= "*** Error in `%s': %s: 0x%s ***\n") at 
../sysdeps/unix/sysv/linux/libc_fatal.c:196
  #3   in malloc_printerr (action=3, str= "double free or 
corruption (out)", ptr=) at malloc.c:4902
  #4   in _int_free (av=, p=, 
have_lock=0) at malloc.c:3758
  #5   in error_free (err=) at util/error.c:166
  #6   in do_delvm (mon=, qdict=) 
at /home/qemudbg/src/qemu/savevm.c:1132
  #7   in handle_user_command (mon=mon@entry=, 
cmdline=) at /home/qemudbg/src/qemu/monitor.c:4167
  #8   in monitor_command_cb (opaque=, 
cmdline=, readline_opaque=) at 
/home/qemudbg/src/qemu/monitor.c:4878
  #9   in readline_handle_byte (rs=, ch=) at util/readline.c:371
  #10  in monitor_read (opaque=, buf=, size=) at /home/qemudbg/src/qemu/monitor.c:4861
  #11  in qemu_chr_be_write (len=, buf= "\n\003", s=) at qemu-char.c:165
  #12 tcp_chr_read (chan=, cond=, opaque=) at qemu-char.c:2487
  #13  in g_main_context_dispatch () from 
/usr/lib64/libglib-2.0.so.0
  #14  in glib_pollfds_poll () at main-loop.c:190
  #15 os_host_main_loop_wait (timeout=) at main-loop.c:235
  #16 main_loop_wait (nonblocking=) at main-loop.c:484
  #17  in main_loop () at vl.c:2051
  #18 main (argc=, argv=, envp=) 
at vl.c:4507

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1336194/+subscriptions



[Qemu-devel] [Bug 1163065] Re: target-i386 cpu_get_phys_page_debug checks bits in wrong order

2016-11-30 Thread Thomas Huth
Can you still reproduce this problem with the latest version of QEMU? If
so, could you please send a refreshed patch to the qemu-devel mailing
list? We do not pick up patches from the bug tracker. Thanks!

** Changed in: qemu
   Status: New => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1163065

Title:
  target-i386 cpu_get_phys_page_debug checks bits in wrong order

Status in QEMU:
  Incomplete

Bug description:
  In target-i386 cpu_get_phys_page_debug, the CR4_PAE bit is checked
  before CR0_PG. This means that if paging is disabled but the PAE bit
  has been set in CR4, cpu_get_phys_page_debug will return the wrong
  result (it will try to translate the address as virtual rather than
  using it as a physical address).

  Although this might seem like an unusual case, it in fact happens
  consistently when booting Linux on amd64 (from
  linux-2.6.32.60/arch/x86/boot/compressed/head_64.S):

  /* Enable PAE mode */
  xorl%eax, %eax
  orl $(X86_CR4_PAE), %eax
  movl%eax, %cr4
  [... code to set up page tables omitted ...]
  /* Enter paged protected Mode, activating Long Mode */
  movl$(X86_CR0_PG | X86_CR0_PE), %eax /* Enable Paging and Protected 
mode */
  movl%eax, %cr0

  The most noticeable effect of this bug is that using the disassembler
  during this time will fetch the wrong data by trying to read from page
  tables that aren't there. One symptom is that booting Linux amd64 with
  -d in_asm will result in several "Disassembler disagrees with
  translator over instruction decoding" messages.

  Attached is a patch that moves the CR0_PG check to the beginning. I'm
  still not 100% certain that the logic of cpu_get_phys_page_debug
  matches cpu_x86_handle_mmu_fault, but it's a start.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1163065/+subscriptions



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Laszlo Ersek
On 11/30/16 16:08, Michael S. Tsirkin wrote:
> On Wed, Nov 30, 2016 at 11:08:27AM +0100, Laszlo Ersek wrote:
>> Recent git releases support the diff.orderFile permanent setting. (In
>> older releases, the -O option had to be specified on the command line,
>> or in aliases, for the same effect, which was quite inconvenient.) From
>> git-diff(1):
>>
>>-O
>>Output the patch in the order specified in the ,
>>which has one shell glob pattern per line. This overrides
>>the diff.orderFile configuration variable (see git-
>>config(1)). To cancel diff.orderFile, use -O/dev/null.
>>
>> In my experience, an order file such as:
>>
>> configure
>> *Makefile*
> 
> Why add the * before Makefile? In fact, why * after it?

Might not be appropriate for QEMU indeed; I have that pattern because of
files in other projects. (Actually, thanks for drawing my attention to
it, because it should be *[Mm]akefile* :))

Thanks
Laszlo

>> *.json
>> *.txt
>> *.h
>> *.c
>>
>> that is, a priority order that goes from
>> descriptive/declarative/abstract to imperative/specific works wonders
>> for reviewing.
>>
>> Randomly picked example:
>>
>> [Qemu-devel] [PATCH] virtio-gpu: track and limit host memory allocations
>> http://lists.nongnu.org/archive/html/qemu-devel/2016-11/msg05144.html
>>
>> This patch adds several fields to several structures first, and then it
>> does things with those new fields. If you think about what the English
>> verb "to declare" means, it's clear you want to see the declaration
>> first (same as the compiler), and only then how the field is put to use.
>>
>> Thanks!
>> Laszlo




Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Laszlo Ersek
On 11/30/16 13:29, Gerd Hoffmann wrote:
>   Hi,
> 
>>> Want sent a patch?
>>
>> What file for? :)
> 
> create something like scripts/git.orderfile, so people have just to run
> "git config diff.orderfile scripts/git.orderfile" to enable it, and we
> can refine the config without having everybody update the orderfile
> manually?

Good idea -- I didn't expect this to work, but it actually does.

The -O command line option interprets a relative pathname relative to
the working directory. However, if you place a relative pathname in
diff.orderFile in .git/config, then git will look for the order file
relative to the project root directory, not relative to your working
directory (which could be any subdirectory of the project root directory).

> 
>> I've considered modifying
>> , but that article is
>> humongous already.
>>
>> Nonetheless, section "Make code motion patches easy to review" mentions
>> some diff.* settings, so I guess a new section after it ("Format
>> declarative and abstract changes near the top") would be appropriate, if
>> there's no disagreement.
> 
> Yep, adding to the wiki sounds good too.
> 
>>> Can this be automatically enabled per repo, like .gitignore, so it works
>>> without everybody tweaking its local git config?
>>
>> Not to my understanding.
> 
> Too bad.

I think recommending a simple git config command in the wiki, like you
write above, should be fine.

I guess I'll add this item (the patch and the wiki update) to my todo
list... :)

Thanks
Laszlo



Re: [Qemu-devel] [PATCH v3 0/2] Qemu: gdbstub: fix vCont

2016-11-30 Thread Claudio Imbrenda
Hi Paolo, I was wondering if you had seen this new version of the vCont
patchset, which I sent around last month -- is there any more work to do
or things to fix? or is it going to be upstreamed after 2.8?
(btw I just rebased it on 2.8.0-rc2 and it applied cleanly)

please don't keep me in suspense :)

thanks!


Claudio


On 28/10/16 19:15, Claudio Imbrenda wrote:
> This small patchset fixes the incorrect behaviour of the vCont command
> in the gdb stub. 
> 
> The first patch, as suggested be Paolo, refactors some code. The most
> visible change is that it moves vm_start to cpus.c 
> 
> The second one fixes the incorrect behaviour of the vCont command.
> Previously, continuing or stepping a single thread (CPU) caused all
> other CPUs to be started too, whereas the GDB specification clearly
> states that without a default action all threads not explicitly
> mentioned in the command should stay stopped.
> 
> So if the Qemu gdbstub receives a  vCont;c:1  packet, no other CPU
> should be restarted except the first, and when a  vCont;s:1  is
> received, the first CPU should be stepped without restarting the others.
> With this patchset Qemu now behaves as expected.
> 
> See here for reference material about the packets: 
> https://sourceware.org/gdb/current/onlinedocs/gdb/Packets.html
> https://sourceware.org/gdb/onlinedocs/gdb/Packets.html
> 
> v2 -> v3
> * removed resume_some_vcpus
> * cleared up the code and simplified the implementation in light of the 
>   clarification in the specification of the vCont packet
> 
> Claudio Imbrenda (2):
>   move vm_start to cpus.c
>   gdbstub: Fix vCont behaviour
> 
>  cpus.c |  44 ++-
>  gdbstub.c  | 189 
> ++---
>  hw/i386/kvmvapic.c |   2 +
>  include/sysemu/cpus.h  |   1 +
>  include/sysemu/sysemu.h|   2 +
>  target-s390x/misc_helper.c |   2 +
>  vl.c   |  32 +---
>  7 files changed, 195 insertions(+), 77 deletions(-)
> 




Re: [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs

2016-11-30 Thread Markus Armbruster
Second thoughts...

Marc-André Lureau  writes:

> Add some more section titles to organize the produced documents.
>
> Signed-off-by: Marc-André Lureau 
> ---
>  qapi-schema.json |  4 
>  qapi/block-core.json |  6 --
>  qapi/block.json  | 10 --
>  qapi/common.json |  6 --
>  qapi/crypto.json |  5 -
>  qapi/event.json  |  6 ++
>  qapi/rocker.json |  4 
>  qapi/trace.json  |  3 +++
>  8 files changed, 37 insertions(+), 7 deletions(-)
>
> diff --git a/qapi-schema.json b/qapi-schema.json
> index dfe68ba..69340f2 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -20,6 +20,10 @@
>  # QAPI introspection
>  { 'include': 'qapi/introspect.json' }
>  
> +##
> +# = QMP commands
> +##
> +
>  ##
>  # @qmp_capabilities:
>  #
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index ec1da2a..05cedc3 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -1,6 +1,8 @@
>  # -*- Mode: Python -*-
> -#
> -# QAPI block core definitions (vm unrelated)
> +
> +##
> +# == QAPI block core definitions (vm unrelated)
> +##
>  
>  # QAPI common definitions
>  { 'include': 'common.json' }
> diff --git a/qapi/block.json b/qapi/block.json
> index 937df05..e4ad74b 100644
> --- a/qapi/block.json
> +++ b/qapi/block.json
> @@ -1,10 +1,16 @@
>  # -*- Mode: Python -*-
> -#
> -# QAPI block definitions (vm related)
> +
> +##
> +# = QAPI block definitions
> +##
>  
>  # QAPI block core definitions
>  { 'include': 'block-core.json' }
>  
> +##
> +# == QAPI block definitions (vm unrelated)
> +##
> +
>  ##
>  # @BiosAtaTranslation:
>  #
> diff --git a/qapi/common.json b/qapi/common.json
> index 624a861..d93f159 100644
> --- a/qapi/common.json
> +++ b/qapi/common.json
> @@ -1,6 +1,8 @@
>  # -*- Mode: Python -*-
> -#
> -# QAPI common definitions
> +
> +##
> +# = QAPI common definitions
> +##
>  
>  ##
>  # @QapiErrorClass:
> diff --git a/qapi/crypto.json b/qapi/crypto.json
> index 15d296e..1e517b0 100644
> --- a/qapi/crypto.json
> +++ b/qapi/crypto.json
> @@ -1,6 +1,9 @@
>  # -*- Mode: Python -*-
>  #
> -# QAPI crypto definitions
> +
> +##
> +# = QAPI crypto definitions
> +##
>  
>  ##
>  # @QCryptoTLSCredsEndpoint:
> diff --git a/qapi/event.json b/qapi/event.json
> index 37bf34e..59942b0 100644
> --- a/qapi/event.json
> +++ b/qapi/event.json
> @@ -1,3 +1,9 @@
> +# -*- Mode: Python -*-
> +
> +##
> +# = Events
> +##
> +

This suggests *all* events are in this section, which isn't the case.
"Other events"?  "Core events"?  Dunno...

>  ##
>  # @SHUTDOWN:
>  #
> diff --git a/qapi/rocker.json b/qapi/rocker.json
> index ace2776..dd72e02 100644
> --- a/qapi/rocker.json
> +++ b/qapi/rocker.json
> @@ -1,4 +1,8 @@
>  ##
> +# = Rocker API

What about "Rocker switch device"?

> +##
> +
> +##
>  # @RockerSwitch:
>  #
>  # Rocker switch information.
> diff --git a/qapi/trace.json b/qapi/trace.json
> index 4fd39b7..3ad7df7 100644
> --- a/qapi/trace.json
> +++ b/qapi/trace.json
> @@ -5,6 +5,9 @@
>  # This work is licensed under the terms of the GNU GPL, version 2 or later.
>  # See the COPYING file in the top-level directory.
>  
> +##
> +# = Tracing commands
> +##
>  
>  ##
>  # @TraceEventState:



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Stefan Hajnoczi
On Wed, Nov 30, 2016 at 10:08 AM, Laszlo Ersek  wrote:
> Recent git releases support the diff.orderFile permanent setting. (In
> older releases, the -O option had to be specified on the command line,
> or in aliases, for the same effect, which was quite inconvenient.) From
> git-diff(1):
>
>-O
>Output the patch in the order specified in the ,
>which has one shell glob pattern per line. This overrides
>the diff.orderFile configuration variable (see git-
>config(1)). To cancel diff.orderFile, use -O/dev/null.
>
> In my experience, an order file such as:
>
> configure
> *Makefile*
> *.json
> *.txt
> *.h
> *.c
>
> that is, a priority order that goes from
> descriptive/declarative/abstract to imperative/specific works wonders
> for reviewing.

Thanks, you are a gentleman and a scholar!

I've set it in my global git config.

Stefan



[Qemu-devel] QEMU 2.8 release approaching

2016-11-30 Thread Stefan Hajnoczi
Dear QEMU community,
QEMU 2.8.0-rc3 will be tagged on December 6th.  If there are no
pending issues -rc3 will become the QEMU 2.8 final release on December
13th.  Let's make this tag a good one!

If you are currently looking into pending issues or have bug fixes
needing attention from maintainers, please reply to this email.

At this stage only critical bugs, regressions, and build breakage
should hold up the release.

Thanks,
Stefan



Re: [Qemu-devel] a suggestion to place *.c hunks last in patches

2016-11-30 Thread Eric Blake
On 11/30/2016 04:08 AM, Laszlo Ersek wrote:
> Recent git releases support the diff.orderFile permanent setting. (In
> older releases, the -O option had to be specified on the command line,
> or in aliases, for the same effect, which was quite inconvenient.) From
> git-diff(1):
> 
>-O
>Output the patch in the order specified in the ,
>which has one shell glob pattern per line. This overrides
>the diff.orderFile configuration variable (see git-
>config(1)). To cancel diff.orderFile, use -O/dev/null.
> 
> In my experience, an order file such as:
> 
> configure
> *Makefile*
> *.json
> *.txt
> *.h
> *.c
> 
> that is, a priority order that goes from
> descriptive/declarative/abstract to imperative/specific works wonders
> for reviewing.

I've been doing this for some time now, although I sometimes tweak the
order on a per-series basis to highlight what I think is most
interesting in that series.  My current order file contents are:

qapi-schema*.json
qapi/*.json
include/qapi/visitor.h
include/qapi/visitor-impl.h
scripts/qapi.py
scripts/*.py
*.h
qapi/qapi-visit-core.c
*.c

stemming from a patch series that touched visitor interfaces.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH for-2.9 25/30] block: add a model option for MTD devices

2016-11-30 Thread Kevin Wolf
Am 30.11.2016 um 16:09 hat Cédric Le Goater geschrieben:
> On 11/29/2016 07:08 PM, Kevin Wolf wrote:
> > Am 29.11.2016 um 18:30 hat Cédric Le Goater geschrieben:
> >> On 11/29/2016 04:44 PM, Cédric Le Goater wrote:
> >>> This could be used to define the flash model to use on some boards
> >>> definitions.
> >>
> >> As this patch was part of a larger set, I did not send the whole 
> >> set to qemu-block@ list. Could you please take a look at the proposal ? 
> > 
> > This is a device level option rather than a block backend one. We messed
> > up -drive in its early days by including some device options, but we
> > don't generally want to add to this.
> > 
> > The correct way would be to add a qdev property for this and specify it
> > with -device or -global.
> 
> OK. I see. I should use something like this on the command line :
> 
>   -drive file=flash-romulus-test,format=raw,if=mtd,id=bmc \
>   -device mx25l25635e,drive=bmc \
>   -drive file=flash-romulus-test2,format=raw,if=mtd,id=bmc2 \
>   -device mx25l25635e,drive=bmc2 \
>   -drive file=romulus.pnor,format=raw,if=mtd,id=pnor \
>   -device mx66l1g45g,drive=pnor 

I think you mean if=none instead of if=mtd everywhere, now that you're
using an explicit -device.

> and retrieve the attached m25p80 device from the drive with the 
> routine blk_get_attached_dev(). That is changing a bit the way
> the platform is initialized but it is cleaner as no default 
> devices are automatically added.

Right. For compatibility (and convenience) you can and probably should
still support if=mtd to create the device automatically, but then the
user just gets the defaults for the options that -drive doesn't allow to
specify.

Kevin



Re: [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script

2016-11-30 Thread Markus Armbruster
Marc-André Lureau  writes:

> As the name suggests, the qapi2texi script converts JSON QAPI
> description into a texi file suitable for different target
> formats (info/man/txt/pdf/html...).
>
> It parses the following kind of blocks:
>
> Free-form:
>
>   ##
>   # = Section
>   # == Subsection
>   #
>   # Some text foo with *emphasis*
>   # 1. with a list
>   # 2. like that
>   #
>   # And some code:
>   # | $ echo foo
>   # | -> do this
>   # | <- get that
>   #
>   ##
>
> Symbol:
>
>   ##
>   # @symbol:
>   #
>   # Symbol body ditto ergo sum. Foo bar
>   # baz ding.
>   #
>   # @arg: foo
>   # @arg: #optional foo

Let's not use @arg twice.

Terminology: I prefer to use "parameter" for formal parameters, and
"argument" for actual arguments.  This matches how The Python Language
Reference uses the terms.

What about

# @param1: the frob to frobnicate
# @param2: #optional how hard to frobnicate

>   #
>   # Returns: returns bla bla
>   #  Or bla blah

Repeating "returns" is awkward, and we don't do that in our schemas.

We need a period before "Or", or spell it "or".

What about

# Returns: the frobnicated frob.
#  If frob isn't frobnicatable, GenericError.

>   #
>   # Since: version
>   # Notes: notes, comments can have
>   #- itemized list
>   #- like this
>   #
>   # Example:
>   #
>   # -> { "execute": "quit" }
>   # <- { "return": {} }
>   #
>   ##
>
> That's roughly following the following EBNF grammar:
>
> api_comment = "##\n" comment "##\n"
> comment = freeform_comment | symbol_comment
> freeform_comment = { "# " text "\n" | "#\n" }
> symbol_comment = "# @" name ":\n" { member | meta | freeform_comment }

Rejects non-empty comments where "#" is not followed by space.  Such
usage is accepted outside doc comments.  Hmm.

> member = "# @" name ':' [ text ] freeform_comment

Are you missing a "\n" before freeform_comment?

> meta = "# " ( "Returns:", "Since:", "Note:", "Notes:", "Example:", 
> "Examples:" ) [ text ] freeform_comment

Likewise.

> text = free-text markdown-like, "#optional" for members

The grammar is ambiguous: a line "# @foo:\n" can be parsed both as
freeform_comment and as symbol_comment.  Since your intent is obvious
enough, it can still serve as documentation.  It's not a suitable
foundation for parsing, though.  Okay for a commit message.

> Thanks to the following json expressions, the documentation is enhanced
> with extra information about the type of arguments and return value
> expected.

I guess you want to say that we enrich the documentation we extract from
comments with information from the actual schema.  Correct?

Missing: a brief discussion of deficiencies.  These include:

* The generated QMP documentation includes internal types

  We use qapi-schema.json both for defining the external QMP interface
  and for defining internal types.  qmp-introspect.py carefully
  separates the two, to not expose internal types.  qapi2texi.py happily
  exposes everything.

  Currently, about a fifth of the types in the generated docs are
  internal:

  AcpiTableOptions
  BiosAtaTranslation
  BlockDeviceMapEntry
  COLOMessage
  COLOMode
  DummyForceArrays
  FailoverStatus
  FloppyDriveType
  ImageCheck
  LostTickPolicy
  MapEntry
  MigrationParameter
  NetClientDriver
  NetFilterDirection
  NetLegacy
  NetLegacyNicOptions
  NetLegacyOptions
  NetLegacyOptionsKind
  Netdev
  NetdevBridgeOptions
  NetdevDumpOptions
  NetdevHubPortOptions
  NetdevL2TPv3Options
  NetdevNetmapOptions
  NetdevNoneOptions
  NetdevSocketOptions
  NetdevTapOptions
  NetdevUserOptions
  NetdevVdeOptions
  NetdevVhostUserOptions
  NumaNodeOptions
  NumaOptions
  NumaOptionsKind
  OnOffAuto
  OnOffSplit
  PreallocMode
  QCryptoBlockCreateOptions
  QCryptoBlockCreateOptionsLUKS
  QCryptoBlockFormat
  QCryptoBlockInfo
  QCryptoBlockInfoBase
  QCryptoBlockInfoQCow
  QCryptoBlockOpenOptions
  QCryptoBlockOptionsBase
  QCryptoBlockOptionsLUKS
  QCryptoBlockOptionsQCow
  QCryptoSecretFormat
  QCryptoTLSCredsEndpoint
  QapiErrorClass
  ReplayMode
  X86CPUFeatureWordInfo
  X86CPURegister32

  Generating documentation for internal types might be useful, but
  letting them pollute QMP interface documentation isn't.  Needs fixing
  before we release.  Until then, needs a FIXME comment in qapi2texi.py.

* Union support is lacking

  The doc string language is adequate for documenting commands, events,
  and non-union types.  It doesn't really handle union variants.  Hardly
  surprising, as you fitted the language do existing practice, and
  existing (mal-)practice is neglecting to document union variant
  members.

* Documentation is lacking

  See review of qapi-code-gen.txt below.

* Doc comment error message positions are imprecise

  They always point to the beginning o

Re: [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs

2016-11-30 Thread Marc-André Lureau
Hi

- Original Message -
> Second thoughts...
> 
> Marc-André Lureau  writes:
> 
> > Add some more section titles to organize the produced documents.
> >
> > Signed-off-by: Marc-André Lureau 
> > ---
> >  qapi-schema.json |  4 
> >  qapi/block-core.json |  6 --
> >  qapi/block.json  | 10 --
> >  qapi/common.json |  6 --
> >  qapi/crypto.json |  5 -
> >  qapi/event.json  |  6 ++
> >  qapi/rocker.json |  4 
> >  qapi/trace.json  |  3 +++
> >  8 files changed, 37 insertions(+), 7 deletions(-)
> >
> > diff --git a/qapi-schema.json b/qapi-schema.json
> > index dfe68ba..69340f2 100644
> > --- a/qapi-schema.json
> > +++ b/qapi-schema.json
> > @@ -20,6 +20,10 @@
> >  # QAPI introspection
> >  { 'include': 'qapi/introspect.json' }
> >  
> > +##
> > +# = QMP commands
> > +##
> > +
> >  ##
> >  # @qmp_capabilities:
> >  #
> > diff --git a/qapi/block-core.json b/qapi/block-core.json
> > index ec1da2a..05cedc3 100644
> > --- a/qapi/block-core.json
> > +++ b/qapi/block-core.json
> > @@ -1,6 +1,8 @@
> >  # -*- Mode: Python -*-
> > -#
> > -# QAPI block core definitions (vm unrelated)
> > +
> > +##
> > +# == QAPI block core definitions (vm unrelated)
> > +##
> >  
> >  # QAPI common definitions
> >  { 'include': 'common.json' }
> > diff --git a/qapi/block.json b/qapi/block.json
> > index 937df05..e4ad74b 100644
> > --- a/qapi/block.json
> > +++ b/qapi/block.json
> > @@ -1,10 +1,16 @@
> >  # -*- Mode: Python -*-
> > -#
> > -# QAPI block definitions (vm related)
> > +
> > +##
> > +# = QAPI block definitions
> > +##
> >  
> >  # QAPI block core definitions
> >  { 'include': 'block-core.json' }
> >  
> > +##
> > +# == QAPI block definitions (vm unrelated)
> > +##
> > +
> >  ##
> >  # @BiosAtaTranslation:
> >  #
> > diff --git a/qapi/common.json b/qapi/common.json
> > index 624a861..d93f159 100644
> > --- a/qapi/common.json
> > +++ b/qapi/common.json
> > @@ -1,6 +1,8 @@
> >  # -*- Mode: Python -*-
> > -#
> > -# QAPI common definitions
> > +
> > +##
> > +# = QAPI common definitions
> > +##
> >  
> >  ##
> >  # @QapiErrorClass:
> > diff --git a/qapi/crypto.json b/qapi/crypto.json
> > index 15d296e..1e517b0 100644
> > --- a/qapi/crypto.json
> > +++ b/qapi/crypto.json
> > @@ -1,6 +1,9 @@
> >  # -*- Mode: Python -*-
> >  #
> > -# QAPI crypto definitions
> > +
> > +##
> > +# = QAPI crypto definitions
> > +##
> >  
> >  ##
> >  # @QCryptoTLSCredsEndpoint:
> > diff --git a/qapi/event.json b/qapi/event.json
> > index 37bf34e..59942b0 100644
> > --- a/qapi/event.json
> > +++ b/qapi/event.json
> > @@ -1,3 +1,9 @@
> > +# -*- Mode: Python -*-
> > +
> > +##
> > +# = Events
> > +##
> > +
> 
> This suggests *all* events are in this section, which isn't the case.
> "Other events"?  "Core events"?  Dunno...

"Other events" sounds nice to me. I think we could improve the organization 
after. 

> >  ##
> >  # @SHUTDOWN:
> >  #
> > diff --git a/qapi/rocker.json b/qapi/rocker.json
> > index ace2776..dd72e02 100644
> > --- a/qapi/rocker.json
> > +++ b/qapi/rocker.json
> > @@ -1,4 +1,8 @@
> >  ##
> > +# = Rocker API
> 
> What about "Rocker switch device"?

ok

> 
> > +##
> > +
> > +##
> >  # @RockerSwitch:
> >  #
> >  # Rocker switch information.
> > diff --git a/qapi/trace.json b/qapi/trace.json
> > index 4fd39b7..3ad7df7 100644
> > --- a/qapi/trace.json
> > +++ b/qapi/trace.json
> > @@ -5,6 +5,9 @@
> >  # This work is licensed under the terms of the GNU GPL, version 2 or
> >  later.
> >  # See the COPYING file in the top-level directory.
> >  
> > +##
> > +# = Tracing commands
> > +##
> >  
> >  ##
> >  # @TraceEventState:
> 



Re: [Qemu-devel] [PATCH v6 4/4] hw/intc/arm_gicv3_kvm: Reset GICv3 cpu interface registers

2016-11-30 Thread Vijay Kilari
On Mon, Nov 28, 2016 at 10:05 PM, Peter Maydell
 wrote:
> On 28 November 2016 at 16:01, Vijay Kilari  wrote:
>> On Mon, Nov 28, 2016 at 6:31 PM, Peter Maydell  
>> wrote:
>>> On 23 November 2016 at 12:39,   wrote:
 From: Vijaya Kumar K 

 Reset CPU interface registers of GICv3 when CPU is reset.
 For this, object interface is used, which is called from
 arm_cpu_reset function.

 Signed-off-by: Vijaya Kumar K 
>>>
>>> This approach doesn't handle the SMP case correctly --
>>> when a CPU is reset then the CPU interface for that CPU
>>> (and only that CPU) should be reset. Your code will
>>> reset every CPU interface every time any CPU is reset.
>>
>> arm_cpu_reset is not called when particular cpu is reset?.
>> Is it called for all cpus?.
>
> It's called to reset a particular CPU (so it will be called
> once for each CPU).
>
>> OR object_child_foreach_recursive() is calling to reset cpu
>> interfaces of
>> all cpus?.
>
> It does "look through the whole graph of objects in the
> simulation and call the function on anything in the
> graph that implements the interface". I've just seen that
> your code is doing "ignore the call if the CPU that
> triggered this isn't the one we care about", though --
> I missed that the first time reading the code.
>
> Still I would prefer it if we did this with the same
> mechanism for both TCG and KVM. A generic mechanism for
> "let the CPU reset trigger reset of many other devices in the
> system" isn't widely useful because real hardware doesn't
> have that kind of action-at-a-distance behaviour.

To make direct call from arm_cpu_reset() to reset CPUIF,
I could not find a way to get GICv3CPUState from CPUARMState or
ARMCPU struct.

Any idea how to get GICv3CPUState?

In  hw/intc/arm_gicv3_cpuif.c implementation,
el_hook function is registered to fetch GICv3CPUState from CPUARMState
struct, but it is for TCG

>
> thanks
> -- PMM



Re: [Qemu-devel] [PATCH for-2.9 26/30] aspeed/smc: use flash model option

2016-11-30 Thread Cédric Le Goater
On 11/29/2016 04:44 PM, Cédric Le Goater wrote:
> so that we can change the flash model from the command line.

After kevin input on this topic, we should drop patch 25 and 26.

Thanks,

C. 

> Signed-off-by: Cédric Le Goater 
> Reviewed-by: Joel Stanley 
> ---
>  hw/arm/aspeed.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
> index a92c2f1c362b..f4232ce42cd0 100644
> --- a/hw/arm/aspeed.c
> +++ b/hw/arm/aspeed.c
> @@ -138,6 +138,8 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, 
> const char *flashtype,
>  DriveInfo *dinfo = drive_get_next(IF_MTD);
>  qemu_irq cs_line;
>  
> +flashtype = dinfo && dinfo->model ? dinfo->model : flashtype;
> +
>  /*
>   * FIXME: check that we are not using a flash module exceeding
>   * the controller segment size
> 




[Qemu-devel] [PATCH] target-mips: fix bad shifts in {dextp|dextpdp}

2016-11-30 Thread Yongbok Kim
Fixed issues in the MIPSDSP64 instructions dextp and dextpdp.
Shifting can go out of 32 bit range.

https://bugs.launchpad.net/qemu/+bug/1631625

Reported-by: Thomas Huth 
Reported-by: Jia Liu 
Signed-off-by: Yongbok Kim 
---
 target-mips/dsp_helper.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target-mips/dsp_helper.c b/target-mips/dsp_helper.c
index df7d220..dc70793 100644
--- a/target-mips/dsp_helper.c
+++ b/target-mips/dsp_helper.c
@@ -3477,7 +3477,7 @@ target_ulong helper_dextp(target_ulong ac, target_ulong 
size, CPUMIPSState *env)
 
 if (sub >= -1) {
 temp = (tempB << (64 - len)) | (tempA >> len);
-temp = temp & ((0x01 << (size + 1)) - 1);
+temp = temp & ((1ULL << (size + 1)) - 1);
 set_DSPControl_efi(0, env);
 } else {
 set_DSPControl_efi(1, env);
@@ -3506,7 +3506,7 @@ target_ulong helper_dextpdp(target_ulong ac, target_ulong 
size,
 
 if (sub >= -1) {
 temp = (tempB << (64 - len)) | (tempA >> len);
-temp = temp & ((0x01 << (size + 1)) - 1);
+temp = temp & ((1ULL << (size + 1)) - 1);
 set_DSPControl_pos(sub, env);
 set_DSPControl_efi(0, env);
 } else {
-- 
1.7.1




[Qemu-devel] [Bug 902413] Re: qemu-i386-user on ARM host: wine hangs/spins when trying to run anything

2016-11-30 Thread Thomas Huth
So can we close this bug now, or is there still something left to do
here?

** Changed in: qemu
   Status: New => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/902413

Title:
  qemu-i386-user on ARM host: wine hangs/spins when trying to run
  anything

Status in QEMU:
  Incomplete
Status in wine package in Gentoo Linux:
  New

Bug description:
  With qemu built from git from 217bfb445b54db618a30f3a39170bebd9fd9dbf2
  and configured with './configure --target-list=i386-linux-user
  --static --interp-prefix=/home/pgriffais/natty-i386/', trying to run
  wine 1.3.15 from an Ubuntu 11.04 chroot results in hangs. If I run an
  i386 emulated wineserver, wineserver hangs in:

  0x600c7f8c in read () at ../sysdeps/unix/syscall-template.S:82
  82../sysdeps/unix/syscall-template.S: No such file or directory.
in ../sysdeps/unix/syscall-template.S
  (gdb) bt
  #0  0x600c7f8c in read () at ../sysdeps/unix/syscall-template.S:82
  #1  0x6004a316 in read (cpu_env=0x622c3ee8, num=3, arg1=6, arg2=1121255519, 
  arg3=1, arg4=134875664, arg5=1, arg6=1121255528, arg7=0, arg8=0)
  at /usr/include/bits/unistd.h:45
  #2  do_syscall (cpu_env=0x622c3ee8, num=3, arg1=6, arg2=1121255519, arg3=1, 
  arg4=134875664, arg5=1, arg6=1121255528, arg7=0, arg8=0)
  at /home/ubuntu/src/qemu/linux-user/syscall.c:4691
  #3  0x600262f0 in cpu_loop (env=0x622c3ee8)
  at /home/ubuntu/src/qemu/linux-user/main.c:321
  #4  0x60026bbc in main (argc=, 
  argv=, envp=)
  at /home/ubuntu/src/qemu/linux-user/main.c:3817

  While wine hangs in:

  0x600c84ac in recvmsg () at ../sysdeps/unix/syscall-template.S:82
  82../sysdeps/unix/syscall-template.S: No such file or directory.
in ../sysdeps/unix/syscall-template.S
  (gdb) bt
  #0  0x600c84ac in recvmsg () at ../sysdeps/unix/syscall-template.S:82
  #1  0x60041c4e in do_sendrecvmsg (fd=4, target_msg=, 
  flags=1073741824, send=0)
  at /home/ubuntu/src/qemu/linux-user/syscall.c:1834
  #2  0x600497ec in do_socketcall (cpu_env=, num=102, 
  arg1=17, arg2=1122504544, arg3=2076831732, arg4=1122504568, 
  arg5=2076942688, arg6=1122504888, arg7=0, arg8=0)
  at /home/ubuntu/src/qemu/linux-user/syscall.c:2235
  #3  do_syscall (cpu_env=, num=102, arg1=17, 
  arg2=1122504544, arg3=2076831732, arg4=1122504568, arg5=2076942688, 
  arg6=1122504888, arg7=0, arg8=0)
  at /home/ubuntu/src/qemu/linux-user/syscall.c:6085
  #4  0x600262f0 in cpu_loop (env=0x622c3f08)
  at /home/ubuntu/src/qemu/linux-user/main.c:321
  #5  0x60026bbc in main (argc=, 
  argv=, envp=)
  at /home/ubuntu/src/qemu/linux-user/main.c:3817

  However if I build wineserver 1.3.15 natively for ARM and run it on
  the host while wine is emulated, I get the following:

  root@tiberiusstation:/home/ubuntu# ./natty-i386/usr/bin/wine notepad
  Unsupported ancillary data: 1/2
  Unsupported ancillary data: 1/2
  Unsupported ancillary data: 1/2
  err:process:__wine_kernel_init boot event wait timed out

  I assume the last one is due to wineboot.exe hanging. The main wine
  process hangs in there:

  cg_temp_new_internal_i32 (temp_local=)
  at /home/ubuntu/src/qemu/tcg/tcg.c:483
  483   }
  (gdb) bt
  #0  tcg_temp_new_internal_i32 (temp_local=)
  at /home/ubuntu/src/qemu/tcg/tcg.c:483
  #1  0x60052ac6 in tcg_temp_new_i32 (val=6)
  at /home/ubuntu/src/qemu/tcg/tcg.h:442
  #2  tcg_const_i32 (val=6) at /home/ubuntu/src/qemu/tcg/tcg.c:530
  #3  0x6005ef0c in tcg_gen_shri_i32 (ot=2, op1=2, op2=7, is_right=1, 
  is_arith=0, s=)
  at /home/ubuntu/src/qemu/tcg/tcg-op.h:605
  #4  gen_shift_rm_im (ot=2, op1=2, op2=7, is_right=1, is_arith=0, 
  s=)
  at /home/ubuntu/src/qemu/target-i386/translate.c:1514
  #5  0x6006df90 in gen_shifti (s=0xbefea970, pc_start=)
  at /home/ubuntu/src/qemu/target-i386/translate.c:1946
  #6  disas_insn (s=0xbefea970, pc_start=)
  at /home/ubuntu/src/qemu/target-i386/translate.c:5397
  #7  0x60091758 in gen_intermediate_code_internal (env=0x625656f8, 
  tb=0x402cdf48) at /home/ubuntu/src/qemu/target-i386/translate.c:7825
  #8  gen_intermediate_code_pc (env=0x625656f8, tb=0x402cdf48)
  at /home/ubuntu/src/qemu/target-i386/translate.c:7896
  #9  0x60054bf2 in cpu_restore_state (tb=0x402cdf48, env=0x62565690, 
  searched_pc=1617393812) at /home/ubuntu/src/qemu/translate-all.c:126
  #10 0x60091d9e in handle_cpu_signal (host_signum=, 
  pinfo=, puc=0xbefeab70)
  at /home/ubuntu/src/qemu/user-exec.c:117
  #11 cpu_x86_signal_handler (host_signum=, 
  pinfo=, puc=0xbefeab70)
  at /home/ubuntu/src/qemu/user-exec.c:458
  #12 0x6003c764 in host_signal_handler (host_signum=11, info=0xbefeaaf0, 
  puc=)
  at /home/ubuntu/src/qemu/linux-user/signal.c:492
  #13 
  #14 0x60677894 in static_code_gen_buffer ()
  #15 0x6000a260 in cpu_x86_exec (env=0x0)
  at /home/ubuntu/src/qemu/cpu-ex

[Qemu-devel] [Bug 1297218] Re: guest hangs after live migration due to tsc jump

2016-11-30 Thread Thomas Huth
If I've got comment 27 right, the issue has also been fixed upstream, so
I'm setting the status now to "Fix released". If there's still something
left to do here, feel free to change it again.

** Changed in: qemu
   Status: New => Fix Released

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1297218

Title:
  guest hangs after live migration due to tsc jump

Status in QEMU:
  Fix Released
Status in glusterfs package in Ubuntu:
  Invalid
Status in qemu package in Ubuntu:
  Fix Released
Status in glusterfs source package in Trusty:
  Confirmed
Status in qemu source package in Trusty:
  Fix Released

Bug description:
  =
  SRU Justification:
  1. Impact: guests hang after live migration with 100% cpu
  2. Upstream fix: a set of four patches fix this upstream
  3. Stable fix: we have a backport of the four patches into a single patch.
  4. Test case: try a set of migrations of different VMS (it is unfortunately 
not 100% reproducible)
  5. Regression potential: the patch is not trivial, however the 
lp:qa-regression-tests testsuite passed 100% with this package.
  =

  We have two identical Ubuntu servers running libvirt/kvm/qemu, sharing
  a Gluster filesystem. Guests can be live migrated between them.
  However, live migration often leads to the guest being stuck at 100%
  for a while. In that case, the dmesg output for such a guest will show
  (once it recovers): Clocksource tsc unstable (delta = 662463064082
  ns). In this particular example, a guest was migrated and only after
  11 minutes (662 seconds) did it become responsive again.

  It seems that newly booted guests doe not suffer from this problem,
  these can be migrated back and forth at will. After a day or so, the
  problem becomes apparent. It also seems that migrating from server A
  to server B causes much more problems than going from B back to A. If
  necessary, I can do more measurements to qualify these observations.

  The VM servers run Ubuntu 13.04 with these packages:
  Kernel: 3.8.0-35-generic x86_64
  Libvirt: 1.0.2
  Qemu: 1.4.0
  Gluster-fs: 3.4.2 (libvirt access the images via the filesystem, not using 
libgfapi yet as the Ubuntu libvirt is not linked against libgfapi).
  The interconnect between both machines (both for migration and gluster) is 
10GbE.
  Both servers are synced to NTP and well within 1ms form one another.

  Guests are either Ubuntu 13.04 or 13.10.

  On the guests, the current_clocksource is kvm-clock.
  The XML definition of the guests only contains:  

  Now as far as I've read in the documentation of kvm-clock, it specifically 
supports live migrations, so I'm a bit surprised at these problems. There isn't 
all that much information to find on these issue, although I have found 
postings by others that seem to have run into the same issues, but without a 
solution.
  ---
  ApportVersion: 2.14.1-0ubuntu3
  Architecture: amd64
  DistroRelease: Ubuntu 14.04
  Package: libvirt (not installed)
  ProcCmdline: BOOT_IMAGE=/boot/vmlinuz-3.13.0-24-generic 
root=UUID=1b0c3c6d-a9b8-4e84-b076-117ae267d178 ro console=ttyS1,115200n8 
BOOTIF=01-00-25-90-75-b5-c8
  ProcVersionSignature: Ubuntu 3.13.0-24.47-generic 3.13.9
  Tags:  trusty apparmor apparmor apparmor apparmor apparmor
  Uname: Linux 3.13.0-24-generic x86_64
  UpgradeStatus: No upgrade log present (probably fresh install)
  UserGroups:

  _MarkForUpload: True
  modified.conffile..etc.default.libvirt.bin: [modified]
  modified.conffile..etc.libvirt.libvirtd.conf: [modified]
  modified.conffile..etc.libvirt.qemu.conf: [modified]
  modified.conffile..etc.libvirt.qemu.networks.default.xml: [deleted]
  mtime.conffile..etc.default.libvirt.bin: 2014-05-12T19:07:40.020662
  mtime.conffile..etc.libvirt.libvirtd.conf: 2014-05-13T14:40:25.894837
  mtime.conffile..etc.libvirt.qemu.conf: 2014-05-12T18:58:27.885506

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1297218/+subscriptions



[Qemu-devel] [Bug 1027525] Re: Unable to insert cd media located on ro nfs mount

2016-11-30 Thread Thomas Huth
Can you still reproduce this problem with the latest version of QEMU? If
so, could you please refresh your patch and send it to the qemu-devel
mailing list? (we do not accept patches from the bug tracker)

** Changed in: qemu
   Status: New => Incomplete

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1027525

Title:
  Unable to insert cd media located on ro nfs mount

Status in QEMU:
  Incomplete

Bug description:
  When issuing a "change" command via the monitor, qemu is unable to
  open the iso file if it is mounted on a read-only nfs share. If I
  mount read-write (and make sure the file is writable by the qemu
  process), then the change command succeeds. Note that this doesn't
  affect media specified on the command line when starting qemu, only
  when changing via the monitor.

  To reproduce, mount cd images directory read only, e.g.

  [root@kvmhost0 ~]# grep iso /etc/fstab
  10.48.50.20:/iso /srv/kvm/iso nfs4 defaults,ro 0 0

  Start qemu with minimal options, just need access to the monitor:

  [root@kvmhost0 ~]# kvm -vnc 127.0.0.1:0 -S

  Connect to the monitor and issue a change command:

  (qemu) change ide1-cd0 /srv/kvm/iso/ubuntu-12.04-server-amd64.iso
  Could not open '/srv/kvm/iso/ubuntu-12.04-server-amd64.iso

  Re-mount the iso directory read-write and notice that the command
  succeeds:

  [root@kvmhost0 ~]# mount -o remount,rw /srv/kvm/iso

  (qemu) change ide1-cd0 /srv/kvm/iso/ubuntu-12.04-server-amd64.iso
  (qemu)

  [root@kvmhost0 ~]# kvm --version
  QEMU emulator version 1.1.1 (qemu-kvm-1.1.1), Copyright (c) 2003-2008 Fabrice 
Bellard
  [root@kvmhost0 ~]# uname -a
  Linux kvmhost0 3.4.5-1-ARCH #1 SMP PREEMPT Mon Jul 16 21:35:54 CEST 2012 
x86_64 GNU/Linux

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1027525/+subscriptions



  1   2   3   >