Re: [Qemu-devel] drive-backup

2016-02-25 Thread Fam Zheng
On Thu, 02/25 08:49, Stefan Priebe - Profihost AG wrote:
> 
> Am 22.02.2016 um 23:08 schrieb John Snow:
> > 
> > 
> > On 02/22/2016 03:21 PM, Stefan Priebe wrote:
> >> Hello,
> >>
> >> is there any chance or hack to work with a bigger cluster size for the
> >> drive backup job?
> >>
> >> See:
> >> http://git.qemu.org/?p=qemu.git;a=blob;f=block/backup.c;h=16105d40b193be9bb40346027bdf58e62b956a96;hb=98d2c6f2cd80afaa2dc10091f5e35a97c181e4f5
> >>
> >>
> >> This is very slow with ceph - may be due to the 64k block size. I would
> >> like to check whether this is faster with cephs native block size of 4mb.
> >>
> >> Greets,
> >> Stefan
> >>
> > 
> > It's hardcoded to 64K at the moment, but I am checking in a patch to
> > round up the cluster size to be the bigger of (64k,
> > $target_cluster_size) in order to make sure that incremental backups in
> > particular never copy a fraction of a cluster. As a side-effect, the
> > same round-up will happen for all modes (sync=top,none,full).
> > 
> > If QEMU is aware of the target cluster size of 4MB, this would
> > immediately jump the copy-size up to 4MB clusters for you.
> > 
> > See: https://lists.nongnu.org/archive/html/qemu-devel/2016-02/msg02839.html
> 
> Thanks for your patches and thanks for your great answer. But our
> problem is not the target but the source ;-) The target has a local
> cache and don't care about the cluster size but the source does not.
> 
> But it works fine if we change the default cluster size to 4MB. So it
> has point us to the right direction.

Does it mean overriding the copy granularity is what you want to do?
Asking because drive-mirror has a "granularity" parameter for this purpose, if
so it should probably be considered for drive-backup as well.

Fam




Re: [Qemu-devel] [PATCH] loader: fix potential memory leak

2016-02-25 Thread Cao jin

sorry, It just came to me that I forgot to cc qemu-trivial

On 02/24/2016 05:12 PM, Cao jin wrote:

Signed-off-by: Cao jin 
---
  hw/core/loader.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 3a57415..24fea65 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -827,10 +827,16 @@ int rom_add_file(const char *file, const char *fw_dir,
  err:
  if (fd != -1)
  close(fd);
+
  g_free(rom->data);
  g_free(rom->path);
  g_free(rom->name);
+if (fw_dir) {
+g_free(rom->fw_dir);
+g_free(rom->fw_file);
+}
  g_free(rom);
+
  return -1;
  }




--
Yours Sincerely,

Cao jin





Re: [Qemu-devel] [PATCH] qemu-ga: Fixed minor version switch issue

2016-02-25 Thread Leonid Bloch
On Feb 25, 2016 4:09 AM, "Michael Roth"  wrote:
>
> Quoting Leonid Bloch (2016-01-11 03:12:41)
> > With automatically generated GUID, on minor version changes, an error
> > occurred, stating that there is a problem with the installer.
> > Now, a notification is shown, warning the user that another version of
> > this product is already installed, and that configuration or removal of
> > the existing version is possible through Add/Remove Programs on the
> > Control Panel (expected behavior).
> >
> > Signed-off-by: Leonid Bloch 
>
> Thanks, applied to qga tree:
>
>   https://github.com/mdroth/qemu/commits/qga

Thanks, Michael.

>
> > ---
> >  qga/installer/qemu-ga.wxs | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/qga/installer/qemu-ga.wxs b/qga/installer/qemu-ga.wxs
> > index 9473875..7f92891 100644
> > --- a/qga/installer/qemu-ga.wxs
> > +++ b/qga/installer/qemu-ga.wxs
> > @@ -41,7 +41,7 @@
> >
> > >  Name="QEMU guest agent"
> > -Id="*"
> > +Id="{DF9974AD-E41A-4304-81AD-69AA8F299766}"
> >  UpgradeCode="{EB6B8302-C06E-4BEC-ADAC-932C68A3A98D}"
> >  Manufacturer="$(env.QEMU_GA_MANUFACTURER)"
> >  Version="$(env.QEMU_GA_VERSION)"
> > --
> > 2.4.3
> >
>


Re: [Qemu-devel] kvm: "warning: host doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]"

2016-02-25 Thread Jan Kiszka
On 2016-02-25 09:33, Lan Tianyu wrote:
> 2016-02-20 17:00 GMT+08:00 Paolo Bonzini :
>>
>>
>> - Original Message -
>>> From: "Jan Kiszka" 
>>> To: "Eduardo Habkost" , "Paolo Bonzini" 
>>> 
>>> Cc: "qemu-devel" , "kvm" 
>>> Sent: Saturday, February 20, 2016 9:09:32 AM
>>> Subject: kvm: "warning: host doesn't support requested feature: 
>>> CPUID.01H:ECX.x2apic [bit 21]"
>>>
>>> Hi all,
>>>
>>> I suppose 5120901a37 introduced this: qemu with kernel_irqchip=off now
>>> generates these warnings, one per VCPU, during QEMU startup. Is the plan
>>> to live with them until we finally have x2APIC emulation in userspace
>>> (ie. also MSR vmexiting to there), or should we otherwise avoid it?
>>
>> I think it's a bug, x2apic should be auto-suppressed with kernel_irqchip=off.
>>
> 
> The patch is to fix the issue.
> ->8
> From 58f2a3a94c8e7bf9f3474bcafb6c59cc4f8bcbd9 Mon Sep 17 00:00:00 2001
> From: Lan Tianyu 
> Date: Sun, 15 Jul 2001 01:40:17 -0400
> Subject: [PATCH] Qemu/KVM: Remove x2apic feature from CPU model when
>  kernel_irqchip=off
> 
> x2apic feature is in the kvm_default_props and automatically added to all
> CPU models when KVM is enabled regardless of kernel_irqchip=off. This will
> trigger "warning: host doesn't support requested feature: CPUID.01H:
> ECX.x2apic [bit 21]" when kernel_irqchip=off. This patch is to remove x2apic
> feature when kernel_irqchip=off.

We know this, but it's probably worth to mention the underlying reason
here: userspace devices don't support x2APIC.

> 
> Signed-off-by: Lan Tianyu 
> ---
>  target-i386/cpu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 0d447b5..2ec7eb7 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -2105,6 +2105,9 @@ static void x86_cpu_load_def(X86CPU *cpu,
> X86CPUDefinition *def, Error **errp)
> 
>  /* Special cases not set in the X86CPUDefinition structs: */
>  if (kvm_enabled()) {
> +   if (!kvm_irqchip_in_kernel())
> +   x86_cpu_change_kvm_default("x2apic", "off");
> +
>  x86_cpu_apply_props(cpu, kvm_default_props);
>  }
> 
> --
> 1.9.3
> 

Make sure to comply with the coding style (there is a checkpatch.pl also
in QEMU). And please post as a new thread with proper subject, otherwise
people (and tools) will not find your patch as such.

Jan



Re: [Qemu-devel] [OpenBIOS] Trying to figure out what 9 means to the escc

2016-02-25 Thread Hervé Poussineau

Le 24/02/2016 21:13, Programmingkid a écrit :

With the below patch I can see that Mac OS 9.0 is having escc_mem_write() go to 
the SERIAL_CTRL case. Then to the W_CMD case. Then to the CMD_HI case. This 
then causes newreg to be set to the value 9. What I need to know is what is 
this value for. Does anyone know what it means?


Basically, you need to first select to which register you write, and then, 
which value you want to write to this selected register.

Here, you write to register 0 W_CMD to choose the register 9 (by register mask value 1 + 
Point High Command, which adds 8) [pdf page 148], which is "Master Interrupt 
Control" register (W_MINTR)
Then, you write 0xc0 to the previously selected register W_MINTR; c0 is reset for 
channels A & B [pdf page 167]

Hervé



Afterwords Mac OS 9.0 will write the value 0xc0 to the escc. This causes the 
escc to reset.

This pdf might be helpful for anyone who is interested in helping: 
http://www.zilog.com/docs/serial/scc_escc_um.pdf

---
  hw/char/escc.c |   28 
  1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index 98a1c21..f1fc70e 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -472,6 +472,7 @@ static void escc_update_parameters(ChannelState *s)
  static void escc_mem_write(void *opaque, hwaddr addr,
 uint64_t val, unsigned size)
  {
+
  ESCCState *serial = opaque;
  ChannelState *s;
  uint32_t saddr;
@@ -481,22 +482,31 @@ static void escc_mem_write(void *opaque, hwaddr addr,
  saddr = (addr >> serial->it_shift) & 1;
  channel = (addr >> (serial->it_shift + 1)) & 1;
  s = &serial->chn[channel];
+
+printf("%s(): start value:0x%x register:0x%x\n", __func__, val, saddr);
+
  switch (saddr) {
  case SERIAL_CTRL:
+printf("%s() SERIAL_CTRL case\n", __func__);
  trace_escc_mem_writeb_ctrl(CHN_C(s), s->reg, val & 0xff);
  newreg = 0;
  switch (s->reg) {
  case W_CMD:
+printf("%s() W_CMD case\n", __func__);
  newreg = val & CMD_PTR_MASK;
  val &= CMD_CMD_MASK;
  switch (val) {
  case CMD_HI:
+printf("%s() CMD_HI case\n", __func__);
  newreg |= CMD_HI;
+printf("%s(): newreg = 0x%x\n", __func__, newreg);
  break;
  case CMD_CLR_TXINT:
+printf("%s() CMD_CLR_TXINT case\n", __func__);
  clr_txint(s);
  break;
  case CMD_CLR_IUS:
+printf("%s() CMD_CLR_IUS case\n", __func__);
  if (s->rxint_under_svc) {
  s->rxint_under_svc = 0;
  if (s->txint) {
@@ -508,6 +518,7 @@ static void escc_mem_write(void *opaque, hwaddr addr,
  escc_update_irq(s);
  break;
  default:
+printf("%s(): unprogrammed command detected: value:%d\n", 
__func__, val);
  break;
  }
  break;
@@ -515,36 +526,44 @@ static void escc_mem_write(void *opaque, hwaddr addr,
  case W_SYNC1 ... W_TXBUF:
  case W_MISC1 ... W_CLOCK:
  case W_MISC2 ... W_EXTINT:
+printf("%s() W_MISC2 case\n", __func__);
  s->wregs[s->reg] = val;
  break;
  case W_TXCTRL1:
  case W_TXCTRL2:
+printf("%s() W_TXCTRL2 case\n", __func__);
  s->wregs[s->reg] = val;
  escc_update_parameters(s);
  break;
  case W_BRGLO:
  case W_BRGHI:
+printf("%s() W_BRGHI case\n", __func__);
  s->wregs[s->reg] = val;
  s->rregs[s->reg] = val;
  escc_update_parameters(s);
  break;
  case W_MINTR:
+printf("%s(): W_MINTR detected\n", __func__);
  switch (val & MINTR_RST_MASK) {
  case 0:
  default:
  break;
  case MINTR_RST_B:
+printf("%s() MINTR_RST_B case\n", __func__);
  escc_reset_chn(&serial->chn[0]);
  return;
  case MINTR_RST_A:
+printf("%s() MINTR_RST_A case\n", __func__);
  escc_reset_chn(&serial->chn[1]);
  return;
  case MINTR_RST_ALL:
+printf("%s(): MINTR_RST_ALL case\n", __func__);
  escc_reset(DEVICE(serial));
  return;
  }
  break;
  default:
+printf("%s(): unprogrammed command detected: value:%d\n", 
__func__, val);
  break;
  }
  if (s->reg == 0)
@@ -553,6 +572,7 @@ static void escc_mem_write(void *opaque, hwaddr addr,
  s->reg = 0;
  break;
  case SERIAL_DATA:
+printf("%s() SERIAL_DATA case\n", __func__);
  trace_escc_mem_writeb_data(CHN_C(s), val);

Re: [Qemu-devel] KVM call for agenda for 2016-03-01

2016-02-25 Thread Thomas Huth
On 23.02.2016 16:33, Juan Quintela wrote:
> 
> Hi
> 
> Please, send any topic that you are interested in covering.
> 
> At the end of Monday I will send an email with the agenda or the
> cancellation of the call, so hurry up.

Shall we talk about CPU hotplug again? There are a lot of discussions
going on, but as far as I can tell, it seems there is still no 100%
common understanding yet how the final solution should really look like...

 Thomas




Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> Stop!

It builds fine here. Did you check out my tree?

> 
> Hey, stubs/pc_dimm.c disappeared from this patch:
> === from [PATCH v7 0/5] don't use NVDIMM for balooning/[PATCH 3/5]
> pc-dimm: add pc_dimm_build_list() ===
> 
> diff --git a/stubs/pc_dimm.c b/stubs/pc_dimm.c
> new file mode 100644
> index 000..5312f50
> --- /dev/null
> +++ b/stubs/pc_dimm.c
> @@ -0,0 +1,12 @@
> +#include "qom/object.h"
> +#include "hw/mem/pc-dimm.h"
> +
> +int qmp_pc_dimm_device_list(Object *obj, void *opaque)
> +{
> +   return 0;
> +}
> +
> +int pc_dimm_build_list(Object *obj, void *opaque)
> +{
> +   return 0;
> +}
> 
> 
> 
> 
> This will not compile!!!
> make: *** No rule to make target `stubs/pc_dimm.c', needed by
> `stubs/pc_dimm.o'.  Stop.
> 
> 
> On 24.02.2016 23:35, Michael S. Tsirkin wrote:
> >From: Vladimir Sementsov-Ogievskiy 
> >
> >Like pc_dimm_build_list_sorted but not sorted - for cases where sorting
> >is not necessary. Add stubbed version too - for targets without
> >CONFIG_MEM_HOTPLUG.
> >
> >Signed-off-by: Vladimir Sementsov-Ogievskiy 
> >Reviewed-by: Michael S. Tsirkin 
> >Signed-off-by: Michael S. Tsirkin 
> >---
> >  include/hw/mem/pc-dimm.h|  3 +++
> >  hw/mem/pc-dimm.c| 15 +++
> >  stubs/qmp_pc_dimm_device_list.c |  8 
> >  stubs/Makefile.objs |  2 +-
> >  4 files changed, 19 insertions(+), 9 deletions(-)
> >  delete mode 100644 stubs/qmp_pc_dimm_device_list.c
> >
> >diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
> >index 218dfb0..0f587a4 100644
> >--- a/include/hw/mem/pc-dimm.h
> >+++ b/include/hw/mem/pc-dimm.h
> >@@ -94,4 +94,7 @@ void pc_dimm_memory_plug(DeviceState *dev, 
> >MemoryHotplugState *hpms,
> >   MemoryRegion *mr, uint64_t align, Error **errp);
> >  void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
> > MemoryRegion *mr);
> >+
> >+int pc_dimm_build_list(Object *obj, void *opaque);
> >+
> >  #endif
> >diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> >index 835179e..09e99ce 100644
> >--- a/hw/mem/pc-dimm.c
> >+++ b/hw/mem/pc-dimm.c
> >@@ -267,6 +267,21 @@ static int pc_dimm_build_list_sorted(Object *obj, void 
> >*opaque)
> >  return 0;
> >  }
> >+int pc_dimm_build_list(Object *obj, void *opaque)
> >+{
> >+GSList **list = opaque;
> >+
> >+if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
> >+DeviceState *dev = DEVICE(obj);
> >+if (dev->realized) { /* only realized DIMMs matter */
> >+*list = g_slist_prepend(*list, dev);
> >+}
> >+}
> >+
> >+object_child_foreach(obj, pc_dimm_build_list, opaque);
> >+return 0;
> >+}
> >+
> >  uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
> > uint64_t address_space_size,
> > uint64_t *hint, uint64_t align, uint64_t 
> > size,
> >diff --git a/stubs/qmp_pc_dimm_device_list.c 
> >b/stubs/qmp_pc_dimm_device_list.c
> >deleted file mode 100644
> >index def2115..000
> >--- a/stubs/qmp_pc_dimm_device_list.c
> >+++ /dev/null
> >@@ -1,8 +0,0 @@
> >-#include "qemu/osdep.h"
> >-#include "qom/object.h"
> >-#include "hw/mem/pc-dimm.h"
> >-
> >-int qmp_pc_dimm_device_list(Object *obj, void *opaque)
> >-{
> >-   return 0;
> >-}
> >diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> >index e922de9..fb247d4 100644
> >--- a/stubs/Makefile.objs
> >+++ b/stubs/Makefile.objs
> >@@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
> >  stub-obj-$(CONFIG_WIN32) += fd-register.o
> >  stub-obj-y += cpus.o
> >  stub-obj-y += kvm.o
> >-stub-obj-y += qmp_pc_dimm_device_list.o
> >+stub-obj-y += pc_dimm.o
> >  stub-obj-y += target-monitor-defs.o
> >  stub-obj-y += target-get-monitor-def.o
> >  stub-obj-y += vhost.o
> 
> 
> -- 
> Best regards,
> Vladimir



Re: [Qemu-devel] [PATCH 1/2] virtio-balloon: export all balloon statistics

2016-02-25 Thread Markus Armbruster
"Denis V. Lunev"  writes:

> On 02/24/2016 06:43 PM, Eric Blake wrote:
>> On 02/24/2016 07:31 AM, Michael S. Tsirkin wrote:
>>> Roman Kagan  writes:
 On Tue, Feb 23, 2016 at 05:49:21PM +0200, Michael S. Tsirkin wrote:
> On Tue, Feb 23, 2016 at 06:29:33PM +0300, Denis V. Lunev wrote:
> > On 02/23/2016 06:24 PM, Michael S. Tsirkin wrote:
> > >On Tue, Feb 23, 2016 at 05:59:44PM +0300, Denis V. Lunev wrote:
> > >>From: Igor Redko 
> > >>
> > >>We are making experiments with different autoballooning strategies
> > >>based on the guest behavior. Thus we need to experiment with different
> > >>guest statistics. For now every counter change requires QEMU 
> > >>recompilation
> > >>and dances with Libvirt.
> > >>
> > >>This patch introduces transport for unrecognized counters in 
> > >>virtio-balloon.
> > >>This transport can be used for measuring benefits from using new
> > >>balloon counters, before submitting any patches. Current alternative
> > >>is 'guest-exec' transport which isn't made for such delicate matters
> > >>and can influence test results.
> > >>
> > >>Originally all counters with tag >= VIRTIO_BALLOON_S_NR were ignored.
> > >>Instead of this we keep first (VIRTIO_BALLOON_S_NR + 32) counters 
> > >>from the
> > >>queue and pass unrecognized ones with the following names: 
> > >>'x-stat-',
> > >>where  is a tag number in hex. Defined counters are reported with 
> > >>their
> > >>regular names.
> > >>
> > >>Signed-off-by: Igor Redko 
> > >>Signed-off-by: Denis V. Lunev 
> > >>CC: Michael S. Tsirkin 
> > >This seems to open the ABI to abuse.
> > >Seems like a reasonable way to experiment though.
> > >How about adding this within #if 0 statements?
> > >You can uncomment them for debugging ...
> > I'd prefer to have this enabled.

Yes, conditional compilation should be used sparingly.  I don't have an
opinion on whether using it here is appropriate.

> > Why do you think that it opens "abuse" way?
> 
> Because people will use this to hack drivers and management tools
> bypassing qemu.

Easy to avoid: shuffle the N in x-stat-N around from time to time, to
reinforce the lesson that you must not rely on their presence or
semantics.  I doubt it'll be necessary beyond the renumbering that
happens naturally when we add supported counters, or the reshuffling
that happens when somebody messes with the unsupported counters.

 I'm curious why you think it's a problem?  Even the existing stats are
 simply propagated to the management level by qemu with no processing
 other than assigning text labels.  The proposed naming scheme for
 unrecognized counters includes "x-" prefix which explicitly marks them
 as unstable so people using them take their risk.

 One of the benefits is forward compatibility, so that counters that have
 graduated into supported ones and have got their own number and name,
 can be made to work with qemu that doesn't yet recognize them.
>>> Then management does start relying on the x- prefixed things,
>>> and once it's used to that it's a slippery slope.
>> Any management tool that relies on an x- prefix name is broken.

Or at least assumes the full risk of breaking without notice whenever
QEMU changes.  Abbreviating that to just "broken" seems fair enough :)

>>  We've
>> explicitly documented that the x- prefix is unstable and liable to go
>> away with a future release. Any management app that wants to use a
>> feature beginning with x- should FIRST push hard to get the x- removed
>> and stabilize the interface (and libvirt, at least, does just that).
>>
> this was exactly an original idea. Names started with 'x-' are
> _officially_ unstable and for debug purpose. That is why I'd
> prefer if v2 of the patchset will be taken.

Looks like fair use of x- to me.



Re: [Qemu-devel] [PATCH 1/2] virtio-balloon: export all balloon statistics

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 09:44:06AM +0100, Markus Armbruster wrote:
> "Denis V. Lunev"  writes:
> 
> > On 02/24/2016 06:43 PM, Eric Blake wrote:
> >> On 02/24/2016 07:31 AM, Michael S. Tsirkin wrote:
> >>> Roman Kagan  writes:
>  On Tue, Feb 23, 2016 at 05:49:21PM +0200, Michael S. Tsirkin wrote:
> > On Tue, Feb 23, 2016 at 06:29:33PM +0300, Denis V. Lunev wrote:
> > > On 02/23/2016 06:24 PM, Michael S. Tsirkin wrote:
> > > >On Tue, Feb 23, 2016 at 05:59:44PM +0300, Denis V. Lunev wrote:
> > > >>From: Igor Redko 
> > > >>
> > > >>We are making experiments with different autoballooning strategies
> > > >>based on the guest behavior. Thus we need to experiment with 
> > > >>different
> > > >>guest statistics. For now every counter change requires QEMU 
> > > >>recompilation
> > > >>and dances with Libvirt.
> > > >>
> > > >>This patch introduces transport for unrecognized counters in 
> > > >>virtio-balloon.
> > > >>This transport can be used for measuring benefits from using new
> > > >>balloon counters, before submitting any patches. Current alternative
> > > >>is 'guest-exec' transport which isn't made for such delicate matters
> > > >>and can influence test results.
> > > >>
> > > >>Originally all counters with tag >= VIRTIO_BALLOON_S_NR were 
> > > >>ignored.
> > > >>Instead of this we keep first (VIRTIO_BALLOON_S_NR + 32) counters 
> > > >>from the
> > > >>queue and pass unrecognized ones with the following names: 
> > > >>'x-stat-',
> > > >>where  is a tag number in hex. Defined counters are reported 
> > > >>with their
> > > >>regular names.
> > > >>
> > > >>Signed-off-by: Igor Redko 
> > > >>Signed-off-by: Denis V. Lunev 
> > > >>CC: Michael S. Tsirkin 
> > > >This seems to open the ABI to abuse.
> > > >Seems like a reasonable way to experiment though.
> > > >How about adding this within #if 0 statements?
> > > >You can uncomment them for debugging ...
> > > I'd prefer to have this enabled.
> 
> Yes, conditional compilation should be used sparingly.  I don't have an
> opinion on whether using it here is appropriate.
> 
> > > Why do you think that it opens "abuse" way?
> > 
> > Because people will use this to hack drivers and management tools
> > bypassing qemu.
> 
> Easy to avoid: shuffle the N in x-stat-N around from time to time, to
> reinforce the lesson that you must not rely on their presence or
> semantics.  I doubt it'll be necessary beyond the renumbering that
> happens naturally when we add supported counters, or the reshuffling
> that happens when somebody messes with the unsupported counters.
> 
>  I'm curious why you think it's a problem?  Even the existing stats are
>  simply propagated to the management level by qemu with no processing
>  other than assigning text labels.  The proposed naming scheme for
>  unrecognized counters includes "x-" prefix which explicitly marks them
>  as unstable so people using them take their risk.
> 
>  One of the benefits is forward compatibility, so that counters that have
>  graduated into supported ones and have got their own number and name,
>  can be made to work with qemu that doesn't yet recognize them.
> >>> Then management does start relying on the x- prefixed things,
> >>> and once it's used to that it's a slippery slope.
> >> Any management tool that relies on an x- prefix name is broken.
> 
> Or at least assumes the full risk of breaking without notice whenever
> QEMU changes.  Abbreviating that to just "broken" seems fair enough :)
> 
> >>  We've
> >> explicitly documented that the x- prefix is unstable and liable to go
> >> away with a future release. Any management app that wants to use a
> >> feature beginning with x- should FIRST push hard to get the x- removed
> >> and stabilize the interface (and libvirt, at least, does just that).
> >>
> > this was exactly an original idea. Names started with 'x-' are
> > _officially_ unstable and for debug purpose. That is why I'd
> > prefer if v2 of the patchset will be taken.
> 
> Looks like fair use of x- to me.


Well I already heard:

One of the benefits is forward compatibility, so that counters that have
graduated into supported ones and have got their own number and name,
can be made to work with qemu that doesn't yet recognize them.

in this thread, which seems to mean exactly that people start planning to abuse 
it
even before it's merged.

-- 
MST



Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Vladimir Sementsov-Ogievskiy

On 25.02.2016 11:39, Michael S. Tsirkin wrote:

On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir Sementsov-Ogievskiy wrote:

Stop!

It builds fine here. Did you check out my tree?


anyway, this file should be here, as it is added into Makefile:

--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += pc_dimm.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += vhost.o


===
git clone git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tmp
cd tmp/
git checkout for_upstream
./configure  --target-list=x86_64-softmmu
make -j9
> make: *** No rule to make target `stubs/pc_dimm.o', needed by 
`libqemustub.a'.  Stop





Hey, stubs/pc_dimm.c disappeared from this patch:
=== from [PATCH v7 0/5] don't use NVDIMM for balooning/[PATCH 3/5]
pc-dimm: add pc_dimm_build_list() ===

diff --git a/stubs/pc_dimm.c b/stubs/pc_dimm.c
new file mode 100644
index 000..5312f50
--- /dev/null
+++ b/stubs/pc_dimm.c
@@ -0,0 +1,12 @@
+#include "qom/object.h"
+#include "hw/mem/pc-dimm.h"
+
+int qmp_pc_dimm_device_list(Object *obj, void *opaque)
+{
+   return 0;
+}
+
+int pc_dimm_build_list(Object *obj, void *opaque)
+{
+   return 0;
+}




This will not compile!!!
make: *** No rule to make target `stubs/pc_dimm.c', needed by
`stubs/pc_dimm.o'.  Stop.


On 24.02.2016 23:35, Michael S. Tsirkin wrote:

From: Vladimir Sementsov-Ogievskiy 

Like pc_dimm_build_list_sorted but not sorted - for cases where sorting
is not necessary. Add stubbed version too - for targets without
CONFIG_MEM_HOTPLUG.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
  include/hw/mem/pc-dimm.h|  3 +++
  hw/mem/pc-dimm.c| 15 +++
  stubs/qmp_pc_dimm_device_list.c |  8 
  stubs/Makefile.objs |  2 +-
  4 files changed, 19 insertions(+), 9 deletions(-)
  delete mode 100644 stubs/qmp_pc_dimm_device_list.c

diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 218dfb0..0f587a4 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -94,4 +94,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState 
*hpms,
   MemoryRegion *mr, uint64_t align, Error **errp);
  void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
 MemoryRegion *mr);
+
+int pc_dimm_build_list(Object *obj, void *opaque);
+
  #endif
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 835179e..09e99ce 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -267,6 +267,21 @@ static int pc_dimm_build_list_sorted(Object *obj, void 
*opaque)
  return 0;
  }
+int pc_dimm_build_list(Object *obj, void *opaque)
+{
+GSList **list = opaque;
+
+if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+DeviceState *dev = DEVICE(obj);
+if (dev->realized) { /* only realized DIMMs matter */
+*list = g_slist_prepend(*list, dev);
+}
+}
+
+object_child_foreach(obj, pc_dimm_build_list, opaque);
+return 0;
+}
+
  uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 uint64_t address_space_size,
 uint64_t *hint, uint64_t align, uint64_t size,
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
deleted file mode 100644
index def2115..000
--- a/stubs/qmp_pc_dimm_device_list.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu/osdep.h"
-#include "qom/object.h"
-#include "hw/mem/pc-dimm.h"
-
-int qmp_pc_dimm_device_list(Object *obj, void *opaque)
-{
-   return 0;
-}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index e922de9..fb247d4 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
  stub-obj-$(CONFIG_WIN32) += fd-register.o
  stub-obj-y += cpus.o
  stub-obj-y += kvm.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += pc_dimm.o
  stub-obj-y += target-monitor-defs.o
  stub-obj-y += target-get-monitor-def.o
  stub-obj-y += vhost.o


--
Best regards,
Vladimir



--
Best regards,
Vladimir




Re: [Qemu-devel] Making all TB invalidation asynchronous (MTTCG safe_work)?

2016-02-25 Thread Frederic Konrad
Hi Alex,

We decided in Seattle to make this flag per tb (eg move it to the tb
struct).



On 24/02/2016 18:30, Alex Bennée wrote:
> Hi,
>
> So I've been working on reducing MTTCG tb_lock contention and currently
> have a tb_lock around the following code (in my cpu_exec):
>
> /* Note: we do it here to avoid a gcc bug on Mac OS X when
>doing it in tb_find_slow */
> tb_lock();
> if (tcg_ctx.tb_ctx.tb_invalidated_flag) {
> /* as some TB could have been invalidated because
>of memory exceptions while generating the code, we
>must recompute the hash index here */
> next_tb = 0;
> tcg_ctx.tb_ctx.tb_invalidated_flag = 0;
> }
> /* see if we can patch the calling TB. When the TB
>spans two pages, we cannot safely do a direct
>jump. */
> if (next_tb != 0 && tb->page_addr[1] == -1
> && !qemu_loglevel_mask(CPU_LOG_TB_NOCHAIN)) {
> tb_add_jump((TranslationBlock *)(next_tb & ~TB_EXIT_MASK),
> next_tb & TB_EXIT_MASK, tb);
> }
> tb_unlock();
>
> And this started me down the rabbit hole of the meaning of
> tcg_ctx.tb_ctx.tb_invalidated_flag. So as far as I follow there are two
> places this is set:
>
>  * We've run out of translation memory and we are throwing everything
>away (tb_alloc == NULL)
>  * We've invalidated the physical pages of some TranslationBlocks
>
> The first case there is a slightly convoluted buffer overflow handing
> code (tb_gen_code):
>
> if (unlikely(!tb)) {
>  buffer_overflow:
> /* flush must be done */
> tb_flush_safe(cpu);
> /* Don't forget to invalidate previous TB info.  */
> tcg_ctx.tb_ctx.tb_invalidated_flag = 1;
> tb_unlock();
> cpu_loop_exit(cpu);
> }
>
> Which I'm sure could be more simply handled by just queuing the safe
> tb_flush and returning a NULL tb and letting the execution loop unwind
> before resetting the translation buffers.
>
> The second case has been partially asynced by Fred:
>
> /* invalidate one TB */
> void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
> {
> CPUState *cpu;
> PageDesc *p;
> unsigned int h;
> tb_page_addr_t phys_pc;
> struct CPUDiscardTBParams *params;
>
> assert_tb_lock(); /* added by me because of bellow */
>
> /* remove the TB from the hash list */
> phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
> h = tb_phys_hash_func(phys_pc);
> tb_hash_remove(&tcg_ctx.tb_ctx.tb_phys_hash[h], tb);
>
> /* remove the TB from the page list */
> if (tb->page_addr[0] != page_addr) {
> p = page_find(tb->page_addr[0] >> TARGET_PAGE_BITS);
> tb_page_remove(&p->first_tb, tb);
> invalidate_page_bitmap(p);
> }
> if (tb->page_addr[1] != -1 && tb->page_addr[1] != page_addr) {
> p = page_find(tb->page_addr[1] >> TARGET_PAGE_BITS);
> tb_page_remove(&p->first_tb, tb);
> invalidate_page_bitmap(p);
> }
>
> tcg_ctx.tb_ctx.tb_invalidated_flag = 1;
>
> CPU_FOREACH(cpu) {
> params = g_malloc(sizeof(struct CPUDiscardTBParams));
> params->cpu = cpu;
> params->tb = tb;
> async_run_on_cpu(cpu, cpu_discard_tb_from_jmp_cache, params);
> }
> async_run_safe_work_on_cpu(first_cpu, tb_invalidate_jmp_remove, tb);
>
> tcg_ctx.tb_ctx.tb_phys_invalidate_count++;
> }
>
> But I'm wondering why we can't defer all the page invalidation to safe
> work?
>
> I don't think it matters to the invalidating vCPU as it has to get
> to the end of its block anyway. For other vCPUs as there is no strict
> synchronisation can we not pretend what ever the operation was that
> triggered the invalidation happened just as the block ended?
>
> The final case I don't quite follow is the avoiding invalidation of
> tb_next in cpu_exec_nocache() if we have already caused a tb
> invalidation event:
>
> tb->orig_tb = tcg_ctx.tb_ctx.tb_invalidated_flag ? NULL : orig_tb;
>
> Which is later (in cpu_io_recompile):
>
> if (tb->cflags & CF_NOCACHE) {
> if (tb->orig_tb) {
> /* Invalidate original TB if this TB was generated in
>  * cpu_exec_nocache() */
> tb_phys_invalidate(tb->orig_tb, -1);
> }
> tb_free(tb);
> }
>
> My aim in all of this is to see if we can remove another flag from
> tb_ctx (one less thing to mutex access to) and make the code flow easier
> to follow. So remaining question:
>
> * Are there cases where not immediately invalidating the tb_page
>   structures would cause problems for the emulation?

Is that the same issue we might have with the memory barriers?

Fred
>
> Thanks in advance for any elucidation ;-)
>
> --
> Alex Bennée
>




Re: [Qemu-devel] [PATCH 3/3] replay: introduce block devices record/replay

2016-02-25 Thread Pavel Dovgalyuk
> From: Kevin Wolf [mailto:kw...@redhat.com]
> > > Coroutines aren't randomly assigned to threads, but threads actively
> > > enter coroutines. To my knowledge this happens only when starting a
> > > request (either vcpu or I/O thread; consistent per device) or by a
> > > callback when some event happens (only I/O thread). I can't see any
> > > non-determinism here.
> >
> > Behavior of coroutines looks strange for me.
> > Consider the code below (co_readv function of the replay driver).
> > In record mode it somehow changes the thread it assigned to.
> > Code in point A is executed in CPU thread and code in point B - in some 
> > other thread.
> > May this happen because this coroutine yields somewhere and its execution 
> > is restored
> > by aio_poll, which is called from iothread?
> > In this case event finishing callback cannot be executed deterministically
> > (always in CPU thread or always in IO thread).
> >
> > static int coroutine_fn blkreplay_co_readv(BlockDriverState *bs,
> > int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
> > {
> > BDRVBlkreplayState *s = bs->opaque;
> > uint32_t reqid = request_id++;
> > Request *req;
> > // A
> > bdrv_co_readv(bs->file->bs, sector_num, nb_sectors, qiov);
> >
> > if (replay_mode == REPLAY_MODE_RECORD) {
> > replay_save_block_event(reqid);
> > } else {
> > assert(replay_mode == REPLAY_MODE_PLAY);
> > if (reqid == current_request) {
> > current_finished = true;
> > } else {
> > req = block_request_insert(reqid, bs, qemu_coroutine_self());
> > qemu_coroutine_yield();
> > block_request_remove(req);
> > }
> > }
> > // B
> > return 0;
> > }
> 
> Yes, I guess this can happen. As I described above, the coroutine can be
> entered from a vcpu thread initially. After yielding for the first time,
> it is resumed from the I/O thread. So if there are paths where the
> coroutine never yields, the coroutine completes in the original vcpu
> thread. (It's not the common case that bdrv_co_readv() doesn't yield,
> but it happens e.g. with unallocated sectors in qcow2.)
> 
> If this is a problem for you, you need to force the coroutine into the
> I/O thread. You can do that by scheduling a BH, then yield, and then let
> the BH reenter the coroutine.

Thanks, this approach seems to work. I got rid of replay_run_block_event,
because BH basically does the same job.

There is one problem with flush event - callbacks for flush are called for
all layers and I couldn't synchronize them correctly yet.
I'll probably have to add new callback to block driver, which handles
flush request for the whole stack of the drivers.

Pavel Dovgalyuk




Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 11:55:56AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> On 25.02.2016 11:39, Michael S. Tsirkin wrote:
> >On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> >>Stop!
> >It builds fine here. Did you check out my tree?
> 
> anyway, this file should be here, as it is added into Makefile:
> 
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
>  stub-obj-$(CONFIG_WIN32) += fd-register.o
>  stub-obj-y += cpus.o
>  stub-obj-y += kvm.o
> -stub-obj-y += qmp_pc_dimm_device_list.o
> +stub-obj-y += pc_dimm.o
>  stub-obj-y += target-monitor-defs.o
>  stub-obj-y += target-get-monitor-def.o
>  stub-obj-y += vhost.o
> 

Hmm that's right.
Thanks!
Looks like it was picking up an old object in the filesystem :(
I'll respin - for now, does everything work for you if you drop
this line from the makefile?

> ===
> git clone git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tmp
> cd tmp/
> git checkout for_upstream
> ./configure  --target-list=x86_64-softmmu
> make -j9
> > make: *** No rule to make target `stubs/pc_dimm.o', needed by
> `libqemustub.a'.  Stop



[Qemu-devel] [PULL v2 00/23] vhost, virtio, pci, pc

2016-02-25 Thread Michael S. Tsirkin
Changes from v1:
drop a missing dependency from the makefile.

The following changes since commit 8eb779e4223a18db9838a49ece1bc72cfdfb7761:

  Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging 
(2016-02-22 16:55:41 +)

are available in the git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to 9f7247650dce2e7af831a63518299692dd5fa208:

  q35: No need to check gigabyte_align (2016-02-25 11:13:18 +0200)


vhost, virtio, pci, pc

Fixes all over the place.
virtio dataplane migration support.
Old q35 machine types removed.

Signed-off-by: Michael S. Tsirkin 


Cao jin (2):
  pci core: function pci_host_bus_register() cleanup
  pci core: function pci_bus_init() cleanup

Eduardo Habkost (5):
  q35: Remove old machine versions
  machine: Remove no_tco field
  ich9: Remove enable_tco arguments from init functions
  q35: Remove unused q35-acpi-dsdt.aml file
  q35: No need to check gigabyte_align

Michael S. Tsirkin (3):
  bios-linker-loader: document+validate input
  vhost-user: don't merge regions with different fds
  tests/vhost-user-bridge: fix build on 32 bit systems

Paolo Bonzini (8):
  block-migration: acquire AioContext as necessary
  vring: make vring_enable_notification return void
  virtio: add AioContext-specific function for host notifiers
  virtio: export vring_notify as virtio_should_notify
  virtio-blk: fix "disabled data plane" mode
  virtio-blk: do not use vring in dataplane
  virtio-scsi: do not use vring in dataplane
  vring: remove

Vladimir Sementsov-Ogievskiy (5):
  move get_current_ram_size to virtio-balloon.c
  pc-dimm: rename pc_dimm_built_list()
  pc-dimm: add pc_dimm_build_list()
  virtio-balloon: rewrite get_current_ram_size()
  balloon: Use only 'pc-dimm' type dimm for ballooning

 Makefile  |   2 +-
 hw/block/dataplane/virtio-blk.h   |   1 +
 include/exec/cpu-common.h |   1 -
 include/hw/acpi/bios-linker-loader.h  |   2 +-
 include/hw/acpi/ich9.h|   1 -
 include/hw/boards.h   |   1 -
 include/hw/i386/ich9.h|   2 +-
 include/hw/mem/pc-dimm.h  |   3 +
 include/hw/virtio/dataplane/vring-accessors.h |  75 
 include/hw/virtio/dataplane/vring.h   |  51 ---
 include/hw/virtio/vhost-backend.h |   4 +
 include/hw/virtio/virtio-blk.h|   4 +-
 include/hw/virtio/virtio-scsi.h   |  21 +-
 include/hw/virtio/virtio.h|   3 +
 hw/acpi/aml-build.c   |   2 +-
 hw/acpi/bios-linker-loader.c  |  91 -
 hw/acpi/ich9.c|   8 +-
 hw/arm/virt-acpi-build.c  |   3 +-
 hw/block/dataplane/virtio-blk.c   | 130 +-
 hw/block/virtio-blk.c |  51 +--
 hw/i386/acpi-build.c  |   3 +-
 hw/i386/pc_q35.c  | 176 +
 hw/isa/lpc_ich9.c |   4 +-
 hw/mem/pc-dimm.c  |  47 +--
 hw/pci/pci.c  |  13 +-
 hw/scsi/virtio-scsi-dataplane.c   | 196 ++---
 hw/scsi/virtio-scsi.c |  52 +--
 hw/virtio/dataplane/vring.c   | 549 --
 hw/virtio/vhost-user.c|  20 +
 hw/virtio/vhost.c |   7 +
 hw/virtio/virtio-balloon.c|  18 +
 hw/virtio/virtio.c|  20 +-
 migration/block.c |  65 ++-
 stubs/qmp_pc_dimm_device_list.c   |  13 -
 tests/vhost-user-bridge.c |  14 +-
 hw/virtio/Makefile.objs   |   1 -
 hw/virtio/dataplane/Makefile.objs |   1 -
 pc-bios/q35-acpi-dsdt.aml | Bin 7344 -> 0 bytes
 stubs/Makefile.objs   |   1 -
 trace-events  |   3 -
 40 files changed, 320 insertions(+), 1339 deletions(-)
 delete mode 100644 include/hw/virtio/dataplane/vring-accessors.h
 delete mode 100644 include/hw/virtio/dataplane/vring.h
 delete mode 100644 hw/virtio/dataplane/vring.c
 delete mode 100644 stubs/qmp_pc_dimm_device_list.c
 delete mode 100644 hw/virtio/dataplane/Makefile.objs
 delete mode 100644 pc-bios/q35-acpi-dsdt.aml




[Qemu-devel] [PULL v2 01/23] bios-linker-loader: document+validate input

2016-02-25 Thread Michael S. Tsirkin
While guest/host ABI is documented in hw/acpi/bios-linker-loader.c,
the API was left undocumented.

This adds documentation for all API functions.

Additionally, input is validated to make sure all
pointers fall within range of provided files.

To allow this validation for checksum commands,
bios_linker_loader_add_checksum is changed to accept GArray * in place
of void *.

Reported-by: Igor Mammedov 
Signed-off-by: Michael S. Tsirkin 
---
 include/hw/acpi/bios-linker-loader.h |  2 +-
 hw/acpi/aml-build.c  |  2 +-
 hw/acpi/bios-linker-loader.c | 91 ++--
 hw/arm/virt-acpi-build.c |  3 +-
 hw/i386/acpi-build.c |  3 +-
 5 files changed, 92 insertions(+), 9 deletions(-)

diff --git a/include/hw/acpi/bios-linker-loader.h 
b/include/hw/acpi/bios-linker-loader.h
index 498c0af..e54b6b4 100644
--- a/include/hw/acpi/bios-linker-loader.h
+++ b/include/hw/acpi/bios-linker-loader.h
@@ -13,7 +13,7 @@ void bios_linker_loader_alloc(GArray *linker,
   bool alloc_fseg);
 
 void bios_linker_loader_add_checksum(GArray *linker, const char *file,
- void *table,
+ GArray *table,
  void *start, unsigned size,
  uint8_t *checksum);
 
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 603068b..6675535 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -1451,7 +1451,7 @@ build_header(GArray *linker, GArray *table_data,
 h->checksum = 0;
 /* Checksum to be filled in by Guest linker */
 bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE,
-table_data->data, h, len, &h->checksum);
+table_data, h, len, &h->checksum);
 }
 
 void *acpi_data_push(GArray *table_data, unsigned size)
diff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c
index e04d60a..ace9abb 100644
--- a/hw/acpi/bios-linker-loader.c
+++ b/hw/acpi/bios-linker-loader.c
@@ -25,6 +25,13 @@
 
 #include "qemu/bswap.h"
 
+/*
+ * Linker/loader is a paravirtualized interface that passes commands to guest.
+ * The commands can be used to request guest to
+ * - allocate memory chunks and initialize them from QEMU FW CFG files
+ * - link allocated chunks by storing pointer to one chunk into another
+ * - calculate ACPI checksum of part of the chunk and store into same chunk
+ */
 #define BIOS_LINKER_LOADER_FILESZ FW_CFG_MAX_FILE_PATH
 
 struct BiosLinkerLoaderEntry {
@@ -88,6 +95,12 @@ enum {
 BIOS_LINKER_LOADER_ALLOC_ZONE_FSEG = 0x2,
 };
 
+/*
+ * bios_linker_loader_init: allocate a new linker file blob array.
+ *
+ * After initialization, linker commands can be added, and will
+ * be stored in the array.
+ */
 GArray *bios_linker_loader_init(void)
 {
 return g_array_new(false, true /* clear */, 1);
@@ -99,6 +112,16 @@ void *bios_linker_loader_cleanup(GArray *linker)
 return g_array_free(linker, false);
 }
 
+/*
+ * bios_linker_loader_alloc: ask guest to load file into guest memory.
+ *
+ * @linker: linker file blob array
+ * @file: file to be loaded
+ * @alloc_align: required minimal alignment in bytes. Must be a power of 2.
+ * @alloc_fseg: request allocation in FSEG zone (useful for the RSDP ACPI 
table)
+ *
+ * Note: this command must precede any other linker command using this file.
+ */
 void bios_linker_loader_alloc(GArray *linker,
   const char *file,
   uint32_t alloc_align,
@@ -106,6 +129,8 @@ void bios_linker_loader_alloc(GArray *linker,
 {
 BiosLinkerLoaderEntry entry;
 
+assert(!(alloc_align & (alloc_align - 1)));
+
 memset(&entry, 0, sizeof entry);
 strncpy(entry.alloc.file, file, sizeof entry.alloc.file - 1);
 entry.command = cpu_to_le32(BIOS_LINKER_LOADER_COMMAND_ALLOCATE);
@@ -118,23 +143,77 @@ void bios_linker_loader_alloc(GArray *linker,
 g_array_prepend_vals(linker, &entry, sizeof entry);
 }
 
+/*
+ * bios_linker_loader_add_checksum: ask guest to add checksum of file data
+ * into (same) file at the specified pointer.
+ *
+ * Checksum calculation simply sums -X for each byte X in the range
+ * using 8-bit math (i.e. ACPI checksum).
+ *
+ * @linker: linker file blob array
+ * @file: file that includes the checksum to be calculated
+ *and the data to be checksummed
+ * @table: @file blob contents
+ * @start, @size: range of data to checksum
+ * @checksum: location of the checksum to be patched within file blob
+ *
+ * Notes:
+ * - checksum byte initial value must have been pushed into @table
+ *   and reside at address @checksum.
+ * - @size bytes must have been pushed into @table and reside at address
+ *   @start.
+ * - Guest calculates checksum of specified range of data, result is added to
+ *   initial value at @checksum into copy of @file in Guest memory.
+ * - Range might include t

[Qemu-devel] [PULL v2 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Michael S. Tsirkin
From: Vladimir Sementsov-Ogievskiy 

Like pc_dimm_build_list_sorted but not sorted - for cases where sorting
is not necessary. Add stubbed version too - for targets without
CONFIG_MEM_HOTPLUG.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 include/hw/mem/pc-dimm.h|  3 +++
 hw/mem/pc-dimm.c| 15 +++
 stubs/qmp_pc_dimm_device_list.c |  8 
 stubs/Makefile.objs |  1 -
 4 files changed, 18 insertions(+), 9 deletions(-)
 delete mode 100644 stubs/qmp_pc_dimm_device_list.c

diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 218dfb0..0f587a4 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -94,4 +94,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState 
*hpms,
  MemoryRegion *mr, uint64_t align, Error **errp);
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr);
+
+int pc_dimm_build_list(Object *obj, void *opaque);
+
 #endif
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 835179e..09e99ce 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -267,6 +267,21 @@ static int pc_dimm_build_list_sorted(Object *obj, void 
*opaque)
 return 0;
 }
 
+int pc_dimm_build_list(Object *obj, void *opaque)
+{
+GSList **list = opaque;
+
+if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+DeviceState *dev = DEVICE(obj);
+if (dev->realized) { /* only realized DIMMs matter */
+*list = g_slist_prepend(*list, dev);
+}
+}
+
+object_child_foreach(obj, pc_dimm_build_list, opaque);
+return 0;
+}
+
 uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
uint64_t address_space_size,
uint64_t *hint, uint64_t align, uint64_t size,
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
deleted file mode 100644
index def2115..000
--- a/stubs/qmp_pc_dimm_device_list.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu/osdep.h"
-#include "qom/object.h"
-#include "hw/mem/pc-dimm.h"
-
-int qmp_pc_dimm_device_list(Object *obj, void *opaque)
-{
-   return 0;
-}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index e922de9..bccd445 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -35,7 +35,6 @@ stub-obj-y += vmstate.o
 stub-obj-$(CONFIG_WIN32) += fd-register.o
 stub-obj-y += cpus.o
 stub-obj-y += kvm.o
-stub-obj-y += qmp_pc_dimm_device_list.o
 stub-obj-y += target-monitor-defs.o
 stub-obj-y += target-get-monitor-def.o
 stub-obj-y += vhost.o
-- 
MST




[Qemu-devel] [PULL v2 04/23] pc-dimm: rename pc_dimm_built_list()

2016-02-25 Thread Michael S. Tsirkin
From: Vladimir Sementsov-Ogievskiy 

s/pc_dimm_built_list/pc_dimm_build_list_sorted

- need for add pc_dimm_build_list (not sorted) in the next patch
- fix typo (built -> build)

Signed-off-by: Vladimir Sementsov-Ogievskiy 

Reviewed-by: Igor Mammedov 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/mem/pc-dimm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 650f0f8..835179e 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -252,7 +252,7 @@ static gint pc_dimm_addr_sort(gconstpointer a, 
gconstpointer b)
 return 0;
 }
 
-static int pc_dimm_built_list(Object *obj, void *opaque)
+static int pc_dimm_build_list_sorted(Object *obj, void *opaque)
 {
 GSList **list = opaque;
 
@@ -263,7 +263,7 @@ static int pc_dimm_built_list(Object *obj, void *opaque)
 }
 }
 
-object_child_foreach(obj, pc_dimm_built_list, opaque);
+object_child_foreach(obj, pc_dimm_build_list_sorted, opaque);
 return 0;
 }
 
@@ -297,7 +297,7 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 }
 
 assert(address_space_end > address_space_start);
-object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);
+object_child_foreach(qdev_get_machine(), pc_dimm_build_list_sorted, &list);
 
 if (hint) {
 new_addr = *hint;
-- 
MST




[Qemu-devel] [PULL v2 03/23] move get_current_ram_size to virtio-balloon.c

2016-02-25 Thread Michael S. Tsirkin
From: Vladimir Sementsov-Ogievskiy 

get_current_ram_size() is used only in virtio-balloon.c
This patch moves it into virtio-balloon and make it static, to allow
some balloon-specific tuning.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Denis V. Lunev 
Reviewed-by: Eric Blake 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 include/exec/cpu-common.h   |  1 -
 hw/mem/pc-dimm.c| 26 --
 hw/virtio/virtio-balloon.c  | 26 ++
 stubs/qmp_pc_dimm_device_list.c |  5 -
 4 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 85aa403..a0ad2ac 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -54,7 +54,6 @@ typedef uintptr_t ram_addr_t;
 #endif
 
 extern ram_addr_t ram_size;
-ram_addr_t get_current_ram_size(void);
 
 /* memory API */
 
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 1aa12c6..650f0f8 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -192,32 +192,6 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 return 0;
 }
 
-ram_addr_t get_current_ram_size(void)
-{
-MemoryDeviceInfoList *info_list = NULL;
-MemoryDeviceInfoList **prev = &info_list;
-MemoryDeviceInfoList *info;
-ram_addr_t size = ram_size;
-
-qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
-for (info = info_list; info; info = info->next) {
-MemoryDeviceInfo *value = info->value;
-
-if (value) {
-switch (value->type) {
-case MEMORY_DEVICE_INFO_KIND_DIMM:
-size += value->u.dimm->size;
-break;
-default:
-break;
-}
-}
-}
-qapi_free_MemoryDeviceInfoList(info_list);
-
-return size;
-}
-
 static int pc_dimm_slot2bitmap(Object *obj, void *opaque)
 {
 unsigned long *bitmap = opaque;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index a382f43..d6d7e96 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -305,6 +305,32 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, 
uint8_t *config_data)
 memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
 }
 
+static ram_addr_t get_current_ram_size(void)
+{
+MemoryDeviceInfoList *info_list = NULL;
+MemoryDeviceInfoList **prev = &info_list;
+MemoryDeviceInfoList *info;
+ram_addr_t size = ram_size;
+
+qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
+for (info = info_list; info; info = info->next) {
+MemoryDeviceInfo *value = info->value;
+
+if (value) {
+switch (value->type) {
+case MEMORY_DEVICE_INFO_KIND_DIMM:
+size += value->u.dimm->size;
+break;
+default:
+break;
+}
+}
+}
+qapi_free_MemoryDeviceInfoList(info_list);
+
+return size;
+}
+
 static void virtio_balloon_set_config(VirtIODevice *vdev,
   const uint8_t *config_data)
 {
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
index a4af7fe..def2115 100644
--- a/stubs/qmp_pc_dimm_device_list.c
+++ b/stubs/qmp_pc_dimm_device_list.c
@@ -6,8 +6,3 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
 {
return 0;
 }
-
-ram_addr_t get_current_ram_size(void)
-{
-return ram_size;
-}
-- 
MST




[Qemu-devel] [PULL v2 02/23] vhost-user: don't merge regions with different fds

2016-02-25 Thread Michael S. Tsirkin
vhost currently merges regions with contiguious virtual and physical
addresses.  This breaks for vhost-user since that also needs fds to
match.

Add a vhost_ops entry to compare the fds for vhost-user only.

Cc: qemu-sta...@nongnu.org
Cc: Victor Kaplansky 
Signed-off-by: Michael S. Tsirkin 
---
 include/hw/virtio/vhost-backend.h |  4 
 hw/virtio/vhost-user.c| 20 
 hw/virtio/vhost.c |  7 +++
 3 files changed, 31 insertions(+)

diff --git a/include/hw/virtio/vhost-backend.h 
b/include/hw/virtio/vhost-backend.h
index c59cc81..a6e5c97 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -70,6 +70,9 @@ typedef int (*vhost_set_vring_enable_op)(struct vhost_dev 
*dev,
 typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev);
 typedef int (*vhost_migration_done_op)(struct vhost_dev *dev,
char *mac_addr);
+typedef bool (*vhost_backend_can_merge_op)(struct vhost_dev *dev,
+   uint64_t start1, uint64_t size1,
+   uint64_t start2, uint64_t size2);
 
 typedef struct VhostOps {
 VhostBackendType backend_type;
@@ -97,6 +100,7 @@ typedef struct VhostOps {
 vhost_set_vring_enable_op vhost_set_vring_enable;
 vhost_requires_shm_log_op vhost_requires_shm_log;
 vhost_migration_done_op vhost_migration_done;
+vhost_backend_can_merge_op vhost_backend_can_merge;
 } VhostOps;
 
 extern const VhostOps user_ops;
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 7fde137..7ed3dd9 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -611,6 +611,25 @@ static int vhost_user_migration_done(struct vhost_dev 
*dev, char* mac_addr)
 return -1;
 }
 
+static bool vhost_user_can_merge(struct vhost_dev *dev,
+ uint64_t start1, uint64_t size1,
+ uint64_t start2, uint64_t size2)
+{
+ram_addr_t ram_addr;
+int mfd, rfd;
+MemoryRegion *mr;
+
+mr = qemu_ram_addr_from_host((void *)(uintptr_t)start1, &ram_addr);
+assert(mr);
+mfd = qemu_get_ram_fd(ram_addr);
+
+mr = qemu_ram_addr_from_host((void *)(uintptr_t)start2, &ram_addr);
+assert(mr);
+rfd = qemu_get_ram_fd(ram_addr);
+
+return mfd == rfd;
+}
+
 const VhostOps user_ops = {
 .backend_type = VHOST_BACKEND_TYPE_USER,
 .vhost_backend_init = vhost_user_init,
@@ -633,4 +652,5 @@ const VhostOps user_ops = {
 .vhost_set_vring_enable = vhost_user_set_vring_enable,
 .vhost_requires_shm_log = vhost_user_requires_shm_log,
 .vhost_migration_done = vhost_user_migration_done,
+.vhost_backend_can_merge = vhost_user_can_merge,
 };
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 72d0c9e..392d848 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -260,6 +260,13 @@ static void vhost_dev_assign_memory(struct vhost_dev *dev,
 continue;
 }
 
+if (dev->vhost_ops->vhost_backend_can_merge &&
+!dev->vhost_ops->vhost_backend_can_merge(dev, uaddr, size,
+ reg->userspace_addr,
+ reg->memory_size)) {
+continue;
+}
+
 if (merged) {
 --to;
 assert(to >= 0);
-- 
MST




[Qemu-devel] [PULL v2 12/23] virtio: add AioContext-specific function for host notifiers

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

This is used to register ioeventfd with a dataplane thread.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/virtio.h |  2 ++
 hw/virtio/virtio.c | 16 
 2 files changed, 18 insertions(+)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index c38a2fe..3ecdb20 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -249,6 +249,8 @@ void virtio_queue_set_guest_notifier_fd_handler(VirtQueue 
*vq, bool assign,
 EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq);
 void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler);
+void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
+bool assign, bool set_handler);
 void virtio_queue_notify_vq(VirtQueue *vq);
 void virtio_irq(VirtQueue *vq);
 VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index e365960..f419e7c 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1786,6 +1786,22 @@ static void 
virtio_queue_host_notifier_read(EventNotifier *n)
 }
 }
 
+void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
+bool assign, bool set_handler)
+{
+if (assign && set_handler) {
+aio_set_event_notifier(ctx, &vq->host_notifier, true,
+   virtio_queue_host_notifier_read);
+} else {
+aio_set_event_notifier(ctx, &vq->host_notifier, true, NULL);
+}
+if (!assign) {
+/* Test and clear notifier before after disabling event,
+ * in case poll callback didn't have time to run. */
+virtio_queue_host_notifier_read(&vq->host_notifier);
+}
+}
+
 void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign,
bool set_handler)
 {
-- 
MST




[Qemu-devel] [PULL v2 10/23] block-migration: acquire AioContext as necessary

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

This is needed because dataplane will run during block migration as well.

The block device migration code is quite liberal in taking the iothread
mutex.  For simplicity, keep it the same way, even though one could
actually choose between the BQL (for regular BlockDriverStates) and
the AioContext (for dataplane BlockDriverStates).  When the block layer
is made fully thread safe, aio_context_acquire shall go away altogether.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Acked-by: Stefan Hajnoczi 
Reviewed-by: Fam Zheng 
---
 migration/block.c | 65 ---
 1 file changed, 52 insertions(+), 13 deletions(-)

diff --git a/migration/block.c b/migration/block.c
index 3a8330a..72883d7 100644
--- a/migration/block.c
+++ b/migration/block.c
@@ -54,17 +54,25 @@ typedef struct BlkMigDevState {
 int shared_base;
 int64_t total_sectors;
 QSIMPLEQ_ENTRY(BlkMigDevState) entry;
+Error *blocker;
 
 /* Only used by migration thread.  Does not need a lock.  */
 int bulk_completed;
 int64_t cur_sector;
 int64_t cur_dirty;
 
-/* Protected by block migration lock.  */
+/* Data in the aio_bitmap is protected by block migration lock.
+ * Allocation and free happen during setup and cleanup respectively.
+ */
 unsigned long *aio_bitmap;
+
+/* Protected by block migration lock.  */
 int64_t completed_sectors;
+
+/* During migration this is protected by iothread lock / AioContext.
+ * Allocation and free happen during setup and cleanup respectively.
+ */
 BdrvDirtyBitmap *dirty_bitmap;
-Error *blocker;
 } BlkMigDevState;
 
 typedef struct BlkMigBlock {
@@ -100,7 +108,7 @@ typedef struct BlkMigState {
 int prev_progress;
 int bulk_completed;
 
-/* Lock must be taken _inside_ the iothread lock.  */
+/* Lock must be taken _inside_ the iothread lock and any AioContexts.  */
 QemuMutex lock;
 } BlkMigState;
 
@@ -264,11 +272,13 @@ static int mig_save_device_bulk(QEMUFile *f, 
BlkMigDevState *bmds)
 
 if (bmds->shared_base) {
 qemu_mutex_lock_iothread();
+aio_context_acquire(bdrv_get_aio_context(bs));
 while (cur_sector < total_sectors &&
!bdrv_is_allocated(bs, cur_sector, MAX_IS_ALLOCATED_SEARCH,
   &nr_sectors)) {
 cur_sector += nr_sectors;
 }
+aio_context_release(bdrv_get_aio_context(bs));
 qemu_mutex_unlock_iothread();
 }
 
@@ -302,11 +312,21 @@ static int mig_save_device_bulk(QEMUFile *f, 
BlkMigDevState *bmds)
 block_mig_state.submitted++;
 blk_mig_unlock();
 
+/* We do not know if bs is under the main thread (and thus does
+ * not acquire the AioContext when doing AIO) or rather under
+ * dataplane.  Thus acquire both the iothread mutex and the
+ * AioContext.
+ *
+ * This is ugly and will disappear when we make bdrv_* thread-safe,
+ * without the need to acquire the AioContext.
+ */
 qemu_mutex_lock_iothread();
+aio_context_acquire(bdrv_get_aio_context(bmds->bs));
 blk->aiocb = bdrv_aio_readv(bs, cur_sector, &blk->qiov,
 nr_sectors, blk_mig_read_cb, blk);
 
 bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector, nr_sectors);
+aio_context_release(bdrv_get_aio_context(bmds->bs));
 qemu_mutex_unlock_iothread();
 
 bmds->cur_sector = cur_sector + nr_sectors;
@@ -321,8 +341,10 @@ static int set_dirty_tracking(void)
 int ret;
 
 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
+aio_context_acquire(bdrv_get_aio_context(bmds->bs));
 bmds->dirty_bitmap = bdrv_create_dirty_bitmap(bmds->bs, BLOCK_SIZE,
   NULL, NULL);
+aio_context_release(bdrv_get_aio_context(bmds->bs));
 if (!bmds->dirty_bitmap) {
 ret = -errno;
 goto fail;
@@ -333,18 +355,24 @@ static int set_dirty_tracking(void)
 fail:
 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
 if (bmds->dirty_bitmap) {
+aio_context_acquire(bdrv_get_aio_context(bmds->bs));
 bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);
+aio_context_release(bdrv_get_aio_context(bmds->bs));
 }
 }
 return ret;
 }
 
+/* Called with iothread lock taken.  */
+
 static void unset_dirty_tracking(void)
 {
 BlkMigDevState *bmds;
 
 QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
+aio_context_acquire(bdrv_get_aio_context(bmds->bs));
 bdrv_release_dirty_bitmap(bmds->bs, bmds->dirty_bitmap);
+aio_context_release(bdrv_get_aio_context(bmds->bs));
 }
 }
 
@@ -444,7 +472,7 @@ static void blk_mig_reset_dirty_cursor(void)
 }
 }
 
-/* Called with iothread lock taken.  */
+/* Called with iothread lock and AioContext taken.  */
 
 static int mig

[Qemu-devel] [PULL v2 06/23] virtio-balloon: rewrite get_current_ram_size()

2016-02-25 Thread Michael S. Tsirkin
From: Vladimir Sementsov-Ogievskiy 

Use pc_dimm_built_list() instead of qmp_pc_dimm_device_list()

Actually, Qapi is not related to this internal helper.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/virtio/virtio-balloon.c | 23 ++-
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index d6d7e96..388e873 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -307,26 +307,15 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, 
uint8_t *config_data)
 
 static ram_addr_t get_current_ram_size(void)
 {
-MemoryDeviceInfoList *info_list = NULL;
-MemoryDeviceInfoList **prev = &info_list;
-MemoryDeviceInfoList *info;
+GSList *list = NULL, *item;
 ram_addr_t size = ram_size;
 
-qmp_pc_dimm_device_list(qdev_get_machine(), &prev);
-for (info = info_list; info; info = info->next) {
-MemoryDeviceInfo *value = info->value;
-
-if (value) {
-switch (value->type) {
-case MEMORY_DEVICE_INFO_KIND_DIMM:
-size += value->u.dimm->size;
-break;
-default:
-break;
-}
-}
+pc_dimm_build_list(qdev_get_machine(), &list);
+for (item = list; item; item = g_slist_next(item)) {
+Object *obj = OBJECT(item->data);
+size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
 }
-qapi_free_MemoryDeviceInfoList(info_list);
+g_slist_free(list);
 
 return size;
 }
-- 
MST




[Qemu-devel] [PULL v2 14/23] virtio-blk: fix "disabled data plane" mode

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

In disabled mode, virtio-blk dataplane seems to be enabled, but flow
actually goes through the normal virtio path.  This patch simplifies a bit
the handling of disabled mode.  In disabled mode, virtio_blk_handle_output
might be called even if s->dataplane is not NULL.

This is a bit tricky, because the current check for s->dataplane will
always trigger, causing a continuous stream of calls to
virtio_blk_data_plane_start.  Unfortunately, these calls will not
do anything.  To fix this, set the "started" flag even in disabled
mode, and skip virtio_blk_data_plane_start if the started flag is true.
The resulting changes also prepare the code for the next patch, were
virtio-blk dataplane will reuse the same virtio_blk_handle_output function
as "regular" virtio-blk.

Because struct VirtIOBlockDataPlane is opaque in virtio-blk.c, we have
to move s->dataplane->started inside struct VirtIOBlock.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Cornelia Huck 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/virtio-blk.h  |  1 +
 hw/block/dataplane/virtio-blk.c | 21 +
 hw/block/virtio-blk.c   |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 199bb0e..781969d 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -56,6 +56,7 @@ typedef struct VirtIOBlock {
 /* Function to push to vq and notify guest */
 void (*complete_request)(struct VirtIOBlockReq *req, unsigned char status);
 Notifier migration_state_notifier;
+bool dataplane_started;
 struct VirtIOBlockDataPlane *dataplane;
 } VirtIOBlock;
 
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 03b81bc..cc521c1 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -28,7 +28,6 @@
 #include "qom/object_interfaces.h"
 
 struct VirtIOBlockDataPlane {
-bool started;
 bool starting;
 bool stopping;
 bool disabled;
@@ -264,11 +263,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
 VirtQueue *vq;
 int r;
 
-if (s->started || s->disabled) {
-return;
-}
-
-if (s->starting) {
+if (vblk->dataplane_started || s->starting) {
 return;
 }
 
@@ -300,7 +295,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
 vblk->complete_request = complete_request_vring;
 
 s->starting = false;
-s->started = true;
+vblk->dataplane_started = true;
 trace_virtio_blk_data_plane_start(s);
 
 blk_set_aio_context(s->conf->conf.blk, s->ctx);
@@ -319,9 +314,10 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s)
 k->set_guest_notifiers(qbus->parent, 1, false);
   fail_guest_notifiers:
 vring_teardown(&s->vring, s->vdev, 0);
-s->disabled = true;
   fail_vring:
+s->disabled = true;
 s->starting = false;
+vblk->dataplane_started = true;
 }
 
 /* Context: QEMU global mutex held */
@@ -331,13 +327,14 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
 VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
 VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
 
+if (!vblk->dataplane_started || s->stopping) {
+return;
+}
 
 /* Better luck next time. */
 if (s->disabled) {
 s->disabled = false;
-return;
-}
-if (!s->started || s->stopping) {
+vblk->dataplane_started = false;
 return;
 }
 s->stopping = true;
@@ -364,6 +361,6 @@ void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s)
 /* Clean up guest notifier (irq) */
 k->set_guest_notifiers(qbus->parent, 1, false);
 
-s->started = false;
+vblk->dataplane_started = false;
 s->stopping = false;
 }
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index c427698..e04c8f5 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -589,7 +589,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, 
VirtQueue *vq)
 /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
  * dataplane here instead of waiting for .set_status().
  */
-if (s->dataplane) {
+if (s->dataplane && !s->dataplane_started) {
 virtio_blk_data_plane_start(s->dataplane);
 return;
 }
-- 
MST




[Qemu-devel] [PULL v2 08/23] pci core: function pci_host_bus_register() cleanup

2016-02-25 Thread Michael S. Tsirkin
From: Cao jin 

remove unused param, and rename the other to a meaningful one.

Signed-off-by: Cao jin 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Eduardo Habkost 
---
 hw/pci/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b282120..b071361 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -278,9 +278,9 @@ static void pcibus_reset(BusState *qbus)
 }
 }
 
-static void pci_host_bus_register(PCIBus *bus, DeviceState *parent)
+static void pci_host_bus_register(DeviceState *host)
 {
-PCIHostState *host_bridge = PCI_HOST_BRIDGE(parent);
+PCIHostState *host_bridge = PCI_HOST_BRIDGE(host);
 
 QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
 }
@@ -344,7 +344,7 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
 /* host bridge */
 QLIST_INIT(&bus->child);
 
-pci_host_bus_register(bus, parent);
+pci_host_bus_register(parent);
 }
 
 bool pci_bus_is_express(PCIBus *bus)
-- 
MST




[Qemu-devel] [PULL v2 13/23] virtio: export vring_notify as virtio_should_notify

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

Virtio dataplane needs to trigger the irq manually through the
guest notifier.  Export virtio_should_notify so that it can be
used around event_notifier_set.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Acked-by: Cornelia Huck 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/virtio.h | 1 +
 hw/virtio/virtio.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 3ecdb20..2b5b248 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -163,6 +163,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int 
*in_bytes,
unsigned int *out_bytes,
unsigned max_in_bytes, unsigned max_out_bytes);
 
+bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq);
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
 
 void virtio_save(VirtIODevice *vdev, QEMUFile *f);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index f419e7c..08275a9 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1162,7 +1162,7 @@ void virtio_irq(VirtQueue *vq)
 virtio_notify_vector(vq->vdev, vq->vector);
 }
 
-static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq)
+bool virtio_should_notify(VirtIODevice *vdev, VirtQueue *vq)
 {
 uint16_t old, new;
 bool v;
@@ -1187,7 +1187,7 @@ static bool vring_notify(VirtIODevice *vdev, VirtQueue 
*vq)
 
 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
 {
-if (!vring_notify(vdev, vq)) {
+if (!virtio_should_notify(vdev, vq)) {
 return;
 }
 
-- 
MST




[Qemu-devel] [PULL v2 22/23] q35: Remove unused q35-acpi-dsdt.aml file

2016-02-25 Thread Michael S. Tsirkin
From: Eduardo Habkost 

The file was used only by older machine-types, and it is not
needed anymore.

Signed-off-by: Eduardo Habkost 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Markus Armbruster 
Reviewed-by: Igor Mammedov 
---
 Makefile  |   2 +-
 hw/i386/pc_q35.c  |   4 
 pc-bios/q35-acpi-dsdt.aml | Bin 7344 -> 0 bytes
 3 files changed, 1 insertion(+), 5 deletions(-)
 delete mode 100644 pc-bios/q35-acpi-dsdt.aml

diff --git a/Makefile b/Makefile
index 16db398..70e3ebc 100644
--- a/Makefile
+++ b/Makefile
@@ -391,7 +391,7 @@ bepocz
 ifdef INSTALL_BLOBS
 BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
 vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
-acpi-dsdt.aml q35-acpi-dsdt.aml \
+acpi-dsdt.aml \
 ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin 
QEMU,cgthree.bin \
 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
 pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 06a5f95..da28d77 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -116,10 +116,6 @@ static void pc_q35_init(MachineState *machine)
 }
 
 pc_cpus_init(pcms);
-if (!pcmc->has_acpi_build) {
-/* only machine types 1.7 & older need this */
-pc_acpi_init("q35-acpi-dsdt.aml");
-}
 
 kvmclock_create();
 
diff --git a/pc-bios/q35-acpi-dsdt.aml b/pc-bios/q35-acpi-dsdt.aml
deleted file mode 100644
index 
d71b3a328ced5ce2cb16d153cfa7cda0aca966a4..
GIT binary patch
literal 0
HcmV?d1

literal 7344
zcmb7JOK%(38ND;4q|uO)h7v8y@)KILX!?jAj?xxrVRD9~Xj9UNl${hbz>%C3Dhw2a
z>i}_#0J2)tjutIqH9?njz;)Vx&@8+3u8VHkZI>wuYi0F(-^VN8JBol}}QFjmou-lXJ69`%#YD
z*p$8E52EtTn)BzK%!g7rL8_iB0Id9SllkMgDGzUOs9X=S`lDQYUObF&^f
zUh8HYD=*w^HdHYh?X0)L?EYO9M(-^2sv`$Gg(*L1ul{rC#pMgvK7Z$a>8qdp^^3qEs
z7W#LCwKG2=Lu@8&R$7Jfi2v&+W6I5Arj
z_wiY!Cy_EJ>mmXkxn#)%UOaA=+_g~57@Gf>o^e6Cm
zOZ^X2vE+BcW=rkUiTk(X*3zOhlenUrJ8@%au^Z2~I&>I~N{0@1@7?Dn`jw-I)5{;k
z3%5F|PlNrDPRSpSTgz9aIUQGY^E+{4`D!;_pb@!2BXXnBp+mo;0Z5aC_k9U5PhW73T8!%bd!#9|eS`ZdKNzD{(XGTq!PhTAL-+rJkfqU0WX|
zevtI?pB^OYAjusa^;K{D(}OMbr>(sD_y30as_#$WW^A?!1%LeaqcmmDU#cw4SFn71
zt=oHV+^Us2e6OOsql!4ug-G?ev8WqM)Cd|QhHibh-g+gx3=eU=x#9W=Jv5Ctj9h=$
zciWGyP+NuTtEG%`uq$KNh&Llwxzz|PCRbd4kI1tiS5#Q4tT|yBn?{UHHNqxnoPRT;
z?@+4T-uq#5GsKz8lb6GjMrLRHGc~8Hx+-wz=!U(g?kRWpfoku)eWM&5(=(akC{O9}
zEU_?AiE^NNPrZlzoQuh7?|pZ5{pPW7Vk#~4{GmA&5b=5zj*j02BdRzfSB(rLy9JBziD&x+G=1WQ1!sDuM=hVDwogFQr*HZ6EuX&a
z6VUXDm_kj=315|*SYr0o;X^f_hu
zoU(jQ***bHpGC`O(ehceeFB<3&saXsSU%6#J^@Xi)0WR^%jdN16VUXDuPx)gJ!|$_#tfT-1)IJfQ!eu1_)Syy;
z3YC=VfC`nB6rh0GCjt~mM-l=Q
z$P7?GGe7~205y~dP(w)pYA7i{4J889P$EDLB?YLVqyROP2v9?b05y~ppoWqH)KDTo
z4J889P*Q*zN(xXzi2w!CR~G>age%6ANdXFo%b+1C_1q#rf%M!WK!Nn!Qh);LxupOF
zj8t*9g9uf${6jxh`}BkK*)Z)&?MFX-Gef^pY2ATVIh?q;Q9|NwlxY*vCh`=PYBnm=
zuF|GPn-#A(Ro}p3VsG@Jzq^AqnbE$VD_*T{gw0V9n)8KmKljP78s#;y2Wp@C{2^@X
z-G@8=grXKsqB-B*YmCr0jQ%a2$LbEP9eFtIR$*>FVX;H&-vW_g2Y!n5yo(uTefU%7GH#`
zQNCuBuW|WWs(kH~^0h(vm2~-$*C@YYlwaZUE2;7;r<7l5?^Uw&Dod3gJoWnBfv*Z$
zW#a`!whLJvdnDld)8V27RCx($edzkd|lo|#fA18*9K6{w-
zbCDVbUm_=lkv@Bv^!=S02A?G-hLJvdnDl*`8V27eCx($edzke7mKp{hEGLGMzQHg-
zZJbtDi*JSTYRSRBy25yUZAT^DLeBRTepS%lR(I#gmhURwWmGo-%BucWaW;&RS+7*R
zp#-be&ocP0fFH({>u!6_|2r1^oBVIGzxY?$kMaz#>0Aqn*N4#v75-7t>b#Htw{=zW
zMRn-2ij;etubD5*qXKsu*Cmpl-{5EpSHMzbJ>7
jWOr3|Z^>>TeOu6vW%m==m1I|zT_`(zH&CsL?5gVjcvrSt

-- 
MST




[Qemu-devel] [PULL v2 11/23] vring: make vring_enable_notification return void

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

Make the API more similar to the regular virtqueue API.  This will
help when modifying the code to not use vring.c anymore.

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Acked-by: Cornelia Huck 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/dataplane/vring.h | 2 +-
 hw/block/dataplane/virtio-blk.c | 3 ++-
 hw/virtio/dataplane/vring.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/hw/virtio/dataplane/vring.h 
b/include/hw/virtio/dataplane/vring.h
index e80985e..e1c2a65 100644
--- a/include/hw/virtio/dataplane/vring.h
+++ b/include/hw/virtio/dataplane/vring.h
@@ -42,7 +42,7 @@ static inline void vring_set_broken(Vring *vring)
 bool vring_setup(Vring *vring, VirtIODevice *vdev, int n);
 void vring_teardown(Vring *vring, VirtIODevice *vdev, int n);
 void vring_disable_notification(VirtIODevice *vdev, Vring *vring);
-bool vring_enable_notification(VirtIODevice *vdev, Vring *vring);
+void vring_enable_notification(VirtIODevice *vdev, Vring *vring);
 bool vring_should_notify(VirtIODevice *vdev, Vring *vring);
 void *vring_pop(VirtIODevice *vdev, Vring *vring, size_t sz);
 void vring_push(VirtIODevice *vdev, Vring *vring, VirtQueueElement *elem,
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 0d99781..03b81bc 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -128,7 +128,8 @@ static void handle_notify(EventNotifier *e)
 /* Re-enable guest->host notifies and stop processing the vring.
  * But if the guest has snuck in more descriptors, keep processing.
  */
-if (vring_enable_notification(s->vdev, &s->vring)) {
+vring_enable_notification(s->vdev, &s->vring);
+if (!vring_more_avail(s->vdev, &s->vring)) {
 break;
 }
 } else { /* fatal error */
diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
index 4308d9f..157e8b8 100644
--- a/hw/virtio/dataplane/vring.c
+++ b/hw/virtio/dataplane/vring.c
@@ -175,7 +175,7 @@ void vring_disable_notification(VirtIODevice *vdev, Vring 
*vring)
  *
  * Return true if the vring is empty, false if there are more requests.
  */
-bool vring_enable_notification(VirtIODevice *vdev, Vring *vring)
+void vring_enable_notification(VirtIODevice *vdev, Vring *vring)
 {
 if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {
 vring_avail_event(&vring->vr) = vring->vr.avail->idx;
@@ -183,7 +183,6 @@ bool vring_enable_notification(VirtIODevice *vdev, Vring 
*vring)
 vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY);
 }
 smp_mb(); /* ensure update is seen before reading avail_idx */
-return !vring_more_avail(vdev, vring);
 }
 
 /* This is stolen from linux/drivers/vhost/vhost.c:vhost_notify() */
-- 
MST




[Qemu-devel] [PULL v2 15/23] virtio-blk: do not use vring in dataplane

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 hw/block/dataplane/virtio-blk.h |   1 +
 include/hw/virtio/virtio-blk.h  |   3 --
 hw/block/dataplane/virtio-blk.c | 112 +---
 hw/block/virtio-blk.c   |  49 +++---
 4 files changed, 19 insertions(+), 146 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.h b/hw/block/dataplane/virtio-blk.h
index c88d40e..0714c11 100644
--- a/hw/block/dataplane/virtio-blk.h
+++ b/hw/block/dataplane/virtio-blk.h
@@ -26,5 +26,6 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s);
 void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s);
 void virtio_blk_data_plane_stop(VirtIOBlockDataPlane *s);
 void virtio_blk_data_plane_drain(VirtIOBlockDataPlane *s);
+void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s);
 
 #endif /* HW_DATAPLANE_VIRTIO_BLK_H */
diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h
index 781969d..ae84d92 100644
--- a/include/hw/virtio/virtio-blk.h
+++ b/include/hw/virtio/virtio-blk.h
@@ -53,9 +53,6 @@ typedef struct VirtIOBlock {
 unsigned short sector_mask;
 bool original_wce;
 VMChangeStateEntry *change;
-/* Function to push to vq and notify guest */
-void (*complete_request)(struct VirtIOBlockReq *req, unsigned char status);
-Notifier migration_state_notifier;
 bool dataplane_started;
 struct VirtIOBlockDataPlane *dataplane;
 } VirtIOBlock;
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index cc521c1..36f3d2b 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -18,8 +18,6 @@
 #include "qemu/thread.h"
 #include "qemu/error-report.h"
 #include "hw/virtio/virtio-access.h"
-#include "hw/virtio/dataplane/vring.h"
-#include "hw/virtio/dataplane/vring-accessors.h"
 #include "sysemu/block-backend.h"
 #include "hw/virtio/virtio-blk.h"
 #include "virtio-blk.h"
@@ -35,7 +33,7 @@ struct VirtIOBlockDataPlane {
 VirtIOBlkConf *conf;
 
 VirtIODevice *vdev;
-Vring vring;/* virtqueue vring */
+VirtQueue *vq;  /* virtqueue vring */
 EventNotifier *guest_notifier;  /* irq */
 QEMUBH *bh; /* bh for guest notification */
 
@@ -48,94 +46,26 @@ struct VirtIOBlockDataPlane {
  */
 IOThread *iothread;
 AioContext *ctx;
-EventNotifier host_notifier;/* doorbell */
 
 /* Operation blocker on BDS */
 Error *blocker;
-void (*saved_complete_request)(struct VirtIOBlockReq *req,
-   unsigned char status);
 };
 
 /* Raise an interrupt to signal guest, if necessary */
-static void notify_guest(VirtIOBlockDataPlane *s)
+void virtio_blk_data_plane_notify(VirtIOBlockDataPlane *s)
 {
-if (!vring_should_notify(s->vdev, &s->vring)) {
-return;
-}
-
-event_notifier_set(s->guest_notifier);
+qemu_bh_schedule(s->bh);
 }
 
 static void notify_guest_bh(void *opaque)
 {
 VirtIOBlockDataPlane *s = opaque;
 
-notify_guest(s);
-}
-
-static void complete_request_vring(VirtIOBlockReq *req, unsigned char status)
-{
-VirtIOBlockDataPlane *s = req->dev->dataplane;
-stb_p(&req->in->status, status);
-
-vring_push(s->vdev, &req->dev->dataplane->vring, &req->elem, req->in_len);
-
-/* Suppress notification to guest by BH and its scheduled
- * flag because requests are completed as a batch after io
- * plug & unplug is introduced, and the BH can still be
- * executed in dataplane aio context even after it is
- * stopped, so needn't worry about notification loss with BH.
- */
-qemu_bh_schedule(s->bh);
-}
-
-static void handle_notify(EventNotifier *e)
-{
-VirtIOBlockDataPlane *s = container_of(e, VirtIOBlockDataPlane,
-   host_notifier);
-VirtIOBlock *vblk = VIRTIO_BLK(s->vdev);
-
-event_notifier_test_and_clear(&s->host_notifier);
-blk_io_plug(s->conf->conf.blk);
-for (;;) {
-MultiReqBuffer mrb = {};
-
-/* Disable guest->host notifies to avoid unnecessary vmexits */
-vring_disable_notification(s->vdev, &s->vring);
-
-for (;;) {
-VirtIOBlockReq *req = vring_pop(s->vdev, &s->vring,
-sizeof(VirtIOBlockReq));
-
-if (req == NULL) {
-break; /* no more requests */
-}
-
-virtio_blk_init_request(vblk, req);
-trace_virtio_blk_data_plane_process_request(s, req->elem.out_num,
-req->elem.in_num,
-req->elem.index);
-
-virtio_blk_handle_request(req, &mrb);
-}
-
-if (mrb.num_reqs) {
-virtio_blk_submit_multireq(s->conf->conf.blk, &mrb);
-  

[Qemu-devel] [PULL v2 07/23] balloon: Use only 'pc-dimm' type dimm for ballooning

2016-02-25 Thread Michael S. Tsirkin
From: Vladimir Sementsov-Ogievskiy 

For now there are only two dimm's: pc-dimm and nvdimm. This patch is
actually needed to disable ballooning on nvdimm. But, to avoid future
bugs, instead of disallowing nvdimm, we allow only pc-dimm. So, if
someone adds new dimm which should be balloon-able, then this ability
should be explicitly specified here.

Why ballooning for nvdimm should be disabled for now:

NVDIMM for now is planned to use as a backing store for DAX filesystem
in the guest and thus this memory is excluded from guest memory
management and LRUs.

In this case libvirt running QEMU along with configured balloon almost
immediately inflates balloon and effectively kill the guest as
qemu counts nvdimm as part of the ram.

Counting dimm devices as part of the ram for ballooning was started from
commit 463756d03:
 virtio-balloon: Fix balloon not working correctly when hotplug memory

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Signed-off-by: Denis V. Lunev 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
 hw/virtio/virtio-balloon.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 388e873..3fb6c52 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -313,7 +313,10 @@ static ram_addr_t get_current_ram_size(void)
 pc_dimm_build_list(qdev_get_machine(), &list);
 for (item = list; item; item = g_slist_next(item)) {
 Object *obj = OBJECT(item->data);
-size += object_property_get_int(obj, PC_DIMM_SIZE_PROP, &error_abort);
+if (!strcmp(object_get_typename(obj), TYPE_PC_DIMM)) {
+size += object_property_get_int(obj, PC_DIMM_SIZE_PROP,
+&error_abort);
+}
 }
 g_slist_free(list);
 
-- 
MST




[Qemu-devel] [PULL v2 16/23] virtio-scsi: do not use vring in dataplane

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/virtio-scsi.h |  21 +
 hw/scsi/virtio-scsi-dataplane.c | 196 +---
 hw/scsi/virtio-scsi.c   |  52 ++-
 3 files changed, 35 insertions(+), 234 deletions(-)

diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index a8029aa..209eaa4 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -22,7 +22,6 @@
 #include "hw/pci/pci.h"
 #include "hw/scsi/scsi.h"
 #include "sysemu/iothread.h"
-#include "hw/virtio/dataplane/vring.h"
 
 #define TYPE_VIRTIO_SCSI_COMMON "virtio-scsi-common"
 #define VIRTIO_SCSI_COMMON(obj) \
@@ -58,13 +57,6 @@ struct VirtIOSCSIConf {
 
 struct VirtIOSCSI;
 
-typedef struct {
-struct VirtIOSCSI *parent;
-Vring vring;
-EventNotifier host_notifier;
-EventNotifier guest_notifier;
-} VirtIOSCSIVring;
-
 typedef struct VirtIOSCSICommon {
 VirtIODevice parent_obj;
 VirtIOSCSIConf conf;
@@ -96,18 +88,12 @@ typedef struct VirtIOSCSI {
 QTAILQ_HEAD(, VirtIOSCSIBlkChangeNotifier) insert_notifiers;
 QTAILQ_HEAD(, VirtIOSCSIBlkChangeNotifier) remove_notifiers;
 
-/* Vring is used instead of vq in dataplane code, because of the underlying
- * memory layer thread safety */
-VirtIOSCSIVring *ctrl_vring;
-VirtIOSCSIVring *event_vring;
-VirtIOSCSIVring **cmd_vrings;
 bool dataplane_started;
 bool dataplane_starting;
 bool dataplane_stopping;
 bool dataplane_disabled;
 bool dataplane_fenced;
 Error *blocker;
-Notifier migration_state_notifier;
 uint32_t host_features;
 } VirtIOSCSI;
 
@@ -123,9 +109,6 @@ typedef struct VirtIOSCSIReq {
 QEMUSGList qsgl;
 QEMUIOVector resp_iov;
 
-/* Set by dataplane code. */
-VirtIOSCSIVring *vring;
-
 union {
 /* Used for two-stage request submission */
 QTAILQ_ENTRY(VirtIOSCSIReq) next;
@@ -168,8 +151,6 @@ void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev,
 void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread *iothread);
 void virtio_scsi_dataplane_start(VirtIOSCSI *s);
 void virtio_scsi_dataplane_stop(VirtIOSCSI *s);
-void virtio_scsi_vring_push_notify(VirtIOSCSIReq *req);
-VirtIOSCSIReq *virtio_scsi_pop_req_vring(VirtIOSCSI *s,
- VirtIOSCSIVring *vring);
+void virtio_scsi_dataplane_notify(VirtIODevice *vdev, VirtIOSCSIReq *req);
 
 #endif /* _QEMU_VIRTIO_SCSI_H */
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 8340326..367e476 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -39,14 +39,10 @@ void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread 
*iothread)
 }
 }
 
-static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s,
-   VirtQueue *vq,
-   EventNotifierHandler *handler,
-   int n)
+static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n)
 {
 BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
 VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
-VirtIOSCSIVring *r;
 int rc;
 
 /* Set up virtqueue notify */
@@ -55,105 +51,17 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI 
*s,
 fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
 rc);
 s->dataplane_fenced = true;
-return NULL;
+return rc;
 }
 
-r = g_new(VirtIOSCSIVring, 1);
-r->host_notifier = *virtio_queue_get_host_notifier(vq);
-r->guest_notifier = *virtio_queue_get_guest_notifier(vq);
-aio_set_event_notifier(s->ctx, &r->host_notifier, true, handler);
-
-r->parent = s;
-
-if (!vring_setup(&r->vring, VIRTIO_DEVICE(s), n)) {
-fprintf(stderr, "virtio-scsi: VRing setup failed\n");
-goto fail_vring;
-}
-return r;
-
-fail_vring:
-aio_set_event_notifier(s->ctx, &r->host_notifier, true, NULL);
-k->set_host_notifier(qbus->parent, n, false);
-g_free(r);
-return NULL;
-}
-
-VirtIOSCSIReq *virtio_scsi_pop_req_vring(VirtIOSCSI *s,
- VirtIOSCSIVring *vring)
-{
-VirtIOSCSICommon *vs = (VirtIOSCSICommon *)s;
-VirtIOSCSIReq *req;
-
-req = vring_pop((VirtIODevice *)s, &vring->vring,
-sizeof(VirtIOSCSIReq) + vs->cdb_size);
-if (!req) {
-return NULL;
-}
-virtio_scsi_init_req(s, NULL, req);
-req->vring = vring;
-return req;
-}
-
-void virtio_scsi_vring_push_notify(VirtIOSCSIReq *req)
-{
-VirtIODevice *vdev = VIRTIO_DEVICE(req->vring->parent);
-
-vring_push(vdev, &req->vring->vring, &req->elem,
-   req->qsgl.size + req->resp_iov.size);
-
-if (vring_should_notify(vdev, &req->vring->vring)

[Qemu-devel] [PULL v2 09/23] pci core: function pci_bus_init() cleanup

2016-02-25 Thread Michael S. Tsirkin
From: Cao jin 

remove unused param

Signed-off-by: Cao jin 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Eduardo Habkost 
---
 hw/pci/pci.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b071361..e67664d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -331,7 +331,6 @@ const char *pci_root_bus_path(PCIDevice *dev)
 }
 
 static void pci_bus_init(PCIBus *bus, DeviceState *parent,
- const char *name,
  MemoryRegion *address_space_mem,
  MemoryRegion *address_space_io,
  uint8_t devfn_min)
@@ -364,8 +363,7 @@ void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, 
DeviceState *parent,
  uint8_t devfn_min, const char *typename)
 {
 qbus_create_inplace(bus, bus_size, typename, parent, name);
-pci_bus_init(bus, parent, name, address_space_mem,
- address_space_io, devfn_min);
+pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_min);
 }
 
 PCIBus *pci_bus_new(DeviceState *parent, const char *name,
@@ -376,8 +374,7 @@ PCIBus *pci_bus_new(DeviceState *parent, const char *name,
 PCIBus *bus;
 
 bus = PCI_BUS(qbus_create(typename, parent, name));
-pci_bus_init(bus, parent, name, address_space_mem,
- address_space_io, devfn_min);
+pci_bus_init(bus, parent, address_space_mem, address_space_io, devfn_min);
 return bus;
 }
 
-- 
MST




[Qemu-devel] [PULL v2 21/23] ich9: Remove enable_tco arguments from init functions

2016-02-25 Thread Michael S. Tsirkin
From: Eduardo Habkost 

The enable_tco arguments are always true, so they are not needed
anymore.

Signed-off-by: Eduardo Habkost 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Markus Armbruster 
Reviewed-by: Igor Mammedov 
---
 include/hw/acpi/ich9.h | 1 -
 include/hw/i386/ich9.h | 2 +-
 hw/acpi/ich9.c | 8 +++-
 hw/i386/pc_q35.c   | 2 +-
 hw/isa/lpc_ich9.c  | 4 ++--
 5 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 345fd8d..63fa198 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -62,7 +62,6 @@ typedef struct ICH9LPCPMRegs {
 
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
   bool smm_enabled,
-  bool enable_tco,
   qemu_irq sci_irq);
 
 void ich9_pm_iospace_update(ICH9LPCPMRegs *pm, uint32_t pm_io_base);
diff --git a/include/hw/i386/ich9.h b/include/hw/i386/ich9.h
index b9d2b04..b411434 100644
--- a/include/hw/i386/ich9.h
+++ b/include/hw/i386/ich9.h
@@ -17,7 +17,7 @@
 void ich9_lpc_set_irq(void *opaque, int irq_num, int level);
 int ich9_lpc_map_irq(PCIDevice *pci_dev, int intx);
 PCIINTxRoute ich9_route_intx_pin_to_irq(void *opaque, int pirq_pin);
-void ich9_lpc_pm_init(PCIDevice *pci_lpc, bool smm_enabled, bool enable_tco);
+void ich9_lpc_pm_init(PCIDevice *pci_lpc, bool smm_enabled);
 I2CBus *ich9_smb_init(PCIBus *bus, int devfn, uint32_t smb_io_base);
 
 void ich9_generate_smi(void);
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 4f9ce05..7220254 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -240,7 +240,7 @@ static void pm_powerdown_req(Notifier *n, void *opaque)
 }
 
 void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
-  bool smm_enabled, bool enable_tco,
+  bool smm_enabled,
   qemu_irq sci_irq)
 {
 memory_region_init(&pm->io, OBJECT(lpc_pci), "ich9-pm", ICH9_PMIO_SIZE);
@@ -264,10 +264,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 
 pm->smm_enabled = smm_enabled;
 
-pm->enable_tco = enable_tco;
-if (pm->enable_tco) {
-acpi_pm_tco_init(&pm->tco_regs, &pm->io);
-}
+pm->enable_tco = true;
+acpi_pm_tco_init(&pm->tco_regs, &pm->io);
 
 pm->irq = sci_irq;
 qemu_register_reset(pm_reset, pm);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 3ba0c38..06a5f95 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -225,7 +225,7 @@ static void pc_q35_init(MachineState *machine)
  (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
 
 /* connect pm stuff to lpc */
-ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), true);
+ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms));
 
 /* ahci and SATA device, for q35 1 ahci controller is built-in */
 ahci = pci_create_simple_multifunction(host_bus,
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 6cf2eb6..4e896b2 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -369,13 +369,13 @@ static void ich9_set_sci(void *opaque, int irq_num, int 
level)
 }
 }
 
-void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled, bool enable_tco)
+void ich9_lpc_pm_init(PCIDevice *lpc_pci, bool smm_enabled)
 {
 ICH9LPCState *lpc = ICH9_LPC_DEVICE(lpc_pci);
 qemu_irq sci_irq;
 
 sci_irq = qemu_allocate_irq(ich9_set_sci, lpc, 0);
-ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, enable_tco, sci_irq);
+ich9_pm_init(lpc_pci, &lpc->pm, smm_enabled, sci_irq);
 ich9_lpc_reset(&lpc->d.qdev);
 }
 
-- 
MST




Re: [Qemu-devel] CPU hotplug, again

2016-02-25 Thread David Gibson
On Wed, Feb 24, 2016 at 02:41:17PM +0100, Igor Mammedov wrote:
> On Wed, 24 Feb 2016 22:28:22 +1100
> David Gibson  wrote:
> 
> > On Wed, Feb 24, 2016 at 11:48:33AM +0100, Igor Mammedov wrote:
> > > On Wed, 24 Feb 2016 13:01:06 +1100
> > > David Gibson  wrote:
> > >   
> > > > On Tue, Feb 23, 2016 at 12:18:59PM +0100, Igor Mammedov wrote:  
> > > > > On Tue, 23 Feb 2016 21:05:04 +1100
> > > > > David Gibson  wrote:
> > > > > 
> > > > > > On Tue, Feb 23, 2016 at 03:10:26PM +0530, Bharata B Rao wrote:
> > > > > > > On Tue, Feb 23, 2016 at 04:24:31PM +1100, David Gibson wrote: 
> > > > > > >  
> > > > > > > > Hi Andreas,
> > > > > > > > 
> > > > > > > > I've now found (with Thomas' help) your RFC series for 
> > > > > > > > socket/core
> > > > > > > > based cpu hotplug on x86
> > > > > > > > (https://github.com/afaerber/qemu-cpu/compare/qom-cpu-x86).  It 
> > > > > > > > seems
> > > > > > > > sensible enough as far as it goes, but doesn't seem to address 
> > > > > > > > a bunch
> > > > > > > > of the things that I was attempting to do with the cpu-package
> > > > > > > > proposal - and which we absolutely need for cpu hotplug on 
> > > > > > > > Power.
> > > > > > > > 
> > > > > > > > 1) What interface do you envisage beyond cpu_add?
> > > > > > > > 
> > > > > > > > The patches I see just construct extra socket and core objects, 
> > > > > > > > but
> > > > > > > > still control hotplug (for x86) through the cpu_add interface.  
> > > > > > > > That
> > > > > > > > interface is absolutely unusable on Power, since it operates on 
> > > > > > > > a
> > > > > > > > per-thread basis, whereas the PAPR guest<->host interfaces can 
> > > > > > > > only
> > > > > > > > communicate information at a per-core granularity.
> > > > > > > > 
> > > > > > > > 2) When hotplugging at core or socket granularity, where would 
> > > > > > > > the
> > > > > > > >code to construct the individual thread objects sit?
> > > > > > > > 
> > > > > > > > Your series has the construction done in both the machine init 
> > > > > > > > path
> > > > > > > > and the hotplug path.  The latter works because hotplug occurs 
> > > > > > > > at
> > > > > > > > thread granularity.  If we're hotplugging at core or socket
> > > > > > > > granularity what would do the construct?  The core/socket object
> > > > > > > > itself (in instance_init?  in realize?); the hotplug handler?
> > > > > > > > something else?
> > > > > > > > 
> > > > > > > > 3) How does the management layer determine what is pluggable?
> > > > > > > > 
> > > > > > > > Both the number of pluggable slots, and what it will need to do 
> > > > > > > > to
> > > > > > > > populate them.
> > > > > > > > 
> > > > > > > > 4) How do we enforce that toplogies illegal for the platform 
> > > > > > > > can't be
> > > > > > > >constructed?  
> > > > > > > 
> > > > > > > 5) QOM-links
> > > > > > > 
> > > > > > > Andreas, You have often talked about setting up links from 
> > > > > > > machine object
> > > > > > > to the CPU objects. Would the below code correctly capture that 
> > > > > > > idea of
> > > > > > > yours ?
> > > > > > > 
> > > > > > > #define SPAPR_MACHINE_CPU_CORE_PROP "core"
> > > > > > > 
> > > > > > > /* MachineClass.init for sPAPR */
> > > > > > > static void ppc_spapr_init(MachineState *machine)
> > > > > > > {
> > > > > > > sPAPRMachineState *spapr = SPAPR_MACHINE(machine);
> > > > > > > int spapr_smp_cores = smp_cpus / smp_threads;
> > > > > > > int spapr_max_cores = max_cpus / smp_threads;
> > > > > > > 
> > > > > > > ...
> > > > > > > for (i = 0; i < spapr_max_cores; i++) {
> > > > > > > Object *obj = object_new(TYPE_SPAPR_CPU_CORE);
> > > > > > > sPAPRCPUCore *core = SPAPR_CPU_CORE(obj);
> > > > > > > char name[32];
> > > > > > > 
> > > > > > > snprintf(name, sizeof(name), "%s[%d]", 
> > > > > > > SPAPR_MACHINE_CPU_CORE_PROP, i);
> > > > > > > 
> > > > > > > /*
> > > > > > >  * Create links from machine objects to all possible 
> > > > > > > cores.
> > > > > > >  */
> > > > > > > object_property_add_link(OBJECT(spapr), name, 
> > > > > > > TYPE_SPAPR_CPU_CORE,
> > > > > > >  (Object **)&spapr->core[i],
> > > > > > >  NULL, NULL, &error_abort); 
> > > > > > > 
> > > > > > > /*
> > > > > > >  * Set the QOM link from machine object to core object 
> > > > > > > for all
> > > > > > >  * boot time CPUs specified with -smp. For rest of the 
> > > > > > > hotpluggable
> > > > > > >  * cores this is done from the core hotplug path.
> > > > > > >  */
> > > > > > > if (i < spapr_smp_cores) {
> > > > > > > object_property_set_link(OBJECT(spapr), OBJECT(core),
> > > > > > >  SPAPR_MACHINE_CPU_CORE_PROP, 
> > > > > > > &error_abort);  
> > > > > > 
> > > > > > I hope we can at least have a helper function to both constr

[Qemu-devel] [PULL v2 17/23] vring: remove

2016-02-25 Thread Michael S. Tsirkin
From: Paolo Bonzini 

Signed-off-by: Paolo Bonzini 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Fam Zheng 
Acked-by: Stefan Hajnoczi 
---
 include/hw/virtio/dataplane/vring-accessors.h |  75 
 include/hw/virtio/dataplane/vring.h   |  51 ---
 hw/virtio/dataplane/vring.c   | 548 --
 hw/virtio/Makefile.objs   |   1 -
 hw/virtio/dataplane/Makefile.objs |   1 -
 trace-events  |   3 -
 6 files changed, 679 deletions(-)
 delete mode 100644 include/hw/virtio/dataplane/vring-accessors.h
 delete mode 100644 include/hw/virtio/dataplane/vring.h
 delete mode 100644 hw/virtio/dataplane/vring.c
 delete mode 100644 hw/virtio/dataplane/Makefile.objs

diff --git a/include/hw/virtio/dataplane/vring-accessors.h 
b/include/hw/virtio/dataplane/vring-accessors.h
deleted file mode 100644
index 815c19b..000
--- a/include/hw/virtio/dataplane/vring-accessors.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#ifndef VRING_ACCESSORS_H
-#define VRING_ACCESSORS_H
-
-#include "standard-headers/linux/virtio_ring.h"
-#include "hw/virtio/virtio.h"
-#include "hw/virtio/virtio-access.h"
-
-static inline uint16_t vring_get_used_idx(VirtIODevice *vdev, Vring *vring)
-{
-return virtio_tswap16(vdev, vring->vr.used->idx);
-}
-
-static inline void vring_set_used_idx(VirtIODevice *vdev, Vring *vring,
-  uint16_t idx)
-{
-vring->vr.used->idx = virtio_tswap16(vdev, idx);
-}
-
-static inline uint16_t vring_get_avail_idx(VirtIODevice *vdev, Vring *vring)
-{
-return virtio_tswap16(vdev, vring->vr.avail->idx);
-}
-
-static inline uint16_t vring_get_avail_ring(VirtIODevice *vdev, Vring *vring,
-int i)
-{
-return virtio_tswap16(vdev, vring->vr.avail->ring[i]);
-}
-
-static inline void vring_set_used_ring_id(VirtIODevice *vdev, Vring *vring,
-  int i, uint32_t id)
-{
-vring->vr.used->ring[i].id = virtio_tswap32(vdev, id);
-}
-
-static inline void vring_set_used_ring_len(VirtIODevice *vdev, Vring *vring,
-  int i, uint32_t len)
-{
-vring->vr.used->ring[i].len = virtio_tswap32(vdev, len);
-}
-
-static inline uint16_t vring_get_used_flags(VirtIODevice *vdev, Vring *vring)
-{
-return virtio_tswap16(vdev, vring->vr.used->flags);
-}
-
-static inline uint16_t vring_get_avail_flags(VirtIODevice *vdev, Vring *vring)
-{
-return virtio_tswap16(vdev, vring->vr.avail->flags);
-}
-
-static inline void vring_set_used_flags(VirtIODevice *vdev, Vring *vring,
-uint16_t flags)
-{
-vring->vr.used->flags |= virtio_tswap16(vdev, flags);
-}
-
-static inline void vring_clear_used_flags(VirtIODevice *vdev, Vring *vring,
-  uint16_t flags)
-{
-vring->vr.used->flags &= virtio_tswap16(vdev, ~flags);
-}
-
-static inline unsigned int vring_get_num(Vring *vring)
-{
-return vring->vr.num;
-}
-
-/* Are there more descriptors available? */
-static inline bool vring_more_avail(VirtIODevice *vdev, Vring *vring)
-{
-return vring_get_avail_idx(vdev, vring) != vring->last_avail_idx;
-}
-
-#endif
diff --git a/include/hw/virtio/dataplane/vring.h 
b/include/hw/virtio/dataplane/vring.h
deleted file mode 100644
index e1c2a65..000
--- a/include/hw/virtio/dataplane/vring.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright 2012 Red Hat, Inc. and/or its affiliates
- * Copyright IBM, Corp. 2012
- *
- * Based on Linux 2.6.39 vhost code:
- * Copyright (C) 2009 Red Hat, Inc.
- * Copyright (C) 2006 Rusty Russell IBM Corporation
- *
- * Author: Michael S. Tsirkin 
- * Stefan Hajnoczi 
- *
- * Inspiration, some code, and most witty comments come from
- * Documentation/virtual/lguest/lguest.c, by Rusty Russell
- *
- * This work is licensed under the terms of the GNU GPL, version 2.
- */
-
-#ifndef VRING_H
-#define VRING_H
-
-#include "qemu-common.h"
-#include "standard-headers/linux/virtio_ring.h"
-#include "hw/virtio/virtio.h"
-
-typedef struct {
-MemoryRegion *mr_desc;  /* memory region for the vring desc */
-MemoryRegion *mr_avail; /* memory region for the vring avail */
-MemoryRegion *mr_used;  /* memory region for the vring used */
-struct vring vr;/* virtqueue vring mapped to host memory */
-uint16_t last_avail_idx;/* last processed avail ring index */
-uint16_t last_used_idx; /* last processed used ring index */
-uint16_t signalled_used;/* EVENT_IDX state */
-bool signalled_used_valid;
-bool broken;/* was there a fatal error? */
-} Vring;
-
-/* Fail future vring_pop() and vring_push() calls until reset */
-static inline void vring_set_broken(Vring *vring)
-{
-vring->broken = true;
-}
-
-bool vring_setup(Vring *vring, VirtIODevice *vdev, int n);
-void vring_

[Qemu-devel] [PULL v2 23/23] q35: No need to check gigabyte_align

2016-02-25 Thread Michael S. Tsirkin
From: Eduardo Habkost 

gigabyte_align is always true on q35, so we don't need the
!gigabyte_align compat code anymore.

Signed-off-by: Eduardo Habkost 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Markus Armbruster 
Reviewed-by: Igor Mammedov 
---
 hw/i386/pc_q35.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index da28d77..46522c9 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -81,11 +81,9 @@ static void pc_q35_init(MachineState *machine)
  * If it doesn't, we need to split it in chunks below and above 4G.
  * In any case, try to make sure that guest addresses aligned at
  * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
- * For old machine types, use whatever split we used historically to avoid
- * breaking migration.
  */
 if (machine->ram_size >= 0xb000) {
-lowmem = pcmc->gigabyte_align ? 0x8000 : 0xb000;
+lowmem = 0x8000;
 } else {
 lowmem = 0xb000;
 }
-- 
MST




[Qemu-devel] [PULL v2 20/23] machine: Remove no_tco field

2016-02-25 Thread Michael S. Tsirkin
From: Eduardo Habkost 

The field is always set to zero, so it is not necessary anymore.

Signed-off-by: Eduardo Habkost 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Markus Armbruster 
Reviewed-by: Igor Mammedov 
---
 include/hw/boards.h | 1 -
 hw/i386/pc_q35.c| 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 0f30959..de3b3bd 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -84,7 +84,6 @@ struct MachineClass {
 no_cdrom:1,
 no_sdcard:1,
 has_dynamic_sysbus:1,
-no_tco:1,
 pci_allow_0_address:1;
 int is_default;
 const char *default_machine_opts;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 2974912..3ba0c38 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -225,7 +225,7 @@ static void pc_q35_init(MachineState *machine)
  (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
 
 /* connect pm stuff to lpc */
-ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), !mc->no_tco);
+ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), true);
 
 /* ahci and SATA device, for q35 1 ahci controller is built-in */
 ahci = pci_create_simple_multifunction(host_bus,
@@ -280,7 +280,6 @@ static void pc_q35_machine_options(MachineClass *m)
 m->default_machine_opts = "firmware=bios-256k.bin";
 m->default_display = "std";
 m->no_floppy = 1;
-m->no_tco = 0;
 }
 
 static void pc_q35_2_6_machine_options(MachineClass *m)
-- 
MST




[Qemu-devel] [PULL v2 19/23] q35: Remove old machine versions

2016-02-25 Thread Michael S. Tsirkin
From: Eduardo Habkost 

Migration with q35 was not possible before commit
04329029a8c539eb5f75dcb6d8b016f0c53a031a, because q35
unconditionally creates an ich9-ahci device, that was marked as
unmigratable. So all q35 machine classes before pc-q35-2.4 were
not migratable, so there's no point in keeping compatibility code
for them.

Remove all old pc-q35 machine classes and keep only pc-q35-2.4
and newer.

Signed-off-by: Eduardo Habkost 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Markus Armbruster 
Reviewed-by: Igor Mammedov 
---
 hw/i386/pc_q35.c | 165 ---
 1 file changed, 165 deletions(-)

diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 208a224..2974912 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -259,62 +259,6 @@ static void pc_q35_init(MachineState *machine)
 }
 }
 
-/* Looking for a pc_compat_2_4() function? It doesn't exist.
- * pc_compat_*() functions that run on machine-init time and
- * change global QEMU state are deprecated. Please don't create
- * one, and implement any pc-*-2.4 (and newer) compat code in
- * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().
- */
-
-static void pc_compat_2_3(MachineState *machine)
-{
-PCMachineState *pcms = PC_MACHINE(machine);
-savevm_skip_section_footers();
-if (kvm_enabled()) {
-pcms->smm = ON_OFF_AUTO_OFF;
-}
-global_state_set_optional();
-savevm_skip_configuration();
-}
-
-static void pc_compat_2_2(MachineState *machine)
-{
-pc_compat_2_3(machine);
-machine->suppress_vmdesc = true;
-}
-
-static void pc_compat_2_1(MachineState *machine)
-{
-pc_compat_2_2(machine);
-x86_cpu_change_kvm_default("svm", NULL);
-}
-
-static void pc_compat_2_0(MachineState *machine)
-{
-pc_compat_2_1(machine);
-}
-
-static void pc_compat_1_7(MachineState *machine)
-{
-pc_compat_2_0(machine);
-x86_cpu_change_kvm_default("x2apic", NULL);
-}
-
-static void pc_compat_1_6(MachineState *machine)
-{
-pc_compat_1_7(machine);
-}
-
-static void pc_compat_1_5(MachineState *machine)
-{
-pc_compat_1_6(machine);
-}
-
-static void pc_compat_1_4(MachineState *machine)
-{
-pc_compat_1_5(machine);
-}
-
 #define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \
 static void pc_init_##suffix(MachineState *machine) \
 { \
@@ -371,112 +315,3 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
 
 DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
pc_q35_2_4_machine_options);
-
-
-static void pc_q35_2_3_machine_options(MachineClass *m)
-{
-pc_q35_2_4_machine_options(m);
-m->hw_version = "2.3.0";
-m->no_floppy = 0;
-m->no_tco = 1;
-SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
-}
-
-DEFINE_Q35_MACHINE(v2_3, "pc-q35-2.3", pc_compat_2_3,
-   pc_q35_2_3_machine_options);
-
-
-static void pc_q35_2_2_machine_options(MachineClass *m)
-{
-PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-pc_q35_2_3_machine_options(m);
-m->hw_version = "2.2.0";
-SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
-pcmc->rsdp_in_ram = false;
-}
-
-DEFINE_Q35_MACHINE(v2_2, "pc-q35-2.2", pc_compat_2_2,
-   pc_q35_2_2_machine_options);
-
-
-static void pc_q35_2_1_machine_options(MachineClass *m)
-{
-PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-pc_q35_2_2_machine_options(m);
-m->hw_version = "2.1.0";
-m->default_display = NULL;
-SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
-pcmc->smbios_uuid_encoded = false;
-pcmc->enforce_aligned_dimm = false;
-}
-
-DEFINE_Q35_MACHINE(v2_1, "pc-q35-2.1", pc_compat_2_1,
-   pc_q35_2_1_machine_options);
-
-
-static void pc_q35_2_0_machine_options(MachineClass *m)
-{
-PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-pc_q35_2_1_machine_options(m);
-m->hw_version = "2.0.0";
-SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
-pcmc->has_reserved_memory = false;
-pcmc->smbios_legacy_mode = true;
-pcmc->acpi_data_size = 0x1;
-}
-
-DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0,
-   pc_q35_2_0_machine_options);
-
-
-static void pc_q35_1_7_machine_options(MachineClass *m)
-{
-PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-pc_q35_2_0_machine_options(m);
-m->hw_version = "1.7.0";
-m->default_machine_opts = NULL;
-m->option_rom_has_mr = true;
-SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
-pcmc->smbios_defaults = false;
-pcmc->gigabyte_align = false;
-}
-
-DEFINE_Q35_MACHINE(v1_7, "pc-q35-1.7", pc_compat_1_7,
-   pc_q35_1_7_machine_options);
-
-
-static void pc_q35_1_6_machine_options(MachineClass *m)
-{
-PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
-pc_q35_machine_options(m);
-m->hw_version = "1.6.0";
-m->rom_file_has_mr = false;
-SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
-pcmc->has_acpi_build = false;
-}
-
-DEFINE_Q35_MACHINE(v1_6, "pc-q35-1.6", pc_compat_1_6,
-   pc_q35_1_6_mac

[Qemu-devel] [PULL v2 18/23] tests/vhost-user-bridge: fix build on 32 bit systems

2016-02-25 Thread Michael S. Tsirkin
Mainly casts between void * and uint64_t, and wrong
format for size_t.

Signed-off-by: Michael S. Tsirkin 
---
 tests/vhost-user-bridge.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index f2b6c67..0779ba2 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -414,7 +414,7 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
 if (vmsg->size > sizeof(vmsg->payload)) {
 fprintf(stderr,
 "Error: too big message request: %d, size: vmsg->size: %u, "
-"while sizeof(vmsg->payload) = %lu\n",
+"while sizeof(vmsg->payload) = %zu\n",
 vmsg->request, vmsg->size, sizeof(vmsg->payload));
 exit(1);
 }
@@ -578,7 +578,7 @@ vubr_post_buffer(VubrDev *dev, VubrVirtq *vq, uint8_t *buf, 
int32_t len)
 exit(1);
 }
 
-void *chunk_start = (void *)gpa_to_va(dev, desc[i].addr);
+void *chunk_start = (void *)(uintptr_t)gpa_to_va(dev, desc[i].addr);
 uint32_t chunk_len = desc[i].len;
 uint32_t chunk_write_len = MIN(remaining_len, chunk_len);
 
@@ -641,7 +641,7 @@ vubr_process_desc(VubrDev *dev, VubrVirtq *vq)
 DPRINT("Chunks: ");
 i = d_index;
 do {
-void *chunk_start = (void *)gpa_to_va(dev, desc[i].addr);
+void *chunk_start = (void *)(uintptr_t)gpa_to_va(dev, desc[i].addr);
 uint32_t chunk_len = desc[i].len;
 
 assert(!(desc[i].flags & VRING_DESC_F_WRITE));
@@ -861,7 +861,7 @@ vubr_set_mem_table_exec(VubrDev *dev, VhostUserMsg *vmsg)
 if (mmap_addr == MAP_FAILED) {
 vubr_die("mmap");
 }
-dev_region->mmap_addr = (uint64_t) mmap_addr;
+dev_region->mmap_addr = (uint64_t)(uintptr_t)mmap_addr;
 DPRINT("mmap_addr:   0x%016"PRIx64"\n", dev_region->mmap_addr);
 
 close(vmsg->fds[i]);
@@ -935,9 +935,9 @@ vubr_set_vring_addr_exec(VubrDev *dev, VhostUserMsg *vmsg)
 DPRINT("avail_user_addr:  0x%016llx\n", vra->avail_user_addr);
 DPRINT("log_guest_addr:   0x%016llx\n", vra->log_guest_addr);
 
-vq->desc = (struct vring_desc *)qva_to_va(dev, vra->desc_user_addr);
-vq->used = (struct vring_used *)qva_to_va(dev, vra->used_user_addr);
-vq->avail = (struct vring_avail *)qva_to_va(dev, vra->avail_user_addr);
+vq->desc = (struct vring_desc *)(uintptr_t)qva_to_va(dev, 
vra->desc_user_addr);
+vq->used = (struct vring_used *)(uintptr_t)qva_to_va(dev, 
vra->used_user_addr);
+vq->avail = (struct vring_avail *)(uintptr_t)qva_to_va(dev, 
vra->avail_user_addr);
 vq->log_guest_addr = vra->log_guest_addr;
 
 DPRINT("Setting virtq addresses:\n");
-- 
MST




Re: [Qemu-devel] [PATCH 1/2] virtio-balloon: export all balloon statistics

2016-02-25 Thread Roman Kagan
On Thu, Feb 25, 2016 at 10:54:17AM +0200, Michael S. Tsirkin wrote:
> On Thu, Feb 25, 2016 at 09:44:06AM +0100, Markus Armbruster wrote:
> > "Denis V. Lunev"  writes:
> > 
> > > On 02/24/2016 06:43 PM, Eric Blake wrote:
> > >> On 02/24/2016 07:31 AM, Michael S. Tsirkin wrote:
> > >>> Roman Kagan  writes:
> >  On Tue, Feb 23, 2016 at 05:49:21PM +0200, Michael S. Tsirkin wrote:
> > > On Tue, Feb 23, 2016 at 06:29:33PM +0300, Denis V. Lunev wrote:
> > > > On 02/23/2016 06:24 PM, Michael S. Tsirkin wrote:
> > > > >On Tue, Feb 23, 2016 at 05:59:44PM +0300, Denis V. Lunev wrote:
> > > > >>From: Igor Redko 
> > > > >>
> > > > >>We are making experiments with different autoballooning strategies
> > > > >>based on the guest behavior. Thus we need to experiment with 
> > > > >>different
> > > > >>guest statistics. For now every counter change requires QEMU 
> > > > >>recompilation
> > > > >>and dances with Libvirt.
> > > > >>
> > > > >>This patch introduces transport for unrecognized counters in 
> > > > >>virtio-balloon.
> > > > >>This transport can be used for measuring benefits from using new
> > > > >>balloon counters, before submitting any patches. Current 
> > > > >>alternative
> > > > >>is 'guest-exec' transport which isn't made for such delicate 
> > > > >>matters
> > > > >>and can influence test results.
> > > > >>
> > > > >>Originally all counters with tag >= VIRTIO_BALLOON_S_NR were 
> > > > >>ignored.
> > > > >>Instead of this we keep first (VIRTIO_BALLOON_S_NR + 32) counters 
> > > > >>from the
> > > > >>queue and pass unrecognized ones with the following names: 
> > > > >>'x-stat-',
> > > > >>where  is a tag number in hex. Defined counters are reported 
> > > > >>with their
> > > > >>regular names.
> > > > >>
> > > > >>Signed-off-by: Igor Redko 
> > > > >>Signed-off-by: Denis V. Lunev 
> > > > >>CC: Michael S. Tsirkin 
> > > > >This seems to open the ABI to abuse.
> > > > >Seems like a reasonable way to experiment though.
> > > > >How about adding this within #if 0 statements?
> > > > >You can uncomment them for debugging ...
> > > > I'd prefer to have this enabled.
> > 
> > Yes, conditional compilation should be used sparingly.  I don't have an
> > opinion on whether using it here is appropriate.
> > 
> > > > Why do you think that it opens "abuse" way?
> > > 
> > > Because people will use this to hack drivers and management tools
> > > bypassing qemu.
> > 
> > Easy to avoid: shuffle the N in x-stat-N around from time to time, to
> > reinforce the lesson that you must not rely on their presence or
> > semantics.  I doubt it'll be necessary beyond the renumbering that
> > happens naturally when we add supported counters, or the reshuffling
> > that happens when somebody messes with the unsupported counters.
> > 
> >  I'm curious why you think it's a problem?  Even the existing stats are
> >  simply propagated to the management level by qemu with no processing
> >  other than assigning text labels.  The proposed naming scheme for
> >  unrecognized counters includes "x-" prefix which explicitly marks them
> >  as unstable so people using them take their risk.
> > 
> >  One of the benefits is forward compatibility, so that counters that 
> >  have
> >  graduated into supported ones and have got their own number and name,
> >  can be made to work with qemu that doesn't yet recognize them.
> > >>> Then management does start relying on the x- prefixed things,
> > >>> and once it's used to that it's a slippery slope.
> > >> Any management tool that relies on an x- prefix name is broken.
> > 
> > Or at least assumes the full risk of breaking without notice whenever
> > QEMU changes.  Abbreviating that to just "broken" seems fair enough :)
> > 
> > >>  We've
> > >> explicitly documented that the x- prefix is unstable and liable to go
> > >> away with a future release. Any management app that wants to use a
> > >> feature beginning with x- should FIRST push hard to get the x- removed
> > >> and stabilize the interface (and libvirt, at least, does just that).
> > >>
> > > this was exactly an original idea. Names started with 'x-' are
> > > _officially_ unstable and for debug purpose. That is why I'd
> > > prefer if v2 of the patchset will be taken.
> > 
> > Looks like fair use of x- to me.
> 
> 
> Well I already heard:
> 
>   One of the benefits is forward compatibility, so that counters that have
>   graduated into supported ones and have got their own number and name,
>   can be made to work with qemu that doesn't yet recognize them.
> 
> in this thread, which seems to mean exactly that people start planning to 
> abuse it
> even before it's merged.

That quote (from yours truly) states the opposite.

The whole point 

[Qemu-devel] [PATCH] doc/memory.txt: fix typo

2016-02-25 Thread Cao jin
to match structure MemoryRegionOps definition

Signed-off-by: Cao jin 
---
And there seems are some out of date content in this file, like
"cpu_register_io_memory()" mentioned in the last line, which is removed several
years ago in commit 97161e177. I am sure how to modify it, So I take the
liberty to CC the guys in the cc-list(get list from get_maintainer.pl).

 docs/memory.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/memory.txt b/docs/memory.txt
index 8745f76..1a3ad622 100644
--- a/docs/memory.txt
+++ b/docs/memory.txt
@@ -297,7 +297,7 @@ various constraints can be supplied to control how these 
callbacks are called:
  - .valid.min_access_size, .valid.max_access_size define the access sizes
(in bytes) which the device accepts; accesses outside this range will
have device and bus specific behaviour (ignored, or machine check)
- - .valid.aligned specifies that the device only accepts naturally aligned
+ - .valid.unaligned specifies that the device only accepts naturally aligned
accesses.  Unaligned accesses invoke device and bus specific behaviour.
  - .impl.min_access_size, .impl.max_access_size define the access sizes
(in bytes) supported by the *implementation*; other access sizes will be
-- 
2.1.0






[Qemu-devel] [PATCH 0/3] Add some more files to the MAINTAINERS file

2016-02-25 Thread Thomas Huth
These three patches add some more USB, Spice and UI related files
to the MAINTAINERS file.

Gerd, I'm not sure whether you want to take the third patch as is,
since this adds the whole include/ui/ folder to one of your sections,
so feel free to ignore it if you think it is too generic.

Thomas Huth (3):
  MAINTAINERS: Add some missing entries for USB related files
  MAINTAINERS: Add spice-display.h to the SPICE section
  MAINTAINERS: Add an entry for the include/ui/ folder

 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

-- 
1.8.3.1




[Qemu-devel] [PATCH 3/3] MAINTAINERS: Add an entry for the include/ui/ folder

2016-02-25 Thread Thomas Huth
The ui/ folder is listed in the "Graphics" section, so I think
the "include/ui/" folder should be listed there, too.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 18f2c17..72e55fa 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1096,6 +1096,7 @@ Graphics
 M: Gerd Hoffmann 
 S: Odd Fixes
 F: ui/
+F: include/ui/
 
 Cocoa graphics
 M: Andreas Färber 
-- 
1.8.3.1




[Qemu-devel] [PATCH 1/3] MAINTAINERS: Add some missing entries for USB related files

2016-02-25 Thread Thomas Huth
USB-related docs and include files should go into the USB
section of the MAINTAINERS file.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 4 
 1 file changed, 4 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 606d9c0..67d70a9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -853,6 +853,10 @@ M: Gerd Hoffmann 
 S: Maintained
 F: hw/usb/*
 F: tests/usb-*-test.c
+F: docs/usb2.txt
+F: docs/usb-storage.txt
+F: include/hw/usb.h
+F: include/hw/usb/
 
 USB (serial adapter)
 M: Gerd Hoffmann 
-- 
1.8.3.1




[Qemu-devel] [PATCH 2/3] MAINTAINERS: Add spice-display.h to the SPICE section

2016-02-25 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 67d70a9..18f2c17 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1087,6 +1087,7 @@ SPICE
 M: Gerd Hoffmann 
 S: Supported
 F: include/ui/qemu-spice.h
+F: include/ui/spice-display.h
 F: ui/spice-*.c
 F: audio/spiceaudio.c
 F: hw/display/qxl*
-- 
1.8.3.1




[Qemu-devel] [PATCH] MAINTAINERS: Add docs/migration.txt to the "Migration" section

2016-02-25 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 72e55fa..9148966 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1247,6 +1247,7 @@ F: include/migration/
 F: migration/
 F: scripts/vmstate-static-checker.py
 F: tests/vmstate-static-checker-data/
+F: docs/migration.txt
 
 Seccomp
 M: Eduardo Otubo 
-- 
1.8.3.1




Re: [Qemu-devel] [PULL 0/8] tcg queued patches

2016-02-25 Thread Peter Maydell
On 23 February 2016 at 18:33, Richard Henderson  wrote:
> A revision of the Feb 15 pull, with patch 5 adjusted to work around
> the reported Werror bug in gcc 4.8.2, and Peter's renaming patch
> set included.
>
>
> r~
>
>
> The following changes since commit 90ce6e2644db2c47d72f364b4de57342e50bd10a:
>
>   include: Clean up includes (2016-02-23 12:43:05 +)
>
> are available in the git repository at:
>
>   git://github.com/rth7680/qemu.git tags/pull-tcg-20160223
>
> for you to fetch changes up to c3b7f66800fbf9f47fddbcf2e2cd30ea932e0aae:
>
>   tcg: Remove unnecessary osdep.h includes from tcg-target.inc.c (2016-02-23 
> 08:31:03 -0800)
>
> 
> Queued TCG patches
>

Applied, thanks.

-- PMM



[Qemu-devel] [Bug 1543057] Re: Warnings are treated as errors

2016-02-25 Thread madship
I have same error "PCIDevice has no member named 'qdev'" with you.
Did you find any solutions to this error?

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

Title:
  Warnings are treated as errors

Status in QEMU:
  New

Bug description:
  System: Ubuntu 14.04, 32bit
  Kernel: 3.13.0-55-generic
  Qemu: v. 2.2.50

  Error msg:

  hw/acpi/pcihp.c: In function ‘acpi_pcihp_pc_no_hotplug’:
  hw/acpi/pcihp.c:117:34: error: ‘PCIDevice’ has no member named ‘qdev’
   return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable;
^
  hw/acpi/pcihp.c:118:1: error: control reaches end of non-void function 
[-Werror=return-type]
   }
   ^
  cc1: all warnings being treated as errors

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



Re: [Qemu-devel] [Qemu-ppc] Migrating decrementer

2016-02-25 Thread Mark Cave-Ayland
On 25/02/16 05:00, Mark Cave-Ayland wrote:

> On 25/02/16 04:33, Mark Cave-Ayland wrote:
> 
>> cpu_start/resume():
>> cpu->tb_env->tb_offset =
>> qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) * tb_env->tb_freq +
>> cpu->tb_env->tb_offset -
>> qemu_clock_get_ns(QEMU_CLOCK_HOST)
> 
> Actually just realised this is slightly wrong and in fact should be:
> 
> cpu_start/resume():
> cpu->tb_env->tb_offset =
> muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
>  cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) +
> cpu->tb_env->tb_offset -
> qemu_clock_get_ns(QEMU_CLOCK_HOST)

Sign. And let me try that again, this time after caffeine:

cpu_start/resume():
cpu->tb_env->tb_offset =
muldiv64(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL),
 cpu->tb_env->tb_freq, NANOSECONDS_PER_SECOND) +
cpu->tb_env->tb_offset -
cpu_get_host_ticks();

This should translate to: at CPU start, calculate the difference between
the current guest virtual timebase and the host timebase, storing the
difference in cpu->tb_env->tb_offset.


ATB,

Mark.




[Qemu-devel] [Bug 1549654] [NEW] qemu-system-arm emulator

2016-02-25 Thread Mehdi Amiri
Public bug reported:

Hi,

I don't know if this is a bug or a feature in new QEMU software. I was
following an online tutorial using QEMU  to develop a simple bare-metal
program for qemu-system-arm. I decided to try a more recent software and
I got surprised when I found the small code can not run on newer QEMU
software (all newer than 2.0.0) but can run on the old QEMU from Ubuntu
(Debian 2.0.0+dfsg-2ubuntu1.22) and the stock version from website.
After putting the qemu-system-arm in single step and saving the log, the
following is the output which you can see the 1st instruction stores R3
at [fp, #-8] and the second instruction can not restores the value from
the same address to R0:

0x00010074:  e50b3008  str  r3, [fp, #-8]

R00= R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=00010074
PSR=41d3 -Z-- A S svc32

IN: kmain
0x00010078:  e51b0008  ldr  r0, [fp, #-8]

R00= R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=00010078
PSR=41d3 -Z-- A S svc32

IN: kmain
0x0001007c:  ebe3  bl   0x10010

R00= R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=0001007c
PSR=41d3 -Z-- A S svc32

--
Meanwhile the older version of QEMU 2.0.0 does this very well and can execute 
the program normally:

0x00010074:  e50b3008  str  r3, [fp, #-8]

R00= R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=00010074
PSR=41d3 -Z-- A svc32

IN: kmain
0x00010078:  e51b0008  ldr  r0, [fp, #-8]

R00= R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=00010078
PSR=41d3 -Z-- A svc32

IN: kmain
0x0001007c:  ebe3  bl   0x10010

R00=0001008c R01= R02= R03=0001008c
R04= R05= R06= R07=
R08= R09= R10= R11=00011094
R12= R13=00011088 R14=00010008 R15=0001007c
PSR=41d3 -Z-- A svc32


The command line to use was:

qemu-system-arm -M vexpress-a9 -cpu cortex-a9 -smp 1 -m 64M -nographic
-kernel kernel.elf -singlestep -D file.log -d in_asm,cpu

The kernel.elf is a simple program (elf) file, created from two sources:

boot.S:

.global _RESET
_RESET:
LDR sp, =_STACK
BL kmain
B .

And kernel.c:

# define UART0_MEM   0x10009000

volatile unsigned int * const UART0 = (unsigned int *) UART0_MEM;
void dprint(const char* message){
while(*message != 0) {
*UART0=*message;
++message;
}
}
void kmain() {
const char *hi="Hello!";
dprint(hi);
};

The linker scripts is:
ENTRY(_RESET)
SECTIONS
{
 . = 0x1;
 .boot . : { boot.o(.text) }
 .text : { *(.text) }
 .data : { *(.data) }
 .bss : { *(.bss COMMON) }
 . = ALIGN(8);
 . = . + 0x1000; /* 4kB of stack memory */
 _STACK = .;
}

This error cases the dprint function to find *message as 0 and do not
print the output in newer QEMU software.

Thank you for consideration.

** Affects: qemu
 Importance: Undecided
 Status: New

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

Title:
  qemu-system-arm emulator

Status in QEMU:
  New

Bug description:
  Hi,

  I don't know if this is a bug or a feature in new QEMU software. I was
  following an online tutorial using QEMU  to develop a simple bare-
  metal program for qemu-system-arm. I decided to try a more recent
  software and I got surprised when I found the small code can not run
  on newer QEMU software (all newer than 2.0.0) but can run on the old
  QEMU from Ubuntu (Debian 2.0.0+dfsg-2ubuntu1.22) and the stock version
  from website. After putting the qemu-system-arm in single step and
  saving the log, the following is the output which you can see the 1st
  instruction stores R3 at [fp, #-8] and the second instruction can not
  restores the value from the same address to R0:

  0x00010074:  e50b3008  str  r3, [fp, #-8]

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=00010074
  PSR=41d3 -Z-- A S svc32
  
  IN: kmain
  0x00010078:  e51b0008  ldrr0, 

Re: [Qemu-devel] kvm: "warning: host doesn't support requested feature: CPUID.01H:ECX.x2apic [bit 21]"

2016-02-25 Thread Lan Tianyu
2016-02-20 17:00 GMT+08:00 Paolo Bonzini :
>
>
> - Original Message -
>> From: "Jan Kiszka" 
>> To: "Eduardo Habkost" , "Paolo Bonzini" 
>> 
>> Cc: "qemu-devel" , "kvm" 
>> Sent: Saturday, February 20, 2016 9:09:32 AM
>> Subject: kvm: "warning: host doesn't support requested feature: 
>> CPUID.01H:ECX.x2apic [bit 21]"
>>
>> Hi all,
>>
>> I suppose 5120901a37 introduced this: qemu with kernel_irqchip=off now
>> generates these warnings, one per VCPU, during QEMU startup. Is the plan
>> to live with them until we finally have x2APIC emulation in userspace
>> (ie. also MSR vmexiting to there), or should we otherwise avoid it?
>
> I think it's a bug, x2apic should be auto-suppressed with kernel_irqchip=off.
>

The patch is to fix the issue.
->8
>From 58f2a3a94c8e7bf9f3474bcafb6c59cc4f8bcbd9 Mon Sep 17 00:00:00 2001
From: Lan Tianyu 
Date: Sun, 15 Jul 2001 01:40:17 -0400
Subject: [PATCH] Qemu/KVM: Remove x2apic feature from CPU model when
 kernel_irqchip=off

x2apic feature is in the kvm_default_props and automatically added to all
CPU models when KVM is enabled regardless of kernel_irqchip=off. This will
trigger "warning: host doesn't support requested feature: CPUID.01H:
ECX.x2apic [bit 21]" when kernel_irqchip=off. This patch is to remove x2apic
feature when kernel_irqchip=off.

Signed-off-by: Lan Tianyu 
---
 target-i386/cpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0d447b5..2ec7eb7 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -2105,6 +2105,9 @@ static void x86_cpu_load_def(X86CPU *cpu,
X86CPUDefinition *def, Error **errp)

 /* Special cases not set in the X86CPUDefinition structs: */
 if (kvm_enabled()) {
+   if (!kvm_irqchip_in_kernel())
+   x86_cpu_change_kvm_default("x2apic", "off");
+
 x86_cpu_apply_props(cpu, kvm_default_props);
 }

--
1.9.3



Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Vladimir Sementsov-Ogievskiy

On 25.02.2016 12:11, Michael S. Tsirkin wrote:

On Thu, Feb 25, 2016 at 11:55:56AM +0300, Vladimir Sementsov-Ogievskiy wrote:

On 25.02.2016 11:39, Michael S. Tsirkin wrote:

On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir Sementsov-Ogievskiy wrote:

Stop!

It builds fine here. Did you check out my tree?

anyway, this file should be here, as it is added into Makefile:

--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
  stub-obj-$(CONFIG_WIN32) += fd-register.o
  stub-obj-y += cpus.o
  stub-obj-y += kvm.o
-stub-obj-y += qmp_pc_dimm_device_list.o
+stub-obj-y += pc_dimm.o
  stub-obj-y += target-monitor-defs.o
  stub-obj-y += target-get-monitor-def.o
  stub-obj-y += vhost.o


Hmm that's right.
Thanks!
Looks like it was picking up an old object in the filesystem :(
I'll respin - for now, does everything work for you if you drop
this line from the makefile?


it will break compilation for targets without memory hotplug, it was 
discussed on list. stubs are necessary.





===
git clone git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tmp
cd tmp/
git checkout for_upstream
./configure  --target-list=x86_64-softmmu
make -j9

make: *** No rule to make target `stubs/pc_dimm.o', needed by

`libqemustub.a'.  Stop



--
Best regards,
Vladimir




[Qemu-devel] [PATCH] MAINTAINERS: Remove the old s390-virtio machine

2016-02-25 Thread Thomas Huth
The old s390-virtio machine has been removed last year, so we don't
need the corresponding section in the MAINTAINERS file anymore.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 6 --
 1 file changed, 6 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9148966..341574c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -653,12 +653,6 @@ F: hw/*/grlib*
 
 S390 Machines
 -
-S390 Virtio
-M: Alexander Graf 
-S: Maintained
-F: hw/s390x/s390-*.c
-X: hw/s390x/*pci*.[hc]
-
 S390 Virtio-ccw
 M: Cornelia Huck 
 M: Christian Borntraeger 
-- 
1.8.3.1




Re: [Qemu-devel] [PULL v2 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Vladimir Sementsov-Ogievskiy
here stubs are deleted. it will break compilation for targets without 
memory hotplug, it was discussed on list. stubs from my patch are 
necessary.


On 25.02.2016 12:16, Michael S. Tsirkin wrote:

From: Vladimir Sementsov-Ogievskiy 

Like pc_dimm_build_list_sorted but not sorted - for cases where sorting
is not necessary. Add stubbed version too - for targets without
CONFIG_MEM_HOTPLUG.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
Reviewed-by: Michael S. Tsirkin 
Signed-off-by: Michael S. Tsirkin 
---
  include/hw/mem/pc-dimm.h|  3 +++
  hw/mem/pc-dimm.c| 15 +++
  stubs/qmp_pc_dimm_device_list.c |  8 
  stubs/Makefile.objs |  1 -
  4 files changed, 18 insertions(+), 9 deletions(-)
  delete mode 100644 stubs/qmp_pc_dimm_device_list.c

diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 218dfb0..0f587a4 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -94,4 +94,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState 
*hpms,
   MemoryRegion *mr, uint64_t align, Error **errp);
  void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
 MemoryRegion *mr);
+
+int pc_dimm_build_list(Object *obj, void *opaque);
+
  #endif
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 835179e..09e99ce 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -267,6 +267,21 @@ static int pc_dimm_build_list_sorted(Object *obj, void 
*opaque)
  return 0;
  }
  
+int pc_dimm_build_list(Object *obj, void *opaque)

+{
+GSList **list = opaque;
+
+if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+DeviceState *dev = DEVICE(obj);
+if (dev->realized) { /* only realized DIMMs matter */
+*list = g_slist_prepend(*list, dev);
+}
+}
+
+object_child_foreach(obj, pc_dimm_build_list, opaque);
+return 0;
+}
+
  uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
 uint64_t address_space_size,
 uint64_t *hint, uint64_t align, uint64_t size,
diff --git a/stubs/qmp_pc_dimm_device_list.c b/stubs/qmp_pc_dimm_device_list.c
deleted file mode 100644
index def2115..000
--- a/stubs/qmp_pc_dimm_device_list.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "qemu/osdep.h"
-#include "qom/object.h"
-#include "hw/mem/pc-dimm.h"
-
-int qmp_pc_dimm_device_list(Object *obj, void *opaque)
-{
-   return 0;
-}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index e922de9..bccd445 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -35,7 +35,6 @@ stub-obj-y += vmstate.o
  stub-obj-$(CONFIG_WIN32) += fd-register.o
  stub-obj-y += cpus.o
  stub-obj-y += kvm.o
-stub-obj-y += qmp_pc_dimm_device_list.o
  stub-obj-y += target-monitor-defs.o
  stub-obj-y += target-get-monitor-def.o
  stub-obj-y += vhost.o



--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH] doc/memory.txt: fix typo

2016-02-25 Thread Peter Maydell
On 25 February 2016 at 09:32, Cao jin  wrote:
> to match structure MemoryRegionOps definition
>
> Signed-off-by: Cao jin 
> ---
> And there seems are some out of date content in this file, like
> "cpu_register_io_memory()" mentioned in the last line, which is removed 
> several
> years ago in commit 97161e177. I am sure how to modify it, So I take the
> liberty to CC the guys in the cc-list(get list from get_maintainer.pl).k

The part that says
# - .old_mmio can be used to ease porting from code using
#   cpu_register_io_memory(). It should not be used in new code.

could be changed to say "has been used to ease porting from code that
used to use cpu_register_io_memory()" if you like. The information
here is not wrong, really, just the tense.

(There are just 32 uses of old_mmio left in the codebase, which
hopefully we may eventually get rid of.)

>  docs/memory.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/docs/memory.txt b/docs/memory.txt
> index 8745f76..1a3ad622 100644
> --- a/docs/memory.txt
> +++ b/docs/memory.txt
> @@ -297,7 +297,7 @@ various constraints can be supplied to control how these 
> callbacks are called:
>   - .valid.min_access_size, .valid.max_access_size define the access sizes
> (in bytes) which the device accepts; accesses outside this range will
> have device and bus specific behaviour (ignored, or machine check)
> - - .valid.aligned specifies that the device only accepts naturally aligned
> + - .valid.unaligned specifies that the device only accepts naturally aligned
> accesses.  Unaligned accesses invoke device and bus specific behaviour.

This doesn't look like the right change, because (a) a field named
unaligned which you set true to specifiy that unaligned accesses
are invalid would be very confusing and (b) the comment in the
header file says that 'valid.unaligned' means that the device does
support unaligned accesses.

>   - .impl.min_access_size, .impl.max_access_size define the access sizes
> (in bytes) supported by the *implementation*; other access sizes will be

We also seem to be missing documentation of valid.accepts.

thanks
-- PMM



Re: [Qemu-devel] [PATCH] MAINTAINERS: Remove the old s390-virtio machine

2016-02-25 Thread Thomas Huth
On 25.02.2016 10:57, Thomas Huth wrote:
> The old s390-virtio machine has been removed last year, so we don't
> need the corresponding section in the MAINTAINERS file anymore.
> 
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS | 6 --
>  1 file changed, 6 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9148966..341574c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -653,12 +653,6 @@ F: hw/*/grlib*
>  
>  S390 Machines
>  -
> -S390 Virtio
> -M: Alexander Graf 
> -S: Maintained
> -F: hw/s390x/s390-*.c
> -X: hw/s390x/*pci*.[hc]
> -
>  S390 Virtio-ccw
>  M: Cornelia Huck 
>  M: Christian Borntraeger 

By the way, I think you can now also remove the "X:
hw/s390x/s390-virtio-bus.[ch]" entry from the virtio-ccw machine, since
these two files do not exist anymore.

 Thomas




[Qemu-devel] [PATCH] Postcopy: Fix sync count in info migrate

2016-02-25 Thread Dr. David Alan Gilbert (git)
From: "Dr. David Alan Gilbert" 

I'd missed the sync count off in the postcopy case.

Signed-off-by: Dr. David Alan Gilbert 
---
 migration/migration.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/migration/migration.c b/migration/migration.c
index fc5e50b..34d3e5f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -626,6 +626,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
 info->ram->normal_bytes = norm_mig_bytes_transferred();
 info->ram->dirty_pages_rate = s->dirty_pages_rate;
 info->ram->mbps = s->mbps;
+info->ram->dirty_sync_count = s->dirty_sync_count;
 
 if (blk_mig_active()) {
 info->has_disk = true;
-- 
2.5.0




Re: [Qemu-devel] [PATCH] doc/memory.txt: fix typo

2016-02-25 Thread Cao jin



On 02/25/2016 06:00 PM, Peter Maydell wrote:

On 25 February 2016 at 09:32, Cao jin  wrote:

to match structure MemoryRegionOps definition

Signed-off-by: Cao jin 
---
And there seems are some out of date content in this file, like
"cpu_register_io_memory()" mentioned in the last line, which is removed several
years ago in commit 97161e177. I am sure how to modify it, So I take the
liberty to CC the guys in the cc-list(get list from get_maintainer.pl).k




Hi peter,
Thanks for your quick response.
Can`t believe I miss a "not" in my word..."I am not sure how to modify 
it" so I CC you guys:)



--
Yours Sincerely,

Cao jin





Re: [Qemu-devel] [PATCH 1/2] virtio-balloon: export all balloon statistics

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 12:30:21PM +0300, Roman Kagan wrote:
> On Thu, Feb 25, 2016 at 10:54:17AM +0200, Michael S. Tsirkin wrote:
> > On Thu, Feb 25, 2016 at 09:44:06AM +0100, Markus Armbruster wrote:
> > > "Denis V. Lunev"  writes:
> > > 
> > > > On 02/24/2016 06:43 PM, Eric Blake wrote:
> > > >> On 02/24/2016 07:31 AM, Michael S. Tsirkin wrote:
> > > >>> Roman Kagan  writes:
> > >  On Tue, Feb 23, 2016 at 05:49:21PM +0200, Michael S. Tsirkin wrote:
> > > > On Tue, Feb 23, 2016 at 06:29:33PM +0300, Denis V. Lunev wrote:
> > > > > On 02/23/2016 06:24 PM, Michael S. Tsirkin wrote:
> > > > > >On Tue, Feb 23, 2016 at 05:59:44PM +0300, Denis V. Lunev wrote:
> > > > > >>From: Igor Redko 
> > > > > >>
> > > > > >>We are making experiments with different autoballooning 
> > > > > >>strategies
> > > > > >>based on the guest behavior. Thus we need to experiment with 
> > > > > >>different
> > > > > >>guest statistics. For now every counter change requires QEMU 
> > > > > >>recompilation
> > > > > >>and dances with Libvirt.
> > > > > >>
> > > > > >>This patch introduces transport for unrecognized counters in 
> > > > > >>virtio-balloon.
> > > > > >>This transport can be used for measuring benefits from using new
> > > > > >>balloon counters, before submitting any patches. Current 
> > > > > >>alternative
> > > > > >>is 'guest-exec' transport which isn't made for such delicate 
> > > > > >>matters
> > > > > >>and can influence test results.
> > > > > >>
> > > > > >>Originally all counters with tag >= VIRTIO_BALLOON_S_NR were 
> > > > > >>ignored.
> > > > > >>Instead of this we keep first (VIRTIO_BALLOON_S_NR + 32) 
> > > > > >>counters from the
> > > > > >>queue and pass unrecognized ones with the following names: 
> > > > > >>'x-stat-',
> > > > > >>where  is a tag number in hex. Defined counters are 
> > > > > >>reported with their
> > > > > >>regular names.
> > > > > >>
> > > > > >>Signed-off-by: Igor Redko 
> > > > > >>Signed-off-by: Denis V. Lunev 
> > > > > >>CC: Michael S. Tsirkin 
> > > > > >This seems to open the ABI to abuse.
> > > > > >Seems like a reasonable way to experiment though.
> > > > > >How about adding this within #if 0 statements?
> > > > > >You can uncomment them for debugging ...
> > > > > I'd prefer to have this enabled.
> > > 
> > > Yes, conditional compilation should be used sparingly.  I don't have an
> > > opinion on whether using it here is appropriate.
> > > 
> > > > > Why do you think that it opens "abuse" way?
> > > > 
> > > > Because people will use this to hack drivers and management tools
> > > > bypassing qemu.
> > > 
> > > Easy to avoid: shuffle the N in x-stat-N around from time to time, to
> > > reinforce the lesson that you must not rely on their presence or
> > > semantics.  I doubt it'll be necessary beyond the renumbering that
> > > happens naturally when we add supported counters, or the reshuffling
> > > that happens when somebody messes with the unsupported counters.
> > > 
> > >  I'm curious why you think it's a problem?  Even the existing stats 
> > >  are
> > >  simply propagated to the management level by qemu with no processing
> > >  other than assigning text labels.  The proposed naming scheme for
> > >  unrecognized counters includes "x-" prefix which explicitly marks 
> > >  them
> > >  as unstable so people using them take their risk.
> > > 
> > >  One of the benefits is forward compatibility, so that counters that 
> > >  have
> > >  graduated into supported ones and have got their own number and name,
> > >  can be made to work with qemu that doesn't yet recognize them.
> > > >>> Then management does start relying on the x- prefixed things,
> > > >>> and once it's used to that it's a slippery slope.
> > > >> Any management tool that relies on an x- prefix name is broken.
> > > 
> > > Or at least assumes the full risk of breaking without notice whenever
> > > QEMU changes.  Abbreviating that to just "broken" seems fair enough :)
> > > 
> > > >>  We've
> > > >> explicitly documented that the x- prefix is unstable and liable to go
> > > >> away with a future release. Any management app that wants to use a
> > > >> feature beginning with x- should FIRST push hard to get the x- removed
> > > >> and stabilize the interface (and libvirt, at least, does just that).
> > > >>
> > > > this was exactly an original idea. Names started with 'x-' are
> > > > _officially_ unstable and for debug purpose. That is why I'd
> > > > prefer if v2 of the patchset will be taken.
> > > 
> > > Looks like fair use of x- to me.
> > 
> > 
> > Well I already heard:
> > 
> > One of the benefits is forward compatibility, so that counters that have
> > graduated into supported ones and have

Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Paolo Bonzini


On 25/02/2016 10:54, Vladimir Sementsov-Ogievskiy wrote:
> On 25.02.2016 12:11, Michael S. Tsirkin wrote:
>> On Thu, Feb 25, 2016 at 11:55:56AM +0300, Vladimir Sementsov-Ogievskiy
>> wrote:
>>> On 25.02.2016 11:39, Michael S. Tsirkin wrote:
 On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir
 Sementsov-Ogievskiy wrote:
> Stop!
 It builds fine here. Did you check out my tree?
>>> anyway, this file should be here, as it is added into Makefile:
>>>
>>> --- a/stubs/Makefile.objs
>>> +++ b/stubs/Makefile.objs
>>> @@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
>>>   stub-obj-$(CONFIG_WIN32) += fd-register.o
>>>   stub-obj-y += cpus.o
>>>   stub-obj-y += kvm.o
>>> -stub-obj-y += qmp_pc_dimm_device_list.o
>>> +stub-obj-y += pc_dimm.o
>>>   stub-obj-y += target-monitor-defs.o
>>>   stub-obj-y += target-get-monitor-def.o
>>>   stub-obj-y += vhost.o
>>>
>> Hmm that's right.
>> Thanks!
>> Looks like it was picking up an old object in the filesystem :(
>> I'll respin - for now, does everything work for you if you drop
>> this line from the makefile?
> 
> it will break compilation for targets without memory hotplug, it was
> discussed on list. stubs are necessary.

mst,

indeed it's not clear to me why you're deleting qmp_pc_dimm_device_list.c...

On the other hand, pc_dimm_build_list doesn't need a stub.  Just put it
in hw/virtio/virtio-balloon.c.

Paolo

> 
>>
>>> ===
>>> git clone git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tmp
>>> cd tmp/
>>> git checkout for_upstream
>>> ./configure  --target-list=x86_64-softmmu
>>> make -j9
 make: *** No rule to make target `stubs/pc_dimm.o', needed by
>>> `libqemustub.a'.  Stop
> 
> 



Re: [Qemu-devel] [PATCH 1/9] dma-helpers: Expose the sg mapping logic

2016-02-25 Thread Alex Pyrgiotis
Hi Paolo,

Thanks a lot for your clarifications. See my comments inline:

(tl;dr: I suggest we reconsider Fam Zheng's attempt to remove the global
bounce buffer, which would make dma-helpers simpler and unblock this patch)

On 02/22/2016 12:43 PM, Paolo Bonzini wrote:
> 
> 
> On 19/02/2016 12:50, Alex Pyrgiotis wrote:
>> QEMU/Hardware space:
>> 5. The SCSI controller code will create a QEMUSGList that points to
>>the memory regions of the SCSI request. This QEMUSGList will also
>>include the MMIO regions.
>> 6. The QEMU device implementation, e.g. scsi-block, chooses to use
>>the dma_* interface.
>> 7. The dma_blk_read/write() code will ultimately attempt to map all the
>>memory regions pointed by the QEMUSGList in order to create a
>>QEMUIOVector.
>> 8. At some point during the mapping loop, the code will encounter an
>>MMIO region. Since reading and writing from/to an MMIO region
>>requires  special handling, e.g., we need to call
>>MemoryRegion->ops->write(), we cannot include it in our read/write
>>system call to the host kernel.

This step and the next one were not clear to me, but thanks to your
comments, I now get what's happening behind the scenes. So, let's reiterate:

All normal regions in a QEMUSGList point to an address range in the
guest's RAM. The MMIO regions of QEMU's virtual devices, however, do not
correspond to such an address range, so QEMU must create a bounce buffer
to represent them. This bounce buffer is added in the I/O vector which
contains the rest of the mapped addresses and is later given to a
readv()/writev() call.

>> 9. This leads to a partial read/write and the mapping loop will resume
>>once the partial read/write() has finished.

The MMIO region is the trigger for a partial read/write, but it's not
the actual reason. The actual reason is that there is only *one*
*global* bounce buffer. This means that if it's in use it or we
need to use it twice, we will have to wait.

>> Are we in the same page so far?
> 
> Yes.
> 
>> Are the above OK? If so, I have some questions:
>>
>> a) Is an MMIO region one of the reasons why we can't map an sg?
> 
> Yes, the only one pretty much.
> 
>> b) At which point will the relevant ops->write() method for the MMIO
>>region be called when we have to DMA into the region?? Is it handled
>>implicitly in dma_memory_map()?
> 
> It's in address_space_unmap:
> 
> if (is_write) {
> address_space_write(as, bounce.addr, MEMTXATTRS_UNSPECIFIED,
> bounce.buffer, access_len);
> }
> 
> Likewise, address_space_map does the ops->read call through
> address_space_read.
> 
>> c) I'm not quite sure about the logic of the "nothing mapped" section.
>>Correct me if I'm wrong, but what I think it does is that it
>>registers a callback (reschedule_dma) once some sort of mapping has
>>completed. What kind of mapping is this? Is there anything more to
>>it?
> 
> Once something (presumably a concurrent user of dma-helpers.c) calls
> address_space_unmap to free the mapping (the bounce.buffer in the above
> address_space_write call), reschedule_dma is called.
>
>>> However, it is not possible to do the same for ioctls.  This is actually
>>> the reason why no one has ever tried to make scsi-generic do anything
>>> but bounce-buffering. I think that your code breaks horribly in this
>>> case, and I don't see a way to fix it, except for reverting to bounce
>>> buffering.

Sure, you're right, there's no sensible way to break an ioctl()
operation in many. However, I'd argue that we shouldn't need to, as it
would be much better if the DMA operation was never restarted in the
first place. Instead, if we dealt with the bigger issue of the global
bounce buffer, we could kill two birds with one stone.

I see that there was an attempt [1] to replace the global bounce buffer
with something more dynamic. In short, the objections [2] were the
following:

1. It introduced locking/unlocking a global mutex in the hot path as
   well as a hash table lookup.
2. It allowed for unbounded memory allocations.

An improvement that would address (1) is to get rid of any global state:

Since the mapping operation takes place in the context of a DMA
operation, we could provide a ctx-type struct to the dma_memory_(un)map
--> address_space_(un)map functions that would contain a hash table. If
any memory allocations were needed, we would track them using that hash
table, which would require no locks. Moreover, if the initialization of
the hash table hurts the performance in the general case, we could use
instead a skip list, if the number of memory allocations is small (e.g.
< 100).

If a mapping operation does not take place in the context of a DMA
operation, we could pass NULL and the address_space_(un)map code would
fallback to the global bounce buffer. Having a fallback would allow for
a smooth transition.

As for the point raised in (2), we can have a limit on the allocated
pages, e.g. 1024

[Qemu-devel] [PATCH] MAINTAINERS: Add an entry for virtio header files

2016-02-25 Thread Thomas Huth
Files in the include/hw/virtio/ folder should be included in the
"virtio" sections of the MAINTAINERS file.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 341574c..cda55c4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -873,6 +873,7 @@ M: Michael S. Tsirkin 
 S: Supported
 F: hw/*/virtio*
 F: net/vhost-user.c
+F: include/hw/virtio/
 
 virtio-9p
 M: Aneesh Kumar K.V 
-- 
1.8.3.1




Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 11:09:16AM +0100, Paolo Bonzini wrote:
> 
> 
> On 25/02/2016 10:54, Vladimir Sementsov-Ogievskiy wrote:
> > On 25.02.2016 12:11, Michael S. Tsirkin wrote:
> >> On Thu, Feb 25, 2016 at 11:55:56AM +0300, Vladimir Sementsov-Ogievskiy
> >> wrote:
> >>> On 25.02.2016 11:39, Michael S. Tsirkin wrote:
>  On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir
>  Sementsov-Ogievskiy wrote:
> > Stop!
>  It builds fine here. Did you check out my tree?
> >>> anyway, this file should be here, as it is added into Makefile:
> >>>
> >>> --- a/stubs/Makefile.objs
> >>> +++ b/stubs/Makefile.objs
> >>> @@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
> >>>   stub-obj-$(CONFIG_WIN32) += fd-register.o
> >>>   stub-obj-y += cpus.o
> >>>   stub-obj-y += kvm.o
> >>> -stub-obj-y += qmp_pc_dimm_device_list.o
> >>> +stub-obj-y += pc_dimm.o
> >>>   stub-obj-y += target-monitor-defs.o
> >>>   stub-obj-y += target-get-monitor-def.o
> >>>   stub-obj-y += vhost.o
> >>>
> >> Hmm that's right.
> >> Thanks!
> >> Looks like it was picking up an old object in the filesystem :(
> >> I'll respin - for now, does everything work for you if you drop
> >> this line from the makefile?
> > 
> > it will break compilation for targets without memory hotplug, it was
> > discussed on list. stubs are necessary.
> 
> mst,
> 
> indeed it's not clear to me why you're deleting qmp_pc_dimm_device_list.c...
> 
> On the other hand, pc_dimm_build_list doesn't need a stub.  Just put it
> in hw/virtio/virtio-balloon.c.
> 
> Paolo

Bad merge and I corrupted my test system again so it was
missing the problem :(

I'm fixing it up, thanks everyone!

> > 
> >>
> >>> ===
> >>> git clone git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tmp
> >>> cd tmp/
> >>> git checkout for_upstream
> >>> ./configure  --target-list=x86_64-softmmu
> >>> make -j9
>  make: *** No rule to make target `stubs/pc_dimm.o', needed by
> >>> `libqemustub.a'.  Stop
> > 
> > 



[Qemu-devel] [PATCH] MAINTAINERS: Add an entry for the include/hw/virtio/dataplane folder

2016-02-25 Thread Thomas Huth
dataplane header files belong to virtio-blk, so there should be a
corresponding entry in the MAINTAINERS file.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index cda55c4..901a1b2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -891,6 +891,7 @@ S: Supported
 F: hw/block/virtio-blk.c
 F: hw/block/dataplane/*
 F: hw/virtio/dataplane/*
+F: include/hw/virtio/dataplane/
 T: git git://github.com/stefanha/qemu.git block
 
 virtio-ccw
-- 
1.8.3.1




[Qemu-devel] [Bug 1543057] Re: Warnings are treated as errors

2016-02-25 Thread Peter Maydell
(a) That warnings are treated as errors  is a feature, not a bug (it happens 
for development builds only)
(b) the definition of struct PCIDevice in include/hw/pci/pci.h starts with 
"DeviceState qdev;" so it's not clear to me how that error could be produced in 
the first place

I see the original submitter was using 2.2.50 -- I suggest using either
(a) a release build of QEMU or (b) current master. 2.2.50 will be from
somewhere on trunk between 2.2 and 2.3, so might quite possibly have had
a build bug that was quickly fixed subsequently.

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

Title:
  Warnings are treated as errors

Status in QEMU:
  New

Bug description:
  System: Ubuntu 14.04, 32bit
  Kernel: 3.13.0-55-generic
  Qemu: v. 2.2.50

  Error msg:

  hw/acpi/pcihp.c: In function ‘acpi_pcihp_pc_no_hotplug’:
  hw/acpi/pcihp.c:117:34: error: ‘PCIDevice’ has no member named ‘qdev’
   return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable;
^
  hw/acpi/pcihp.c:118:1: error: control reaches end of non-void function 
[-Werror=return-type]
   }
   ^
  cc1: all warnings being treated as errors

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



Re: [Qemu-devel] [PATCH 1/9] dma-helpers: Expose the sg mapping logic

2016-02-25 Thread Paolo Bonzini


On 25/02/2016 11:10, Alex Pyrgiotis wrote:
> All normal regions in a QEMUSGList point to an address range in the
> guest's RAM. The MMIO regions of QEMU's virtual devices, however, do not
> correspond to such an address range, so QEMU must create a bounce buffer
> to represent them. This bounce buffer is added in the I/O vector which
> contains the rest of the mapped addresses and is later given to a
> readv()/writev() call.

Correct.

>>> 9. This leads to a partial read/write and the mapping loop will resume
>>>once the partial read/write() has finished.
> 
> The MMIO region is the trigger for a partial read/write, but it's not
> the actual reason. The actual reason is that there is only *one*
> *global* bounce buffer. This means that if it's in use it or we
> need to use it twice, we will have to wait.

Yes.

 However, it is not possible to do the same for ioctls.  This is actually
 the reason why no one has ever tried to make scsi-generic do anything
 but bounce-buffering. I think that your code breaks horribly in this
 case, and I don't see a way to fix it, except for reverting to bounce
 buffering.
> 
> Sure, you're right, there's no sensible way to break an ioctl()
> operation in many. However, I'd argue that we shouldn't need to, as it
> would be much better if the DMA operation was never restarted in the
> first place. Instead, if we dealt with the bigger issue of the global
> bounce buffer, we could kill two birds with one stone.
> 
> I see that there was an attempt [1] to replace the global bounce buffer
> with something more dynamic. In short, the objections [2] were the
> following:
> 
> 1. It introduced locking/unlocking a global mutex in the hot path as
>well as a hash table lookup.
> 2. It allowed for unbounded memory allocations.
> 
> An improvement that would address (1) is to get rid of any global state:
> 
> Since the mapping operation takes place in the context of a DMA
> operation, we could provide a ctx-type struct to the dma_memory_(un)map
> --> address_space_(un)map functions that would contain a hash table. If
> any memory allocations were needed, we would track them using that hash
> table, which would require no locks. Moreover, if the initialization of
> the hash table hurts the performance in the general case, we could use
> instead a skip list, if the number of memory allocations is small (e.g.
> < 100).

You don't need a hash table either if you manage the bounce buffer list
per DMA transfer, and the simplest way to achieve that is to move the
bounce buffer from exec.c to dma-helpers.c entirely.

The patch could first introduce address_space_map_direct that never uses
the bounce buffer.  dma-helpers.c can call address_space_map_direct and,
if it fails, proceed to allocate (and fill if writing to the device) a
bounce buffer.  Since the QEMUSGList is mapped and unmapped
beginning-to-end, you can just use a FIFO queue.  The FIFO queue stores
a (QEMUSGList, buffer) tuple.  When unmapping a QEMUSGList you check if
it matches the head of the queue; if it does, you write back the
contents of the bounce buffer (for reads from the device) and free it.
If it doesn't match, you call address_space_unmap.

Then, once the bounce buffer is implemented within dma-helpers.c, you
remove address_space_map and rename address_space_map_direct to
address_space_map.  cpu_register_map_client goes away.

The unbounded memory allocation can be avoided by bounding the number of
entries in the queue.  In the case of scsi-generic you could just as
well allow INT_MAX entries, because scsi-generic would do unbounded
memory allocation anyway for the bounce buffer.

Modulo the "& BDRV_SECTOR_MASK" issue, this actually seems simpler than
what this series was doing.

Paolo



Re: [Qemu-devel] [PULL 05/23] pc-dimm: add pc_dimm_build_list()

2016-02-25 Thread Michael S. Tsirkin
On Thu, Feb 25, 2016 at 11:09:16AM +0100, Paolo Bonzini wrote:
> 
> 
> On 25/02/2016 10:54, Vladimir Sementsov-Ogievskiy wrote:
> > On 25.02.2016 12:11, Michael S. Tsirkin wrote:
> >> On Thu, Feb 25, 2016 at 11:55:56AM +0300, Vladimir Sementsov-Ogievskiy
> >> wrote:
> >>> On 25.02.2016 11:39, Michael S. Tsirkin wrote:
>  On Thu, Feb 25, 2016 at 10:01:18AM +0300, Vladimir
>  Sementsov-Ogievskiy wrote:
> > Stop!
>  It builds fine here. Did you check out my tree?
> >>> anyway, this file should be here, as it is added into Makefile:
> >>>
> >>> --- a/stubs/Makefile.objs
> >>> +++ b/stubs/Makefile.objs
> >>> @@ -35,7 +35,7 @@ stub-obj-y += vmstate.o
> >>>   stub-obj-$(CONFIG_WIN32) += fd-register.o
> >>>   stub-obj-y += cpus.o
> >>>   stub-obj-y += kvm.o
> >>> -stub-obj-y += qmp_pc_dimm_device_list.o
> >>> +stub-obj-y += pc_dimm.o
> >>>   stub-obj-y += target-monitor-defs.o
> >>>   stub-obj-y += target-get-monitor-def.o
> >>>   stub-obj-y += vhost.o
> >>>
> >> Hmm that's right.
> >> Thanks!
> >> Looks like it was picking up an old object in the filesystem :(
> >> I'll respin - for now, does everything work for you if you drop
> >> this line from the makefile?
> > 
> > it will break compilation for targets without memory hotplug, it was
> > discussed on list. stubs are necessary.
> 
> mst,
> 
> indeed it's not clear to me why you're deleting qmp_pc_dimm_device_list.c...
> 
> On the other hand, pc_dimm_build_list doesn't need a stub.  Just put it
> in hw/virtio/virtio-balloon.c.
> 
> Paolo

Like this then?

diff --git a/include/hw/mem/pc-dimm.h b/include/hw/mem/pc-dimm.h
index 0f587a4..f6cbc78 100644
--- a/include/hw/mem/pc-dimm.h
+++ b/include/hw/mem/pc-dimm.h
@@ -95,6 +95,4 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugState 
*hpms,
 void pc_dimm_memory_unplug(DeviceState *dev, MemoryHotplugState *hpms,
MemoryRegion *mr);
 
-int pc_dimm_build_list(Object *obj, void *opaque);
-
 #endif
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 09e99ce..835179e 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -267,21 +267,6 @@ static int pc_dimm_build_list_sorted(Object *obj, void 
*opaque)
 return 0;
 }
 
-int pc_dimm_build_list(Object *obj, void *opaque)
-{
-GSList **list = opaque;
-
-if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
-DeviceState *dev = DEVICE(obj);
-if (dev->realized) { /* only realized DIMMs matter */
-*list = g_slist_prepend(*list, dev);
-}
-}
-
-object_child_foreach(obj, pc_dimm_build_list, opaque);
-return 0;
-}
-
 uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
uint64_t address_space_size,
uint64_t *hint, uint64_t align, uint64_t size,
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 3fb6c52..24eab0a 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -305,12 +305,27 @@ static void virtio_balloon_get_config(VirtIODevice *vdev, 
uint8_t *config_data)
 memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
 }
 
+int build_dimm_list(Object *obj, void *opaque)
+{
+GSList **list = opaque;
+
+if (object_dynamic_cast(obj, TYPE_PC_DIMM)) {
+DeviceState *dev = DEVICE(obj);
+if (dev->realized) { /* only realized DIMMs matter */
+*list = g_slist_prepend(*list, dev);
+}
+}
+
+object_child_foreach(obj, build_dimm_list, opaque);
+return 0;
+}
+
 static ram_addr_t get_current_ram_size(void)
 {
 GSList *list = NULL, *item;
 ram_addr_t size = ram_size;
 
-pc_dimm_build_list(qdev_get_machine(), &list);
+build_dimm_list(qdev_get_machine(), &list);
 for (item = list; item; item = g_slist_next(item)) {
 Object *obj = OBJECT(item->data);
 if (!strcmp(object_get_typename(obj), TYPE_PC_DIMM)) {





Re: [Qemu-devel] [RFC] QMP: add query-hotpluggable-cpus

2016-02-25 Thread Igor Mammedov
On Thu, 25 Feb 2016 12:03:21 +1100
David Gibson  wrote:

> On Wed, Feb 24, 2016 at 12:03:41PM +0100, Igor Mammedov wrote:
> > On Wed, 24 Feb 2016 21:51:19 +1100
> > David Gibson  wrote:
> >   
> > > On Wed, Feb 24, 2016 at 09:42:10AM +0100, Markus Armbruster wrote:  
> > > > David Gibson  writes:
> > > > 
> > > > > On Mon, Feb 22, 2016 at 10:05:54AM +0100, Markus Armbruster wrote:
> > > > >> David Gibson  writes:
> > > > >> 
> > > > >> > On Fri, Feb 19, 2016 at 10:51:11AM +0100, Markus Armbruster wrote: 
> > > > >> >
> > > > >> >> David Gibson  writes:
> > > > >> >> 
> > > > >> >> > On Thu, Feb 18, 2016 at 11:37:39AM +0100, Igor Mammedov wrote:  
> > > > >> >> >   
> > > > >> >> >> On Thu, 18 Feb 2016 14:39:52 +1100
> > > > >> >> >> David Gibson  wrote:
> > > > >> >> >> 
> > > > >> >> >> > On Tue, Feb 16, 2016 at 11:36:55AM +0100, Igor Mammedov 
> > > > >> >> >> > wrote:
> > > > >> >> >> > > On Mon, 15 Feb 2016 20:43:41 +0100
> > > > >> >> >> > > Markus Armbruster  wrote:
> > > > >> >> >> > >   
> > > > >> >> >> > > > Igor Mammedov  writes:
> > > > >> >> >> > > >   
> > > > >> >> >> > > > > it will allow mgmt to query present and possible to 
> > > > >> >> >> > > > > hotplug CPUs
> > > > >> >> >> > > > > it is required from a target platform that wish to 
> > > > >> >> >> > > > > support
> > > > >> >> >> > > > > command to set board specific 
> > > > >> >> >> > > > > MachineClass.possible_cpus() hook,
> > > > >> >> >> > > > > which will return a list of possible CPUs with options
> > > > >> >> >> > > > > that would be needed for hotplugging possible CPUs.
> > > > >> >> >> > > > >
> > > > >> >> >> > > > > For RFC there are:
> > > > >> >> >> > > > >'arch_id': 'int' - mandatory unique CPU number,
> > > > >> >> >> > > > >   for x86 it's APIC ID for ARM 
> > > > >> >> >> > > > > it's MPIDR
> > > > >> >> >> > > > >'type': 'str' - CPU object type for usage with 
> > > > >> >> >> > > > > device_add
> > > > >> >> >> > > > >
> > > > >> >> >> > > > > and a set of optional fields that would allows mgmt 
> > > > >> >> >> > > > > tools
> > > > >> >> >> > > > > to know at what granularity and where a new CPU could 
> > > > >> >> >> > > > > be
> > > > >> >> >> > > > > hotplugged;
> > > > >> >> >> > > > > [node],[socket],[core],[thread]
> > > > >> >> >> > > > > Hopefully that should cover needs for CPU hotplug 
> > > > >> >> >> > > > > porposes for
> > > > >> >> >> > > > > magor targets and we can extend structure in future 
> > > > >> >> >> > > > > adding
> > > > >> >> >> > > > > more fields if it will be needed.
> > > > >> >> >> > > > >
> > > > >> >> >> > > > > also for present CPUs there is a 'cpu_link' field which
> > > > >> >> >> > > > > would allow mgmt inspect whatever object/abstraction
> > > > >> >> >> > > > > the target platform considers as CPU object.
> > > > >> >> >> > > > >
> > > > >> >> >> > > > > For RFC purposes implements only for x86 target so 
> > > > >> >> >> > > > > far.
> > > > >> >> >> > > > 
> > > > >> >> >> > > > Adding ad hoc queries as we go won't scale.  Could this 
> > > > >> >> >> > > > be solved by a
> > > > >> >> >> > > > generic introspection interface?  
> > > > >> >> >> > > Do you mean generic QOM introspection?
> > > > >> >> >> > > 
> > > > >> >> >> > > Using QOM we could have '/cpus' container and create QOM 
> > > > >> >> >> > > links
> > > > >> >> >> > > for exiting (populated links) and possible (empty links) 
> > > > >> >> >> > > CPUs.
> > > > >> >> >> > > However in that case link's name will need have a special 
> > > > >> >> >> > > format
> > > > >> >> >> > > that will convey an information necessary for mgmt to 
> > > > >> >> >> > > hotplug
> > > > >> >> >> > > a CPU object, at least:
> > > > >> >> >> > >   - where: [node],[socket],[core],[thread] options
> > > > >> >> >> > >   - optionally what CPU object to use with device_add 
> > > > >> >> >> > > command  
> > > > >> >> >> > 
> > > > >> >> >> > Hmm.. is it not enough to follow the link and get the 
> > > > >> >> >> > topology
> > > > >> >> >> > information by examining the target?
> > > > >> >> >> One can't follow a link if it's an empty one, hence
> > > > >> >> >> CPU placement information should be provided somehow,
> > > > >> >> >> either:
> > > > >> >> >
> > > > >> >> > Ah, right, so the issue is determining the socket/core/thread
> > > > >> >> > addresses that cpus which aren't yet present will have.
> > > > >> >> >
> > > > >> >> >>  * by precreating cpu-package objects with properties that
> > > > >> >> >>would describe it /could be inspected via OQM/
> > > > >> >> >
> > > > >> >> > So, we could do this, but I think the natural way would be to 
> > > > >> >> > have the
> > > > >> >> > information for each potential thread in the package.  Just 
> > > > >> >> > putting
> > > > >> >> > say "core number" in the package itself assumes more than I'd 
> > > > >> >> > like
> > > > >> >> > about how packages sit in the heirarch

Re: [Qemu-devel] [PATCH] MAINTAINERS: Add an entry for the include/hw/virtio/dataplane folder

2016-02-25 Thread Paolo Bonzini


On 25/02/2016 11:14, Thomas Huth wrote:
> dataplane header files belong to virtio-blk, so there should be a
> corresponding entry in the MAINTAINERS file.
> 
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index cda55c4..901a1b2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -891,6 +891,7 @@ S: Supported
>  F: hw/block/virtio-blk.c
>  F: hw/block/dataplane/*
>  F: hw/virtio/dataplane/*
> +F: include/hw/virtio/dataplane/
>  T: git git://github.com/stefanha/qemu.git block
>  
>  virtio-ccw
> 

The folder is going away in the next pull request from mst. :)

Paolo



Re: [Qemu-devel] [PATCH] MAINTAINERS: Remove the old s390-virtio machine

2016-02-25 Thread Cornelia Huck
On Thu, 25 Feb 2016 11:02:03 +0100
Thomas Huth  wrote:

> By the way, I think you can now also remove the "X:
> hw/s390x/s390-virtio-bus.[ch]" entry from the virtio-ccw machine, since
> these two files do not exist anymore.

I'd apply such a patch as well :)




Re: [Qemu-devel] [PATCH] MAINTAINERS: Remove the old s390-virtio machine

2016-02-25 Thread Cornelia Huck
On Thu, 25 Feb 2016 10:57:54 +0100
Thomas Huth  wrote:

> The old s390-virtio machine has been removed last year, so we don't
> need the corresponding section in the MAINTAINERS file anymore.
> 
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS | 6 --
>  1 file changed, 6 deletions(-)

Thanks, applied.




Re: [Qemu-devel] [PATCH] MAINTAINERS: Add an entry for the include/hw/virtio/dataplane folder

2016-02-25 Thread Thomas Huth
On 25.02.2016 11:23, Paolo Bonzini wrote:
> 
> 
> On 25/02/2016 11:14, Thomas Huth wrote:
>> dataplane header files belong to virtio-blk, so there should be a
>> corresponding entry in the MAINTAINERS file.
>>
>> Signed-off-by: Thomas Huth 
>> ---
>>  MAINTAINERS | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index cda55c4..901a1b2 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -891,6 +891,7 @@ S: Supported
>>  F: hw/block/virtio-blk.c
>>  F: hw/block/dataplane/*
>>  F: hw/virtio/dataplane/*
>> +F: include/hw/virtio/dataplane/
>>  T: git git://github.com/stefanha/qemu.git block
>>  
>>  virtio-ccw
>>
> 
> The folder is going away in the next pull request from mst. :)

Ooops, ok, then please simply ignore this patch :-)

 Thomas




Re: [Qemu-devel] [PATCH] MAINTAINERS: Add an entry for the include/hw/virtio/dataplane folder

2016-02-25 Thread Paolo Bonzini


On 25/02/2016 11:27, Thomas Huth wrote:
> On 25.02.2016 11:23, Paolo Bonzini wrote:
>>
>>
>> On 25/02/2016 11:14, Thomas Huth wrote:
>>> dataplane header files belong to virtio-blk, so there should be a
>>> corresponding entry in the MAINTAINERS file.
>>>
>>> Signed-off-by: Thomas Huth 
>>> ---
>>>  MAINTAINERS | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index cda55c4..901a1b2 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -891,6 +891,7 @@ S: Supported
>>>  F: hw/block/virtio-blk.c
>>>  F: hw/block/dataplane/*
>>>  F: hw/virtio/dataplane/*
>>> +F: include/hw/virtio/dataplane/
>>>  T: git git://github.com/stefanha/qemu.git block
>>>  
>>>  virtio-ccw
>>>
>>
>> The folder is going away in the next pull request from mst. :)
> 
> Ooops, ok, then please simply ignore this patch :-)

Well, I now notice that I didn't remove hw/virtio/dataplane/* from
MAINTAINERS when killing the code, so here's another thing to fix in the
file.

Paolo



[Qemu-devel] [PATCH v5 1/8] hw/timer: QOM'ify etraxfs_timer

2016-02-25 Thread xiaoqiang zhao
assign etraxfs_timer_init to etraxfs_timer_info.instance_init
and drop the SysBusDeviceClass::init

Reviewed-by: Edgar E. Iglesias 
Signed-off-by: xiaoqiang zhao 
---
 hw/timer/etraxfs_timer.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c
index 36d8f46..4f115c7 100644
--- a/hw/timer/etraxfs_timer.c
+++ b/hw/timer/etraxfs_timer.c
@@ -315,9 +315,10 @@ static void etraxfs_timer_reset(void *opaque)
 qemu_irq_lower(t->irq);
 }
 
-static int etraxfs_timer_init(SysBusDevice *dev)
+static void etraxfs_timer_init(Object *obj)
 {
-ETRAXTimerState *t = ETRAX_TIMER(dev);
+ETRAXTimerState *t = ETRAX_TIMER(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
 t->bh_t0 = qemu_bh_new(timer0_hit, t);
 t->bh_t1 = qemu_bh_new(timer1_hit, t);
@@ -329,24 +330,23 @@ static int etraxfs_timer_init(SysBusDevice *dev)
 sysbus_init_irq(dev, &t->irq);
 sysbus_init_irq(dev, &t->nmi);
 
-memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t,
+memory_region_init_io(&t->mmio, obj, &timer_ops, t,
   "etraxfs-timer", 0x5c);
 sysbus_init_mmio(dev, &t->mmio);
-qemu_register_reset(etraxfs_timer_reset, t);
-return 0;
 }
 
 static void etraxfs_timer_class_init(ObjectClass *klass, void *data)
 {
-SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+DeviceClass *dc = DEVICE_CLASS(klass);
 
-sdc->init = etraxfs_timer_init;
+dc->reset = etraxfs_timer_reset;
 }
 
 static const TypeInfo etraxfs_timer_info = {
 .name  = TYPE_ETRAX_FS_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(ETRAXTimerState),
+.instance_init = etraxfs_timer_init,
 .class_init= etraxfs_timer_class_init,
 };
 
-- 
2.1.4





[Qemu-devel] [PATCH v5 4/8] hw/timer: QOM'ify m48txx_sysbus (pass 2)

2016-02-25 Thread xiaoqiang zhao
assign DeviceClass::vmsd instead of using vmstate_register function

Signed-off-by: xiaoqiang zhao 
---
 hw/timer/m48t59.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index 3c683aa..f5897d8 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -637,6 +637,26 @@ static const VMStateDescription vmstate_m48t59 = {
 }
 };
 
+static const VMStateDescription vmstate_m48t59_isa = {
+.name = "m48t59",
+.version_id = 1,
+.minimum_version_id = 1,
+.fields = (VMStateField[]) {
+VMSTATE_STRUCT(state, M48txxISAState, 0, vmstate_m48t59, M48t59State),
+VMSTATE_END_OF_LIST()
+}
+};
+
+static const VMStateDescription vmstate_m48t59_sys_bus = {
+.name = "m48t59",
+.version_id = 1,
+.minimum_version_id = 1,
+.fields = (VMStateField[]) {
+VMSTATE_STRUCT(state, M48txxSysBusState, 0, vmstate_m48t59, 
M48t59State),
+VMSTATE_END_OF_LIST()
+}
+};
+
 static void m48t59_reset_common(M48t59State *NVRAM)
 {
 NVRAM->addr = 0;
@@ -742,8 +762,6 @@ static void m48t59_realize_common(M48t59State *s, Error 
**errp)
 s->wd_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, &watchdog_cb, s);
 }
 qemu_get_timedate(&s->alarm, 0);
-
-vmstate_register(NULL, -1, &vmstate_m48t59, s);
 }
 
 static void m48t59_isa_realize(DeviceState *dev, Error **errp)
@@ -822,6 +840,7 @@ static void m48txx_isa_class_init(ObjectClass *klass, void 
*data)
 dc->realize = m48t59_isa_realize;
 dc->reset = m48t59_reset_isa;
 dc->props = m48t59_isa_properties;
+dc->vmsd = &vmstate_m48t59_isa;
 nc->read = m48txx_isa_read;
 nc->write = m48txx_isa_write;
 nc->toggle_lock = m48txx_isa_toggle_lock;
@@ -866,6 +885,7 @@ static void m48txx_sysbus_class_init(ObjectClass *klass, 
void *data)
 dc->realize = m48t59_realize;
 dc->reset = m48t59_reset_sysbus;
 dc->props = m48t59_sysbus_properties;
+dc->vmsd = &vmstate_m48t59_sys_bus;
 nc->read = m48txx_sysbus_read;
 nc->write = m48txx_sysbus_write;
 nc->toggle_lock = m48txx_sysbus_toggle_lock;
-- 
2.1.4





[Qemu-devel] [PATCH v5 5/8] hw/timer: QOM'ify milkymist_sysctl

2016-02-25 Thread xiaoqiang zhao
* split the old SysBus init function into an instance_init
  and a Device realize function
* use DeviceClass::realize instead of SysBusDeviceClass::init

Reviewed-by: Peter Maydell 
Signed-off-by: xiaoqiang zhao 
---
 hw/timer/milkymist-sysctl.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/hw/timer/milkymist-sysctl.c b/hw/timer/milkymist-sysctl.c
index 5f29480..30a4bc4 100644
--- a/hw/timer/milkymist-sysctl.c
+++ b/hw/timer/milkymist-sysctl.c
@@ -270,9 +270,10 @@ static void milkymist_sysctl_reset(DeviceState *d)
 s->regs[R_GPIO_IN] = s->strappings;
 }
 
-static int milkymist_sysctl_init(SysBusDevice *dev)
+static void milkymist_sysctl_init(Object *obj)
 {
-MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
+MilkymistSysctlState *s = MILKYMIST_SYSCTL(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
 sysbus_init_irq(dev, &s->gpio_irq);
 sysbus_init_irq(dev, &s->timer0_irq);
@@ -282,14 +283,18 @@ static int milkymist_sysctl_init(SysBusDevice *dev)
 s->bh1 = qemu_bh_new(timer1_hit, s);
 s->ptimer0 = ptimer_init(s->bh0);
 s->ptimer1 = ptimer_init(s->bh1);
-ptimer_set_freq(s->ptimer0, s->freq_hz);
-ptimer_set_freq(s->ptimer1, s->freq_hz);
 
-memory_region_init_io(&s->regs_region, OBJECT(s), &sysctl_mmio_ops, s,
+memory_region_init_io(&s->regs_region, obj, &sysctl_mmio_ops, s,
 "milkymist-sysctl", R_MAX * 4);
 sysbus_init_mmio(dev, &s->regs_region);
+}
 
-return 0;
+static void milkymist_sysctl_realize(DeviceState *dev, Error **errp)
+{
+MilkymistSysctlState *s = MILKYMIST_SYSCTL(dev);
+
+ptimer_set_freq(s->ptimer0, s->freq_hz);
+ptimer_set_freq(s->ptimer1, s->freq_hz);
 }
 
 static const VMStateDescription vmstate_milkymist_sysctl = {
@@ -319,9 +324,8 @@ static Property milkymist_sysctl_properties[] = {
 static void milkymist_sysctl_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k->init = milkymist_sysctl_init;
+dc->realize = milkymist_sysctl_realize;
 dc->reset = milkymist_sysctl_reset;
 dc->vmsd = &vmstate_milkymist_sysctl;
 dc->props = milkymist_sysctl_properties;
@@ -331,6 +335,7 @@ static const TypeInfo milkymist_sysctl_info = {
 .name  = TYPE_MILKYMIST_SYSCTL,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(MilkymistSysctlState),
+.instance_init = milkymist_sysctl_init,
 .class_init= milkymist_sysctl_class_init,
 };
 
-- 
2.1.4





[Qemu-devel] [PATCH v5 3/8] hw/timer: QOM'ify m48txx_sysbus (pass 1)

2016-02-25 Thread xiaoqiang zhao
* split the old SysBus init function into an instance_init
  and a Device realize function
* use DeviceClass::realize instead of SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao 
---
 hw/timer/m48t59.c | 35 ++-
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c
index bbcfeb2..3c683aa 100644
--- a/hw/timer/m48t59.c
+++ b/hw/timer/m48t59.c
@@ -763,30 +763,31 @@ static void m48t59_isa_realize(DeviceState *dev, Error 
**errp)
 }
 }
 
-static int m48t59_init1(SysBusDevice *dev)
+static void m48t59_init1(Object *obj)
 {
-M48txxSysBusDeviceClass *u = M48TXX_SYS_BUS_GET_CLASS(dev);
-M48txxSysBusState *d = M48TXX_SYS_BUS(dev);
-Object *o = OBJECT(dev);
+M48txxSysBusDeviceClass *u = M48TXX_SYS_BUS_GET_CLASS(obj);
+M48txxSysBusState *d = M48TXX_SYS_BUS(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 M48t59State *s = &d->state;
-Error *err = NULL;
 
 s->model = u->info.model;
 s->size = u->info.size;
 sysbus_init_irq(dev, &s->IRQ);
 
-memory_region_init_io(&s->iomem, o, &nvram_ops, s, "m48t59.nvram",
+memory_region_init_io(&s->iomem, obj, &nvram_ops, s, "m48t59.nvram",
   s->size);
-memory_region_init_io(&d->io, o, &m48t59_io_ops, s, "m48t59", 4);
-sysbus_init_mmio(dev, &s->iomem);
-sysbus_init_mmio(dev, &d->io);
-m48t59_realize_common(s, &err);
-if (err != NULL) {
-error_free(err);
-return -1;
-}
+memory_region_init_io(&d->io, obj, &m48t59_io_ops, s, "m48t59", 4);
+}
 
-return 0;
+static void m48t59_realize(DeviceState *dev, Error **errp)
+{
+M48txxSysBusState *d = M48TXX_SYS_BUS(dev);
+M48t59State *s = &d->state;
+SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+
+sysbus_init_mmio(sbd, &s->iomem);
+sysbus_init_mmio(sbd, &d->io);
+m48t59_realize_common(s, errp);
 }
 
 static uint32_t m48txx_isa_read(Nvram *obj, uint32_t addr)
@@ -860,10 +861,9 @@ static Property m48t59_sysbus_properties[] = {
 static void m48txx_sysbus_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 NvramClass *nc = NVRAM_CLASS(klass);
 
-k->init = m48t59_init1;
+dc->realize = m48t59_realize;
 dc->reset = m48t59_reset_sysbus;
 dc->props = m48t59_sysbus_properties;
 nc->read = m48txx_sysbus_read;
@@ -889,6 +889,7 @@ static const TypeInfo m48txx_sysbus_type_info = {
 .name = TYPE_M48TXX_SYS_BUS,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(M48txxSysBusState),
+.instance_init = m48t59_init1,
 .abstract = true,
 .class_init = m48txx_sysbus_class_init,
 .interfaces = (InterfaceInfo[]) {
-- 
2.1.4





[Qemu-devel] [PATCH v5 8/8] hw/timer: QOM'ify grlib_gptimer

2016-02-25 Thread xiaoqiang zhao
* split the old SysBus init function into an instance_init
  and a Device realize function
* use DeviceClass::realize instead of SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao 
---
 hw/timer/grlib_gptimer.c | 32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c
index dd000f5..95d5b0d 100644
--- a/hw/timer/grlib_gptimer.c
+++ b/hw/timer/grlib_gptimer.c
@@ -348,16 +348,29 @@ static void grlib_gptimer_reset(DeviceState *d)
 }
 }
 
-static int grlib_gptimer_init(SysBusDevice *dev)
+static void grlib_gptimer_init(Object *obj)
 {
-GPTimerUnit  *unit = GRLIB_GPTIMER(dev);
-unsigned int  i;
+GPTimerUnit  *unit = GRLIB_GPTIMER(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
 assert(unit->nr_timers > 0);
 assert(unit->nr_timers <= GPTIMER_MAX_TIMERS);
 
 unit->timers = g_malloc0(sizeof unit->timers[0] * unit->nr_timers);
 
+memory_region_init_io(&unit->iomem, obj, &grlib_gptimer_ops,
+  unit, "gptimer",
+  UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers);
+
+sysbus_init_mmio(dev, &unit->iomem);
+}
+
+static void grlib_gptimer_realize(DeviceState *dev, Error **errp)
+{
+GPTimerUnit  *unit = GRLIB_GPTIMER(dev);
+SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+unsigned int  i;
+
 for (i = 0; i < unit->nr_timers; i++) {
 GPTimer *timer = &unit->timers[i];
 
@@ -367,17 +380,10 @@ static int grlib_gptimer_init(SysBusDevice *dev)
 timer->id = i;
 
 /* One IRQ line for each timer */
-sysbus_init_irq(dev, &timer->irq);
+sysbus_init_irq(sbd, &timer->irq);
 
 ptimer_set_freq(timer->ptimer, unit->freq_hz);
 }
-
-memory_region_init_io(&unit->iomem, OBJECT(unit), &grlib_gptimer_ops,
-  unit, "gptimer",
-  UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers);
-
-sysbus_init_mmio(dev, &unit->iomem);
-return 0;
 }
 
 static Property grlib_gptimer_properties[] = {
@@ -390,9 +396,8 @@ static Property grlib_gptimer_properties[] = {
 static void grlib_gptimer_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k->init = grlib_gptimer_init;
+dc->realize = grlib_gptimer_realize;
 dc->reset = grlib_gptimer_reset;
 dc->props = grlib_gptimer_properties;
 }
@@ -401,6 +406,7 @@ static const TypeInfo grlib_gptimer_info = {
 .name  = TYPE_GRLIB_GPTIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(GPTimerUnit),
+.instance_init = grlib_gptimer_init,
 .class_init= grlib_gptimer_class_init,
 };
 
-- 
2.1.4





[Qemu-devel] [PATCH v5 7/8] hw/timer: QOM'ify slavio_timer

2016-02-25 Thread xiaoqiang zhao
rename slavio_timer_init1 to slavio_timer_init and assign
it to slavio_timer_info.instance_init, then we drop the
SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao 
---
 hw/timer/slavio_timer.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c
index fb3e08b..b2c9364 100644
--- a/hw/timer/slavio_timer.c
+++ b/hw/timer/slavio_timer.c
@@ -373,9 +373,10 @@ static void slavio_timer_reset(DeviceState *d)
 s->cputimer_mode = 0;
 }
 
-static int slavio_timer_init1(SysBusDevice *dev)
+static void slavio_timer_init(Object *obj)
 {
-SLAVIO_TIMERState *s = SLAVIO_TIMER(dev);
+SLAVIO_TIMERState *s = SLAVIO_TIMER(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 QEMUBH *bh;
 unsigned int i;
 TimerContext *tc;
@@ -394,14 +395,12 @@ static int slavio_timer_init1(SysBusDevice *dev)
 
 size = i == 0 ? SYS_TIMER_SIZE : CPU_TIMER_SIZE;
 snprintf(timer_name, sizeof(timer_name), "timer-%i", i);
-memory_region_init_io(&tc->iomem, OBJECT(s), &slavio_timer_mem_ops, tc,
+memory_region_init_io(&tc->iomem, obj, &slavio_timer_mem_ops, tc,
   timer_name, size);
 sysbus_init_mmio(dev, &tc->iomem);
 
 sysbus_init_irq(dev, &s->cputimer[i].irq);
 }
-
-return 0;
 }
 
 static Property slavio_timer_properties[] = {
@@ -412,9 +411,7 @@ static Property slavio_timer_properties[] = {
 static void slavio_timer_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k->init = slavio_timer_init1;
 dc->reset = slavio_timer_reset;
 dc->vmsd = &vmstate_slavio_timer;
 dc->props = slavio_timer_properties;
@@ -424,6 +421,7 @@ static const TypeInfo slavio_timer_info = {
 .name  = TYPE_SLAVIO_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(SLAVIO_TIMERState),
+.instance_init = slavio_timer_init,
 .class_init= slavio_timer_class_init,
 };
 
-- 
2.1.4





[Qemu-devel] [PATCH v5 2/8] hw/timer: QOM'ify lm32_timer

2016-02-25 Thread xiaoqiang zhao
* split the old SysBus init function into an instance_init
  and a Device realize function
* use DeviceClass::realize instead of SysBusDeviceClass::init

Reviewed-by: Peter Maydell 
Signed-off-by: xiaoqiang zhao 
---
 hw/timer/lm32_timer.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/hw/timer/lm32_timer.c b/hw/timer/lm32_timer.c
index 3198355..e45a65b 100644
--- a/hw/timer/lm32_timer.c
+++ b/hw/timer/lm32_timer.c
@@ -176,21 +176,26 @@ static void timer_reset(DeviceState *d)
 ptimer_stop(s->ptimer);
 }
 
-static int lm32_timer_init(SysBusDevice *dev)
+static void lm32_timer_init(Object *obj)
 {
-LM32TimerState *s = LM32_TIMER(dev);
+LM32TimerState *s = LM32_TIMER(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
 sysbus_init_irq(dev, &s->irq);
 
 s->bh = qemu_bh_new(timer_hit, s);
 s->ptimer = ptimer_init(s->bh);
-ptimer_set_freq(s->ptimer, s->freq_hz);
 
-memory_region_init_io(&s->iomem, OBJECT(s), &timer_ops, s,
+memory_region_init_io(&s->iomem, obj, &timer_ops, s,
   "timer", R_MAX * 4);
 sysbus_init_mmio(dev, &s->iomem);
+}
 
-return 0;
+static void lm32_timer_realize(DeviceState *dev, Error **errp)
+{
+LM32TimerState *s = LM32_TIMER(dev);
+
+ptimer_set_freq(s->ptimer, s->freq_hz);
 }
 
 static const VMStateDescription vmstate_lm32_timer = {
@@ -213,9 +218,8 @@ static Property lm32_timer_properties[] = {
 static void lm32_timer_class_init(ObjectClass *klass, void *data)
 {
 DeviceClass *dc = DEVICE_CLASS(klass);
-SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
 
-k->init = lm32_timer_init;
+dc->realize = lm32_timer_realize;
 dc->reset = timer_reset;
 dc->vmsd = &vmstate_lm32_timer;
 dc->props = lm32_timer_properties;
@@ -225,6 +229,7 @@ static const TypeInfo lm32_timer_info = {
 .name  = TYPE_LM32_TIMER,
 .parent= TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(LM32TimerState),
+.instance_init = lm32_timer_init,
 .class_init= lm32_timer_class_init,
 };
 
-- 
2.1.4





[Qemu-devel] [PATCH v5 6/8] hw/timer: QOM'ify puv3_ost

2016-02-25 Thread xiaoqiang zhao
assign puv3_ost_init to puv3_ost_info.instance_init
and drop the SysBusDeviceClass::init

Signed-off-by: xiaoqiang zhao 
---
 hw/timer/puv3_ost.c | 18 +-
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/hw/timer/puv3_ost.c b/hw/timer/puv3_ost.c
index 93650b7..72c87ba 100644
--- a/hw/timer/puv3_ost.c
+++ b/hw/timer/puv3_ost.c
@@ -113,9 +113,10 @@ static void puv3_ost_tick(void *opaque)
 }
 }
 
-static int puv3_ost_init(SysBusDevice *dev)
+static void puv3_ost_init(Object *obj)
 {
-PUV3OSTState *s = PUV3_OST(dev);
+PUV3OSTState *s = PUV3_OST(obj);
+SysBusDevice *dev = SYS_BUS_DEVICE(obj);
 
 s->reg_OIER = 0;
 s->reg_OSSR = 0;
@@ -128,25 +129,16 @@ static int puv3_ost_init(SysBusDevice *dev)
 s->ptimer = ptimer_init(s->bh);
 ptimer_set_freq(s->ptimer, 50 * 1000 * 1000);
 
-memory_region_init_io(&s->iomem, OBJECT(s), &puv3_ost_ops, s, "puv3_ost",
+memory_region_init_io(&s->iomem, obj, &puv3_ost_ops, s, "puv3_ost",
 PUV3_REGS_OFFSET);
 sysbus_init_mmio(dev, &s->iomem);
-
-return 0;
-}
-
-static void puv3_ost_class_init(ObjectClass *klass, void *data)
-{
-SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
-
-sdc->init = puv3_ost_init;
 }
 
 static const TypeInfo puv3_ost_info = {
 .name = TYPE_PUV3_OST,
 .parent = TYPE_SYS_BUS_DEVICE,
 .instance_size = sizeof(PUV3OSTState),
-.class_init = puv3_ost_class_init,
+.instance_init = puv3_ost_init,
 };
 
 static void puv3_ost_register_type(void)
-- 
2.1.4





[Qemu-devel] [PATCH v5 0/8] QOM'ify hw/timer/*

2016-02-25 Thread xiaoqiang zhao
This patch series QOM'ify timer code under hw/timer directory.
Main idea is to split the initfn's work, some to TypeInfo.instance_init
and some is placed in DeviceClass::realize.
Drop the use of SysBusDeviceClass::init if possible.

Patch 3,4 (m48t59) has been tested in a sparc vm with debian linux guest
and savevm/loadvm looks fine.

Comments from the relevant maintainers are needed!

changes in v5:
* drop patch 'hw/timer: QOM'ify tusb6010'
* fix minor errors in grlib_gptimer.c
* correct the usage of vmstate for M48txxISAState and M48txxSysBusState


changes in v4: 
* correct some misused "Reviewed-by" tags
* fix 'make check' fail case in the "/arm/device/introspect/concrete"
  test in tusb6010.c 

changes in v3: 
* remove unnecessary OBJECT cast
* refine some commit message
* use DeviceClass::vmsd instead of vmstate_register to register
  the VMState if possible

changes in v2: 
fix a stupid typo (timmer->timer)


xiaoqiang zhao (8):
  hw/timer: QOM'ify etraxfs_timer
  hw/timer: QOM'ify lm32_timer
  hw/timer: QOM'ify m48txx_sysbus (pass 1)
  hw/timer: QOM'ify m48txx_sysbus (pass 2)
  hw/timer: QOM'ify milkymist_sysctl
  hw/timer: QOM'ify puv3_ost
  hw/timer: QOM'ify slavio_timer
  hw/timer: QOM'ify grlib_gptimer

 hw/timer/etraxfs_timer.c| 14 +--
 hw/timer/grlib_gptimer.c| 32 ++--
 hw/timer/lm32_timer.c   | 19 +--
 hw/timer/m48t59.c   | 59 ++---
 hw/timer/milkymist-sysctl.c | 21 ++--
 hw/timer/puv3_ost.c | 18 --
 hw/timer/slavio_timer.c | 12 -
 7 files changed, 101 insertions(+), 74 deletions(-)

-- 
2.1.4





[Qemu-devel] [PATCH] MAINTAINERS: Remove entry for hw/s390x/s390-virtio-bus.[ch]

2016-02-25 Thread Thomas Huth
The files have been deleted recently, no need to keep these entries
anymore.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index cda55c4..0f15d88 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -660,7 +660,6 @@ M: Alexander Graf 
 S: Supported
 F: hw/char/sclp*.[hc]
 F: hw/s390x/
-X: hw/s390x/s390-virtio-bus.[ch]
 F: include/hw/s390x/
 F: pc-bios/s390-ccw/
 F: hw/watchdog/wdt_diag288.c
-- 
1.8.3.1




Re: [Qemu-devel] [PULL 00/19] Misc changes for 2016-02-24

2016-02-25 Thread Peter Maydell
On 24 February 2016 at 13:27, Paolo Bonzini  wrote:
> The following changes since commit dd5e38b19d7cb07d317e1285941d8245c01da540:
>
>   Merge remote-tracking branch 
> 'remotes/pmaydell/tags/pull-target-arm-20160218-1' into staging (2016-02-18 
> 15:20:35 +)
>
> are available in the git repository at:
>
>   git://github.com/bonzini/qemu.git tags/for-upstream
>
> for you to fetch changes up to 38ec9d285196af55320f986dbf477ecf0d928ad6:
>
>   target-i386: fix confusion in xcr0 bit position vs. mask (2016-02-24 
> 14:20:40 +0100)
>
> 
> * Asynchronous dump-guest-memory from Peter
> * improved logging with -D -daemonize from Dimitris
> * more address_space_* optimization from Gonglei
> * TCG xsave/xrstor thinko fix
> * chardev bugfix and documentation patch

Hi. I'm afraid this failed to build with the w32 compiler that doesn't
like duplicate typedefs:

In file included from
/home/petmay01/linaro/qemu-for-merges/include/exec/ioport.h:29,
 from /home/petmay01/linaro/qemu-for-merges/include/hw/hw.h:11,
 from /home/petmay01/linaro/qemu-for-merges/stubs/reset.c:2:
/home/petmay01/linaro/qemu-for-merges/include/exec/memory.h:156:
error: redefinition of typedef ‘RAMBlock’
/home/petmay01/linaro/qemu-for-merges/include/qemu/typedefs.h:85:
error: previous declaration of ‘RAMBlock’ was here

thanks
-- PMM



Re: [Qemu-devel] [PATCH 1/2] virtio-balloon: export all balloon statistics

2016-02-25 Thread Markus Armbruster
"Michael S. Tsirkin"  writes:

> On Thu, Feb 25, 2016 at 12:30:21PM +0300, Roman Kagan wrote:
>> On Thu, Feb 25, 2016 at 10:54:17AM +0200, Michael S. Tsirkin wrote:
>> > On Thu, Feb 25, 2016 at 09:44:06AM +0100, Markus Armbruster wrote:
>> > > "Denis V. Lunev"  writes:
>> > > 
>> > > > On 02/24/2016 06:43 PM, Eric Blake wrote:
>> > > >> On 02/24/2016 07:31 AM, Michael S. Tsirkin wrote:
>> > > >>> Roman Kagan  writes:
>> > >  On Tue, Feb 23, 2016 at 05:49:21PM +0200, Michael S. Tsirkin wrote:
>> > > > On Tue, Feb 23, 2016 at 06:29:33PM +0300, Denis V. Lunev wrote:
>> > > > > On 02/23/2016 06:24 PM, Michael S. Tsirkin wrote:
>> > > > > >On Tue, Feb 23, 2016 at 05:59:44PM +0300, Denis V. Lunev wrote:
>> > > > > >>From: Igor Redko 
>> > > > > >>
>> > > > > >>We are making experiments with different autoballooning 
>> > > > > >>strategies
>> > > > > >>based on the guest behavior. Thus we need to experiment with 
>> > > > > >>different
>> > > > > >>guest statistics. For now every counter change requires QEMU 
>> > > > > >>recompilation
>> > > > > >>and dances with Libvirt.
>> > > > > >>
>> > > > > >>This patch introduces transport for unrecognized counters in 
>> > > > > >>virtio-balloon.
>> > > > > >>This transport can be used for measuring benefits from using 
>> > > > > >>new
>> > > > > >>balloon counters, before submitting any patches. Current 
>> > > > > >>alternative
>> > > > > >>is 'guest-exec' transport which isn't made for such delicate 
>> > > > > >>matters
>> > > > > >>and can influence test results.
>> > > > > >>
>> > > > > >>Originally all counters with tag >= VIRTIO_BALLOON_S_NR were 
>> > > > > >>ignored.
>> > > > > >>Instead of this we keep first (VIRTIO_BALLOON_S_NR + 32) 
>> > > > > >>counters from the
>> > > > > >>queue and pass unrecognized ones with the following names: 
>> > > > > >>'x-stat-',
>> > > > > >>where  is a tag number in hex. Defined counters are 
>> > > > > >>reported with their
>> > > > > >>regular names.
>> > > > > >>
>> > > > > >>Signed-off-by: Igor Redko 
>> > > > > >>Signed-off-by: Denis V. Lunev 
>> > > > > >>CC: Michael S. Tsirkin 
>> > > > > >This seems to open the ABI to abuse.
>> > > > > >Seems like a reasonable way to experiment though.
>> > > > > >How about adding this within #if 0 statements?
>> > > > > >You can uncomment them for debugging ...
>> > > > > I'd prefer to have this enabled.
>> > > 
>> > > Yes, conditional compilation should be used sparingly.  I don't have an
>> > > opinion on whether using it here is appropriate.
>> > > 
>> > > > > Why do you think that it opens "abuse" way?
>> > > > 
>> > > > Because people will use this to hack drivers and management tools
>> > > > bypassing qemu.
>> > > 
>> > > Easy to avoid: shuffle the N in x-stat-N around from time to time, to
>> > > reinforce the lesson that you must not rely on their presence or
>> > > semantics.  I doubt it'll be necessary beyond the renumbering that
>> > > happens naturally when we add supported counters, or the reshuffling
>> > > that happens when somebody messes with the unsupported counters.
>> > > 
>> > >  I'm curious why you think it's a problem?  Even the existing stats 
>> > >  are
>> > >  simply propagated to the management level by qemu with no processing
>> > >  other than assigning text labels.  The proposed naming scheme for
>> > >  unrecognized counters includes "x-" prefix which explicitly marks 
>> > >  them
>> > >  as unstable so people using them take their risk.
>> > > 
>> > >  One of the benefits is forward compatibility, so that counters that 
>> > >  have
>> > >  graduated into supported ones and have got their own number and 
>> > >  name,
>> > >  can be made to work with qemu that doesn't yet recognize them.
>> > > >>> Then management does start relying on the x- prefixed things,
>> > > >>> and once it's used to that it's a slippery slope.
>> > > >> Any management tool that relies on an x- prefix name is broken.
>> > > 
>> > > Or at least assumes the full risk of breaking without notice whenever
>> > > QEMU changes.  Abbreviating that to just "broken" seems fair enough :)
>> > > 
>> > > >>  We've
>> > > >> explicitly documented that the x- prefix is unstable and liable to go
>> > > >> away with a future release. Any management app that wants to use a
>> > > >> feature beginning with x- should FIRST push hard to get the x- removed
>> > > >> and stabilize the interface (and libvirt, at least, does just that).
>> > > >>
>> > > > this was exactly an original idea. Names started with 'x-' are
>> > > > _officially_ unstable and for debug purpose. That is why I'd
>> > > > prefer if v2 of the patchset will be taken.
>> > > 
>> > > Looks like fair use of x- to me.
>> > 
>> > 

Re: [Qemu-devel] [PATCH] MAINTAINERS: Remove entry for hw/s390x/s390-virtio-bus.[ch]

2016-02-25 Thread Cornelia Huck
On Thu, 25 Feb 2016 11:45:00 +0100
Thomas Huth  wrote:

> The files have been deleted recently, no need to keep these entries
> anymore.
> 
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS | 1 -
>  1 file changed, 1 deletion(-)

Thanks, applied.




Re: [Qemu-devel] [PATCH v5 4/8] hw/timer: QOM'ify m48txx_sysbus (pass 2)

2016-02-25 Thread Peter Maydell
On 25 February 2016 at 10:30, xiaoqiang zhao  wrote:
> assign DeviceClass::vmsd instead of using vmstate_register function
>
> Signed-off-by: xiaoqiang zhao 
> ---
>  hw/timer/m48t59.c | 24 ++--
>  1 file changed, 22 insertions(+), 2 deletions(-)

So, did you test this, and if so what did you do?

thanks
-- PMM



Re: [Qemu-devel] [PATCH v5 0/8] QOM'ify hw/timer/*

2016-02-25 Thread Peter Maydell
On 25 February 2016 at 10:30, xiaoqiang zhao  wrote:
> This patch series QOM'ify timer code under hw/timer directory.
> Main idea is to split the initfn's work, some to TypeInfo.instance_init
> and some is placed in DeviceClass::realize.
> Drop the use of SysBusDeviceClass::init if possible.
>
> Patch 3,4 (m48t59) has been tested in a sparc vm with debian linux guest
> and savevm/loadvm looks fine.

...ah, I see you answered my question about testing here. Thanks.

-- PMM



Re: [Qemu-devel] [PATCH] Postcopy: Fix sync count in info migrate

2016-02-25 Thread Hailiang Zhang

On 2016/2/25 18:03, Dr. David Alan Gilbert (git) wrote:

From: "Dr. David Alan Gilbert" 

I'd missed the sync count off in the postcopy case.

Signed-off-by: Dr. David Alan Gilbert 
---
  migration/migration.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/migration/migration.c b/migration/migration.c
index fc5e50b..34d3e5f 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -626,6 +626,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
  info->ram->normal_bytes = norm_mig_bytes_transferred();
  info->ram->dirty_pages_rate = s->dirty_pages_rate;
  info->ram->mbps = s->mbps;
+info->ram->dirty_sync_count = s->dirty_sync_count;

  if (blk_mig_active()) {
  info->has_disk = true;



Reviewed-by: zhanghailiang 

I noticed that, the stats of 'POSTCOPY_ACTIVE' is almost the copy of 'ACTIVE'
case. Maybe we can simplify it.






[Qemu-devel] [PATCH] MAINTAINERS: Add entry for the include/hw/vfio/ folder

2016-02-25 Thread Thomas Huth
The headers in include/hw/vfio/ should be listed in the VFIO
section of the MAINTAINERS file.

Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0f15d88..9179386 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -861,6 +861,7 @@ VFIO
 M: Alex Williamson 
 S: Supported
 F: hw/vfio/*
+F: include/hw/vfio/
 
 vhost
 M: Michael S. Tsirkin 
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v6 2/3] qmp event: Refactor QUORUM_REPORT_BAD

2016-02-25 Thread Alberto Garcia
On Thu 25 Feb 2016 06:33:08 AM CET, Changlong Xie  
wrote:
> +Read/Write operation:
>  { "event": "QUORUM_REPORT_BAD",
> - "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 
> 5 },
> + "data": { "node-name": "node0", "sector-num": 345435, "sectors-count": 
> 5,
> + "type": "read" },
>   "timestamp": { "seconds": 1344522075, "microseconds": 745528 } }

Since you introduced the 'type' field and this is now an example of a
read error, you can change the description to say simply "Read
operation:". In my opinion there's no need to add yet another example
for a write operation, I think it's clear enough.

> +Flush operation:
> +{ "event": "QUORUM_REPORT_BAD",
> + "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 
> 2097120,
> + "type": "flush", "error": "Broken pipe" },
> + "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }

Here (and in the previous case) please indent "type" so it goes under
"node-name":

   { "event": "QUORUM_REPORT_BAD",
 "data": { "node-name": "node0", "sector-num": 0, "sectors-count": 2097120,
   "type": "flush", "error": "Broken pipe" },
 "timestamp": { "seconds": 1456406829, "microseconds": 291763 } }

Otherwise I think the patch looks perfect now. Thanks!

Berto



Re: [Qemu-devel] [PATCH] Postcopy: Fix sync count in info migrate

2016-02-25 Thread Dr. David Alan Gilbert
* Hailiang Zhang (zhang.zhanghaili...@huawei.com) wrote:
> On 2016/2/25 18:03, Dr. David Alan Gilbert (git) wrote:
> >From: "Dr. David Alan Gilbert" 
> >
> >I'd missed the sync count off in the postcopy case.
> >
> >Signed-off-by: Dr. David Alan Gilbert 
> >---
> >  migration/migration.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> >diff --git a/migration/migration.c b/migration/migration.c
> >index fc5e50b..34d3e5f 100644
> >--- a/migration/migration.c
> >+++ b/migration/migration.c
> >@@ -626,6 +626,7 @@ MigrationInfo *qmp_query_migrate(Error **errp)
> >  info->ram->normal_bytes = norm_mig_bytes_transferred();
> >  info->ram->dirty_pages_rate = s->dirty_pages_rate;
> >  info->ram->mbps = s->mbps;
> >+info->ram->dirty_sync_count = s->dirty_sync_count;
> >
> >  if (blk_mig_active()) {
> >  info->has_disk = true;
> >
> 
> Reviewed-by: zhanghailiang 

Thanks,

> I noticed that, the stats of 'POSTCOPY_ACTIVE' is almost the copy of 'ACTIVE'
> case. Maybe we can simplify it.

Yes, I keep intending to add more stats to POSTCOPY_ACTIVE, but haven't
done so yet.

Dave

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



[Qemu-devel] [PULL v2 5/8] linux-user: sync syscall numbers with kernel

2016-02-25 Thread riku . voipio
From: Riku Voipio 

Sync syscall numbers to match the linux v4.5-rc1 kernel.

Reviewed-by: Laurent Vivier 
Signed-off-by: Riku Voipio 
---
 linux-user/aarch64/syscall_nr.h|  2 +-
 linux-user/alpha/syscall_nr.h  |  6 ++
 linux-user/cris/syscall_nr.h   | 24 
 linux-user/i386/syscall_nr.h   | 27 +++
 linux-user/microblaze/syscall_nr.h |  8 
 linux-user/mips64/syscall_nr.h | 23 +++
 linux-user/openrisc/syscall_nr.h   | 28 
 linux-user/ppc/syscall_nr.h| 24 
 linux-user/s390x/syscall_nr.h  | 30 ++
 linux-user/sparc/syscall_nr.h  | 14 ++
 linux-user/sparc64/syscall_nr.h| 14 ++
 linux-user/tilegx/syscall_nr.h |  4 
 linux-user/x86_64/syscall_nr.h | 13 +
 13 files changed, 200 insertions(+), 17 deletions(-)

diff --git a/linux-user/aarch64/syscall_nr.h b/linux-user/aarch64/syscall_nr.h
index 74f4275..c8a8599 100644
--- a/linux-user/aarch64/syscall_nr.h
+++ b/linux-user/aarch64/syscall_nr.h
@@ -262,7 +262,6 @@
 #define TARGET_NR_process_vm_writev 271
 #define TARGET_NR_kcmp 272
 #define TARGET_NR_finit_module 273
-
 #define TARGET_NR_sched_setattr 274
 #define TARGET_NR_sched_getattr 275
 #define TARGET_NR_renameat2 276
@@ -274,6 +273,7 @@
 #define TARGET_NR_userfaultfd 282
 #define TARGET_NR_membarrier 283
 #define TARGET_NR_mlock2 284
+#define TARGET_NR_copy_file_range 285
 
 #define TARGET_NR_open 1024
 #define TARGET_NR_link 1025
diff --git a/linux-user/alpha/syscall_nr.h b/linux-user/alpha/syscall_nr.h
index dde8d5c..00e14bb 100644
--- a/linux-user/alpha/syscall_nr.h
+++ b/linux-user/alpha/syscall_nr.h
@@ -444,3 +444,9 @@
 #define TARGET_NR_process_vm_writev 505
 #define TARGET_NR_kcmp  506
 #define TARGET_NR_finit_module  507
+#define TARGET_NR_sched_setattr 508
+#define TARGET_NR_sched_getattr 509
+#define TARGET_NR_renameat2 510
+#define TARGET_NR_getrandom 511
+#define TARGET_NR_memfd_create  512
+#define TARGET_NR_execveat  513
diff --git a/linux-user/cris/syscall_nr.h b/linux-user/cris/syscall_nr.h
index 694bd02..44f0b64 100644
--- a/linux-user/cris/syscall_nr.h
+++ b/linux-user/cris/syscall_nr.h
@@ -336,3 +336,27 @@
 #define TARGET_NR_preadv 333
 #define TARGET_NR_pwritev334
 #define TARGET_NR_setns  335
+#define TARGET_NR_name_to_handle_at  336
+#define TARGET_NR_open_by_handle_at  337
+#define TARGET_NR_rt_tgsigqueueinfo  338
+#define TARGET_NR_perf_event_open339
+#define TARGET_NR_recvmmsg   340
+#define TARGET_NR_accept4341
+#define TARGET_NR_fanotify_init  342
+#define TARGET_NR_fanotify_mark  343
+#define TARGET_NR_prlimit64  344
+#define TARGET_NR_clock_adjtime  345
+#define TARGET_NR_syncfs 346
+#define TARGET_NR_sendmmsg   347
+#define TARGET_NR_process_vm_readv   348
+#define TARGET_NR_process_vm_writev  349
+#define TARGET_NR_kcmp   350
+#define TARGET_NR_finit_module   351
+#define TARGET_NR_sched_setattr  352
+#define TARGET_NR_sched_getattr  353
+#define TARGET_NR_renameat2  354
+#define TARGET_NR_seccomp355
+#define TARGET_NR_getrandom  356
+#define TARGET_NR_memfd_create   357
+#define TARGET_NR_bpf358
+#define TARGET_NR_execveat   359
diff --git a/linux-user/i386/syscall_nr.h b/linux-user/i386/syscall_nr.h
index c8f7302..fa3f0b4 100644
--- a/linux-user/i386/syscall_nr.h
+++ b/linux-user/i386/syscall_nr.h
@@ -353,3 +353,30 @@
 #define TARGET_NR_process_vm_writev 348
 #define TARGET_NR_kcmp  349
 #define TARGET_NR_finit_module  350
+#define TARGET_NR_sched_setattr 351
+#define TARGET_NR_sched_getattr 352
+#define TARGET_NR_renameat2 353
+#define TARGET_NR_seccomp   354
+#define TARGET_NR_getrandom 355
+#define TARGET_NR_memfd_create  356
+#define TARGET_NR_bpf   357
+#define TARGET_NR_execveat  358
+#define TARGET_NR_socket359
+#define TARGET_NR_socketpair360
+#define TARGET_NR_bind  361
+#define TARGET_NR_connect   362
+#define TARGET_NR_listen363
+#define TARGET_NR_accept4   364
+#define TARGET_NR_getsockopt365
+#define TARGET_NR_setsockopt366
+#define TARGET_NR_getsockname   367
+#define TARGET_NR_getpeername   368
+#define TARGET_NR_sendto369
+#define TARGET_NR_sendmsg   370
+#define TARGET_NR_recvfrom  371
+#define TARGET_NR_recvmsg   372
+#define TARGET_NR_shutdown  373
+#define TARGET_NR_userfaultfd 

[Qemu-devel] [PULL v2 0/8] linux-user updates and fixes

2016-02-25 Thread riku . voipio
From: Riku Voipio 

The following changes since commit 1b1624092d1f1f746adea6e1237a07f6788c2e3d:

  Merge remote-tracking branch 'remotes/spice/tags/pull-spice-20160223-1' into 
staging (2016-02-23 16:14:17 +)

are available in the git repository at:

  git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20160225

for you to fetch changes up to f894efd19917321844b31e5dd7a061fdc6fb322d:

  linux-user: add getrandom() syscall (2016-02-24 15:22:15 +0200)


Second pull req with getrandom fix


Laurent Vivier (3):
  linux-user: fix realloc size of target_fd_trans.
  linux-user: set ppc64/ppc64le default CPU to POWER8
  linux-user: add getrandom() syscall

Lluís Vilanova (1):
  build: [linux-user] Rename "syscall.h" to "target_syscall.h" in target
directories

Peter Maydell (1):
  linux-user: Don't assert if guest tries shmdt(0)

Riku Voipio (3):
  linux-user: sync syscall numbers with kernel
  linux-user: remove unavailable syscalls from aarch64
  linux-user: correct timerfd_create syscall numbers

 linux-user/aarch64/syscall.h   |  13 --
 linux-user/aarch64/syscall_nr.h|  61 +---
 linux-user/aarch64/target_syscall.h|  18 +++
 linux-user/alpha/syscall.h | 257 
 linux-user/alpha/syscall_nr.h  |   6 +
 linux-user/alpha/target_syscall.h  | 262 +
 linux-user/arm/syscall.h   |  50 ---
 linux-user/arm/target_syscall.h|  54 +++
 linux-user/cris/syscall.h  |  46 --
 linux-user/cris/syscall_nr.h   |  24 +++
 linux-user/cris/target_syscall.h   |  46 ++
 linux-user/i386/syscall.h  | 152 ---
 linux-user/i386/syscall_nr.h   |  29 +++-
 linux-user/i386/target_syscall.h   | 157 
 linux-user/m68k/syscall.h  |  25 
 linux-user/m68k/syscall_nr.h   |   2 +-
 linux-user/m68k/target_syscall.h   |  29 
 linux-user/main.c  |   2 +-
 linux-user/microblaze/syscall.h|  56 ---
 linux-user/microblaze/syscall_nr.h |   8 +
 linux-user/microblaze/target_syscall.h |  56 +++
 linux-user/mips/syscall.h  | 233 -
 linux-user/mips/target_syscall.h   | 237 +
 linux-user/mips64/syscall.h| 230 -
 linux-user/mips64/syscall_nr.h |  23 +++
 linux-user/mips64/target_syscall.h | 234 +
 linux-user/openrisc/syscall.h  |  29 
 linux-user/openrisc/syscall_nr.h   |  28 ++--
 linux-user/openrisc/target_syscall.h   |  34 +
 linux-user/ppc/syscall.h   |  75 --
 linux-user/ppc/syscall_nr.h|  26 +++-
 linux-user/ppc/target_syscall.h|  80 ++
 linux-user/qemu.h  |   2 +-
 linux-user/s390x/syscall.h |  29 
 linux-user/s390x/syscall_nr.h  |  30 
 linux-user/s390x/target_syscall.h  |  34 +
 linux-user/sh4/syscall.h   |  17 ---
 linux-user/sh4/syscall_nr.h|   2 +-
 linux-user/sh4/target_syscall.h|  22 +++
 linux-user/sparc/syscall.h |  20 ---
 linux-user/sparc/syscall_nr.h  |  16 +-
 linux-user/sparc/target_syscall.h  |  25 
 linux-user/sparc64/syscall.h   |  21 ---
 linux-user/sparc64/syscall_nr.h|  14 ++
 linux-user/sparc64/target_syscall.h|  26 
 linux-user/syscall.c   |  31 ++--
 linux-user/tilegx/syscall.h|  43 --
 linux-user/tilegx/syscall_nr.h |   4 +
 linux-user/tilegx/target_syscall.h |  43 ++
 linux-user/unicore32/syscall.h |  60 
 linux-user/unicore32/target_syscall.h  |  60 
 linux-user/x86_64/syscall.h| 102 -
 linux-user/x86_64/syscall_nr.h |  15 +-
 linux-user/x86_64/target_syscall.h | 107 ++
 54 files changed, 1754 insertions(+), 1551 deletions(-)
 delete mode 100644 linux-user/aarch64/syscall.h
 create mode 100644 linux-user/aarch64/target_syscall.h
 delete mode 100644 linux-user/alpha/syscall.h
 create mode 100644 linux-user/alpha/target_syscall.h
 delete mode 100644 linux-user/arm/syscall.h
 create mode 100644 linux-user/arm/target_syscall.h
 delete mode 100644 linux-user/cris/syscall.h
 create mode 100644 linux-user/cris/target_syscall.h
 delete mode 100644 linux-user/i386/syscall.h
 create mode 100644 linux-user/i386/target_syscall.h
 delete mode 100644 linux-user/m68k/syscall.h
 create mode 100644 linux-user/m68k/target_syscall.h
 delete mode 100644 linux-user/microblaze/syscall.h
 create mode 100644 linux-user/microblaze/target_syscall.h
 delete mode 100644 linux-user/mips/syscall.h

[Qemu-devel] [PULL v2 6/8] linux-user: remove unavailable syscalls from aarch64

2016-02-25 Thread riku . voipio
From: Riku Voipio 

QEMU lists deprecated system call numbers in for Aarch64. These
are never enabled for Linux kernel, so don't define them in Qemu
either. Remove the ifdef around host_to_target_stat64 since
all architectures need it now.

Reviewed-by: Peter Maydell 
Signed-off-by: Riku Voipio 
---
 linux-user/aarch64/syscall_nr.h | 59 -
 linux-user/syscall.c|  2 --
 2 files changed, 61 deletions(-)

diff --git a/linux-user/aarch64/syscall_nr.h b/linux-user/aarch64/syscall_nr.h
index c8a8599..59511d8 100644
--- a/linux-user/aarch64/syscall_nr.h
+++ b/linux-user/aarch64/syscall_nr.h
@@ -275,62 +275,3 @@
 #define TARGET_NR_mlock2 284
 #define TARGET_NR_copy_file_range 285
 
-#define TARGET_NR_open 1024
-#define TARGET_NR_link 1025
-#define TARGET_NR_unlink 1026
-#define TARGET_NR_mknod 1027
-#define TARGET_NR_chmod 1028
-#define TARGET_NR_chown 1029
-#define TARGET_NR_mkdir 1030
-#define TARGET_NR_rmdir 1031
-#define TARGET_NR_lchown 1032
-#define TARGET_NR_access 1033
-#define TARGET_NR_rename 1034
-#define TARGET_NR_readlink 1035
-#define TARGET_NR_symlink 1036
-#define TARGET_NR_utimes 1037
-#define TARGET_NR_stat 1038
-#define TARGET_NR_lstat 1039
-#define TARGET_NR_pipe 1040
-#define TARGET_NR_dup2 1041
-#define TARGET_NR_epoll_create 1042
-#define TARGET_NR_inotify_init 1043
-#define TARGET_NR_eventfd 1044
-#define TARGET_NR_signalfd 1045
-#define TARGET_NR_sendfile64 1046
-#define TARGET_NR_ftruncate64 1047
-#define TARGET_NR_truncate64 1048
-#define TARGET_NR_stat64 1049
-#define TARGET_NR_lstat64 1050
-#define TARGET_NR_fstat64 1051
-#define TARGET_NR_fcntl64 1052
-/* #define TARGET_NR_fadvise64 1053 */
-#define TARGET_NR_newfstatat 1054
-#define TARGET_NR_fstatfs64 1055
-#define TARGET_NR_statfs64 1056
-#define TARGET_NR_lseek64 1057
-#define TARGET_NR_mmap64 1058
-#define TARGET_NR_alarm 1059
-#define TARGET_NR_getpgrp 1060
-#define TARGET_NR_pause 1061
-#define TARGET_NR_time 1062
-#define TARGET_NR_utime 1063
-#define TARGET_NR_creat 1064
-#define TARGET_NR_getdents 1065
-#define TARGET_NR_futimesat 1066
-#define TARGET_NR_select 1067
-#define TARGET_NR_poll 1068
-#define TARGET_NR_epoll_wait 1069
-#define TARGET_NR_ustat 1070
-#define TARGET_NR_vfork 1071
-#define TARGET_NR_oldwait4 1072
-#define TARGET_NR_recv 1073
-#define TARGET_NR_send 1074
-#define TARGET_NR_bdflush 1075
-#define TARGET_NR_umount 1076
-#define TARGET_NR_uselib 1077
-#define TARGET_NR__sysctl 1078
-#define TARGET_NR_fork 1079
-#define TARGET_NR_syscalls (__NR_fork+1)
-
-#define TARGET_NR_sigreturn 1999
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8b76169..539183a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5231,7 +5231,6 @@ static inline int target_to_host_mlockall_arg(int arg)
 }
 #endif
 
-#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
 static inline abi_long host_to_target_stat64(void *cpu_env,
  abi_ulong target_addr,
  struct stat *host_st)
@@ -5294,7 +5293,6 @@ static inline abi_long host_to_target_stat64(void 
*cpu_env,
 
 return 0;
 }
-#endif
 
 /* ??? Using host futex calls even when target atomic operations
are not really atomic probably breaks things.  However implementing
-- 
2.1.4




[Qemu-devel] [PULL v2 2/8] build: [linux-user] Rename "syscall.h" to "target_syscall.h" in target directories

2016-02-25 Thread riku . voipio
From: Lluís Vilanova 

This fixes double-definitions in linux-user builds when using the UST
tracing backend (which indirectly includes the system's "syscall.h").

Signed-off-by: Lluís Vilanova 
Reviewed-by: Peter Maydell 
Signed-off-by: Riku Voipio 
---
 linux-user/aarch64/syscall.h   |  13 --
 linux-user/aarch64/target_syscall.h|  18 +++
 linux-user/alpha/syscall.h | 257 
 linux-user/alpha/target_syscall.h  | 262 +
 linux-user/arm/syscall.h   |  50 ---
 linux-user/arm/target_syscall.h|  54 +++
 linux-user/cris/syscall.h  |  46 --
 linux-user/cris/target_syscall.h   |  46 ++
 linux-user/i386/syscall.h  | 152 ---
 linux-user/i386/target_syscall.h   | 157 
 linux-user/m68k/syscall.h  |  25 
 linux-user/m68k/target_syscall.h   |  29 
 linux-user/microblaze/syscall.h|  56 ---
 linux-user/microblaze/target_syscall.h |  56 +++
 linux-user/mips/syscall.h  | 233 -
 linux-user/mips/target_syscall.h   | 237 +
 linux-user/mips64/syscall.h| 230 -
 linux-user/mips64/target_syscall.h | 234 +
 linux-user/openrisc/syscall.h  |  29 
 linux-user/openrisc/target_syscall.h   |  34 +
 linux-user/ppc/syscall.h   |  75 --
 linux-user/ppc/target_syscall.h|  80 ++
 linux-user/qemu.h  |   2 +-
 linux-user/s390x/syscall.h |  29 
 linux-user/s390x/target_syscall.h  |  34 +
 linux-user/sh4/syscall.h   |  17 ---
 linux-user/sh4/target_syscall.h|  22 +++
 linux-user/sparc/syscall.h |  20 ---
 linux-user/sparc/target_syscall.h  |  25 
 linux-user/sparc64/syscall.h   |  21 ---
 linux-user/sparc64/target_syscall.h|  26 
 linux-user/tilegx/syscall.h|  43 --
 linux-user/tilegx/target_syscall.h |  43 ++
 linux-user/unicore32/syscall.h |  60 
 linux-user/unicore32/target_syscall.h  |  60 
 linux-user/x86_64/syscall.h| 102 -
 linux-user/x86_64/target_syscall.h | 107 ++
 37 files changed, 1525 insertions(+), 1459 deletions(-)
 delete mode 100644 linux-user/aarch64/syscall.h
 create mode 100644 linux-user/aarch64/target_syscall.h
 delete mode 100644 linux-user/alpha/syscall.h
 create mode 100644 linux-user/alpha/target_syscall.h
 delete mode 100644 linux-user/arm/syscall.h
 create mode 100644 linux-user/arm/target_syscall.h
 delete mode 100644 linux-user/cris/syscall.h
 create mode 100644 linux-user/cris/target_syscall.h
 delete mode 100644 linux-user/i386/syscall.h
 create mode 100644 linux-user/i386/target_syscall.h
 delete mode 100644 linux-user/m68k/syscall.h
 create mode 100644 linux-user/m68k/target_syscall.h
 delete mode 100644 linux-user/microblaze/syscall.h
 create mode 100644 linux-user/microblaze/target_syscall.h
 delete mode 100644 linux-user/mips/syscall.h
 create mode 100644 linux-user/mips/target_syscall.h
 delete mode 100644 linux-user/mips64/syscall.h
 create mode 100644 linux-user/mips64/target_syscall.h
 delete mode 100644 linux-user/openrisc/syscall.h
 create mode 100644 linux-user/openrisc/target_syscall.h
 delete mode 100644 linux-user/ppc/syscall.h
 create mode 100644 linux-user/ppc/target_syscall.h
 delete mode 100644 linux-user/s390x/syscall.h
 create mode 100644 linux-user/s390x/target_syscall.h
 delete mode 100644 linux-user/sh4/syscall.h
 create mode 100644 linux-user/sh4/target_syscall.h
 delete mode 100644 linux-user/sparc/syscall.h
 create mode 100644 linux-user/sparc/target_syscall.h
 delete mode 100644 linux-user/sparc64/syscall.h
 create mode 100644 linux-user/sparc64/target_syscall.h
 delete mode 100644 linux-user/tilegx/syscall.h
 create mode 100644 linux-user/tilegx/target_syscall.h
 delete mode 100644 linux-user/unicore32/syscall.h
 create mode 100644 linux-user/unicore32/target_syscall.h
 delete mode 100644 linux-user/x86_64/syscall.h
 create mode 100644 linux-user/x86_64/target_syscall.h

diff --git a/linux-user/aarch64/syscall.h b/linux-user/aarch64/syscall.h
deleted file mode 100644
index dc72a15..000
--- a/linux-user/aarch64/syscall.h
+++ /dev/null
@@ -1,13 +0,0 @@
-struct target_pt_regs {
-uint64_tregs[31];
-uint64_tsp;
-uint64_tpc;
-uint64_tpstate;
-};
-
-#define UNAME_MACHINE "aarch64"
-#define UNAME_MINIMUM_RELEASE "3.8.0"
-#define TARGET_CLONE_BACKWARDS
-#define TARGET_MINSIGSTKSZ   2048
-#define TARGET_MLOCKALL_MCL_CURRENT 1
-#define TARGET_MLOCKALL_MCL_FUTURE  2
diff --git a/linux-user/aarch64/target_syscall.h 
b/linux-user/aarch64/target_syscall.h
new file mode 100644
index 000..f458018
--- /dev/null
+++ b/linux-user/aarch64/tar

[Qemu-devel] [PULL v2 1/8] linux-user: fix realloc size of target_fd_trans.

2016-02-25 Thread riku . voipio
From: Laurent Vivier 

target_fd_trans is an array of "TargetFdTrans *": compute size
accordingly. Use g_renew() as proposed by Paolo.

Reported-by: Paolo Bonzini 
Signed-off-by: Laurent Vivier 
Signed-off-by: Riku Voipio 
---
 linux-user/syscall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 54ce14a..dac5518 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -318,8 +318,8 @@ static void fd_trans_register(int fd, TargetFdTrans *trans)
 if (fd >= target_fd_max) {
 oldmax = target_fd_max;
 target_fd_max = ((fd >> 6) + 1) << 6; /* by slice of 64 entries */
-target_fd_trans = g_realloc(target_fd_trans,
-target_fd_max * sizeof(TargetFdTrans));
+target_fd_trans = g_renew(TargetFdTrans *,
+  target_fd_trans, target_fd_max);
 memset((void *)(target_fd_trans + oldmax), 0,
(target_fd_max - oldmax) * sizeof(TargetFdTrans *));
 }
-- 
2.1.4




[Qemu-devel] [PULL v2 3/8] linux-user: set ppc64/ppc64le default CPU to POWER8

2016-02-25 Thread riku . voipio
From: Laurent Vivier 

Set the default to the latest CPU version to have the
largest set of available features.

It is also really needed in little-endian mode because
POWER7 is not really supported in this mode and some distros
(at least debian) generate POWER8 code for their ppc64le target.

Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813698

Signed-off-by: Laurent Vivier 
Reviewed-by: Alexander Graf 
Reviewed-by: Michael Tokarev 
Signed-off-by: Riku Voipio 
---
 linux-user/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index e719a2d..2a692e0 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4160,7 +4160,7 @@ int main(int argc, char **argv, char **envp)
 cpu_model = "or1200";
 #elif defined(TARGET_PPC)
 # ifdef TARGET_PPC64
-cpu_model = "POWER7";
+cpu_model = "POWER8";
 # else
 cpu_model = "750";
 # endif
-- 
2.1.4




[Qemu-devel] [PULL v2 8/8] linux-user: add getrandom() syscall

2016-02-25 Thread riku . voipio
From: Laurent Vivier 

getrandom() has been introduced in kernel 3.17 and is now used during
the boot sequence of Debian unstable (stretch/sid).

Signed-off-by: Laurent Vivier 
Signed-off-by: Riku Voipio 
---
 linux-user/syscall.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 539183a..9517531 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -249,6 +249,9 @@ _syscall2(int, ioprio_get, int, which, int, who)
 #if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
 _syscall3(int, ioprio_set, int, which, int, who, int, ioprio)
 #endif
+#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
+_syscall3(int, getrandom, void *, buf, size_t, buflen, unsigned int, flags)
+#endif
 
 static bitmask_transtbl fcntl_flags_tbl[] = {
   { TARGET_O_ACCMODE,   TARGET_O_WRONLY,O_ACCMODE,   O_WRONLY,},
@@ -7541,6 +7544,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
arg1,
 ret = get_errno(shutdown(arg1, arg2));
 break;
 #endif
+#if defined(TARGET_NR_getrandom) && defined(__NR_getrandom)
+case TARGET_NR_getrandom:
+p = lock_user(VERIFY_WRITE, arg1, arg2, 0);
+if (!p) {
+goto efault;
+}
+ret = get_errno(getrandom(p, arg2, arg3));
+unlock_user(p, arg1, ret);
+break;
+#endif
 #ifdef TARGET_NR_socket
 case TARGET_NR_socket:
 ret = do_socket(arg1, arg2, arg3);
-- 
2.1.4




[Qemu-devel] [PULL v2 4/8] linux-user: Don't assert if guest tries shmdt(0)

2016-02-25 Thread riku . voipio
From: Peter Maydell 

Our implementation of shmat() and shmdt() for linux-user was
using "zero guest address" as its marker for "entry in the
shm_regions[] array is not in use". This meant that if the
guest did a shmdt(0) we would match on an unused array entry
and call page_set_flags() with both start and end addresses zero,
which causes an assertion failure.

Use an explicit in_use flag to manage the shm_regions[] array,
so that we avoid this problem.

Signed-off-by: Peter Maydell 
Reported-by: Pavel Shamis 
Reviewed-by: Laurent Vivier 
Signed-off-by: Riku Voipio 
---
 linux-user/syscall.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dac5518..8b76169 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2598,8 +2598,9 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
 #define N_SHM_REGIONS  32
 
 static struct shm_region {
-abi_ulong  start;
-abi_ulong  size;
+abi_ulong start;
+abi_ulong size;
+bool in_use;
 } shm_regions[N_SHM_REGIONS];
 
 struct target_semid_ds
@@ -3291,7 +3292,8 @@ static inline abi_ulong do_shmat(int shmid, abi_ulong 
shmaddr, int shmflg)
((shmflg & SHM_RDONLY)? 0 : PAGE_WRITE));
 
 for (i = 0; i < N_SHM_REGIONS; i++) {
-if (shm_regions[i].start == 0) {
+if (!shm_regions[i].in_use) {
+shm_regions[i].in_use = true;
 shm_regions[i].start = raddr;
 shm_regions[i].size = shm_info.shm_segsz;
 break;
@@ -3308,8 +3310,8 @@ static inline abi_long do_shmdt(abi_ulong shmaddr)
 int i;
 
 for (i = 0; i < N_SHM_REGIONS; ++i) {
-if (shm_regions[i].start == shmaddr) {
-shm_regions[i].start = 0;
+if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) {
+shm_regions[i].in_use = false;
 page_set_flags(shmaddr, shmaddr + shm_regions[i].size, 0);
 break;
 }
-- 
2.1.4




[Qemu-devel] [Bug 1549654] Re: qemu-system-arm emulator

2016-02-25 Thread Peter Maydell
> the 1st instruction stores R3 at [fp, #-8] and the second instruction
can not restores the value from the same address

In bare metal code this usually means you're trying to store to an
address which does not actually have any RAM in it.

Here R13=00011088, and for the vexpress-a9 board that has a NOR flash
device at it, not RAM. RAM starts at 0x6000. If you link your
program to use the RAM at the RAM address you should find it works
better.

(In earlier versions of QEMU we did have RAM at the 0 address. In real
hardware the 0 address is a remappable range which may point to flash or
to RAM depending on board configuration. For QEMU we don't model the
reconfigurability, and we picked flash because this allows us to run
various BIOS-style ROM images. It does unfortunately mean we broke a few
odd bare metal images which were relying on the RAM being mapped in
there.)

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

Title:
  qemu-system-arm emulator

Status in QEMU:
  New

Bug description:
  Hi,

  I don't know if this is a bug or a feature in new QEMU software. I was
  following an online tutorial using QEMU  to develop a simple bare-
  metal program for qemu-system-arm. I decided to try a more recent
  software and I got surprised when I found the small code can not run
  on newer QEMU software (all newer than 2.0.0) but can run on the old
  QEMU from Ubuntu (Debian 2.0.0+dfsg-2ubuntu1.22) and the stock version
  from website. After putting the qemu-system-arm in single step and
  saving the log, the following is the output which you can see the 1st
  instruction stores R3 at [fp, #-8] and the second instruction can not
  restores the value from the same address to R0:

  0x00010074:  e50b3008  str  r3, [fp, #-8]

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=00010074
  PSR=41d3 -Z-- A S svc32
  
  IN: kmain
  0x00010078:  e51b0008  ldrr0, [fp, #-8]

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=00010078
  PSR=41d3 -Z-- A S svc32
  
  IN: kmain
  0x0001007c:  ebe3  bl 0x10010

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=0001007c
  PSR=41d3 -Z-- A S svc32

  --
  Meanwhile the older version of QEMU 2.0.0 does this very well and can execute 
the program normally:

  0x00010074:  e50b3008  str  r3, [fp, #-8]

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=00010074
  PSR=41d3 -Z-- A svc32
  
  IN: kmain
  0x00010078:  e51b0008  ldrr0, [fp, #-8]

  R00= R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=00010078
  PSR=41d3 -Z-- A svc32
  
  IN: kmain
  0x0001007c:  ebe3  bl 0x10010

  R00=0001008c R01= R02= R03=0001008c
  R04= R05= R06= R07=
  R08= R09= R10= R11=00011094
  R12= R13=00011088 R14=00010008 R15=0001007c
  PSR=41d3 -Z-- A svc32
  

  The command line to use was:

  qemu-system-arm -M vexpress-a9 -cpu cortex-a9 -smp 1 -m 64M -nographic
  -kernel kernel.elf -singlestep -D file.log -d in_asm,cpu

  The kernel.elf is a simple program (elf) file, created from two
  sources:

  boot.S:

  .global _RESET
  _RESET:
  LDR sp, =_STACK
  BL kmain
  B .

  And kernel.c:

  # define UART0_MEM   0x10009000

  volatile unsigned int * const UART0 = (unsigned int *) UART0_MEM;
  void dprint(const char* message){
while(*message != 0) {
*UART0=*message;
++message;
}
  }
  void kmain() {
const char *hi="Hello!";
dprint(hi);
  };

  The linker scripts is:
  ENTRY(_RESET)
  SECTIONS
  {
   . = 0x1;
   .boot . : { boot.o(.text) }
   .text : { *(.text) }
   .data : { *(.data) }
   .bss : { *(.bss COMMON) }
   . = ALIGN(8);
   . = . + 0x1000; /* 4kB of stack memory */
   _STACK = .;
  }

  This error cases the dprint function to find *message as 0 and do not
  print the output in newer QEMU software.

  Thank you for consideration.

To manage notifications about this bug go to:
https://bugs.launchpad.net/qe

  1   2   3   4   >