[Qemu-devel] [PULL v3 00/15] Tracing patches

2015-11-12 Thread Stefan Hajnoczi
v3:
 * Include "exec/log.h" from translate-a64.c [Peter]

v2:
 * Add missing log.py file [Peter]

The following changes since commit 74fcbd22d20a2fbc1a47a7b00cce5bf98fd7be5f:

  hw/misc: Add support for ADC controller in Xilinx Zynq 7000 (2015-11-12 
21:30:42 +)

are available in the git repository at:

  git://github.com/stefanha/qemu.git tags/tracing-pull-request

for you to fetch changes up to de332788d7c626fce31f6baebab807df5a7410e1:

  log: add "-d trace:PATTERN" (2015-11-13 15:52:57 +0800)





Denis V. Lunev (2):
  trace: no need to call trace_backend_init in different branches now
  log: move qemu-log.c into util/ directory

Paolo Bonzini (11):
  trace: count number of enabled events
  trace: track enabled events in a separate array
  trace: fix documentation
  trace: split trace_init_events out of trace_init_backends
  trace: split trace_init_file out of trace_init_backends
  trace: add "-trace enable=..."
  trace: add "-trace help"
  log: do not unnecessarily include qom/cpu.h
  trace: convert stderr backend to log
  trace: switch default backend to "log"
  log: add "-d trace:PATTERN"

Stefan Hajnoczi (2):
  trace: fix make foo-timestamp rules
  trace: add make dependencies on tracetool source

 Makefile.objs|   1 -
 bsd-user/main.c  |   1 +
 configure|   6 +-
 cpu-exec.c   |   1 +
 exec.c   |   1 +
 hw/acpi/cpu_hotplug.c|   1 +
 hw/timer/a9gtimer.c  |   1 +
 include/exec/log.h   |  60 +++
 include/qemu/log.h   |  60 +--
 linux-user/main.c|   1 +
 qemu-io.c|   2 +-
 qemu-log.c   | 177 
 qemu-options.hx  |  22 ++--
 qom/cpu.c|   1 +
 scripts/tracetool/backend/log.py |  48 +
 scripts/tracetool/backend/stderr.py  |  47 -
 scripts/tracetool/format/events_c.py |   2 +-
 target-alpha/translate.c |   1 +
 target-arm/translate-a64.c   |   1 +
 target-arm/translate.c   |   1 +
 target-cris/translate.c  |   1 +
 target-i386/seg_helper.c |   1 +
 target-i386/smm_helper.c |   1 +
 target-i386/translate.c  |   1 +
 target-lm32/helper.c |   1 +
 target-lm32/translate.c  |   1 +
 target-m68k/translate.c  |   1 +
 target-microblaze/helper.c   |   1 +
 target-microblaze/translate.c|   1 +
 target-mips/helper.c |   1 +
 target-mips/translate.c  |   1 +
 target-moxie/translate.c |   1 +
 target-openrisc/translate.c  |   1 +
 target-ppc/mmu-hash32.c  |   1 +
 target-ppc/mmu-hash64.c  |   1 +
 target-ppc/mmu_helper.c  |   1 +
 target-ppc/translate.c   |   1 +
 target-s390x/translate.c |   1 +
 target-sh4/helper.c  |   1 +
 target-sh4/translate.c   |   1 +
 target-sparc/int32_helper.c  |   1 +
 target-sparc/int64_helper.c  |   1 +
 target-sparc/translate.c |   1 +
 target-tilegx/translate.c|   1 +
 target-tricore/translate.c   |   1 +
 target-unicore32/translate.c |   1 +
 target-xtensa/translate.c|   1 +
 tcg/tcg.c|   1 +
 trace/Makefile.objs  |  48 +
 trace/control-internal.h |  15 ++-
 trace/control.c  |  98 +-
 trace/control.h  |  44 +++-
 trace/event-internal.h   |   2 -
 trace/simple.c   |   6 +-
 trace/simple.h   |   4 +-
 translate-all.c  |   1 +
 util/Makefile.objs   |   1 +
 util/log.c   | 190 +++
 vl.c |  38 ---
 59 files changed, 537 insertions(+), 373 deletions(-)
 create mode 100644 include/exec/log.h
 delete mode 100644 qemu-log.c
 create mode 100644 scripts/tracetool/backend/log.py
 delete mode 100644 scripts/tracetool/backend/stderr.py
 create mode 100644 util/log.c

-- 
2.5.0




Re: [Qemu-devel] [PULL 17/24] qom/object: fix 2 comment typos

2015-11-12 Thread Markus Armbruster
Michael Tokarev  writes:

> 12.11.2015 20:53, Andreas Färber wrote:
>> Am 06.11.2015 um 13:43 schrieb Michael Tokarev:
>>> From: Cao jin 
>>>
>>> Also change the misleading definition of macro OBJECT_CLASS_CHECK
>>>
>>> Signed-off-by: Cao jin 
>>> Signed-off-by: Michael Tokarev 
>> 
>> Michael, please *STOP* queuing QOM patches! You merged the unfixed
>
> I think I do more harm to the project than good, these days.

Nope, you'd have to try much harder for that ;-P

Mistakes happen.  Grieving over them isn't productive.  Looking for
clues on how to avoid repetition can be.

In this particular case, you tried to help out a maintainer, and the
maintainer didn't like the result.  Possible strategy:

0. Make sure to cc: maintainers in your reply to the patch.

1. If you judge the patch not to be trivial, say so.

2. For maintainers who prefer not to be helped out by -trivial (in your
   subjective judgement), reply that you're going to take this only if
   the maintainer gives his blessings.

3. Else, do your usual review and "applied to -trivial" thing.
   Additionally, add any missing cc: maintainer(s) when you commit.
   Perhaps you can even automate this step.  That way, they get cc'ed on
   your pull request, too, giving them a last chance to veto a patch
   they missed / ignored until then.

Basically, just what you do know plus systematic cc'ing.

Thanks for serving as -trivial maintainer!

[...]



Re: [Qemu-devel] [PATCH v2 7/7] spice: Initialization stubs on qemu-spice.h

2015-11-12 Thread Gerd Hoffmann
On Do, 2015-11-12 at 17:02 -0200, Eduardo Habkost wrote:
> This reduces the number of CONFIG_SPICE #ifdefs in vl.c.
> 
> Cc: Gerd Hoffmann 
> Signed-off-by: Eduardo Habkost 
> ---
> Changes v1 -> v2:
> * Move stubs to qemu-spice.h, as the header file already
>   had a separate section for !CONFIG_SPICE

Reviewed-by: Gerd Hoffmann 

cheers,
  Gerd




Re: [Qemu-devel] [PATCH for-2.5 v2] input: Document why x-input-send-event is still experimental

2015-11-12 Thread Gerd Hoffmann
On Do, 2015-11-12 at 11:50 -0700, Eric Blake wrote:
> The x-input-send-event command was introduced in 2.2 with mention
> that it is experimental, but now that several releases have elapsed
> without any changes, it would be nice to document why that was done
> and should still remain experimental in 2.5.
> 
> Meanwhile, our documentation states that we prefer 'lower-case',
> rather than 'CamelCase', for qapi enum values.  The InputButton and
> InputAxis enums violate this convention.  However, because they are
> currently used primarily for generating code that is used internally;
> and their only exposure through QMP is via the experimental
> 'x-input-send-event' command, we are free to change their spelling.
> Of course, it would be nicer to delay such a change until the same
> time we promote the command to non-experimental.  Adding
> documentation will help us remember to do that rename.
> 
> We have plans to tighten the qapi generator to flag instances of
> inconsistent use of naming conventions; if that lands first, it
> will just need to whitelist these exceptions until the time we
> settle on the final interface.

Reviewed-by: Gerd Hoffmann 




[Qemu-devel] [PATCH 1/2] vhost: let SET_VRING_ENABLE message depends on protocol feature

2015-11-12 Thread Yuanhan Liu
But not depend on PROTOCOL_F_MQ feature bit. So that we could use
SET_VRING_ENABLE to sign the backend on stop, even if MQ is disabled.

That's reasonable, since we will have one queue pair at least.

Signed-off-by: Yuanhan Liu 
---
 hw/virtio/vhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 4766f98..a9c8335 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -331,7 +331,7 @@ static int vhost_user_set_vring_enable(struct vhost_dev 
*dev, int enable)
 .num   = enable,
 };
 
-if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) {
+if (!virtio_has_feature(dev->features, VHOST_USER_F_PROTOCOL_FEATURES)) {
 return -1;
 }
 
-- 
1.9.3




[Qemu-devel] [PATCH 2/2] vhost: don't send RESET_OWNER at stop

2015-11-12 Thread Yuanhan Liu
First of all, RESET_OWNER message is sent incorrectly, as it's sent
before GET_VRING_BASE. And the reset message would let the later call
get nothing correct.

And, sending SET_VRING_ENABLE at stop, which has already been done,
makes more sense than RESET_OWNER.

Signed-off-by: Yuanhan Liu 
---
 hw/net/vhost_net.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index d91b7b1..14337a4 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -292,12 +292,6 @@ static void vhost_net_stop_one(struct vhost_net *net,
 int r = vhost_ops->vhost_net_set_backend(&net->dev, &file);
 assert(r >= 0);
 }
-} else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
-for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
-const VhostOps *vhost_ops = net->dev.vhost_ops;
-int r = vhost_ops->vhost_reset_device(&net->dev);
-assert(r >= 0);
-}
 }
 if (net->nc->info->poll) {
 net->nc->info->poll(net->nc, true);
-- 
1.9.3




Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread Thomas Huth
On 13/11/15 02:57, David Gibson wrote:
> On Thu, Nov 12, 2015 at 10:40:11AM +0100, Thomas Huth wrote:
>> On 12/11/15 09:09, Thomas Huth wrote:
>>> On 11/11/15 18:16, Aravinda Prasad wrote:
[...]
 +qemu_mutex_lock(&spapr->mc_in_progress);
>>>
>>> Using a mutex here is definitely wrong. The kvm_arch_handle_exit() code
>>> is run under the Big QEMU Lock™ (see qemu_mutex_lock_iothread() in
>>> kvm_cpu_exec()),
[...]
>> Ok, I now had a look into the LoPAPR spec, and if I've got that right,
>> you really have to serialize the NMIs in case they happen at multiple
>> CPUs at the same time. So I guess the best thing you can do here is
>> something like:
>>
>>while (spapr->mc_in_progress) {
>>/*
>> * There is already another NMI in progress, thus we need
>> * to yield here to wait until it has been finsihed
>> */
>>qemu_mutex_unlock_iothread();
>>usleep(10);
>>qemu_mutex_lock_iothread();
>>}
>>spapr->mc_in_progress = true;
[...]
> You should be able to avoid the nasty usleep by using a pthread
> condition variable.  So here you'd have
> 
> while (spapr->mc_in_progress) {
> pthread_cond_wait(&mc_delivery_cond, &qemu_iothread_lock);
> }
> spapr->mc_in_progress = true;
> 
> Or.. there may be qemu wrappers around the pthread functions you
> should be using.  Once delivery of a single MC is complete, you'd use
> pthread_cond_signal() to wake up any additional ones.
> 
> pthread_cond_wait automatically drops the specified mutex internally,
> so access to mc_in_progress itself is still protected by the iothread
> mutex.

That's a nice one, didn't know that function yet! And actually, there is
already a QEMU wrapper function: qemu_cond_wait() - so this should be
used instead since threads on Windows are working differently in QEMU as
far as I know.

 Thomas





signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [RFC PATCH 0/8] Towards an Heterogeneous QEMU

2015-11-12 Thread Peter Crosthwaite
Hi Christian,

Sorry about the delayed response.

On Tue, Oct 27, 2015 at 3:30 AM, Christian Pinto <
c.pi...@virtualopensystems.com> wrote:

>
>
> On 25/10/2015 22:38, Peter Crosthwaite wrote:
>
> On Thu, Oct 22, 2015 at 2:21 AM, Christian 
> Pinto  wrote:
>
> Hello Peter,
>
>
> On 07/10/2015 17:48, Peter Crosthwaite wrote:
>
> On Mon, Oct 5, 2015 at 8:50 AM, Christian 
> Pinto  wrote:
>
> Hello Peter,
>
> thanks for your comments
>
> On 01/10/2015 18:26, Peter Crosthwaite wrote:
>
> On Tue, Sep 29, 2015 at 6:57 AM, Christian 
> Pinto   wrote:
>
> Hi all,
>
> This RFC patch-series introduces the set of changes enabling the
> architectural elements to model the architecture presented in a
> previous
> RFC
> letter: "[Qemu-devel][RFC] Towards an Heterogeneous QEMU".
>
> and the OS binary image needs
> to be placed in memory at model startup.
>
>
> I don't see what this limitation is exactly. Can you explain more? I
> do see a need to work on the ARM bootloader for AMP flows, it is a
> pure SMP bootloader than assumes total control.
>
> the problem here was to me that when we launch QEMU a binary needs to be
> provided and put in memory
> in order to be executed. In this patch series the slave doesn't have a
> proper memory allocated when first launched.
>
> But it could though couldn't it? Can't the slave guest just have full
> access to it's own address space (probably very similar to the masters
> address space) from machine init time? This seems more realistic than
> setting up the hardware based on guest level information.
>
> Actually the address space for a slave is built at init time, the thing that
> is not
> completely configured is the memory region modeling the RAM. Such region is
> configured
> in terms of size, but there is no pointer to the actual memory. The pointer
> is mmap-ed later
> before the slave boots.
>
>
> based on what information? Is the master guest controlling this? If so
> what is the real-hardware analogue for this concept where the address
> map of the slave can change (i.e. be configured) at runtime?
>
> Hello Peter,
>
> The memory map of a slave is not controlled by the master guest, since it
> is
> dependent from the machine model used for the slave. The only thing the
> master
> controls is the subset of the main memory that is assigned to a slave.  By
> saying that the memory pointer is sent to the slave later, before the
> boot, it is like setting the
> boot address for that specific slave within the whole platform memory. So
> essentially the offset passed for the mmap is from beginning of master
> memory up to the
> beginning of the memory carved out for the specific slave. I see this as a
> way to
> protect the master memory from  malicious accesses from the slave side, so
> this
> way the slave will only "see" the part of the memory that it got assigned.
>
>
That does sound like memory map control though. Is it simpler to just give
the slave full access and implement such protections as a specific feature
(probably some sort of IOMMU)?


> The information about memory (fd + offset for mmap) is sent only later
> when
> the boot is triggered. This is also
> safe since the slave will be waiting in the incoming state, and thus no
> corruption or errors can happen before the
> boot is triggered.
>
> I was thinking more about your comment about slave-to-slave
> interrupts. This would just trivially be a local software-generated
> interrupts of some form within the slave cluster.
>
> Sorry, I did not catch your comment at first time. You are right, if cores
> are in the same cluster
> a software generated interrupt is going to be enough. Of course the eventfd
> based interrupts
> make sense for a remote QEMU.
>
>
> Is eventfd a better implementation of remote-port GPIOs as in the Xilinx work?
>
>
> Functionally I think they provide the same behavior. We went for eventfd
> since
> when designing the code of the IDM we based it on what available on
> upstream QEMU
> to signal events between processes (e.g., eventfd).
>
> Re the terminology, I don't like the idea of thinking of inter-qemu
> "interrupts" as whatever system we decide on should be able to support
> arbitrary signals going from one QEMU to another. I think the Xilinx
> work already has reset signals going between the QEMU peers.
>
>
> We used the inter-qemu interrupt term, since such signal was triggered
> from the IDM
> and is an interrupt. But I see your point and agree that such interrupt
> could be a generic
> inter-qemu signaling mechanism, that can be used as interrupt for this
> specific purpose.
>
>
> The multi client-socket is used for the master to trigger
> the boot of a slave, and also for each master-slave couple to
> exchancge the
> eventd file descriptors. The IDM device can be instantiated
> either
> as a
> PCI or sysbus device.
>
>
> So if everything is is one QEMU, IPIs can be implemented with just a
>
> of registers makes the master in
> "control" each of the slaves. The 

Re: [Qemu-devel] [PATCH v2 2/2] i440fx: print an error message if user tries to enable iommu

2015-11-12 Thread Bandan Das
Eric Blake  writes:

> On 11/12/2015 03:55 PM, Bandan Das wrote:
>> There's no indication of any sort that i440fx doesn't support
>> "iommu=on""
>> 
>> Signed-off-by: Bandan Das 
>> ---
>>  hw/pci-host/piix.c | 5 +
>>  1 file changed, 5 insertions(+)
>> 
>
>> @@ -301,6 +302,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, 
>> Error **errp)
>>  static void i440fx_realize(PCIDevice *dev, Error **errp)
>>  {
>>  dev->config[I440FX_SMRAM] = 0x02;
>> +
>> +if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
>> +error_report("warning: i440fx doesn't support emulated iommu\n");
>
> No trailing \n with error_report().
>
> With that fixed (and perhaps maintainer can do it),

No problem, I sent out an updated version. Thanks for the review!

Bandan

> Reviewed-by: Eric Blake 



[Qemu-devel] [PATCH v3 0/2] Minor cleanups when parsing the "iommu" option

2015-11-12 Thread Bandan Das
Small cleanup changes. The first removes the helper function by directly
checking the property and the second adds a error message if user tries
to use "-machine iommu=on" with i440fx.

v3:
error_report does not need a \n!

v2:
2/2: use error_report for the warning message

Bandan Das (2):
  q35: Check propery to determine if iommu is set
  i440fx: print an error message if user tries to enable iommu

 hw/core/machine.c   | 5 -
 hw/pci-host/piix.c  | 5 +
 hw/pci-host/q35.c   | 2 +-
 include/hw/boards.h | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

-- 
2.5.0




[Qemu-devel] [PATCH v3 1/2] q35: Check propery to determine if iommu is set

2015-11-12 Thread Bandan Das
The helper function machine_iommu() isn't necesary. We can
directly check for the property.

Signed-off-by: Bandan Das 
---
 hw/core/machine.c   | 5 -
 hw/pci-host/q35.c   | 2 +-
 include/hw/boards.h | 1 -
 3 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index f4db340..acca00d 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -462,11 +462,6 @@ bool machine_usb(MachineState *machine)
 return machine->usb;
 }
 
-bool machine_iommu(MachineState *machine)
-{
-return machine->iommu;
-}
-
 bool machine_kernel_irqchip_allowed(MachineState *machine)
 {
 return machine->kernel_irqchip_allowed;
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index c81507d..1fb4707 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -506,7 +506,7 @@ static void mch_realize(PCIDevice *d, Error **errp)
  PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
 }
 /* Intel IOMMU (VT-d) */
-if (machine_iommu(current_machine)) {
+if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
 mch_init_dmar(mch);
 }
 }
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3e9a92c..24eb6f0 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -33,7 +33,6 @@ MachineClass *find_default_machine(void);
 extern MachineState *current_machine;
 
 bool machine_usb(MachineState *machine);
-bool machine_iommu(MachineState *machine);
 bool machine_kernel_irqchip_allowed(MachineState *machine);
 bool machine_kernel_irqchip_required(MachineState *machine);
 int machine_kvm_shadow_mem(MachineState *machine);
-- 
2.5.0




[Qemu-devel] [PATCH v3 2/2] i440fx: print an error message if user tries to enable iommu

2015-11-12 Thread Bandan Das
There's no indication of any sort that i440fx doesn't support
"iommu=on"

Reviewed-by: Eric Blake 
Signed-off-by: Bandan Das 
---
 hw/pci-host/piix.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 7b2fbf9..715208b 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -34,6 +34,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/i386/ioapic.h"
 #include "qapi/visitor.h"
+#include "qemu/error-report.h"
 
 /*
  * I440FX chipset data sheet.
@@ -301,6 +302,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error 
**errp)
 static void i440fx_realize(PCIDevice *dev, Error **errp)
 {
 dev->config[I440FX_SMRAM] = 0x02;
+
+if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
+error_report("warning: i440fx doesn't support emulated iommu");
+}
 }
 
 PCIBus *i440fx_init(const char *host_type, const char *pci_type,
-- 
2.5.0




Re: [Qemu-devel] [PATCH] i.MX: add support for lower and upper interrupt in GPIO.

2015-11-12 Thread Peter Crosthwaite
On Wed, Oct 28, 2015 at 12:10 AM, Jean-Christophe DUBOIS
 wrote:
> Le 27/10/2015 23:41, Peter Crosthwaite a écrit :
>
>
>
> On Tue, Oct 27, 2015 at 3:32 PM, Jean-Christophe Dubois
>  wrote:
>>
>> The i.MX6 GPIO device supports 2 interrupts instead of one.
>>
>> * 1 for the lower 16 GPIOs.
>> * 1 for the upper 16 GPIOs.
>>
>> i.MX31 and i.MX25 only support 1 interrupt for the 32 GPIOs.
>>
>
> So an architectural question, is it the case that the IP always has two
> outbound interrupt lines but MX31 and 25 always OR together on the SoC
> level?
>
>
> Well, I am not part of Freescale so I just don't know anything about
> internal implementation details of this IP and its use inside the SOC.
>
> What we can say is that the dual interrupt version (i.MX6) is newer than the
> single one (i.MX31, i.MX25). So my guess is that this is an evolution of the
> IP and the goal was to make GPIO interrupt handling easier, faster and
> prioritisable.
>
>
>
> If that is the case I think it would be cleaner to do on the board level.
>
>
> At the SOC level I was planning to set (or not) the new property and to
> assign 1 (or 2) IRQ to the device.
>

Ok, there were no architecture clues in the TRM so this approach wins.

Reviewed-by: Peter Crosthwaite 

One possibility is to do some lightweight subclasses for the imx25/31
and imx6 versions, to avoid SoCs having to manipulate number
properties for fixed IPs. See hw/usb/hcd-ehci-sysbus.c for some
examples of SoCs tweaking a peripheral to get their own version of it
as a customized device type.

Regards,
Peter

> Regards
>
> JC
>
>
>
> Regards,
> Peter
>
>
>>
>> So we add a property to turn the behavior on when required.
>>
>> Signed-off-by: Jean-Christophe Dubois 

>>  uint32_t isr;
>>  bool has_edge_sel;
>>  uint32_t edge_sel;
>> +bool has_upper_pin_irq;
>>
>> -qemu_irq irq;
>> +qemu_irq irq[2];
>>  qemu_irq output[IMX_GPIO_PIN_COUNT];
>>  } IMXGPIOState;
>>
>> --
>> 2.5.0
>>
>
>



Re: [Qemu-devel] [PATCH v2 1/2] i.MX: rework CCM driver.

2015-11-12 Thread Peter Crosthwaite
On Wed, Oct 28, 2015 at 4:02 PM, Jean-Christophe Dubois
 wrote:
> The CCM drive is in fact specific to the i.MX31. We need to add an i.MX25
> CCM driver.
>
> As a first step, we split the CCM driver into 2 parts:
> 1) A common/utility part that allow to compute an manipulate clock freq for
>any CCM driver
> 2) The i.MX31 CCM specifc driver.
>
> We also remove EPIT/GPT timer reference to CCM. These objects now use the
> utility function we added in 1) instead of direct reference to CCM object.
>
> Signed-off-by: Jean-Christophe Dubois 
> ---
>
> Changes since v1:
>  * None
>
>  hw/arm/fsl-imx25.c  |   6 +-
>  hw/arm/fsl-imx31.c  |   6 +-
>  hw/misc/Makefile.objs   |   1 +
>  hw/misc/imx31_ccm.c | 240 ++
>  hw/misc/imx_ccm.c   | 249 
> +++-

This is tricky to review as there is a combination of refactoring as
well as major code motion. To get a diff on this, I split the patch in
two, first with a pure mechanical patch that renames everything "IMX
CCM" related to "IMX31 CCM". The diff on that is then easily reviewed
if the patch is formatted with rename detection on. To setup rename
detection:

git config diff.renames true; git config diff.algorithm patience

With that, the diff on the rest (second patch) is:

$ git diff --stat HEAD..77f8cde33bebe057d668c6e6e2c420ee4e37dbae
 hw/arm/fsl-imx25.c  |  4 ---
 hw/arm/fsl-imx31.c  |  4 ---
 hw/misc/Makefile.objs   |  1 +
 hw/misc/imx31_ccm.c | 73 +
 hw/misc/imx_ccm.c   | 50 +++
 hw/timer/imx_epit.c | 10 +++
 hw/timer/imx_gpt.c  | 14 -
 include/hw/misc/imx31_ccm.h | 25 +---
 include/hw/misc/imx_ccm.h   | 48 +
 include/hw/timer/imx_epit.h |  1 -
 include/hw/timer/imx_gpt.h  |  1 -
 11 files changed, 133 insertions(+), 98 deletions(-)

I'm reviewing based on what I can see in this new diff. You can get
the split version here:

https://github.com/pcrost/qemu/commits/imx-ccm.next

>  hw/timer/imx_epit.c |   8 +-
>  hw/timer/imx_gpt.c  |  12 +--
>  include/hw/arm/fsl-imx25.h  |   4 +-
>  include/hw/arm/fsl-imx31.h  |   4 +-
>  include/hw/misc/imx31_ccm.h |  68 
>  include/hw/misc/imx_ccm.h   |  73 +++--
>  include/hw/timer/imx_epit.h |   1 -
>  include/hw/timer/imx_gpt.h  |   1 -
>  13 files changed, 354 insertions(+), 319 deletions(-)
>  create mode 100644 hw/misc/imx31_ccm.c
>  create mode 100644 include/hw/misc/imx31_ccm.h
>
> diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
> index e1cadac..620c5c6 100644
> --- a/hw/arm/fsl-imx25.c
> +++ b/hw/arm/fsl-imx25.c
> @@ -38,7 +38,7 @@ static void fsl_imx25_init(Object *obj)
>  object_initialize(&s->avic, sizeof(s->avic), TYPE_IMX_AVIC);
>  qdev_set_parent_bus(DEVICE(&s->avic), sysbus_get_default());
>
> -object_initialize(&s->ccm, sizeof(s->ccm), TYPE_IMX_CCM);
> +object_initialize(&s->ccm, sizeof(s->ccm), TYPE_IMX31_CCM);
>  qdev_set_parent_bus(DEVICE(&s->ccm), sysbus_get_default());
>
>  for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
> @@ -150,8 +150,6 @@ static void fsl_imx25_realize(DeviceState *dev, Error 
> **errp)
>  { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ }
>  };
>
> -s->gpt[i].ccm = DEVICE(&s->ccm);
> -
>  object_property_set_bool(OBJECT(&s->gpt[i]), true, "realized", &err);
>  if (err) {
>  error_propagate(errp, err);

> +imx_ccm_get_clock_frequency(CLK_AHB) / 100,
> +imx_ccm_get_clock_frequency(CLK_IPG));
> +}
> +
> +static void imx31_ccm_reset(DeviceState *dev)
> +{
> +IMX31CCMState *s = IMX31_CCM(dev);
> +
> +s->ccmr = 0x074b0b7b;
> +s->pdr0 = 0xff870b48;
> +s->pdr1 = 0x49fcfe7f;
> +s->mpctl = PLL_PD(1) | PLL_MFD(0) | PLL_MFI(6) | PLL_MFN(0);
> +s->cgr[0] = s->cgr[1] = s->cgr[2] = 0x;
> +s->spctl = PLL_PD(1) | PLL_MFD(4) | PLL_MFI(0xc) | PLL_MFN(1);
> +s->pmcr0 = 0x80209828;
> +
> +update_clocks(s);
> +}
> +
> +static uint64_t imx31_ccm_read(void *opaque, hwaddr offset,
> +unsigned size)

Indentation of continued arg list slightly out. Here and for write.

> +{
> +IMX31CCMState *s = (IMX31CCMState *)opaque;
> +
> +DPRINTF("(offset=0x%" HWADDR_PRIx ")\n", offset);
> +
> +switch (offset >> 2) {
> +case 0: /* CCMR */
> +DPRINTF(" ccmr = 0x%x\n", s->ccmr);
> +return s->ccmr;
> +case 1:
> +DPRINTF(" pdr0 = 0x%x\n", s->pdr0);
> +return s->pdr0;
> +case 2:
> +DPRINTF(" pdr1 = 0x%x\n", s->pdr1);
> +return s->pdr1;
> +case 4:
> +DPRINTF(" mpctl = 0x%x\n", s->mpctl);
> +return s->mpctl;
> +case 6:
> +DPRINTF(" spctl = 0x%x\n", s->spctl);
> +return s->spctl;
> +case 8:
> +DPRINTF(" cgr0 = 0x%

Re: [Qemu-devel] [PATCH v2 2/2] i.MX: Add i.MX25 CCM driver

2015-11-12 Thread Peter Crosthwaite
On Wed, Oct 28, 2015 at 4:02 PM, Jean-Christophe Dubois
 wrote:
> The i.MX25 CCM device is different from the i.MX31 one.
>
> So for now the emulation was not correct even if linux was working OK
> on top of the i.MX25 emulation.
>
> We add an i.MX25 specific CCM driver and use it in the i.MX25 SOC
> emulation.
>

s/driver/device here and in subject.

> Signed-off-by: Jean-Christophe Dubois 
> ---
>
> Changes since v1:
>  * rework loging to match other i.MX drivers
>
>  hw/arm/fsl-imx25.c  |   2 +-
>  hw/misc/Makefile.objs   |   1 +
>  hw/misc/imx25_ccm.c | 228 
> 
>  include/hw/arm/fsl-imx25.h  |   4 +-
>  include/hw/misc/imx25_ccm.h |  61 
>  5 files changed, 293 insertions(+), 3 deletions(-)
>  create mode 100644 hw/misc/imx25_ccm.c
>  create mode 100644 include/hw/misc/imx25_ccm.h
>
> diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
> index 620c5c6..5301c1c 100644
> --- a/hw/arm/fsl-imx25.c
> +++ b/hw/arm/fsl-imx25.c
> @@ -38,7 +38,7 @@ static void fsl_imx25_init(Object *obj)
>  object_initialize(&s->avic, sizeof(s->avic), TYPE_IMX_AVIC);
>  qdev_set_parent_bus(DEVICE(&s->avic), sysbus_get_default());
>
> -object_initialize(&s->ccm, sizeof(s->ccm), TYPE_IMX31_CCM);
> +object_initialize(&s->ccm, sizeof(s->ccm), TYPE_IMX25_CCM);
>  qdev_set_parent_bus(DEVICE(&s->ccm), sysbus_get_default());
>
>  for (i = 0; i < FSL_IMX25_NUM_UARTS; i++) {
> diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
> index 79b3487..e8dc22d 100644
> --- a/hw/misc/Makefile.objs
> +++ b/hw/misc/Makefile.objs
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
>  obj-$(CONFIG_EXYNOS4) += exynos4210_pmu.o
>  obj-$(CONFIG_IMX) += imx_ccm.o
>  obj-$(CONFIG_IMX) += imx31_ccm.o
> +obj-$(CONFIG_IMX) += imx25_ccm.o
>  obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
>  obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
>  obj-$(CONFIG_MAINSTONE) += mst_fpga.o
> diff --git a/hw/misc/imx25_ccm.c b/hw/misc/imx25_ccm.c
> new file mode 100644
> index 000..e76292d
> --- /dev/null
> +++ b/hw/misc/imx25_ccm.c
> @@ -0,0 +1,228 @@
> +/*
> + * IMX25 Clock Control Module
> + *
> + * Copyright (C) 2012 NICTA
> + * Updated by Jean-Christophe Dubois 
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + *
> + * To get the timer frequencies right, we need to emulate at least part of
> + * the CCM.
> + */
> +
> +#include "hw/misc/imx25_ccm.h"
> +
> +#ifndef DEBUG_IMX25_CCM
> +#define DEBUG_IMX25_CCM 0
> +#endif
> +
> +#define DPRINTF(fmt, args...) \
> +do { \
> +if (DEBUG_IMX25_CCM) { \
> +fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX25_CCM, \
> + __func__, ##args); \
> +} \
> +} while (0)
> +
> +#define CKIH_FREQ 2400 /* 24MHz crystal input */
> +

Is the crystal freq really decided by the controller? Should this be
on the board level instead? Same applies to prev patch.

> +static int imx25_ccm_post_load(void *opaque, int version_id);
> +

Can you just reorder to remove the forward reference?

> +static const VMStateDescription vmstate_imx25_ccm = {
> +.name = TYPE_IMX25_CCM,
> +.version_id = 1,
> +.minimum_version_id = 1,
> +.fields = (VMStateField[]) {
> +VMSTATE_UINT32(mpctl, IMX25CCMState),
> +VMSTATE_UINT32(upctl, IMX25CCMState),
> +VMSTATE_UINT32(cctl, IMX25CCMState),
> +VMSTATE_UINT32_ARRAY(cgcr, IMX25CCMState, 3),
> +VMSTATE_UINT32_ARRAY(pcdr, IMX25CCMState, 4),
> +VMSTATE_UINT32(rcsr, IMX25CCMState),
> +VMSTATE_UINT32(crdr, IMX25CCMState),
> +VMSTATE_UINT32_ARRAY(dcvr, IMX25CCMState, 4),
> +VMSTATE_UINT32_ARRAY(ltr, IMX25CCMState, 4),
> +VMSTATE_UINT32_ARRAY(ltbr, IMX25CCMState, 2),
> +VMSTATE_UINT32_ARRAY(pmcr, IMX25CCMState, 3),
> +VMSTATE_UINT32(mcr, IMX25CCMState),
> +VMSTATE_UINT32_ARRAY(lpimr, IMX25CCMState, 2),
> +VMSTATE_UINT32(pll_refclk_freq, IMX25CCMState),
> +VMSTATE_END_OF_LIST()
> +},
> +.post_load = imx25_ccm_post_load,
> +};
> +
> +static void imx25_ccm_update_clocks(IMX25CCMState *s)
> +{
> +DPRINTF("\n");
> +/*
> + * If we ever emulate more clocks, this should switch to a data-driven
> + * approach
> + */
> +
> +/* Our input CLK */
> +s->pll_refclk_freq = CKIH_FREQ;
> +
> +/* Set MCU PLL CLK */
> +if (EXTRACT(s->cctl, MPLL_BYPASS)) {
> +imx_ccm_set_clock_frequency(CLK_MPLL, s->pll_refclk_freq);
> +} else {
> +imx_ccm_set_clock_frequency(CLK_MPLL,
> +imx_ccm_calc_pll(s->mpctl,
> + s->pll_refclk_freq));
> +}
> +
> +/* Set USB PLL CLK */
> +imx_ccm_set_clock_frequency(CLK_UPLL,
> +imx_ccm_calc_pll(s->upctl,
> + 

Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread Aravinda Prasad


On Friday 13 November 2015 11:27 AM, David Gibson wrote:
> On Fri, Nov 13, 2015 at 10:23:20AM +0530, Aravinda Prasad wrote:
>>
>>
>> On Friday 13 November 2015 07:28 AM, David Gibson wrote:
>>> On Thu, Nov 12, 2015 at 11:53:45PM +0530, Aravinda Prasad wrote:


 On Thursday 12 November 2015 01:39 PM, Thomas Huth wrote:
> On 11/11/15 18:16, Aravinda Prasad wrote:
>> Memory error such as bit flips that cannot be corrected
>> by hardware are passed on to the kernel for handling.
>> If the memory address in error belongs to guest then
>> guest kernel is responsible for taking suitable action.
>> Patch [1] enhances KVM to exit guest with exit reason
>> set to KVM_EXIT_NMI in such cases.
>>
>> This patch handles KVM_EXIT_NMI exit. If the guest OS
>> has registered the machine check handling routine by
>> calling "ibm,nmi-register", then the handler builds
>> the error log and invokes the registered handler else
>> invokes the handler at 0x200.
>>
>> [1] http://marc.info/?l=kvm-ppc&m=144726114408289
>>
>> Signed-off-by: Aravinda Prasad 
>> ---
>>  target-ppc/kvm.c |   69 +++
>>  target-ppc/kvm_ppc.h |   81 
>> ++
>>  2 files changed, 150 insertions(+)
>>
>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>> index 110436d..e2e5170 100644
>> --- a/target-ppc/kvm.c
>> +++ b/target-ppc/kvm.c
>> @@ -1665,6 +1665,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct 
>> kvm_run *run)
>>  ret = 0;
>>  break;
>>  
>> +case KVM_EXIT_NMI:
>> +DPRINTF("handle NMI exception\n");
>> +ret = kvm_handle_nmi(cpu);
>> +break;
>> +
>>  default:
>>  fprintf(stderr, "KVM: unknown exit reason %d\n", 
>> run->exit_reason);
>>  ret = -1;
>> @@ -2484,3 +2489,67 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
>>  {
>>  return data & 0x;
>>  }
>> +
>> +int kvm_handle_nmi(PowerPCCPU *cpu)
>> +{
>> +struct rtas_mc_log mc_log;
>> +CPUPPCState *env = &cpu->env;
>> +sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>> +PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
>> +
>> +cpu_synchronize_state(CPU(ppc_env_get_cpu(env)));
>> +
>> +/* Properly set bits in MSR before we invoke the handler */
>> +env->msr = 0;
>> +
>> +if (!(*pcc->interrupts_big_endian)(cpu)) {
>> +env->msr |= (1ULL << MSR_LE);
>> +}
>> +
>> +#ifdef TARGET_PPC64
>> +env->msr |= (1ULL << MSR_SF);
>> +#endif
>> +
>> +if (!spapr->guest_machine_check_addr) {
>> +/*
>> + * If OS has not registered with "ibm,nmi-register"
>> + * jump to 0x200
>> + */
>
> Shouldn't you also check MSR_ME here first and enter checkstop when
> machine checks are disabled?

 Yes, MSR_ME should be checked first.

> Also I think you have to set up some more registers for machine check
> interrupts, like SRR0 and SRR1?

 SRRO and SRR1 of vcpu are properly set in KVM in kvmppc_interrupt_hv. I
 am not sure if any other registers need to be set.
>>>
>>> DAR and DSISR are the obvious ones you need to consider, although I
>>> suspect they're already set up correctly by the kernel, too.
>>
>> Yes, they are also setup properly by KVM.
> 
> Ok, good.  Might be worth throwing a comment in the qemu code noting
> that the kernel has already set up that state properly.

sure.

> 

-- 
Regards,
Aravinda




Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread David Gibson
On Fri, Nov 13, 2015 at 10:23:20AM +0530, Aravinda Prasad wrote:
> 
> 
> On Friday 13 November 2015 07:28 AM, David Gibson wrote:
> > On Thu, Nov 12, 2015 at 11:53:45PM +0530, Aravinda Prasad wrote:
> >>
> >>
> >> On Thursday 12 November 2015 01:39 PM, Thomas Huth wrote:
> >>> On 11/11/15 18:16, Aravinda Prasad wrote:
>  Memory error such as bit flips that cannot be corrected
>  by hardware are passed on to the kernel for handling.
>  If the memory address in error belongs to guest then
>  guest kernel is responsible for taking suitable action.
>  Patch [1] enhances KVM to exit guest with exit reason
>  set to KVM_EXIT_NMI in such cases.
> 
>  This patch handles KVM_EXIT_NMI exit. If the guest OS
>  has registered the machine check handling routine by
>  calling "ibm,nmi-register", then the handler builds
>  the error log and invokes the registered handler else
>  invokes the handler at 0x200.
> 
>  [1] http://marc.info/?l=kvm-ppc&m=144726114408289
> 
>  Signed-off-by: Aravinda Prasad 
>  ---
>   target-ppc/kvm.c |   69 +++
>   target-ppc/kvm_ppc.h |   81 
>  ++
>   2 files changed, 150 insertions(+)
> 
>  diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>  index 110436d..e2e5170 100644
>  --- a/target-ppc/kvm.c
>  +++ b/target-ppc/kvm.c
>  @@ -1665,6 +1665,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct 
>  kvm_run *run)
>   ret = 0;
>   break;
>   
>  +case KVM_EXIT_NMI:
>  +DPRINTF("handle NMI exception\n");
>  +ret = kvm_handle_nmi(cpu);
>  +break;
>  +
>   default:
>   fprintf(stderr, "KVM: unknown exit reason %d\n", 
>  run->exit_reason);
>   ret = -1;
>  @@ -2484,3 +2489,67 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
>   {
>   return data & 0x;
>   }
>  +
>  +int kvm_handle_nmi(PowerPCCPU *cpu)
>  +{
>  +struct rtas_mc_log mc_log;
>  +CPUPPCState *env = &cpu->env;
>  +sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>  +PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
>  +
>  +cpu_synchronize_state(CPU(ppc_env_get_cpu(env)));
>  +
>  +/* Properly set bits in MSR before we invoke the handler */
>  +env->msr = 0;
>  +
>  +if (!(*pcc->interrupts_big_endian)(cpu)) {
>  +env->msr |= (1ULL << MSR_LE);
>  +}
>  +
>  +#ifdef TARGET_PPC64
>  +env->msr |= (1ULL << MSR_SF);
>  +#endif
>  +
>  +if (!spapr->guest_machine_check_addr) {
>  +/*
>  + * If OS has not registered with "ibm,nmi-register"
>  + * jump to 0x200
>  + */
> >>>
> >>> Shouldn't you also check MSR_ME here first and enter checkstop when
> >>> machine checks are disabled?
> >>
> >> Yes, MSR_ME should be checked first.
> >>
> >>> Also I think you have to set up some more registers for machine check
> >>> interrupts, like SRR0 and SRR1?
> >>
> >> SRRO and SRR1 of vcpu are properly set in KVM in kvmppc_interrupt_hv. I
> >> am not sure if any other registers need to be set.
> > 
> > DAR and DSISR are the obvious ones you need to consider, although I
> > suspect they're already set up correctly by the kernel, too.
> 
> Yes, they are also setup properly by KVM.

Ok, good.  Might be worth throwing a comment in the qemu code noting
that the kernel has already set up that state properly.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v11 20/28] qapi: Forbid case-insensitive clashes

2015-11-12 Thread Eric Blake
On 11/11/2015 07:53 AM, Markus Armbruster wrote:
> Eric Blake  writes:
> 
>> In general, designing user interfaces that rely on case
>> distinction is poor practice.  Another benefit of enforcing
>> a restriction against case-insensitive clashes is that we
>> no longer have to worry about the situation of enum values
>> that could be distinguished by case if mapped by c_name(),
>> but which cannot be distinguished when mapped to C as
>> ALL_CAPS by camel_to_upper().
> 
> With PATCH 19, they're mapped by c_name(N).upper().
> 

Yep, need to reword that, thanks to rebase churn.

>>Thus, having the generator
>> look for case collisions up front will prevent developers
>> from worrying whether different munging rules for member
>> names compared to enum values as a discriminator will cause
>> any problems in qapi unions.
>>
>> There is also the possibility that we may want to add a
>> future extension to QMP of teaching it to be case-insensitive
>> (the user could request command 'Quit' instead of 'quit', or
>> could spell a struct field as 'CPU' instead of 'cpu').  But
>> for that to be a practical extension, we cannot break
>> backwards compatibility with any existing struct that was
>> already relying on case sensitivity.  Fortunately, after the
>> previous patch cleaned up CpuInfo, there are no such existing
>> qapi structs.  Of course, the idea of a future extension is
>> not as strong of a reason to make the change.
>>
>> At any rate, it is easier to be strict now, and relax things
>> later if we find a reason to need case-sensitive QMP members,
>> than it would be to wish we had the restriction in place.
> 
> Suggest to briefly mention the new test.

Will do.

> 
>> Signed-off-by: Eric Blake 
> 
> Patch looks good.
> 

Hmm - this only enforces member name case clashes.  It would also be
worth enforcing command/event/type collisions (technically, only
command/event clashes are user-visible, but tracking all entities is
probably easier) - probably by modifying QAPISchema._def_entity() and
.lookup_entity() to do the same trick of keying the map by a munged
name.  I'll see about adding that as an additional patch.

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v13 3/3] block/gluster: add support for multiple gluster servers

2015-11-12 Thread Jeff Cody
On Thu, Nov 12, 2015 at 11:23:35AM -0500, Jeff Cody wrote:
> On Thu, Nov 12, 2015 at 05:04:02AM -0500, Prasanna Kumar Kalever wrote:
> > On Tuesday, November 10, 2015 9:37:20 PM, Eric Blake wrote:
> > > 
> > > On 11/10/2015 02:09 AM, Prasanna Kumar Kalever wrote:
> > > > This patch adds a way to specify multiple volfile servers to the gluster
> > > > block backend of QEMU with tcp|rdma transport types and their port 
> > > > numbers.
> > > > 
> > > 
> > > [...]
> > 
> > [...]
> > 
> > > 
> > > Overall, I think we are probably on the right track for the QMP
> > > interface; but since blockdev-add is NOT stable yet for 2.5, it won't
> > > hurt to wait to get this in until 2.6, to make sure we have plenty of
> > > time; and it would also be nice to make sure we get nbd, nfs, rbd,
> > > sheepdog all supported in the same release; possibly by sharing common
> > > types instead of introducing GlusterServer as a one-off type.
> > 
> > We are hoping this to go in 2.5 which is really important for gluster
> > hyper-convergence release (next Feb).
> > 
> > Is there any possibility of getting exception for this patch ?
> > 
> > Thanks,
> > -Prasanna
> >
> 
> Today is the hard freeze for 2.5 for new features. As the v14 patches
> hit the list today, I will review them, and if they look good I can
> pull patches into my tree. 
> 
> Whether there is an exception is really up to Peter Maydell
> (added him to the cc) - if all looks good with the patches, I could
> send a pull request out later today with them, but that will be late
> in the evening for Peter.
>

I wanted to give a follow-up - as Eric pointed out in his reviews, the
API interface could be made better by using some QAPI features that
are not currently in qemu (discriminated unions). 

So I won't issue a pull request for this for 2.5, and we'll pick it up for
2.6 once the interface issues can be worked out.

-Jeff



Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread Aravinda Prasad


On Friday 13 November 2015 07:28 AM, David Gibson wrote:
> On Thu, Nov 12, 2015 at 11:53:45PM +0530, Aravinda Prasad wrote:
>>
>>
>> On Thursday 12 November 2015 01:39 PM, Thomas Huth wrote:
>>> On 11/11/15 18:16, Aravinda Prasad wrote:
 Memory error such as bit flips that cannot be corrected
 by hardware are passed on to the kernel for handling.
 If the memory address in error belongs to guest then
 guest kernel is responsible for taking suitable action.
 Patch [1] enhances KVM to exit guest with exit reason
 set to KVM_EXIT_NMI in such cases.

 This patch handles KVM_EXIT_NMI exit. If the guest OS
 has registered the machine check handling routine by
 calling "ibm,nmi-register", then the handler builds
 the error log and invokes the registered handler else
 invokes the handler at 0x200.

 [1] http://marc.info/?l=kvm-ppc&m=144726114408289

 Signed-off-by: Aravinda Prasad 
 ---
  target-ppc/kvm.c |   69 +++
  target-ppc/kvm_ppc.h |   81 
 ++
  2 files changed, 150 insertions(+)

 diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
 index 110436d..e2e5170 100644
 --- a/target-ppc/kvm.c
 +++ b/target-ppc/kvm.c
 @@ -1665,6 +1665,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct 
 kvm_run *run)
  ret = 0;
  break;
  
 +case KVM_EXIT_NMI:
 +DPRINTF("handle NMI exception\n");
 +ret = kvm_handle_nmi(cpu);
 +break;
 +
  default:
  fprintf(stderr, "KVM: unknown exit reason %d\n", 
 run->exit_reason);
  ret = -1;
 @@ -2484,3 +2489,67 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
  {
  return data & 0x;
  }
 +
 +int kvm_handle_nmi(PowerPCCPU *cpu)
 +{
 +struct rtas_mc_log mc_log;
 +CPUPPCState *env = &cpu->env;
 +sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
 +PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
 +
 +cpu_synchronize_state(CPU(ppc_env_get_cpu(env)));
 +
 +/* Properly set bits in MSR before we invoke the handler */
 +env->msr = 0;
 +
 +if (!(*pcc->interrupts_big_endian)(cpu)) {
 +env->msr |= (1ULL << MSR_LE);
 +}
 +
 +#ifdef TARGET_PPC64
 +env->msr |= (1ULL << MSR_SF);
 +#endif
 +
 +if (!spapr->guest_machine_check_addr) {
 +/*
 + * If OS has not registered with "ibm,nmi-register"
 + * jump to 0x200
 + */
>>>
>>> Shouldn't you also check MSR_ME here first and enter checkstop when
>>> machine checks are disabled?
>>
>> Yes, MSR_ME should be checked first.
>>
>>> Also I think you have to set up some more registers for machine check
>>> interrupts, like SRR0 and SRR1?
>>
>> SRRO and SRR1 of vcpu are properly set in KVM in kvmppc_interrupt_hv. I
>> am not sure if any other registers need to be set.
> 
> DAR and DSISR are the obvious ones you need to consider, although I
> suspect they're already set up correctly by the kernel, too.

Yes, they are also setup properly by KVM.

Regards,
Aravinda

> 

-- 
Regards,
Aravinda




Re: [Qemu-devel] [PATCH] nand: fix address overflow

2015-11-12 Thread Peter Crosthwaite
On Tue, Nov 10, 2015 at 7:09 AM, Paolo Bonzini  wrote:
>
>
> On 10/11/2015 14:25, Rabin Vincent wrote:
>> The shifts of the address mask and value shift beyond 32 bits when there
>> are 5 address cycles.
>>
>> Signed-off-by: Rabin Vincent 
>> ---
>>  hw/block/nand.c |4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/block/nand.c b/hw/block/nand.c
>> index 61d2cec..a68266f 100644
>> --- a/hw/block/nand.c
>> +++ b/hw/block/nand.c
>> @@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)
>>
>>  if (s->ale) {
>>  unsigned int shift = s->addrlen * 8;
>> -unsigned int mask = ~(0xff << shift);
>> -unsigned int v = value << shift;
>> +uint64_t mask = ~(0xffull << shift);
>> +uint64_t v = (uint64_t)value << shift;
>>
>>  s->addr = (s->addr & mask) | v;
>>  s->addrlen ++;
>>
>
> Cc: qemu-triv...@nongnu.org
> Reviewed-by: Paolo Bonzini 

Reviewed-by: Peter Crosthwaite 

This is a bugfix right? IIUC This would not have worked for accesses
to devices above column address 255 at all. Should this go to
stable/2.5?

Regards,
Peter

>



[Qemu-devel] [Qemu-ppc] [PATCH for-2.5] mac_dbdma: always initialize channel field in DBDMA_channel

2015-11-12 Thread Programmingkid

On Nov 12, 2015, at 11:04 PM, qemu-ppc-requ...@nongnu.org wrote:

> Message: 3
> Date: Thu, 12 Nov 2015 22:24:08 +0100
> From: Herv? Poussineau 
> To: qemu-devel@nongnu.org
> Cc: "open list:Old World" , Herv? Poussineau
>   
> Subject: [Qemu-ppc] [PATCH for-2.5] mac_dbdma: always initialize
>   channel field in DBDMA_channel
> Message-ID: <1447363448-20405-1-git-send-email-hpous...@reactos.org>
> Content-Type: text/plain; charset=UTF-8
> 
> dbdma_from_ch() uses channel field to return the right DBDMA object.
> Previous code was working if guest OS was only using registered DMA channels.
> However, it lead to QEMU crashes if guest OS was using unregistered DMA 
> channels.
> 
> Signed-off-by: Herv? Poussineau 
> ---
> hw/misc/macio/mac_dbdma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
> index 779683c..5ee8f02 100644
> --- a/hw/misc/macio/mac_dbdma.c
> +++ b/hw/misc/macio/mac_dbdma.c
> @@ -557,7 +557,6 @@ void DBDMA_register_channel(void *dbdma, int nchan, 
> qemu_irq irq,
> DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan);
> 
> ch->irq = irq;
> -ch->channel = nchan;
> ch->rw = rw;
> ch->flush = flush;
> ch->io.opaque = opaque;
> @@ -753,6 +752,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem)
> for (i = 0; i < DBDMA_CHANNELS; i++) {
> DBDMA_io *io = &s->channels[i].io;
> qemu_iovec_init(&io->iov, 1);
> +s->channels[i].channel = i;
> }
> 
> memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x1000);
> -- 
> 2.1.4

What operating system(s) did you use to test this patch out?


Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread David Gibson
On Thu, Nov 12, 2015 at 11:53:45PM +0530, Aravinda Prasad wrote:
> 
> 
> On Thursday 12 November 2015 01:39 PM, Thomas Huth wrote:
> > On 11/11/15 18:16, Aravinda Prasad wrote:
> >> Memory error such as bit flips that cannot be corrected
> >> by hardware are passed on to the kernel for handling.
> >> If the memory address in error belongs to guest then
> >> guest kernel is responsible for taking suitable action.
> >> Patch [1] enhances KVM to exit guest with exit reason
> >> set to KVM_EXIT_NMI in such cases.
> >>
> >> This patch handles KVM_EXIT_NMI exit. If the guest OS
> >> has registered the machine check handling routine by
> >> calling "ibm,nmi-register", then the handler builds
> >> the error log and invokes the registered handler else
> >> invokes the handler at 0x200.
> >>
> >> [1] http://marc.info/?l=kvm-ppc&m=144726114408289
> >>
> >> Signed-off-by: Aravinda Prasad 
> >> ---
> >>  target-ppc/kvm.c |   69 +++
> >>  target-ppc/kvm_ppc.h |   81 
> >> ++
> >>  2 files changed, 150 insertions(+)
> >>
> >> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> >> index 110436d..e2e5170 100644
> >> --- a/target-ppc/kvm.c
> >> +++ b/target-ppc/kvm.c
> >> @@ -1665,6 +1665,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct 
> >> kvm_run *run)
> >>  ret = 0;
> >>  break;
> >>  
> >> +case KVM_EXIT_NMI:
> >> +DPRINTF("handle NMI exception\n");
> >> +ret = kvm_handle_nmi(cpu);
> >> +break;
> >> +
> >>  default:
> >>  fprintf(stderr, "KVM: unknown exit reason %d\n", 
> >> run->exit_reason);
> >>  ret = -1;
> >> @@ -2484,3 +2489,67 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
> >>  {
> >>  return data & 0x;
> >>  }
> >> +
> >> +int kvm_handle_nmi(PowerPCCPU *cpu)
> >> +{
> >> +struct rtas_mc_log mc_log;
> >> +CPUPPCState *env = &cpu->env;
> >> +sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
> >> +PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
> >> +
> >> +cpu_synchronize_state(CPU(ppc_env_get_cpu(env)));
> >> +
> >> +/* Properly set bits in MSR before we invoke the handler */
> >> +env->msr = 0;
> >> +
> >> +if (!(*pcc->interrupts_big_endian)(cpu)) {
> >> +env->msr |= (1ULL << MSR_LE);
> >> +}
> >> +
> >> +#ifdef TARGET_PPC64
> >> +env->msr |= (1ULL << MSR_SF);
> >> +#endif
> >> +
> >> +if (!spapr->guest_machine_check_addr) {
> >> +/*
> >> + * If OS has not registered with "ibm,nmi-register"
> >> + * jump to 0x200
> >> + */
> > 
> > Shouldn't you also check MSR_ME here first and enter checkstop when
> > machine checks are disabled?
> 
> Yes, MSR_ME should be checked first.
> 
> > Also I think you have to set up some more registers for machine check
> > interrupts, like SRR0 and SRR1?
> 
> SRRO and SRR1 of vcpu are properly set in KVM in kvmppc_interrupt_hv. I
> am not sure if any other registers need to be set.

DAR and DSISR are the obvious ones you need to consider, although I
suspect they're already set up correctly by the kernel, too.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread David Gibson
On Thu, Nov 12, 2015 at 10:40:11AM +0100, Thomas Huth wrote:
> On 12/11/15 09:09, Thomas Huth wrote:
> > On 11/11/15 18:16, Aravinda Prasad wrote:
> >> Memory error such as bit flips that cannot be corrected
> >> by hardware are passed on to the kernel for handling.
> >> If the memory address in error belongs to guest then
> >> guest kernel is responsible for taking suitable action.
> >> Patch [1] enhances KVM to exit guest with exit reason
> >> set to KVM_EXIT_NMI in such cases.
> >>
> >> This patch handles KVM_EXIT_NMI exit. If the guest OS
> >> has registered the machine check handling routine by
> >> calling "ibm,nmi-register", then the handler builds
> >> the error log and invokes the registered handler else
> >> invokes the handler at 0x200.
> >>
> >> [1] http://marc.info/?l=kvm-ppc&m=144726114408289
> >>
> >> Signed-off-by: Aravinda Prasad 
[snip]
> >> +env->nip = 0x200;
> >> +return 0;
> >> +}
> >> +
> >> +qemu_mutex_lock(&spapr->mc_in_progress);
> > 
> > Using a mutex here is definitely wrong. The kvm_arch_handle_exit() code
> > is run under the Big QEMU Lock™ (see qemu_mutex_lock_iothread() in
> > kvm_cpu_exec()),
> 
> In case you're looking for the calls, I just noticed that the
> qemu_mutex_lock_iothread() have recently been pushed into
> kvm_arch_handle_exit() itself.
> 
> > so if you would ever get one thread waiting for this
> > mutex here, it could never be unlocked again in rtas_ibm_nmi_interlock()
> > because the other code would wait forever to get the BQL ==> Deadlock.
> > 
> > I think if you want to be able to handle multiple NMIs at once, you
> > likely need something like an error log per CPU instead. And if an NMI
> > happens one CPU while there is already a NMI handler running on the very
> > same CPU, you could likely simply track this with an boolean variable
> > and put the CPU into checkstop if this happens?
> 
> Ok, I now had a look into the LoPAPR spec, and if I've got that right,
> you really have to serialize the NMIs in case they happen at multiple
> CPUs at the same time. So I guess the best thing you can do here is
> something like:
> 
>while (spapr->mc_in_progress) {
>/*
> * There is already another NMI in progress, thus we need
> * to yield here to wait until it has been finsihed
> */
>qemu_mutex_unlock_iothread();
>usleep(10);
>qemu_mutex_lock_iothread();
>}
>spapr->mc_in_progress = true;
> 
> Also LoPAPR talks about 'subsequent processors report "fatal error
> previously reported"', so maybe the other processors should report that
> condition in this case?
> And of course you've also got to check that the same CPU is not getting
> multiple NMIs before the interlock function has been called again.

You should be able to avoid the nasty usleep by using a pthread
condition variable.  So here you'd have

while (spapr->mc_in_progress) {
pthread_cond_wait(&mc_delivery_cond, &qemu_iothread_lock);
}
spapr->mc_in_progress = true;

Or.. there may be qemu wrappers around the pthread functions you
should be using.  Once delivery of a single MC is complete, you'd use
pthread_cond_signal() to wake up any additional ones.

pthread_cond_wait automatically drops the specified mutex internally,
so access to mc_in_progress itself is still protected by the iothread
mutex.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PULL v2 00/15] Tracing patches

2015-11-12 Thread Stefan Hajnoczi
On Wed, Nov 11, 2015 at 11:20:52AM +, Peter Maydell wrote:
> On 11 November 2015 at 07:34, Stefan Hajnoczi  wrote:
> > v2:
> >  * Fixed missing log.py file when merging "trace: convert stderr backend to 
> > log" [Peter]
> >
> > The following changes since commit a77067f6ac9b17beefea506ce5f514072fe3fcf4:
> >
> >   Merge remote-tracking branch 
> > 'remotes/juanquintela/tags/migration/20151110' into staging (2015-11-10 
> > 17:49:39 +)
> >
> > are available in the git repository at:
> >
> >   git://github.com/stefanha/qemu.git tags/tracing-pull-request
> >
> > for you to fetch changes up to 8b7034c1e0bdce2c3dd38e8445d2040449afa15c:
> >
> >   log: add "-d trace:PATTERN" (2015-11-11 06:52:32 +)
> >
> 
> Fails to build on all platforms :-(
> 
> /home/petmay01/linaro/qemu-for-merges/target-arm/translate-a64.c: In
> function ‘gen_intermediate_code_a64’:
> /home/petmay01/linaro/qemu-for-merges/target-arm/translate-a64.c:11229:9:
> error: implicit declaration of function ‘lookup_symbol’
> [-Werror=implicit-function-declaration]
>  qemu_log("IN: %s\n", lookup_symbol(pc_start));
>  ^

Sorry.  I've updated my build-all.sh script to really build all QEMU
targets (including aarch64).

Stefan


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH for-2.5 v2] tests: Ignore recent test binaries

2015-11-12 Thread Eric Blake
Commits 6c6f312d and bd797fc1 added new tests (test-blockjob-txn
and test-timed-average, respectively), but did not mark them for
exclusion in .gitignore.

Signed-off-by: Eric Blake 
---

v2: retitle; also ignore test-timed-average

 tests/.gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index e96f569..1e55722 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,6 +9,7 @@ check-qom-proplist
 rcutorture
 test-aio
 test-bitops
+test-blockjob-txn
 test-coroutine
 test-crypto-cipher
 test-crypto-hash
@@ -45,6 +46,7 @@ test-string-input-visitor
 test-string-output-visitor
 test-thread-pool
 test-throttle
+test-timed-average
 test-visitor-serialization
 test-vmstate
 test-write-threshold
-- 
2.4.3




Re: [Qemu-devel] [PATCH] tests: Ignore test-blockjob-txn

2015-11-12 Thread Eric Blake
On 11/12/2015 07:27 PM, Stefan Hajnoczi wrote:
> On Thu, Nov 12, 2015 at 11:33:48AM -0700, Eric Blake wrote:
>> Commit 6c6f312d added a new test, but did not mark it for
>> exclusion in .gitignore.
>>
>> Signed-off-by: Eric Blake 
>> ---
>>
>> Yeah, I know this affects only non-VPATH builds, which we don't
>> recommend, but we might as well be consistent.
>>
>>  tests/.gitignore | 1 +
>>  1 file changed, 1 insertion(+)
> 
> Reviewed-by: Stefan Hajnoczi 

Another one popped up: bd797fc1 introduced test-timed-average. I'll just
respin a v2 of this, although the subject line will change.

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v13 09/13] add check reset mechanism when hotplug vfio device

2015-11-12 Thread Cao jin



On 11/12/2015 07:51 PM, Michael S. Tsirkin wrote:

On Wed, Nov 11, 2015 at 06:34:27PM +0800, Cao jin wrote:

From: Chen Fan 

Since we support multi-function hotplug. the function 0 indicate
the closure of the slot, so we have the chance to do the check.

Signed-off-by: Chen Fan 
---
  hw/pci/pci.c | 29 +
  hw/vfio/pci.c| 19 +++
  hw/vfio/pci.h|  2 ++
  include/hw/pci/pci_bus.h |  5 +
  4 files changed, 55 insertions(+)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 168b9cc..f6ca6ef 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -81,6 +81,7 @@ static void pci_bus_realize(BusState *qbus, Error **errp)
  PCIBus *bus = PCI_BUS(qbus);

  vmstate_register(NULL, -1, &vmstate_pcibus, bus);
+notifier_with_return_list_init(&bus->hotplug_notifiers);
  }

  static void pci_bus_unrealize(BusState *qbus, Error **errp)
@@ -1835,6 +1836,22 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, 
uint8_t devfn)
  return bus->devices[devfn];
  }

+void pci_bus_add_hotplug_notifier(PCIBus *bus, NotifierWithReturn *notify)
+{
+notifier_with_return_list_add(&bus->hotplug_notifiers, notify);
+}
+
+void pci_bus_remove_hotplug_notifier(NotifierWithReturn *notifier)
+{
+notifier_with_return_remove(notifier);
+}
+
+static int pci_bus_hotplug_notifier(PCIBus *bus, void *opaque)
+{
+return notifier_with_return_list_notify(&bus->hotplug_notifiers,
+opaque);
+}
+
  static void pci_qdev_realize(DeviceState *qdev, Error **errp)
  {
  PCIDevice *pci_dev = (PCIDevice *)qdev;
@@ -1877,6 +1894,18 @@ static void pci_qdev_realize(DeviceState *qdev, Error 
**errp)
  pci_qdev_unrealize(DEVICE(pci_dev), NULL);
  return;
  }
+
+/*
+ *  If the function is func 0, indicate the closure of the slot.
+ *  signal the callback.
+ */
+if (DEVICE(pci_dev)->hotplugged &&
+pci_get_function_0(pci_dev) == pci_dev &&
+pci_bus_hotplug_notifier(bus, pci_dev)) {
+error_setg(errp, "failed to hotplug function 0");
+pci_qdev_unrealize(DEVICE(pci_dev), NULL);
+return;
+}


I don't understand why this is required in pci core.
PCI Device is already constructed anyway.
Just do the checks and call unrealize in vfio.


Because when do multi-function hotplug, the function 0 on the pcie bus 
probably is not a vfio device. so we should trigger the check from pci 
core.



I also don't see why you are tying this to hotplug.
I would check each function as it's added.
But that's a vfio thing, if both you and Alex think
it's a good idea, fine by me.


The device is  initialized one by one no matter it is cold plugged or 
hot plugged, but for the vfio with aer that need to get depended devices 
required by bus reset, so need to make sure the reset depended devices 
are assigned to qemu, in vfio, there is a machine done callback to check 
the bus reset for boot up, so it also should be done in hotplug。


it looks little complicated, Alex, any idea?




  }

  static void pci_default_realize(PCIDevice *dev, Error **errp)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 31ffd44..e619998 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1990,6 +1990,19 @@ static int vfio_check_devices_host_bus_reset(void)
  return 0;
  }

+static int vfio_check_bus_reset(NotifierWithReturn *n, void *opaque)
+{
+VFIOPCIDevice *vdev = container_of(n, VFIOPCIDevice, hotplug_notifier);
+PCIDevice *pci_dev = PCI_DEVICE(vdev);
+PCIDevice *pci_func0 = opaque;
+
+if (pci_get_function_0(pci_dev) != pci_func0) {
+return 0;
+}
+
+return vfio_check_host_bus_reset(vdev);
+}
+
  static int vfio_setup_aer(VFIOPCIDevice *vdev, uint8_t cap_ver,
int pos, uint16_t size)
  {
@@ -2044,6 +2057,9 @@ static int vfio_setup_aer(VFIOPCIDevice *vdev, uint8_t 
cap_ver,
  return ret;
  }

+vdev->hotplug_notifier.notify = vfio_check_bus_reset;
+pci_bus_add_hotplug_notifier(pdev->bus, &vdev->hotplug_notifier);
+
  return 0;

  error:
@@ -2919,6 +2935,9 @@ static void vfio_exitfn(PCIDevice *pdev)
  vfio_unregister_req_notifier(vdev);
  vfio_unregister_err_notifier(vdev);
  pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
+if (vdev->features & VFIO_FEATURE_ENABLE_AER) {
+pci_bus_remove_hotplug_notifier(&vdev->hotplug_notifier);
+}
  vfio_disable_interrupts(vdev);
  if (vdev->intx.mmap_timer) {
  timer_free(vdev->intx.mmap_timer);
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 59ae194..b385f07 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -142,6 +142,8 @@ typedef struct VFIOPCIDevice {
  bool no_kvm_intx;
  bool no_kvm_msi;
  bool no_kvm_msix;
+
+NotifierWithReturn hotplug_notifier;
  } VFIOPCIDevice;

  uint32_t vfio_pci_read_config(PCIDevice *pdev, uint32_t addr, int len);
diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/p

Re: [Qemu-devel] [v2 1/2] cutils: add avx2 instruction optimization

2015-11-12 Thread Li, Liang Z
> > This patch use the ifunc mechanism to select the proper function when
> > running, for platform supports AVX2, excute the AVX2 instructions,
> > else, excute the original code.
> >
> > Signed-off-by: Liang Li 
> > ---
> >  include/qemu-common.h | 28 +++--
> >  util/Makefile.objs|  2 ++
> >  util/avx2.c   | 69
> +++
> >  util/cutils.c | 53 +--
> >  4 files changed, 143 insertions(+), 9 deletions(-)  create mode
> > 100644 util/avx2.c
> >
> > diff --git a/include/qemu-common.h b/include/qemu-common.h index
> > 2f74540..9fa7501 100644
> > --- a/include/qemu-common.h
> > +++ b/include/qemu-common.h
> > @@ -484,15 +484,29 @@ void qemu_hexdump(const char *buf, FILE *fp,
> > const char *prefix, size_t size);  #endif
> >
> >  #define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8 -static inline
> > bool -can_use_buffer_find_nonzero_offset(const void *buf, size_t len)
> > -{
> > -return (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
> > -   * sizeof(VECTYPE)) == 0
> > -&& ((uintptr_t) buf) % sizeof(VECTYPE) == 0);
> > -}
> > +bool can_use_buffer_find_nonzero_offset(const void *buf, size_t len);
> > +
> >  size_t buffer_find_nonzero_offset(const void *buf, size_t len);
> >
> > +extern bool
> > +can_use_buffer_find_nonzero_offset_avx2(const void *buf, size_t len);
> > +
> > +extern size_t buffer_find_nonzero_offset_avx2(const void *buf, size_t
> > +len);
> > +
> > +extern bool
> > +can_use_buffer_find_nonzero_offset_inner(const void *buf, size_t
> > +len);
> > +
> > +extern size_t buffer_find_nonzero_offset_inner(const void *buf,
> > +size_t len);
> > +
> > +__asm__(".type can_use_buffer_find_nonzero_offset,
> > +\%gnu_indirect_function"); __asm__(".type buffer_find_nonzero_offset,
> > +\%gnu_indirect_function");
> > +
> > +
> > +void *can_use_buffer_find_nonzero_offset_ifunc(void) \
> > + __asm__("can_use_buffer_find_nonzero_offset");
> > +
> > +void *buffer_find_nonzero_offset_ifunc(void) \
> > + __asm__("buffer_find_nonzero_offset");
> >  /*
> >   * helper to parse debug environment variables
> >   */
> > diff --git a/util/Makefile.objs b/util/Makefile.objs index
> > d7cc399..6aacad7 100644
> > --- a/util/Makefile.objs
> > +++ b/util/Makefile.objs
> > @@ -1,4 +1,5 @@
> >  util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o
> > +util-obj-y += avx2.o
> >  util-obj-$(CONFIG_POSIX) += compatfd.o
> >  util-obj-$(CONFIG_POSIX) += event_notifier-posix.o
> >  util-obj-$(CONFIG_POSIX) += mmap-alloc.o @@ -29,3 +30,4 @@ util-obj-y
> > += qemu-coroutine.o qemu-coroutine-lock.o qemu-coroutine-io.o
> > util-obj-y += qemu-coroutine-sleep.o  util-obj-y +=
> > coroutine-$(CONFIG_COROUTINE_BACKEND).o
> >  util-obj-y += buffer.o
> > +avx2.o-cflags  := $(AVX2_CFLAGS)
> > diff --git a/util/avx2.c b/util/avx2.c new file mode 100644 index
> > 000..0e6915a
> > --- /dev/null
> > +++ b/util/avx2.c
> > @@ -0,0 +1,69 @@
> > +#include "qemu-common.h"
> > +
> > +#ifdef __AVX2__
> > +#include 
> > +#define AVX2_VECTYPE__m256i
> > +#define AVX2_SPLAT(p)   _mm256_set1_epi8(*(p))
> > +#define AVX2_ALL_EQ(v1, v2) \
> > +(_mm256_movemask_epi8(_mm256_cmpeq_epi8(v1, v2)) == 0x)
> > +#define AVX2_VEC_OR(v1, v2) (_mm256_or_si256(v1, v2))
> > +
> > +inline bool
> > +can_use_buffer_find_nonzero_offset_avx2(const void *buf, size_t len)
> > +{
> > +return (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
> > +   * sizeof(AVX2_VECTYPE)) == 0
> > +&& ((uintptr_t) buf) % sizeof(AVX2_VECTYPE) == 0); }
> > +
> > +size_t buffer_find_nonzero_offset_avx2(const void *buf, size_t len) {
> > +const AVX2_VECTYPE *p = buf;
> > +const AVX2_VECTYPE zero = (AVX2_VECTYPE){0};
> > +size_t i;
> > +
> > +assert(can_use_buffer_find_nonzero_offset_avx2(buf, len));
> > +
> > +if (!len) {
> > +return 0;
> > +}
> > +
> > +for (i = 0; i < BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR; i++) {
> > +if (!AVX2_ALL_EQ(p[i], zero)) {
> > +return i * sizeof(AVX2_VECTYPE);
> > +}
> > +}
> > +
> > +for (i = BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR;
> > + i < len / sizeof(AVX2_VECTYPE);
> > + i += BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR) {
> > +AVX2_VECTYPE tmp0 = AVX2_VEC_OR(p[i + 0], p[i + 1]);
> > +AVX2_VECTYPE tmp1 = AVX2_VEC_OR(p[i + 2], p[i + 3]);
> > +AVX2_VECTYPE tmp2 = AVX2_VEC_OR(p[i + 4], p[i + 5]);
> > +AVX2_VECTYPE tmp3 = AVX2_VEC_OR(p[i + 6], p[i + 7]);
> > +AVX2_VECTYPE tmp01 = AVX2_VEC_OR(tmp0, tmp1);
> > +AVX2_VECTYPE tmp23 = AVX2_VEC_OR(tmp2, tmp3);
> > +if (!AVX2_ALL_EQ(AVX2_VEC_OR(tmp01, tmp23), zero)) {
> > +break;
> > +}
> > +}
> > +
> > +return i * sizeof(AVX2_VECTYPE);
> > +}
> > +
> > +#else
> > +/* use the original functions if avx2 is not en

Re: [Qemu-devel] [Qemu-block] [PULL v3 00/43] Block layer patches (Stefan's tree)

2015-11-12 Thread Stefan Hajnoczi
On Thu, Nov 12, 2015 at 05:26:43PM +0100, Alberto Garcia wrote:
> On Thu, Nov 12, 2015 at 04:37:08PM +0100, Kevin Wolf wrote:
> > The following changes since commit 17e50a72a3aade0eddfebc012a5d7bdd40a03573:
> > 
> >   Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' 
> > into staging (2015-11-12 14:15:32 +)
> > 
> > are available in the git repository at:
> > 
> > 
> >   git://repo.or.cz/qemu/kevin.git tags/for-upstream
> > 
> > for you to fetch changes up to aece5edc96f211eec6febdafc999315a2efd:
> > 
> >   block: Update copyright of the accounting code (2015-11-12 16:22:47 +0100)
> > 
> > 
> > Block layer patches (rebased Stefan's pull request)
> > 
> > 
> > Alberto Garcia (21):
> >   xen_disk: Account for flush operations
> >   ide: Account for write operations correctly
> >   block: define 'clock_type' for the accounting code
> >   util: Infrastructure for computing recent averages
> >   block: Add idle_time_ns to BlockDeviceStats
> >   block: Add statistics for failed and invalid I/O operations
> >   block: Allow configuring whether to account failed and invalid ops
> >   block: Compute minimum, maximum and average I/O latencies
> >   block: Add average I/O queue depth to BlockDeviceTimedStats
> >   block: New option to define the intervals for collecting I/O 
> > statistics
> >   qemu-io: Account for failed, invalid and flush operations
> >   block: Use QEMU_CLOCK_VIRTUAL for the accounting code in qtest mode
> >   iotests: Add test for the block device statistics
> >   nvme: Account for failed and invalid operations
> >   virtio-blk: Account for failed and invalid operations
> >   xen_disk: Account for failed and invalid operations
> >   atapi: Account for failed and invalid operations
> >   ide: Account for failed and invalid operations
> >   macio: Account for failed operations
> >   scsi-disk: Account for failed operations
> >   block: Update copyright of the accounting code
> 
> Hi Kevin,
> 
> Are you not including this one as well?
> 
> https://patchwork.ozlabs.org/patch/542872/

Hi Alberto,
I'll merge that patch into the block branch along with other bug fixes.

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [Qemu-block] [PULL v3 00/43] Block layer patches (Stefan's tree)

2015-11-12 Thread Stefan Hajnoczi
On Thu, Nov 12, 2015 at 04:37:08PM +0100, Kevin Wolf wrote:
> The following changes since commit 17e50a72a3aade0eddfebc012a5d7bdd40a03573:
> 
>   Merge remote-tracking branch 'remotes/jasowang/tags/net-pull-request' into 
> staging (2015-11-12 14:15:32 +)
> 
> are available in the git repository at:
> 
> 
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
> 
> for you to fetch changes up to aece5edc96f211eec6febdafc999315a2efd:
> 
>   block: Update copyright of the accounting code (2015-11-12 16:22:47 +0100)
> 
> 
> Block layer patches (rebased Stefan's pull request)

Thanks for doing this, Kevin!  Much appreciated, I'm back online today.

Stefan


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH] tests: Ignore test-blockjob-txn

2015-11-12 Thread Stefan Hajnoczi
On Thu, Nov 12, 2015 at 11:33:48AM -0700, Eric Blake wrote:
> Commit 6c6f312d added a new test, but did not mark it for
> exclusion in .gitignore.
> 
> Signed-off-by: Eric Blake 
> ---
> 
> Yeah, I know this affects only non-VPATH builds, which we don't
> recommend, but we might as well be consistent.
> 
>  tests/.gitignore | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


Re: [Qemu-devel] [PATCH v3 1/3] target-i386: add a subsection for migrating vcpu's TSC rate

2015-11-12 Thread Haozhong Zhang
On 11/11/15 22:27, Haozhong Zhang wrote:
> On 11/11/15 12:16, Eduardo Habkost wrote:
[...]
> > > diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> > > index 2f8f396..858ed69 100644
> > > --- a/hw/i386/pc_q35.c
> > > +++ b/hw/i386/pc_q35.c
> > > @@ -385,6 +385,7 @@ static void pc_q35_2_4_machine_options(MachineClass 
> > > *m)
> > >  pc_q35_2_5_machine_options(m);
> > >  m->alias = NULL;
> > >  pcmc->broken_reserved_end = true;
> > > +pcmc->save_tsc_khz = false;
> > 
> > I had suggested the PCMachineClass field, but now I've been thinking:
> > all other fields related to tsc_khz are in X86CPU, so I believe this
> > belongs to X86CPU too. It could be a simple X86CPU property set by
> > PC_COMPAT_2_4.
> >
> 
> Reasonable, will update in the next version.

Or maybe no ...

I think there is still a problem to set a X86CPU property in
PC_COMPAT_2_4:

if I create a property for save_tsc_khz by adding
  DEFINE_PROP_BOOL("save-tsc-freq", X86CPU, save_tsc_khz, true)
in x86_cpu_properties and add
  {
  .driver   = TYPE_X86_CPU,
  .property = "save-tsc-freq",
  .value= "off",
  }
in PC_COMPAT_2_4, then "save-tsc-freq" will also become a
user-visible cpu option. But we agreed on keeping it as an
internal flag in the previous discussion.

Any other ways to set a property in PC_COMPAT_* while keeping that
property internal?

Haozhong



Re: [Qemu-devel] [PATCH v4 0/5] handle vhost reset/start/stop correctly

2015-11-12 Thread Yuanhan Liu
On Thu, Nov 12, 2015 at 04:44:19PM +0200, Michael S. Tsirkin wrote:
> On Thu, Nov 12, 2015 at 10:08:15PM +0800, Yuanhan Liu wrote:
> > On Thu, Nov 12, 2015 at 03:33:41PM +0200, Michael S. Tsirkin wrote:
> > > On Wed, Nov 11, 2015 at 09:24:36PM +0800, Yuanhan Liu wrote:
> > > > 
> > > > Patch 1 rename RESET_DEVICE back to RESET_OWNER
> > > > 
> > > > Patch 2 introduced a new function: vhost_net_reset(), which is invoked
> > > > when reset happens, say, driver is unloaded (unbinded).
> > > > 
> > > > Michael suggested to do that only when MQ is not negotiated.
> > > > However, reset happens no matter MQ is enabled or negotiated
> > > > or not, and we should give a sign to backend to reset some
> > > > device to a proper state after it happens.
> > > 
> > > I don't think it's needed: we set all state at start anyway.
> > 
> > Agree with that.
> > 
> > > 
> > > > Note that the message sent is still RESET_OWNER. It might not
> > > > be a good idea, but we could not simply rename it to 
> > > > RESET_DEVICE,
> > > > and maybe adding another RESET_DEVICE might be better.
> > > 
> > > So modern clients don't need this at all.  Old clients need something to
> > > stop device, but singling out reset is not a good idea: even if driver
> > > is unloaded, you need to do that.  snabbswitch (ab)uses RESET_OWNER for
> > > this, so maybe RESET_OWNER should be renamed DISABLE_ALL, to just make
> > > it stop all queues.
> > > 
> > > Does any dpdk version that was released respond to RESET_OWNER in some
> > > way? How exactly?
> > 
> > It just resets some states, such as closing call fd and kick fd,
> > unmapping buf from hugetlbfs from set_mem_table.
> 
> And is this in some dpdk version that has been released?

Yes, it's been there long time ago, and you can find them in recent
releases (say, v2.1).

However, QEMU just added RESET_OWNER since v2.4.0, and it's likely that
we will remove it since this version, v2.5.0.

> 
> > And, apparently we could do that on stop, too. So, from this pov, we
> > don't need RESET_OWNER.
> > 
> > > 
> > > > Patch 3 and 4 send SET_PROTOCOL_FEATURES at start, just like we send
> > > > SET_FEATURES.
> > > > 
> > > > Patch 5 send SET_VRING_ENABLE at start/stop
> > > > 
> > > > Michael, I intended to send it when MQ is negotiated as you 
> > > > suggested,
> > > > however, I found that VHOST_USER_PROTOCOL_F_MQ is defined in 
> > > > vhost-user.c,
> > > > which is not accessible to vhost.c.
> > > > 
> > > > Exporting it to vhost.h will resolve that, however, it's not a 
> > > > good
> > > > idea to move vhost user specific stuff to there. We could also 
> > > > introduce
> > > > another vhost callback to test whether MQ is negotiated: I just 
> > > > don't
> > > > think it's worthy.
> > > > 
> > > > Hence, here I just used a simple test: invoke 
> > > > set_vring_enable() just
> > > > when it is defined. Judging the callback self has another MQ 
> > > > check,
> > > > I guess it's okay.
> > > > 
> > > > And sorry that it took so long to send this version.
> > > 
> > > Hmm, you are saying everyone needs SET_VRING_ENABLE?
> > > Maybe we should make SET_VRING_ENABLE depend on protocol features then,
> > > and not MQ?
> > 
> > I'm thinking something same. Otherwise, there is still no way to inform
> > the backend (or client) when a vhost dev is stopped when MQ is disabled
> > (which is the default state).
> > 
> > So, let's assume all clients have protocol features enabled, and send
> > SET_VRING_ENABLE at start/stop? And if it does not, it's just like we
> > are back to QEMU v2.3, where no RESET_OWNER nor SET_VRING_ENABLE
> > messages are sent on stop: it worked before, and it should also work
> > now.
> 
> So maybe we should drop RESET_OWNER from stop then?

Yeah, agree with you. Sending reset meessage at stop doesn't make too
much sense.

> 
> > > 
> > > I applied patches 1 and 5 for now.
> > 
> > Do you have comment about patch 3 and 4? Should we set protocol features
> > just like we set features at start?
> > 
> > Thanks.
> > 
> > --yliu
> 
> We don't set the at start - we set them on connect.

Okay to me. I will drop them then.

--yliu



Re: [Qemu-devel] [PATCH v2 2/2] i440fx: print an error message if user tries to enable iommu

2015-11-12 Thread Eric Blake
On 11/12/2015 03:55 PM, Bandan Das wrote:
> There's no indication of any sort that i440fx doesn't support
> "iommu=on""
> 
> Signed-off-by: Bandan Das 
> ---
>  hw/pci-host/piix.c | 5 +
>  1 file changed, 5 insertions(+)
> 

> @@ -301,6 +302,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, 
> Error **errp)
>  static void i440fx_realize(PCIDevice *dev, Error **errp)
>  {
>  dev->config[I440FX_SMRAM] = 0x02;
> +
> +if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
> +error_report("warning: i440fx doesn't support emulated iommu\n");

No trailing \n with error_report().

With that fixed (and perhaps maintainer can do it),
Reviewed-by: Eric Blake 

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v2 2/2] i440fx: print an error message if user tries to enable iommu

2015-11-12 Thread Bandan Das
There's no indication of any sort that i440fx doesn't support
"iommu=on""

Signed-off-by: Bandan Das 
---
 hw/pci-host/piix.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 7b2fbf9..ffcb846 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -34,6 +34,7 @@
 #include "sysemu/sysemu.h"
 #include "hw/i386/ioapic.h"
 #include "qapi/visitor.h"
+#include "qemu/error-report.h"
 
 /*
  * I440FX chipset data sheet.
@@ -301,6 +302,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error 
**errp)
 static void i440fx_realize(PCIDevice *dev, Error **errp)
 {
 dev->config[I440FX_SMRAM] = 0x02;
+
+if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
+error_report("warning: i440fx doesn't support emulated iommu\n");
+}
 }
 
 PCIBus *i440fx_init(const char *host_type, const char *pci_type,
-- 
2.5.0




[Qemu-devel] [PATCH v2 1/2] q35: Check propery to determine if iommu is set

2015-11-12 Thread Bandan Das
The helper function machine_iommu() isn't necesary. We can
directly check for the property.

Signed-off-by: Bandan Das 
---
 hw/core/machine.c   | 5 -
 hw/pci-host/q35.c   | 2 +-
 include/hw/boards.h | 1 -
 3 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index f4db340..acca00d 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -462,11 +462,6 @@ bool machine_usb(MachineState *machine)
 return machine->usb;
 }
 
-bool machine_iommu(MachineState *machine)
-{
-return machine->iommu;
-}
-
 bool machine_kernel_irqchip_allowed(MachineState *machine)
 {
 return machine->kernel_irqchip_allowed;
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index c81507d..1fb4707 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -506,7 +506,7 @@ static void mch_realize(PCIDevice *d, Error **errp)
  PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE);
 }
 /* Intel IOMMU (VT-d) */
-if (machine_iommu(current_machine)) {
+if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
 mch_init_dmar(mch);
 }
 }
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 3e9a92c..24eb6f0 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -33,7 +33,6 @@ MachineClass *find_default_machine(void);
 extern MachineState *current_machine;
 
 bool machine_usb(MachineState *machine);
-bool machine_iommu(MachineState *machine);
 bool machine_kernel_irqchip_allowed(MachineState *machine);
 bool machine_kernel_irqchip_required(MachineState *machine);
 int machine_kvm_shadow_mem(MachineState *machine);
-- 
2.5.0




[Qemu-devel] [PATCH v2 0/2] Minor cleanups when parsing the "iommu" option

2015-11-12 Thread Bandan Das
Small cleanup changes. The first removes the helper function by directly
checking the property and the second adds a error message if user tries
to use "-machine iommu=on" with i440fx.

v2:
2/2: use error_report for the warning message

Bandan Das (2):
  q35: Check propery to determine if iommu is set
  i440fx: print an error message if user tries to enable iommu

 hw/core/machine.c   | 5 -
 hw/pci-host/piix.c  | 5 +
 hw/pci-host/q35.c   | 2 +-
 include/hw/boards.h | 1 -
 4 files changed, 6 insertions(+), 7 deletions(-)

-- 
2.5.0




Re: [Qemu-devel] [PATCH 0/4] block/gluster: add support for multiple gluster servers

2015-11-12 Thread Eric Blake
[adding qemu-block]

On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> This release is rebased on qemu master branch.
> In this series of patches 1/4 and 2/4 are unchanged.

According to scripts/get-maintainer.pl, this series should have cc'd
qemu-bl...@nongnu.org.  I don't know if anyone on the block list missed
my reviews because they were only on qemu-devel; and it may matter to
other networked block devices that also need to implement structured
options for use in blockdev-add.

> 
> Prasanna Kumar Kalever (4):
>   block/gluster: rename [server, volname, image] -> [host, volume, path]
>   block/gluster: code cleanup
>   block/gluster: using new qapi schema
>   block/gluster: add support for multiple gluster servers
> 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema

2015-11-12 Thread Eric Blake
On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> this patch adds GlusterConf to qapi/block-core.json
> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 104 
> +--
>  qapi/block-core.json |  60 +++--
>  2 files changed, 109 insertions(+), 55 deletions(-)
> 

Pointing it out here for completeness, even though I first stumbled on
it when reviewing 4/4:

> @@ -190,13 +180,23 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, 
> const char *filename)
>  ret = -EINVAL;
>  goto out;
>  }
> -gconf->host = g_strdup(qp->p[0].value);
> +gconf->server->host = g_strdup(qp->p[0].value);

This is abusing the 'host' field of GlusterServer to track a socket
path, and ignores the fact that port is meaningless for a
gluster+unix:// connection.

> @@ -224,8 +225,9 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, 
> const char *filename,
>  goto out;
>  }
>  
> -ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->host,
> -gconf->port);
> +ret = glfs_set_volfile_server(glfs,
> +  
> GlusterTransport_lookup[gconf->server->transport],
> +  gconf->server->host, gconf->server->port);

At least gluster itself has the same overloaded abuse of terminology;
I'm hoping that a port of 0 is okay when requesting a "unix"
volfile_server.  [I don't know, because I didn't read the docs for
glfs_set_volfile_server()]

> +##
> +# @GlusterServer
> +#
> +# Details for connecting to a gluster server
> +#
> +# @host:   host address (hostname/ipv4/ipv6 addresses)
> +#
> +# @port:   #optional port number on which glusterd is listening
> +#   (default 24007)
> +#
> +# @transport:  #optional transport type used to connect to gluster management
> +#   daemon (default 'tcp')
> +#
> +# Since: 2.5
> +##
> +{ 'struct': 'GlusterServer',
> +  'data': { 'host': 'str',
> +'*port': 'int',
> +'*transport': 'GlusterTransport' } }

And my idea on patch 4/4 was that converting this from simple struct to
flat union might be a more realistic view of things (if transport is
'unix', there can't be a port; and rather than abusing the name 'host'
we could use the name 'socket'; similarly for 'rdma') - but without
additional qapi support, I don't know that we can have an optional
'transport' and still have a discriminated union in time for 2.5.

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 2/2] i440fx: print an error message if user tries to enable iommu

2015-11-12 Thread Bandan Das
Markus Armbruster  writes:

> Bandan Das  writes:
>
>> There's no indication of any sort that i440fx doesn't support
>> "iommu=on""
>>
>> Signed-off-by: Bandan Das 
>> ---
>>  hw/pci-host/piix.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
>> index 7b2fbf9..f12593a 100644
>> --- a/hw/pci-host/piix.c
>> +++ b/hw/pci-host/piix.c
>> @@ -301,6 +301,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, 
>> Error **errp)
>>  static void i440fx_realize(PCIDevice *dev, Error **errp)
>>  {
>>  dev->config[I440FX_SMRAM] = 0x02;
>> +
>> +if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) {
>> +fprintf(stderr, "i440fx doesn't support emulated iommu\n");
>> +}
>>  }
>>  
>>  PCIBus *i440fx_init(const char *host_type, const char *pci_type,
>
> error_report(), please.
>
> If this is just a warning, please prefix the message with "warning: ".

Sure will do. Yeah, it seems good enough just to print a message without
exiting.

> If it isn't, exit(1).



Re: [Qemu-devel] [PATCH 2/3] usb-mtp: Add support for inotify based file monitoring

2015-11-12 Thread Bandan Das
Gerd Hoffmann  writes:

> On Mo, 2015-11-09 at 18:12 -0500, Bandan Das wrote:
>> Gerd Hoffmann  writes:
>> 
>> > On Di, 2015-11-03 at 19:00 -0500, Bandan Das wrote:
>> >> +/* Add a new watch asap so as to not lose events
>> >> */
>> >
>> > This comment sounds like there is a race ("asap").  There isn't one,
>> > correct ordering (adding the watch before reading the directory) is
>> 
>> Hmm, seems like there's still a small window. We may not have even
>> started processing the event because we are still processing the earlier
>> ones.
>
>> > enough to make sure you don't miss anything.  You might see create
>> > events for objects already in the tree though, are you prepared to
>> > handle that?
>> 
>> Oh, interesting.  Current version will happily add duplicate entries.
>> I will add a check.
>
> I think we are talking about the same thing here.
> Things can run in parallel, like this:
>
> process copying a file tree | qemu with usb-mtp
> +--
> create directory|
> | inotify event #1 queued (dir)
> | qemu fetches event #1
> | qemu adds new inotify watch
> copy file into new dir  |
> | inotify event #2 queued (file)
> | qemu reads new directory
> | qemu finds the new file
> | qemu fetches event #2
>
> So, yes, the kernel can add new inotify events for the new watch before

Maybe I am missing something but what if the watch on dir was
added by qemu _after_ the file (say file1) was copied to it.
Then, the kernel would generate events for file2, file3 and so on but
never a CREATE event for file1. Isn't that a possibility ? So, what I mean
by that comment is that add a watchpoint soon enough but it could be
possible that by the time the watch is added, a few files might have already
been copied and will not generate events.

> qemu finished processing the old event (especially before you are done
> reading the directory), and if you are hitting that the effect is that
> you see a create event for the new file even though you already have it
> in the tree.
>
> But it is impossible that you miss the creation of the new file (this is
> what I meant with "there is no race").
>
> hope this clarifies,
>   Gerd



Re: [Qemu-devel] [PATCH 4/4] block/gluster: add support for multiple gluster servers

2015-11-12 Thread Eric Blake
On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> This patch adds a way to specify multiple volfile servers to the gluster
> block backend of QEMU with tcp|rdma transport types and their port numbers.
> 

> This patch gives a mechanism to provide all the server addresses, which are in
> replica set, so in case host1 is down VM can still boot from any of the
> active hosts.
> 
> This is equivalent to the backup-volfile-servers option supported by
> mount.glusterfs (FUSE way of mounting gluster volume)
> 
> Credits: Sincere thanks to Kevin Wolf  and
> "Deepak C Shetty"  for inputs and all their support
> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 288 
> ---
>  qapi/block-core.json |   4 +-
>  2 files changed, 252 insertions(+), 40 deletions(-)

All right - the diffstat is smaller this time around (288 is nicer than
468 lines changed in v13).  There's always a psychological barrier to
reviewing large patches, and breaking things into bite-sized chunks
helps even if the same amount of work is done overall.

> 
> diff --git a/block/gluster.c b/block/gluster.c
> index 615f28b..ba209cf 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -12,6 +12,13 @@
>  #include "qemu/uri.h"
>  
>  #define GLUSTER_OPT_FILENAME"filename"
> +#define GLUSTER_OPT_VOLUME  "volume"
> +#define GLUSTER_OPT_PATH"path"
> +#define GLUSTER_OPT_HOST"host"
> +#define GLUSTER_OPT_PORT"port"
> +#define GLUSTER_OPT_TRANSPORT   "transport"
> +#define GLUSTER_OPT_SERVER_PATTERN  "server."
> +
>  #define GLUSTER_DEFAULT_PORT24007

Once again, I'm jumping to the interface first [1]


> @@ -131,6 +178,7 @@ static int qemu_gluster_parseuri(BlockdevOptionsGluster 
> **pgconf,
>   const char *filename)
>  {
>  BlockdevOptionsGluster *gconf;
> +GlusterServer *gsconf;
>  URI *uri;
>  QueryParams *qp = NULL;
>  bool is_unix = false;
> @@ -142,23 +190,24 @@ static int qemu_gluster_parseuri(BlockdevOptionsGluster 
> **pgconf,
>  }
>  
>  gconf = g_new0(BlockdevOptionsGluster, 1);
> -gconf->server = g_new0(GlusterServer, 1);
> +gconf->server = g_new0(GlusterServerList, 1);
> +gconf->server->value = gsconf = g_new0(GlusterServer, 1);
>  
>  /* transport */
>  if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {
> -gconf->server->transport = GLUSTER_TRANSPORT_TCP;
> +gsconf->transport = GLUSTER_TRANSPORT_TCP;

Most of the changes here in parseuri could have been in patch 3/4 if we
weren't churning on the qapi definition.  But looks like your conversion
here is correct.

> -static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
> -  const char *filename, Error **errp)
> +static struct glfs *qemu_gluster_glfs_init(BlockdevOptionsGluster *gconf,
> +   Error **errp)
>  {

I might have split the refactoring of qemu_gluster_glfs_init() into its
own patch, but not the end of the world the way it was done here.

>  struct glfs *glfs;
>  int ret;
>  int old_errno;
> -BlockdevOptionsGluster *gconf;
> -
> -ret = qemu_gluster_parseuri(&gconf, filename);
> -if (ret < 0) {
> -error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
> - "volume/path[?socket=...]");
> -errno = -ret;
> -goto out;
> -}
> +GlusterServerList *server;
>  
>  glfs = glfs_new(gconf->volume);
>  if (!glfs) {
>  goto out;
>  }
>  
> -ret = glfs_set_volfile_server(glfs,
> -  
> GlusterTransport_lookup[gconf->server->transport],
> -  gconf->server->host, gconf->server->port);
> -if (ret < 0) {
> -goto out;
> +for (server = gconf->server; server; server = server->next) {

I still wonder if gconf->servers (and therefore servers.0, servers.1 in
the command line, instead of server.0, server.1) would have been a
better name for the list, but I don't know if it is worth repainting the
bikeshed at this point in time.  On the other hand, it's user-visible,
so once it gets released, we're stuck with the name, but up until then,
we can do a followup patch if anyone else has a strong opinion.

> +ret = glfs_set_volfile_server(glfs,
> +  
> GlusterTransport_lookup[server->value->transport],
> +  server->value->host, 
> server->value->port);

I asked in v13 if all initializations set the optional transport and
port.  See [3] below

> +if (ret < 0) {
> +goto out;
> +}
>  }
>  
>  /*
> @@ -244,10 +287,9 @@ static struct glfs 
> *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
>  ret = glfs_init(glfs);
>  if (ret) {
>  error_setg_errno(errp, errno,
> -   

Re: [Qemu-devel] [PATCH v2 0/7] vl: graphics stubs + #ifdef cleanup

2015-11-12 Thread Eduardo Habkost
On Thu, Nov 12, 2015 at 02:17:53PM -0700, Eric Blake wrote:
> On 11/12/2015 12:02 PM, Eduardo Habkost wrote:
> > Clean up the graphics initialization code to reduce the number of
> > 
> 
> Lame of git for eating lines that start with #ifdef.  But at least it
> doesn't matter on the cover letter :)

Maybe it's a git-publish bug, I will check. Thanks for noting! :)

-- 
Eduardo



Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema

2015-11-12 Thread Eric Blake
On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> this patch adds GlusterConf to qapi/block-core.json
> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 104 
> +--
>  qapi/block-core.json |  60 +++--
>  2 files changed, 109 insertions(+), 55 deletions(-)

One more comment:

> -static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
> +static int qemu_gluster_parseuri(BlockdevOptionsGluster **pgconf,
> + const char *filename)
>  {
> +BlockdevOptionsGluster *gconf;
>  URI *uri;
>  QueryParams *qp = NULL;
>  bool is_unix = false;
> @@ -155,20 +141,24 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, 
> const char *filename)
>  return -EINVAL;

If we hit this early return, then *pgconf was never assigned...


> +static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
> +  const char *filename, Error **errp)
>  {
> -struct glfs *glfs = NULL;
> +struct glfs *glfs;
>  int ret;
>  int old_errno;
> +BlockdevOptionsGluster *gconf;

but here, gconf is uninitialized,

>  
> -ret = qemu_gluster_parseuri(gconf, filename);
> +ret = qemu_gluster_parseuri(&gconf, filename);
>  if (ret < 0) {
>  error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
>   "volume/path[?socket=...]");

which means we can goto out with it uninitialized...

> @@ -224,8 +225,9 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, 
> const char *filename,
>  goto out;
>  }
>  
> -ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->host,
> -gconf->port);
> +ret = glfs_set_volfile_server(glfs,
> +  
> GlusterTransport_lookup[gconf->server->transport],
> +  gconf->server->host, gconf->server->port);
>  if (ret < 0) {
>  goto out;
>  }

...vs. here where we can goto out with it initialized.

So whatever solution you use to plug the leak must be careful to not
free uninitialized memory.  Easiest solution - initialize gconf to NULL
before qemu_gluster_parseuri (or else go back to a *gconf parameter
rather than **pgconf).

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH for-2.5 v5 1/1] hw/misc: Add support for ADC controller in Xilinx Zynq 7000

2015-11-12 Thread Peter Maydell
On 12 November 2015 at 17:54, Peter Crosthwaite
 wrote:
> From: Guenter Roeck 
>
> Add support for the Xilinx XADC core used in Zynq 7000.
>
> References:
> - Zynq-7000 All Programmable SoC Technical Reference Manual
> - 7 Series FPGAs and Zynq-7000 All Programmable SoC XADC
>   Dual 12-Bit 1 MSPS Analog-to-Digital Converter
>
> Tested with Linux using QEMU machine xilinx-zynq-a9 with devicetree
> files zynq-zc702.dtb and zynq-zc706.dtb, and kernel configuration
> multi_v7_defconfig.
>
> Reviewed-by: Alistair Francis 
> Signed-off-by: Guenter Roeck 
> [ PC changes:
>   * Changed macro names to match TRM where possible
>   * Made programmers model macro scheme consistent
>   * Dropped XADC_ZYNQ_ prefix on local macros
>   * Fix ALM field width
>   * Update threshold-comparison interrupts in _update_ints()
>   * factored out DFIFO pushes into helper. Renamed to "push/pop"
>   * Changed xadc_reg to 10 bits and added OOB check.
>   * Reduced scope of MCTL reset to just stop channel coms.
>   * Added dummy read data to write commands
>   * Changed _ to - seperators in string names and filenames
>   * Dropped  in header comment
>   * Catchall'ed _update_ints() in _write handler.
>   * Minor whitespace changes.
>   * Use ZYNQ_XADC_FIFO_DEPTH instead of ARRAY_SIZE()
> ]
> Signed-off-by: Peter Crosthwaite 
> ---
> v5:
> Fix compile warning
> v4:
> Addressed Alistair review
> Minor whitespace changes
> Use ZYNQ_XADC_FIFO_DEPTH instead of ARRAY_SIZE()
> v3:
> See [PC changes] in commit message
> v2:
> Use extract32()
> Merge zynq_xadc_reset() and _zynq_xadc_reset() into one function
> Use "xlnx,zynq_xadc"
> Move device model to include/hw/misc/zynq_xadc.h
> irq -> qemu_irq
> xadc_dfifo_depth -> xadc_dfifo_entries
> Dropped unnecessary comments
> Merged zynq_xadc_realize() into zynq_xadc_init()
>
>  hw/arm/xilinx_zynq.c|   6 +
>  hw/misc/Makefile.objs   |   1 +
>  hw/misc/zynq-xadc.c | 302 
> 
>  include/hw/misc/zynq-xadc.h |  46 +++
>  4 files changed, 355 insertions(+)
>  create mode 100644 hw/misc/zynq-xadc.c
>  create mode 100644 include/hw/misc/zynq-xadc.h
>

Applied to master, thanks.

-- PMM



[Qemu-devel] [PATCH] scsi: remove scsi_req_free prototype

2015-11-12 Thread Hervé Poussineau
Function has been deleted in ad2d30f79d3b0812f02c741be2189796b788d6d7.

Signed-off-by: Hervé Poussineau 
---
 include/hw/scsi/scsi.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h
index cdaf0f8..1915a73 100644
--- a/include/hw/scsi/scsi.h
+++ b/include/hw/scsi/scsi.h
@@ -250,7 +250,6 @@ SCSIRequest *scsi_req_alloc(const SCSIReqOps *reqops, 
SCSIDevice *d,
 SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun,
   uint8_t *buf, void *hba_private);
 int32_t scsi_req_enqueue(SCSIRequest *req);
-void scsi_req_free(SCSIRequest *req);
 SCSIRequest *scsi_req_ref(SCSIRequest *req);
 void scsi_req_unref(SCSIRequest *req);
 
-- 
2.1.4




[Qemu-devel] [PATCH for-2.5] mac_dbdma: always initialize channel field in DBDMA_channel

2015-11-12 Thread Hervé Poussineau
dbdma_from_ch() uses channel field to return the right DBDMA object.
Previous code was working if guest OS was only using registered DMA channels.
However, it lead to QEMU crashes if guest OS was using unregistered DMA 
channels.

Signed-off-by: Hervé Poussineau 
---
 hw/misc/macio/mac_dbdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c
index 779683c..5ee8f02 100644
--- a/hw/misc/macio/mac_dbdma.c
+++ b/hw/misc/macio/mac_dbdma.c
@@ -557,7 +557,6 @@ void DBDMA_register_channel(void *dbdma, int nchan, 
qemu_irq irq,
 DBDMA_DPRINTF("DBDMA_register_channel 0x%x\n", nchan);
 
 ch->irq = irq;
-ch->channel = nchan;
 ch->rw = rw;
 ch->flush = flush;
 ch->io.opaque = opaque;
@@ -753,6 +752,7 @@ void* DBDMA_init (MemoryRegion **dbdma_mem)
 for (i = 0; i < DBDMA_CHANNELS; i++) {
 DBDMA_io *io = &s->channels[i].io;
 qemu_iovec_init(&io->iov, 1);
+s->channels[i].channel = i;
 }
 
 memory_region_init_io(&s->mem, NULL, &dbdma_ops, s, "dbdma", 0x1000);
-- 
2.1.4




Re: [Qemu-devel] [PATCH v2 0/7] vl: graphics stubs + #ifdef cleanup

2015-11-12 Thread Eric Blake
On 11/12/2015 12:02 PM, Eduardo Habkost wrote:
> Clean up the graphics initialization code to reduce the number of
> 

Lame of git for eating lines that start with #ifdef.  But at least it
doesn't matter on the cover letter :)

> Changes v1 -> v2:
> * Patches 2-6: Move stub files to stubs/ui/
> * Patch 7: Move stubs to qemu-spice.h, as the header file
>   already had a separate section for !CONFIG_SPICE
> * Removed DT_NOGRAPHIC patches from the series (they will be sent
>   as a separate series)
> 
> Eduardo Habkost (7):
>   vl: Add DT_COCOA DisplayType value
>   stubs: VNC initialization stubs
>   stubs: curses_display_init() stub
>   stubs: SDL initialization stubs
>   stubs: cocoa_display_init() stub
>   stubs: gtk_display_init() stub
>   spice: Initialization stubs on qemu-spice.h
> 
>  include/sysemu/sysemu.h |  1 +
>  include/ui/console.h|  4 ++--
>  include/ui/qemu-spice.h | 13 +
>  stubs/Makefile.objs |  1 +
>  stubs/ui/Makefile.objs  |  5 +
>  stubs/ui/cocoa.c| 10 ++
>  stubs/ui/curses.c   | 10 ++
>  stubs/ui/gtk.c  | 10 ++
>  stubs/ui/sdl.c  | 17 +
>  stubs/ui/vnc.c  | 22 ++
>  vl.c| 37 ++---
>  11 files changed, 97 insertions(+), 33 deletions(-)
>  create mode 100644 stubs/ui/Makefile.objs
>  create mode 100644 stubs/ui/cocoa.c
>  create mode 100644 stubs/ui/curses.c
>  create mode 100644 stubs/ui/gtk.c
>  create mode 100644 stubs/ui/sdl.c
>  create mode 100644 stubs/ui/vnc.c
> 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema

2015-11-12 Thread Eric Blake
On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> this patch adds GlusterConf to qapi/block-core.json

Missing a vNN in the subject line.  I think we're up to v14?  But it
doesn't affect what 'git am' will do.

> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 104 
> +--
>  qapi/block-core.json |  60 +++--
>  2 files changed, 109 insertions(+), 55 deletions(-)
> 

Modulo Jeff's findings,

> diff --git a/block/gluster.c b/block/gluster.c
> index ededda2..615f28b 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c

> -typedef struct GlusterConf {
> -char *host;
> -int port;
> -char *volume;
> -char *path;
> -char *transport;
> -} GlusterConf;
> -
> -

So this is the struct being replaced by qapi BlockdevOptionsGluster.
/me jumps ahead to [1] in my review, before continuing here...

I'm back. Looks like your qapi struct matches this nicely, with the
possible exception of what happens if we try to avoid churn by
using/enforcing a 1-element array now rather than converting to array in
patch 4.

> @@ -143,8 +127,10 @@ static int parse_volume_options(GlusterConf *gconf, char 
> *path)
>   * file=gluster+unix:///testvol/dir/a.img?socket=/tmp/glusterd.socket
>   * file=gluster+rdma://1.2.3.4:24007/testvol/a.img
>   */
> -static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
> +static int qemu_gluster_parseuri(BlockdevOptionsGluster **pgconf,
> + const char *filename)

I'm not sure from looking at just the signature why you changed from
*gconf to **pgconf; maybe that sort of conversion would have been worth
mentioning in the commit message (a good rule of thumb - if the change
isn't blatantly obvious, then calling it out in the commit message will
prepare reviewers for it).

> @@ -190,13 +180,23 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, 
> const char *filename)
>  ret = -EINVAL;
>  goto out;
>  }
> -gconf->host = g_strdup(qp->p[0].value);
> +gconf->server->host = g_strdup(qp->p[0].value);
>  } else {
> -gconf->host = g_strdup(uri->server ? uri->server : "localhost");
> -gconf->port = uri->port;
> +gconf->server->host = g_strdup(uri->server ? uri->server : 
> "localhost");
> +if (uri->port) {
> +gconf->server->port = uri->port;
> +} else {
> +gconf->server->port = GLUSTER_DEFAULT_PORT;
> +}
> +gconf->server->has_port = true;
>  }
>  
> +*pgconf = gconf;

Okay, now I see where the change in signature comes into play - you want
to return a new allocation to the user, but only on success.  But I'm
still not necessarily convinced that you need it.  See more at [3] below.

> +
>  out:
> +if (ret < 0) {
> +qapi_free_BlockdevOptionsGluster(gconf);
> +}
>  if (qp) {
>  query_params_free(qp);
>  }
> @@ -204,14 +204,15 @@ out:
>  return ret;
>  }

Okay, this parseuri conversion is sane.  It will need tweaking in patch
4 to deal with gconf->server becoming a list rather than a single
server, but as long as both patches go in, we should be okay.

>  
> -static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char 
> *filename,
> -  Error **errp)
> +static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
> +  const char *filename, Error **errp)
>  {
> -struct glfs *glfs = NULL;
> +struct glfs *glfs;

Jeff already spotted that the change here is spurious.

>  int ret;
>  int old_errno;
> +BlockdevOptionsGluster *gconf;
>  
> -ret = qemu_gluster_parseuri(gconf, filename);
> +ret = qemu_gluster_parseuri(&gconf, filename);
>  if (ret < 0) {
>  error_setg(errp, "Usage: file=gluster[+transport]://[host[:port]]/"
>   "volume/path[?socket=...]");
> @@ -224,8 +225,9 @@ static struct glfs *qemu_gluster_init(GlusterConf *gconf, 
> const char *filename,
>  goto out;
>  }
>  
> -ret = glfs_set_volfile_server(glfs, gconf->transport, gconf->host,
> -gconf->port);
> +ret = glfs_set_volfile_server(glfs,
> +  
> GlusterTransport_lookup[gconf->server->transport],

Line longer than 80 characters; I might have used an intermediate const
char * variable to cut down on the length. But as long as it gets past
scripts/checkpatch.pl, I won't insist on a reformat.

> +  gconf->server->host, gconf->server->port);

Ouch - since you aren't validating that gconf->server->port fits in 16
bits, you may be passing something so large that it silently wraps around.

>  if (ret < 0) {
>  goto out;
>  }
> @@ -242,10 +244,10 @@ static struct glfs *qemu_gluster_init(GlusterConf 
> *gconf, const char *filename,
>  ret = glfs_init(glfs);

Re: [Qemu-devel] [PATCH] tests/.gitignore: ignore test-blockjob-txn

2015-11-12 Thread John Snow
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256



On 11/12/2015 03:31 PM, Eric Blake wrote:
> On 11/12/2015 01:21 PM, John Snow wrote:
>> Reported-by: Eric Blake  Signed-off-by: John
>> Snow  --- tests/.gitignore | 1 + 1 file
>> changed, 1 insertion(+)
> 
> My version of this same patch at least called out the commit that 
> introduced the problem :) 
> https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg03142.html
>
> 
>> 
>> diff --git a/tests/.gitignore b/tests/.gitignore index
>> e96f569..de5e793 100644 --- a/tests/.gitignore +++
>> b/tests/.gitignore @@ -9,6 +9,7 @@ check-qom-proplist rcutorture 
>> test-aio test-bitops +test-blockjob-txn test-coroutine 
>> test-crypto-cipher test-crypto-hash
>> 
> 

Oh, I didn't realize you sent a _patch_, I just saw the part saying
"Hey, stuff gooofed up!"

ignore, NACK, etc

(Sorry, Eric -- I'm on autopilot right now.)

- --js
-BEGIN PGP SIGNATURE-
Version: GnuPG v2

iQIcBAEBCAAGBQJWRPdnAAoJEH3vgQaq/DkOo+YQALWnjexfVyEC7I0kZaIzH/yh
voBG7XiApNPxPqq1X/C+UtGkM6XxIBAECoz2O5+eGnnw9OTcNkdQELcvERfcnG50
+ULvQIf+BeCrMV8fPZaq8uCvwYCIMOxUd2JH22QptYsetBIQHeVnARY8OltdJ1ET
gLRHFcBTYy/LFnQvuIqBNKcSTuiWTSxqHpsQHeDRv2a+0XTIgFCbsPLKKPpR0e7d
UdX1NSUuT0suIcgkDf34Vx1rEmlShFzmtrjVlFG8WFtzN0qrYOqn6SQ+1KxgAeR2
RzQeH8RUy7JgLIbKjARb+4Ya3wxKUFIFqZ3Y871uCG1eYC4BE/q3+Q3CdBM45w3E
DNLLk48efHHYumRXYMwS6dPo84T8s5XC76raWuMXLN8kbzj8F2fAgro1NXYfPlz0
NS81aw0HEDDsupvKafvnatF0neVaP1PCOT33ques2T/SIbzzLM9Eu/gNPaQAlBne
Uf7kV8NU38TW3dBKczzUVH//XeVo8dqsQiByGe4YXeMCC9vLHCBwtfxtnZXZtBth
mZ0JJnlIbnX43M8m0/+PsicFzGpddEOXhb4hgWhSRHxNThJQbALy36oFtKWkTCg4
nR/12rIlQQx/A1MfWtYflAAFxPNgGyp8B6Gu1A0utCUMIPti9oYgmROX7+32I7WZ
R71Xc2d3chK0ozyqh/8w
=eOua
-END PGP SIGNATURE-



Re: [Qemu-devel] [PATCH] tests/.gitignore: ignore test-blockjob-txn

2015-11-12 Thread Eric Blake
On 11/12/2015 01:21 PM, John Snow wrote:
> Reported-by: Eric Blake 
> Signed-off-by: John Snow 
> ---
>  tests/.gitignore | 1 +
>  1 file changed, 1 insertion(+)

My version of this same patch at least called out the commit that
introduced the problem :)
https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg03142.html

> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index e96f569..de5e793 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -9,6 +9,7 @@ check-qom-proplist
>  rcutorture
>  test-aio
>  test-bitops
> +test-blockjob-txn
>  test-coroutine
>  test-crypto-cipher
>  test-crypto-hash
> 

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



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 1/4] block/gluster: rename [server, volname, image] -> [host, volume, path]

2015-11-12 Thread Eric Blake
On 11/12/2015 03:22 AM, Prasanna Kumar Kalever wrote:
> this patch is very much be meaningful after next patch which adds multiple
> gluster servers support. After that,
> 
> an example is, in  'servers' tuple values we use 'server' variable for key

Awkward line break mid-sentence.  The commit message alone is not a
reason to hold up this patch, so maybe the maintainer can adjust it.

> 'host' in the code, it will be quite messy to have colliding names for
> variables, so to maintain better readability and makes it consistent with 
> other
> existing code as well as the input keys/options, this patch renames the
> following variables

I'd suggest replacing everything up to here with:

A future patch will add support for multiple gluster servers.  Our
existing terminology is a bit unusual in relation to what names are used
by other networked devices, and doesn't map very well to the terminology
we expect to use for multiple servers.  Therefore, rename the following
options:

> 'server'  -> 'host'
> 'image'   -> 'path'
> 'volname' -> 'volume'
> 
> Signed-off-by: Prasanna Kumar Kalever 
> Reviewed-by: Eric Blake 
> ---
>  block/gluster.c | 54 +++---
>  1 file changed, 27 insertions(+), 27 deletions(-)

R-b still stands on this one.

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH] tests/.gitignore: ignore test-blockjob-txn

2015-11-12 Thread John Snow
Reported-by: Eric Blake 
Signed-off-by: John Snow 
---
 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index e96f569..de5e793 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,6 +9,7 @@ check-qom-proplist
 rcutorture
 test-aio
 test-bitops
+test-blockjob-txn
 test-coroutine
 test-crypto-cipher
 test-crypto-hash
-- 
2.4.3




Re: [Qemu-devel] [v2 0/2] add avx2 instruction optimization

2015-11-12 Thread Eric Blake
On 11/12/2015 12:56 PM, Dr. David Alan Gilbert wrote:

>> One thing I still can't understand, why the unit test in host environment 
>> shows
>> 'memcmp()' have better performance?

Have you tried running under a profiler, to see if there are hotspots or
at least get an idea of where the time is being spent?

> 
> Are you aware of any program other than QEMU that also wants to do something
> similar?  Finding whether a block of memory is zero, sounds like something
> that would be useful in lots of places, I just can't think which ones.

At least dd, cp, and probably several other utilities.  It would be nice
to post an RFE to glibc to see if they can come up with a dedicated
interface that is faster than memcmp(), although that still only helps
us when targetting a system new enough to have that interface.

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] which machinetypes have an integrated/implied IDE controller?

2015-11-12 Thread Laine Stump
For a long time, libvirt assumed by default that all types of virtual 
machines had an integrated IDE controller named "ide" that wasn't 
specified on the qemu commandline. Since that caused problems 
specifically for the Q35 machine type (which has an *ahci* controller 
that it perplexingly calls "ide"), I added code to libvirt to only make 
that assumption for i440fx-based machinetypes, and to log an error and 
fail in all other cases where someone tried to create a disk attached to 
an IDE controller:


 http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=eadd757

(libvirt doesn't support explicitly adding IDE controllers on the qemu 
commandline, under the assumption that 1) there are lots of better ways 
to attach a disk and 2) nobody has asked for it up to now, and we don't 
want to encourage them to start using something that is slow and 
unnecessary).


But I just received an email from someone who informed me that the 
"ppc-beigeg3" machine type also has an IDE controller, and that 
additionally this is the *only* method of connecting a disk on this 
particular machine. So now I'm wondering how I can determine what other 
machinetypes have an integrated IDE controller, so that I can add them 
to this check. (I would also like to find out which qemu binary supports 
the "ppc-beigeg3" machinetype - I tried running "qemu-blah -M ?" for 
every qemu binary on my Fedora 22 system, and didn't see anything like 
that).




Re: [Qemu-devel] [PATCH 4/4] block/gluster: add support for multiple gluster servers

2015-11-12 Thread Jeff Cody
On Thu, Nov 12, 2015 at 03:52:08PM +0530, Prasanna Kumar Kalever wrote:
> This patch adds a way to specify multiple volfile servers to the gluster
> block backend of QEMU with tcp|rdma transport types and their port numbers.
> 
> Problem:
> 
> Currently VM Image on gluster volume is specified like this:
> 
> file=gluster[+tcp]://host[:port]/testvol/a.img
> 
> Assuming we have three hosts in trusted pool with replica 3 volume
> in action and unfortunately host (mentioned in the command above) went down
> for some reason, since the volume is replica 3 we now have other 2 hosts
> active from which we can boot the VM.
> 
> But currently there is no mechanism to pass the other 2 gluster host
> addresses to qemu.
> 
> Solution:
> 
> New way of specifying VM Image on gluster volume with volfile servers:
> (We still support old syntax to maintain backward compatibility)
> 
> Basic command line syntax looks like:
> 
> Pattern I:
>  -drive driver=gluster,
> volume=testvol,path=/path/a.raw,
> server.0.host=1.2.3.4,
>[server.0.port=24007,]
>[server.0.transport=tcp,]
> server.1.host=5.6.7.8,
>[server.1.port=24008,]
>[server.1.transport=rdma,] ...
> 
> Pattern II:
>  'json:{"driver":"qcow2","file":{"driver":"gluster",
>"volume":"testvol","path":"/path/a.qcow2",
>"server":[{tuple0},{tuple1}, ...{tupleN}]}}'
> 
>driver  => 'gluster' (protocol name)
>volume  => name of gluster volume where our VM image resides
>path=> absolute path of image in gluster volume
> 
>   {tuple}  => {"host":"1.2.3.4"[,"port":"24007","transport":"tcp"]}
> 
>host=> host address (hostname/ipv4/ipv6 addresses)
>port=> port number on which glusterd is listening. (default 24007)
>transport   => transport type used to connect to gluster management daemon,
>it can be tcp|rdma (default 'tcp')
> 
> Examples:
> 1.
>  -drive driver=qcow2,file.driver=gluster,
> file.volume=testvol,file.path=/path/a.qcow2,
> file.server.0.host=1.2.3.4,
> file.server.0.port=24007,
> file.server.0.transport=tcp,
> file.server.1.host=5.6.7.8,
> file.server.1.port=24008,
> file.server.1.transport=rdma
> 2.
>  'json:{"driver":"qcow2","file":{"driver":"gluster","volume":"testvol",
>  "path":"/path/a.qcow2","server":
>  [{"host":"1.2.3.4","port":"24007","transport":"tcp"},
>   {"host":"4.5.6.7","port":"24008","transport":"rdma"}] } }'
> 
> This patch gives a mechanism to provide all the server addresses, which are in
> replica set, so in case host1 is down VM can still boot from any of the
> active hosts.
> 
> This is equivalent to the backup-volfile-servers option supported by
> mount.glusterfs (FUSE way of mounting gluster volume)
> 
> Credits: Sincere thanks to Kevin Wolf  and
> "Deepak C Shetty"  for inputs and all their support
> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 288 
> ---
>  qapi/block-core.json |   4 +-
>  2 files changed, 252 insertions(+), 40 deletions(-)
> 
> diff --git a/block/gluster.c b/block/gluster.c
> index 615f28b..ba209cf 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -12,6 +12,13 @@
>  #include "qemu/uri.h"
>  
>  #define GLUSTER_OPT_FILENAME"filename"
> +#define GLUSTER_OPT_VOLUME  "volume"
> +#define GLUSTER_OPT_PATH"path"
> +#define GLUSTER_OPT_HOST"host"
> +#define GLUSTER_OPT_PORT"port"
> +#define GLUSTER_OPT_TRANSPORT   "transport"
> +#define GLUSTER_OPT_SERVER_PATTERN  "server."
> +
>  #define GLUSTER_DEFAULT_PORT24007
>  
>  
> @@ -64,6 +71,46 @@ static QemuOptsList runtime_opts = {
>  },
>  };
>  
> +static QemuOptsList runtime_json_opts = {
> +.name = "gluster_json",
> +.head = QTAILQ_HEAD_INITIALIZER(runtime_json_opts.head),
> +.desc = {
> +{
> +.name = GLUSTER_OPT_VOLUME,
> +.type = QEMU_OPT_STRING,
> +.help = "name of gluster volume where VM image resides",
> +},
> +{
> +.name = GLUSTER_OPT_PATH,
> +.type = QEMU_OPT_STRING,
> +.help = "absolute path to image file in gluster volume",
> +},
> +{ /* end of list */ }
> +},
> +};
> +
> +static QemuOptsList runtime_tuple_opts = {
> +.name = "gluster_tuple",
> +.head = QTAILQ_HEAD_INITIALIZER(runtime_tuple_opts.head),
> +.desc = {
> +{
> +.name = GLUSTER_OPT_HOST,
> +.type = QEMU_OPT_STRING,
> +.help = "host address (hostname/ipv4/ipv6 addresses)",
> +},
> +{
> +.name = GLUSTER_OPT_PORT,
> +.type = QEMU_OPT_NUMBER,
> +.help = "port number on which glusterd is listening (default 
> 24007)",
> +},
> +{
> +.name = GLUSTER_OPT_TRANSPORT,
> +.type 

Re: [Qemu-devel] [PATCH 3/4] block/gluster: using new qapi schema

2015-11-12 Thread Jeff Cody
On Thu, Nov 12, 2015 at 03:52:07PM +0530, Prasanna Kumar Kalever wrote:
> this patch adds GlusterConf to qapi/block-core.json
> 
> Signed-off-by: Prasanna Kumar Kalever 
> ---
>  block/gluster.c  | 104 
> +--
>  qapi/block-core.json |  60 +++--
>  2 files changed, 109 insertions(+), 55 deletions(-)
> 
> diff --git a/block/gluster.c b/block/gluster.c
> index ededda2..615f28b 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -11,6 +11,10 @@
>  #include "block/block_int.h"
>  #include "qemu/uri.h"
>  
> +#define GLUSTER_OPT_FILENAME"filename"
> +#define GLUSTER_DEFAULT_PORT24007
> +
> +
>  typedef struct GlusterAIOCB {
>  int64_t size;
>  int ret;
> @@ -29,15 +33,6 @@ typedef struct BDRVGlusterReopenState {
>  struct glfs_fd *fd;
>  } BDRVGlusterReopenState;
>  
> -typedef struct GlusterConf {
> -char *host;
> -int port;
> -char *volume;
> -char *path;
> -char *transport;
> -} GlusterConf;
> -
> -
>  static QemuOptsList qemu_gluster_create_opts = {
>  .name = "qemu-gluster-create-opts",
>  .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_opts.head),
> @@ -61,7 +56,7 @@ static QemuOptsList runtime_opts = {
>  .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head),
>  .desc = {
>  {
> -.name = "filename",
> +.name = GLUSTER_OPT_FILENAME,
>  .type = QEMU_OPT_STRING,
>  .help = "URL to the gluster image",
>  },
> @@ -70,18 +65,7 @@ static QemuOptsList runtime_opts = {
>  };
>  
>  
> -static void qemu_gluster_gconf_free(GlusterConf *gconf)
> -{
> -if (gconf) {
> -g_free(gconf->host);
> -g_free(gconf->volume);
> -g_free(gconf->path);
> -g_free(gconf->transport);
> -g_free(gconf);
> -}
> -}
> -
> -static int parse_volume_options(GlusterConf *gconf, char *path)
> +static int parse_volume_options(BlockdevOptionsGluster *gconf, char *path)
>  {
>  char *p, *q;
>  
> @@ -143,8 +127,10 @@ static int parse_volume_options(GlusterConf *gconf, char 
> *path)
>   * file=gluster+unix:///testvol/dir/a.img?socket=/tmp/glusterd.socket
>   * file=gluster+rdma://1.2.3.4:24007/testvol/a.img
>   */
> -static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename)
> +static int qemu_gluster_parseuri(BlockdevOptionsGluster **pgconf,
> + const char *filename)
>  {
> +BlockdevOptionsGluster *gconf;
>  URI *uri;
>  QueryParams *qp = NULL;
>  bool is_unix = false;
> @@ -155,20 +141,24 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, 
> const char *filename)
>  return -EINVAL;
>  }
>  
> +gconf = g_new0(BlockdevOptionsGluster, 1);
> +gconf->server = g_new0(GlusterServer, 1);
> +
>  /* transport */
>  if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {
> -gconf->transport = g_strdup("tcp");
> +gconf->server->transport = GLUSTER_TRANSPORT_TCP;
>  } else if (!strcmp(uri->scheme, "gluster+tcp")) {
> -gconf->transport = g_strdup("tcp");
> +gconf->server->transport = GLUSTER_TRANSPORT_TCP;
>  } else if (!strcmp(uri->scheme, "gluster+unix")) {
> -gconf->transport = g_strdup("unix");
> +gconf->server->transport = GLUSTER_TRANSPORT_UNIX;
>  is_unix = true;
>  } else if (!strcmp(uri->scheme, "gluster+rdma")) {
> -gconf->transport = g_strdup("rdma");
> +gconf->server->transport = GLUSTER_TRANSPORT_RDMA;
>  } else {
>  ret = -EINVAL;
>  goto out;
>  }
> +gconf->server->has_transport = true;
>  
>  ret = parse_volume_options(gconf, uri->path);
>  if (ret < 0) {
> @@ -190,13 +180,23 @@ static int qemu_gluster_parseuri(GlusterConf *gconf, 
> const char *filename)
>  ret = -EINVAL;
>  goto out;
>  }
> -gconf->host = g_strdup(qp->p[0].value);
> +gconf->server->host = g_strdup(qp->p[0].value);
>  } else {
> -gconf->host = g_strdup(uri->server ? uri->server : "localhost");
> -gconf->port = uri->port;
> +gconf->server->host = g_strdup(uri->server ? uri->server : 
> "localhost");
> +if (uri->port) {
> +gconf->server->port = uri->port;
> +} else {
> +gconf->server->port = GLUSTER_DEFAULT_PORT;
> +}
> +gconf->server->has_port = true;
>  }
>  
> +*pgconf = gconf;
> +
>  out:
> +if (ret < 0) {
> +qapi_free_BlockdevOptionsGluster(gconf);
> +}
>  if (qp) {
>  query_params_free(qp);
>  }
> @@ -204,14 +204,15 @@ out:
>  return ret;
>  }
>  
> -static struct glfs *qemu_gluster_init(GlusterConf *gconf, const char 
> *filename,
> -  Error **errp)
> +static struct glfs *qemu_gluster_init(BlockdevOptionsGluster **pgconf,
> +  const char *filename, Error **

Re: [Qemu-devel] [v2 0/2] add avx2 instruction optimization

2015-11-12 Thread Dr. David Alan Gilbert
* Li, Liang Z (liang.z...@intel.com) wrote:
> > >> >
> > >> > I use your new code:
> > >> > -
> > >> >unsigned long *p = ...
> > >> >if (p[0] || p[1] || p[2] || p[3]
> > >> >|| memcmp(p+4, p, size - 4 * sizeof(unsigned long)) != 0)
> > >> >return BUFFER_NOT_ZERO;
> > >> >else
> > >> >return BUFFER_ZERO;
> > >> > ---
> > >> > and the result is almost the same.  I also tried the check 8, 16
> > >> > long data at the beginning, same result.
> > >>
> > >> Interesting...  Well, all I can say is that applaud you for testing
> > >> your hypothesis with the benchmark.
> > >>
> > >> Probably the setup cost of memcmp is too high, because the testing
> > >> loop is already very optimized.
> > >>
> > >> Please submit the AVX2 version if it helps!
> > 
> > I read the email in the wrong order.  Forget about my other email.
> > 
> > Sorry, Juan.
> > 
> 
> One thing I still can't understand, why the unit test in host environment 
> shows
> 'memcmp()' have better performance?

Are you aware of any program other than QEMU that also wants to do something
similar?  Finding whether a block of memory is zero, sounds like something
that would be useful in lots of places, I just can't think which ones.

Dave

> 
> Liang
> > 
> > >
> > > Yes, the AVX2 version really helps. I have already submitted it, could
> > > you help to review it?
> > >
> > > I am curious about the original intention to add the SSE2 Intrinsics,
> > > is the same reason?
> > >
> > > I even suspect the VM may impact the 'memcmp()' performance, is it
> > possible?
> > >
> > > Liang
> > >
> > >> Paolo
> 
--
Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK



[Qemu-devel] [PATCH 3/3] qtest/ahci: use raw format when qemu-img is absent

2015-11-12 Thread John Snow
If we don't have the qemu-img tool, use the raw format
for tests and skip the high-sector LBA48 tests.

Signed-off-by: John Snow 
---
 tests/ahci-test.c | 41 -
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 6d9ac84..7a4e375 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -39,16 +39,16 @@
 #include "hw/pci/pci_ids.h"
 #include "hw/pci/pci_regs.h"
 
-/* Test-specific defines -- in MiB */
-#define TEST_IMAGE_SIZE_MB (200 * 1024)
-#define TEST_IMAGE_SECTORS ((TEST_IMAGE_SIZE_MB / AHCI_SECTOR_SIZE) \
-* 1024 * 1024)
+/* Test images sizes in MB */
+#define TEST_IMAGE_SIZE_MB_LARGE (200 * 1024)
+#define TEST_IMAGE_SIZE_MB_SMALL 64
 
 /*** Globals ***/
 static char tmp_path[] = "/tmp/qtest.XX";
 static char debug_path[] = "/tmp/qtest-blkdebug.XX";
 static bool ahci_pedantic;
 static const char *imgfmt;
+static unsigned test_image_size_mb;
 
 /*** Function Declarations ***/
 static void ahci_test_port_spec(AHCIQState *ahci, uint8_t port);
@@ -61,6 +61,11 @@ static void ahci_test_pmcap(AHCIQState *ahci, uint8_t 
offset);
 
 /*** Utilities ***/
 
+static size_t mb_to_sectors(size_t image_size_mb)
+{
+return (image_size_mb * 1024 * 1024) / AHCI_SECTOR_SIZE;
+}
+
 static void string_bswap16(uint16_t *s, size_t bytes)
 {
 g_assert_cmphex((bytes & 1), ==, 0);
@@ -901,7 +906,7 @@ static void ahci_test_max(AHCIQState *ahci)
 uint64_t nsect;
 uint8_t port;
 uint8_t cmd;
-uint64_t config_sect = TEST_IMAGE_SECTORS - 1;
+uint64_t config_sect = mb_to_sectors(test_image_size_mb) - 1;
 
 if (config_sect > 0xFF) {
 cmd = CMD_READ_MAX_EXT;
@@ -1480,7 +1485,7 @@ static uint64_t offset_sector(enum OffsetType ofst,
 return 1;
 case OFFSET_HIGH:
 ceil = (addr_type == ADDR_MODE_LBA28) ? 0xfff : 0x;
-ceil = MIN(ceil, TEST_IMAGE_SECTORS - 1);
+ceil = MIN(ceil, mb_to_sectors(test_image_size_mb) - 1);
 nsectors = buffsize / AHCI_SECTOR_SIZE;
 return ceil - nsectors + 1;
 default:
@@ -1562,8 +1567,9 @@ static void create_ahci_io_test(enum IOMode type, enum 
AddrMode addr,
 enum BuffLen len, enum OffsetType offset)
 {
 char *name;
-AHCIIOTestOptions *opts = g_malloc(sizeof(AHCIIOTestOptions));
+AHCIIOTestOptions *opts;
 
+opts = g_malloc(sizeof(AHCIIOTestOptions));
 opts->length = len;
 opts->address_type = addr;
 opts->io_type = type;
@@ -1575,6 +1581,13 @@ static void create_ahci_io_test(enum IOMode type, enum 
AddrMode addr,
buff_len_str[len],
offset_str[offset]);
 
+if ((addr == ADDR_MODE_LBA48) && (offset == OFFSET_HIGH) &&
+(mb_to_sectors(test_image_size_mb) <= 0xFFF)) {
+g_test_message("%s: skipped; test image too small", name);
+g_free(name);
+return;
+}
+
 qtest_add_data_func(name, opts, test_io_interface);
 g_free(name);
 }
@@ -1624,8 +1637,18 @@ int main(int argc, char **argv)
 /* Create a temporary image */
 fd = mkstemp(tmp_path);
 g_assert(fd >= 0);
-imgfmt = "qcow2";
-mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB);
+if (have_qemu_img()) {
+imgfmt = "qcow2";
+test_image_size_mb = TEST_IMAGE_SIZE_MB_LARGE;
+mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB_LARGE);
+} else {
+g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; "
+   "skipping LBA48 high-sector tests");
+imgfmt = "raw";
+test_image_size_mb = TEST_IMAGE_SIZE_MB_SMALL;
+ret = ftruncate(fd, test_image_size_mb * 1024 * 1024);
+g_assert(ret == 0);
+}
 close(fd);
 
 /* Create temporary blkdebug instructions */
-- 
2.4.3




[Qemu-devel] [PATCH 1/3] qtest/ahci: always specify image format

2015-11-12 Thread John Snow
Signed-off-by: John Snow 
---
 tests/ahci-test.c | 51 +--
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 59d387c..6d9ac84 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -48,6 +48,7 @@
 static char tmp_path[] = "/tmp/qtest.XX";
 static char debug_path[] = "/tmp/qtest-blkdebug.XX";
 static bool ahci_pedantic;
+static const char *imgfmt;
 
 /*** Function Declarations ***/
 static void ahci_test_port_spec(AHCIQState *ahci, uint8_t port);
@@ -170,11 +171,11 @@ static AHCIQState *ahci_boot(const char *cli, ...)
 va_end(ap);
 } else {
 cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
-",format=qcow2"
+",format=%s"
 " -M q35 "
 "-device ide-hd,drive=drive0 "
 "-global ide-hd.ver=%s";
-s = ahci_boot(cli, tmp_path, "testdisk", "version");
+s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
 }
 
 return s;
@@ -1073,12 +1074,12 @@ static void test_flush_retry(void)
 
 prepare_blkdebug_script(debug_path, "flush_to_disk");
 ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
-"format=qcow2,cache=writeback,"
+"format=%s,cache=writeback,"
 "rerror=stop,werror=stop "
 "-M q35 "
 "-device ide-hd,drive=drive0 ",
 debug_path,
-tmp_path);
+tmp_path, imgfmt);
 
 /* Issue Flush Command and wait for error */
 port = ahci_port_select(ahci);
@@ -1108,10 +1109,10 @@ static void test_migrate_sanity(void)
 const char *uri = "tcp:127.0.0.1:1234";
 
 src = ahci_boot("-m 1024 -M q35 "
-"-hda %s ", tmp_path);
+"-drive if=ide,file=%s,format=%s ", tmp_path, imgfmt);
 dst = ahci_boot("-m 1024 -M q35 "
-"-hda %s "
-"-incoming %s", tmp_path, uri);
+"-drive if=ide,file=%s,format=%s "
+"-incoming %s", tmp_path, imgfmt, uri);
 
 ahci_migrate(src, dst, uri);
 
@@ -1132,10 +1133,11 @@ static void ahci_migrate_simple(uint8_t cmd_read, 
uint8_t cmd_write)
 const char *uri = "tcp:127.0.0.1:1234";
 
 src = ahci_boot_and_enable("-m 1024 -M q35 "
-   "-hda %s ", tmp_path);
+   "-drive if=ide,format=%s,file=%s ",
+   imgfmt, tmp_path);
 dst = ahci_boot("-m 1024 -M q35 "
-"-hda %s "
-"-incoming %s", tmp_path, uri);
+"-drive if=ide,format=%s,file=%s "
+"-incoming %s", imgfmt, tmp_path, uri);
 
 set_context(src->parent);
 
@@ -1190,12 +1192,12 @@ static void ahci_halted_io_test(uint8_t cmd_read, 
uint8_t cmd_write)
 prepare_blkdebug_script(debug_path, "write_aio");
 
 ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
-"format=qcow2,cache=writeback,"
+"format=%s,cache=writeback,"
 "rerror=stop,werror=stop "
 "-M q35 "
 "-device ide-hd,drive=drive0 ",
 debug_path,
-tmp_path);
+tmp_path, imgfmt);
 
 /* Initialize and prepare */
 port = ahci_port_select(ahci);
@@ -1256,20 +1258,20 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, 
uint8_t cmd_write)
 prepare_blkdebug_script(debug_path, "write_aio");
 
 src = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
-   "format=qcow2,cache=writeback,"
+   "format=%s,cache=writeback,"
"rerror=stop,werror=stop "
"-M q35 "
"-device ide-hd,drive=drive0 ",
debug_path,
-   tmp_path);
+   tmp_path, imgfmt);
 
 dst = ahci_boot("-drive file=%s,if=none,id=drive0,"
-"format=qcow2,cache=writeback,"
+"format=%s,cache=writeback,"
 "rerror=stop,werror=stop "
 "-M q35 "
 "-device ide-hd,drive=drive0 "
 "-incoming %s",
-tmp_path, uri);
+tmp_path, imgfmt, uri);
 
 set_context(src->parent);
 
@@ -1327,15 +1329,17 @@ static void test_flush_migrate(void)
 prepare_blkdebug_script(debug_path, "flush_to_disk");
 
 src = ahci_boot_and_enable("-drive file=bl

[Qemu-devel] [PATCH 0/3] qtest/ahci: skip qcow2 tests

2015-11-12 Thread John Snow
Skip tests that need qcow2 to function when qemu-img isn't
set or otherwise present.

When running under raw mode, we no longer properly test
LBA48 reads/writes beyond 137Gb. ahci-test will skip past
any //io//lba48//high test.

While we're at it, try to make failures due to missing qemu-img
binaries a little more apparent in case we find a way to bump
into them again.

John Snow (3):
  qtest/ahci: always specify image format
  libqos: add qemu-img presence check
  qtest/ahci: use raw format when qemu-img is absent

 tests/ahci-test.c | 90 ++-
 tests/libqos/libqos.c | 28 +---
 tests/libqos/libqos.h |  1 +
 3 files changed, 84 insertions(+), 35 deletions(-)

-- 
2.4.3




[Qemu-devel] [PATCH 2/3] libqos: add qemu-img presence check

2015-11-12 Thread John Snow
To allow tests to optionally exercise additional tests
that require the qemu-img tool that may not be present
in all builds.

Signed-off-by: John Snow 
---
 tests/libqos/libqos.c | 28 +++-
 tests/libqos/libqos.h |  1 +
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/tests/libqos/libqos.c b/tests/libqos/libqos.c
index 8d7c5a9..2d1a802 100644
--- a/tests/libqos/libqos.c
+++ b/tests/libqos/libqos.c
@@ -147,6 +147,23 @@ void migrate(QOSState *from, QOSState *to, const char *uri)
 set_context(to);
 }
 
+bool have_qemu_img(void)
+{
+char *rpath;
+const char *path = getenv("QTEST_QEMU_IMG");
+if (!path) {
+return false;
+}
+
+rpath = realpath(path, NULL);
+if (!rpath) {
+return false;
+} else {
+free(rpath);
+return true;
+}
+}
+
 void mkimg(const char *file, const char *fmt, unsigned size_mb)
 {
 gchar *cli;
@@ -155,13 +172,14 @@ void mkimg(const char *file, const char *fmt, unsigned 
size_mb)
 GError *err = NULL;
 char *qemu_img_path;
 gchar *out, *out2;
-char *abs_path;
+char *qemu_img_abs_path;
 
 qemu_img_path = getenv("QTEST_QEMU_IMG");
-abs_path = realpath(qemu_img_path, NULL);
-assert(qemu_img_path);
+g_assert(qemu_img_path);
+qemu_img_abs_path = realpath(qemu_img_path, NULL);
+g_assert(qemu_img_abs_path);
 
-cli = g_strdup_printf("%s create -f %s %s %uM", abs_path,
+cli = g_strdup_printf("%s create -f %s %s %uM", qemu_img_abs_path,
   fmt, file, size_mb);
 ret = g_spawn_command_line_sync(cli, &out, &out2, &rc, &err);
 if (err) {
@@ -183,7 +201,7 @@ void mkimg(const char *file, const char *fmt, unsigned 
size_mb)
 g_free(out);
 g_free(out2);
 g_free(cli);
-free(abs_path);
+free(qemu_img_abs_path);
 }
 
 void mkqcow2(const char *file, unsigned size_mb)
diff --git a/tests/libqos/libqos.h b/tests/libqos/libqos.h
index 492a651..ca14d2e 100644
--- a/tests/libqos/libqos.h
+++ b/tests/libqos/libqos.h
@@ -19,6 +19,7 @@ typedef struct QOSState {
 QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap);
 QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);
 void qtest_shutdown(QOSState *qs);
+bool have_qemu_img(void);
 void mkimg(const char *file, const char *fmt, unsigned size_mb);
 void mkqcow2(const char *file, unsigned size_mb);
 void set_context(QOSState *s);
-- 
2.4.3




Re: [Qemu-devel] [PATCH 09/12] vl: Replace DT_NOGRAPHIC with MachineState field

2015-11-12 Thread Eduardo Habkost
On Thu, Nov 12, 2015 at 10:48:12AM +0100, Paolo Bonzini wrote:
> 
> 
> On 11/11/2015 20:09, Eduardo Habkost wrote:
> > All DisplayType values are just UI options that don't affect any
> > hardware emulation code, except for DT_NOGRAPHIC. Replace
> > DT_NOGRAPHIC with DT_NONE plus a new MachineState.nographic
> > field, so hardware emulation code don't need to use the
> > display_type variable.
> > 
> > Cc: Michael Walle 
> > Cc: Blue Swirl 
> > Cc: Mark Cave-Ayland 
> > Signed-off-by: Eduardo Habkost 
> 
> Can you add a QOM property too, so that "-machine graphics=yes|no" can
> be used?

I can, but I would like to clarify the expected semantics. With
the -machine option, we would have:

* -display, which affects only the display UI.
* -nographic, which affects:
  * The display UI;
  * Hardware emulation;
  * serial/paralllel/virtioconsole output redirection.
* -machine graphics=no, which would affect only hardware
  emulation.

Is that correct?

-- 
Eduardo



[Qemu-devel] [PATCH for-2.5 v5 1/1] hw/misc: Add support for ADC controller in Xilinx Zynq 7000

2015-11-12 Thread Peter Crosthwaite
From: Guenter Roeck 

Add support for the Xilinx XADC core used in Zynq 7000.

References:
- Zynq-7000 All Programmable SoC Technical Reference Manual
- 7 Series FPGAs and Zynq-7000 All Programmable SoC XADC
  Dual 12-Bit 1 MSPS Analog-to-Digital Converter

Tested with Linux using QEMU machine xilinx-zynq-a9 with devicetree
files zynq-zc702.dtb and zynq-zc706.dtb, and kernel configuration
multi_v7_defconfig.

Reviewed-by: Alistair Francis 
Signed-off-by: Guenter Roeck 
[ PC changes:
  * Changed macro names to match TRM where possible
  * Made programmers model macro scheme consistent
  * Dropped XADC_ZYNQ_ prefix on local macros
  * Fix ALM field width
  * Update threshold-comparison interrupts in _update_ints()
  * factored out DFIFO pushes into helper. Renamed to "push/pop"
  * Changed xadc_reg to 10 bits and added OOB check.
  * Reduced scope of MCTL reset to just stop channel coms.
  * Added dummy read data to write commands
  * Changed _ to - seperators in string names and filenames
  * Dropped  in header comment
  * Catchall'ed _update_ints() in _write handler.
  * Minor whitespace changes.
  * Use ZYNQ_XADC_FIFO_DEPTH instead of ARRAY_SIZE()
]
Signed-off-by: Peter Crosthwaite 
---
v5:
Fix compile warning
v4:
Addressed Alistair review
Minor whitespace changes
Use ZYNQ_XADC_FIFO_DEPTH instead of ARRAY_SIZE()
v3:
See [PC changes] in commit message
v2:
Use extract32()
Merge zynq_xadc_reset() and _zynq_xadc_reset() into one function
Use "xlnx,zynq_xadc"
Move device model to include/hw/misc/zynq_xadc.h
irq -> qemu_irq
xadc_dfifo_depth -> xadc_dfifo_entries
Dropped unnecessary comments
Merged zynq_xadc_realize() into zynq_xadc_init()

 hw/arm/xilinx_zynq.c|   6 +
 hw/misc/Makefile.objs   |   1 +
 hw/misc/zynq-xadc.c | 302 
 include/hw/misc/zynq-xadc.h |  46 +++
 4 files changed, 355 insertions(+)
 create mode 100644 hw/misc/zynq-xadc.c
 create mode 100644 include/hw/misc/zynq-xadc.h

diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c
index 82a9db8..1c1a445 100644
--- a/hw/arm/xilinx_zynq.c
+++ b/hw/arm/xilinx_zynq.c
@@ -24,6 +24,7 @@
 #include "hw/block/flash.h"
 #include "sysemu/block-backend.h"
 #include "hw/loader.h"
+#include "hw/misc/zynq-xadc.h"
 #include "hw/ssi.h"
 #include "qemu/error-report.h"
 
@@ -264,6 +265,11 @@ static void zynq_init(MachineState *machine)
 sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xE0101000);
 sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[79-IRQ_OFFSET]);
 
+dev = qdev_create(NULL, TYPE_ZYNQ_XADC);
+qdev_init_nofail(dev);
+sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, 0xF8007100);
+sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[39-IRQ_OFFSET]);
+
 dev = qdev_create(NULL, "pl330");
 qdev_prop_set_uint8(dev, "num_chnls",  8);
 qdev_prop_set_uint8(dev, "num_periph_req",  4);
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index 4aa76ff..aeb6b7d 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -36,6 +36,7 @@ obj-$(CONFIG_OMAP) += omap_sdrc.o
 obj-$(CONFIG_OMAP) += omap_tap.o
 obj-$(CONFIG_SLAVIO) += slavio_misc.o
 obj-$(CONFIG_ZYNQ) += zynq_slcr.o
+obj-$(CONFIG_ZYNQ) += zynq-xadc.o
 obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o
 
 obj-$(CONFIG_PVPANIC) += pvpanic.o
diff --git a/hw/misc/zynq-xadc.c b/hw/misc/zynq-xadc.c
new file mode 100644
index 000..1a32595
--- /dev/null
+++ b/hw/misc/zynq-xadc.c
@@ -0,0 +1,302 @@
+/*
+ * ADC registers for Xilinx Zynq Platform
+ *
+ * Copyright (c) 2015 Guenter Roeck
+ * Based on hw/misc/zynq_slcr.c, written by Michal Simek
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see .
+ */
+
+#include "hw/hw.h"
+#include "hw/misc/zynq-xadc.h"
+#include "qemu/timer.h"
+#include "sysemu/sysemu.h"
+
+enum {
+CFG= 0x000 / 4,
+INT_STS,
+INT_MASK,
+MSTS,
+CMDFIFO,
+RDFIFO,
+MCTL,
+};
+
+#define CFG_ENABLE  BIT(31)
+#define CFG_CFIFOTH_SHIFT   20
+#define CFG_CFIFOTH_LENGTH  4
+#define CFG_DFIFOTH_SHIFT   16
+#define CFG_DFIFOTH_LENGTH  4
+#define CFG_WEDGE   BIT(13)
+#define CFG_REDGE   BIT(12)
+#define CFG_TCKRATE_SHIFT   8
+#define CFG_TCKRATE_LENGTH  2
+
+#define CFG_TCKRATE_DIV(x)  (0x1 << (x - 1))
+
+#define CFG_IGAP_SHIFT  0
+#define CFG_IGAP_LENGTH 5
+
+#define INT_CFIFO_LTH   BIT(9)
+#define INT_DFIFO_GTH   BIT(8)
+#define INT_OT  BIT(7)
+#define INT_ALM_SHIFT   0
+#define INT_ALM_LENGTH  7
+#define INT_ALM_MASK(((1 << I

Re: [Qemu-devel] [PATCH for-2.5 v5 1/1] hw/misc: Add support for ADC controller in Xilinx Zynq 7000

2015-11-12 Thread Guenter Roeck
On Thu, Nov 12, 2015 at 09:54:55AM -0800, Peter Crosthwaite wrote:
> From: Guenter Roeck 
> 
> Add support for the Xilinx XADC core used in Zynq 7000.
> 
> References:
> - Zynq-7000 All Programmable SoC Technical Reference Manual
> - 7 Series FPGAs and Zynq-7000 All Programmable SoC XADC
>   Dual 12-Bit 1 MSPS Analog-to-Digital Converter
> 
> Tested with Linux using QEMU machine xilinx-zynq-a9 with devicetree
> files zynq-zc702.dtb and zynq-zc706.dtb, and kernel configuration
> multi_v7_defconfig.
> 
> Reviewed-by: Alistair Francis 
> Signed-off-by: Guenter Roeck 
> [ PC changes:
>   * Changed macro names to match TRM where possible
>   * Made programmers model macro scheme consistent
>   * Dropped XADC_ZYNQ_ prefix on local macros
>   * Fix ALM field width
>   * Update threshold-comparison interrupts in _update_ints()
>   * factored out DFIFO pushes into helper. Renamed to "push/pop"
>   * Changed xadc_reg to 10 bits and added OOB check.
>   * Reduced scope of MCTL reset to just stop channel coms.
>   * Added dummy read data to write commands
>   * Changed _ to - seperators in string names and filenames
>   * Dropped  in header comment
>   * Catchall'ed _update_ints() in _write handler.
>   * Minor whitespace changes.
>   * Use ZYNQ_XADC_FIFO_DEPTH instead of ARRAY_SIZE()
> ]
> Signed-off-by: Peter Crosthwaite 

For v5 (same configuration as above):

Tested-by: Guenter Roeck 



[Qemu-devel] [PATCH v4 03/17] ipmi: Add a local BMC simulation

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 default-configs/i386-softmmu.mak   |1 +
 default-configs/x86_64-softmmu.mak |1 +
 hw/ipmi/Makefile.objs  |1 +
 hw/ipmi/ipmi_bmc_sim.c | 1731 
 4 files changed, 1734 insertions(+)
 create mode 100644 hw/ipmi/ipmi_bmc_sim.c

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 8fa751a..00a0346 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y
 CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_IPMI_LOCAL=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 6767f4f..39a619f 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -10,6 +10,7 @@ CONFIG_VMWARE_VGA=y
 CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
+CONFIG_IPMI_LOCAL=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
index 65bde11..875271c 100644
--- a/hw/ipmi/Makefile.objs
+++ b/hw/ipmi/Makefile.objs
@@ -1 +1,2 @@
 common-obj-$(CONFIG_IPMI) += ipmi.o
+common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
new file mode 100644
index 000..d246029
--- /dev/null
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -0,0 +1,1731 @@
+/*
+ * IPMI BMC emulation
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include "qemu/timer.h"
+#include "hw/ipmi/ipmi.h"
+#include "qemu/error-report.h"
+
+#define IPMI_NETFN_CHASSIS0x00
+#define IPMI_NETFN_CHASSIS_MAXCMD 0x03
+
+#define IPMI_CMD_GET_CHASSIS_CAPABILITIES 0x00
+#define IPMI_CMD_GET_CHASSIS_STATUS   0x01
+#define IPMI_CMD_CHASSIS_CONTROL  0x02
+
+#define IPMI_NETFN_SENSOR_EVENT   0x04
+#define IPMI_NETFN_SENSOR_EVENT_MAXCMD0x2e
+
+#define IPMI_CMD_SET_SENSOR_EVT_ENABLE0x28
+#define IPMI_CMD_GET_SENSOR_EVT_ENABLE0x29
+#define IPMI_CMD_REARM_SENSOR_EVTS0x2a
+#define IPMI_CMD_GET_SENSOR_EVT_STATUS0x2b
+#define IPMI_CMD_GET_SENSOR_READING   0x2d
+
+/* #define IPMI_NETFN_APP 0x06 In ipmi.h */
+#define IPMI_NETFN_APP_MAXCMD 0x36
+
+#define IPMI_CMD_GET_DEVICE_ID0x01
+#define IPMI_CMD_COLD_RESET   0x02
+#define IPMI_CMD_WARM_RESET   0x03
+#define IPMI_CMD_RESET_WATCHDOG_TIMER 0x22
+#define IPMI_CMD_SET_WATCHDOG_TIMER   0x24
+#define IPMI_CMD_GET_WATCHDOG_TIMER   0x25
+#define IPMI_CMD_SET_BMC_GLOBAL_ENABLES   0x2e
+#define IPMI_CMD_GET_BMC_GLOBAL_ENABLES   0x2f
+#define IPMI_CMD_CLR_MSG_FLAGS0x30
+#define IPMI_CMD_GET_MSG_FLAGS0x31
+#define IPMI_CMD_GET_MSG  0x33
+#define IPMI_CMD_SEND_MSG 0x34
+#define IPMI_CMD_READ_EVT_MSG_BUF 0x35
+
+#define IPMI_NETFN_STORAGE0x0a
+#define IPMI_NETFN_STORAGE_MAXCMD 0x4a
+
+#define IPMI_CMD_GET_SDR_REP_INFO 0x20
+#define IPMI_CMD_GET_SDR_REP_ALLOC_INFO   0x21
+#define IPMI_CMD_RESERVE_SDR_REP  0x22
+#define IPMI_CMD_GET_SDR  0x23
+#define IPMI_CMD_ADD_SDR  0x24
+#define IPMI_CMD_PARTIAL_ADD_SDR  0x25
+#define IPMI_CMD_DELETE_SDR   0x26
+#define IPMI_CMD_CLEAR_SDR_REP0x27
+#define IPMI_CMD_GET_SDR_REP_TIME 0x28
+#define IPMI_CMD_SET_SDR_REP_TIME 0x29
+#define IPMI_CMD_ENTER_SDR_REP_UPD_MODE   0x2A
+#define IPMI_CMD_EXIT_SDR_REP_UPD_MODE0x2B
+#define IPMI_CMD_RUN_INIT_AGENT   0x2C
+#define IPMI_CMD_GET

[Qemu-devel] [PATCH v3] tests/vhost-user-bridge: implement logging of dirty pages

2015-11-12 Thread Victor Kaplansky
During migration devices continue writing to the guest's memory.
The writes has to be reported to QEMU. This change implements
minimal support in vhost-user-bridge required for successful
migration of a guest with virtio-net device.

Signed-off-by: Victor Kaplansky 
---
v3:
- Get rid of vhost_log_chunk_t. Just use uint8_t.
- Implement vubr_set_log_fd_exec().
- Kick the log if log_call_fd has been set up.
- Mark bits in log table atomically to enable more then one
  simultaneous vhost-user backend.
- Fix the calculations of required log table size in an
  assert.
- Fix the coding style: only single space before assignment
  operator.
- Add a comment on the hack to determine that queues are
  ready for processing.
- Other minor cosmetic fixes.
v2:
- use log_guest_addr for used ring reported by qemu instead of
  translating.
- use mmap_size and mmap_offset defined in new
  VHOST_USER_SET_LOG_BASE interface. See the patch
  "vhost-user: modify SET_LOG_BASE to pass mmap size and
  offset".
- start logging dirty pages only after the appropriate feature
  is set by a VHOST_USER_GET_PROTOCOL_FEATURES request.
- updated TODO list.

 tests/vhost-user-bridge.c | 205 --
 1 file changed, 181 insertions(+), 24 deletions(-)

diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index fa18ad5..65aca0b 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -13,16 +13,22 @@
 /*
  * TODO:
  * - main should get parameters from the command line.
- * - implement all request handlers.
+ * - implement all request handlers. Still not implemented:
+ *  vubr_set_protocol_features_exec()
+ *  vubr_get_queue_num_exec()
+ *  vubr_set_vring_enable_exec()
+ *  vubr_send_rarp_exec()
+ *  vubr_set_log_fd_exec()
  * - test for broken requests and virtqueue.
  * - implement features defined by Virtio 1.0 spec.
  * - support mergeable buffers and indirect descriptors.
- * - implement RESET_DEVICE request.
  * - implement clean shutdown.
  * - implement non-blocking writes to UDP backend.
  * - implement polling strategy.
  */
 
+#define _FILE_OFFSET_BITS 64
+
 #include 
 #include 
 #include 
@@ -166,6 +172,7 @@ typedef struct VubrVirtq {
 struct vring_desc *desc;
 struct vring_avail *avail;
 struct vring_used *used;
+uint64_t log_guest_addr;
 } VubrVirtq;
 
 /* Based on qemu/hw/virtio/vhost-user.c */
@@ -173,6 +180,8 @@ typedef struct VubrVirtq {
 #define VHOST_MEMORY_MAX_NREGIONS8
 #define VHOST_USER_F_PROTOCOL_FEATURES 30
 
+#define VHOST_LOG_PAGE 4096
+
 enum VhostUserProtocolFeature {
 VHOST_USER_PROTOCOL_F_MQ = 0,
 VHOST_USER_PROTOCOL_F_LOG_SHMFD = 1,
@@ -220,6 +229,11 @@ typedef struct VhostUserMemory {
 VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
 } VhostUserMemory;
 
+typedef struct VhostUserLog {
+uint64_t mmap_size;
+uint64_t mmap_offset;
+} VhostUserLog;
+
 typedef struct VhostUserMsg {
 VhostUserRequest request;
 
@@ -234,6 +248,7 @@ typedef struct VhostUserMsg {
 struct vhost_vring_state state;
 struct vhost_vring_addr addr;
 VhostUserMemory memory;
+VhostUserLog log;
 } payload;
 int fds[VHOST_MEMORY_MAX_NREGIONS];
 int fd_num;
@@ -265,8 +280,13 @@ typedef struct VubrDev {
 uint32_t nregions;
 VubrDevRegion regions[VHOST_MEMORY_MAX_NREGIONS];
 VubrVirtq vq[MAX_NR_VIRTQUEUE];
+int log_call_fd;
+uint64_t log_size;
+uint8_t *log_table;
 int backend_udp_sock;
 struct sockaddr_in backend_udp_dest;
+int ready;
+uint64_t features;
 } VubrDev;
 
 static const char *vubr_request_str[] = {
@@ -368,7 +388,12 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
 
 rc = recvmsg(conn_fd, &msg, 0);
 
-if (rc <= 0) {
+if (rc == 0) {
+vubr_die("recvmsg");
+fprintf(stderr, "Peer disconnected.\n");
+exit(1);
+}
+if (rc < 0) {
 vubr_die("recvmsg");
 }
 
@@ -395,7 +420,12 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
 
 if (vmsg->size) {
 rc = read(conn_fd, &vmsg->payload, vmsg->size);
-if (rc <= 0) {
+if (rc == 0) {
+vubr_die("recvmsg");
+fprintf(stderr, "Peer disconnected.\n");
+exit(1);
+}
+if (rc < 0) {
 vubr_die("recvmsg");
 }
 
@@ -455,6 +485,16 @@ vubr_consume_raw_packet(VubrDev *dev, uint8_t *buf, 
uint32_t len)
 vubr_backend_udp_sendbuf(dev, buf + hdrlen, len - hdrlen);
 }
 
+/* Kick the log_call_fd if required. */
+static void
+vubr_log_kick(VubrDev *dev)
+{
+if (dev->log_call_fd != -1) {
+DPRINT("Kicking the QEMU's log...\n");
+eventfd_write(dev->log_call_fd, 1);
+}
+}
+
 /* Kick the guest if necessary. */
 static void
 vubr_virtqueue_kick(VubrVirtq *vq)
@@ -466,11 +506,38 @

[Qemu-devel] [PATCH v4 14/17] ipmi: Add SMBIOS table entry

2015-11-12 Thread minyard
From: Corey Minyard 

Add an IPMI table entry to the SMBIOS.

Signed-off-by: Corey Minyard 
Acked-by: Michael S. Tsirkin 
---
 default-configs/i386-softmmu.mak   |  1 +
 default-configs/x86_64-softmmu.mak |  1 +
 hw/smbios/Makefile.objs|  2 +
 hw/smbios/ipmi.c   | 75 ++
 hw/smbios/noipmi.c | 14 +++
 hw/smbios/smbios.c |  2 +
 include/hw/smbios/ipmi.h   | 15 
 7 files changed, 110 insertions(+)
 create mode 100644 hw/smbios/ipmi.c
 create mode 100644 hw/smbios/noipmi.c
 create mode 100644 include/hw/smbios/ipmi.h

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 1730fbb..b73bf3a 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 22a99a2..baf07cc 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -20,6 +20,7 @@ CONFIG_I8254=y
 CONFIG_PCSPK=y
 CONFIG_PCKBD=y
 CONFIG_FDC=y
+CONFIG_SMBIOS=y
 CONFIG_ACPI=y
 CONFIG_ACPI_X86=y
 CONFIG_ACPI_X86_ICH=y
diff --git a/hw/smbios/Makefile.objs b/hw/smbios/Makefile.objs
index f69a92f..5578f51 100644
--- a/hw/smbios/Makefile.objs
+++ b/hw/smbios/Makefile.objs
@@ -1 +1,3 @@
 common-obj-$(CONFIG_SMBIOS) += smbios.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_SMBIOS),$(call lnot,$(CONFIG_IPMI))) += 
noipmi.o
diff --git a/hw/smbios/ipmi.c b/hw/smbios/ipmi.c
new file mode 100644
index 000..9c0ce3c
--- /dev/null
+++ b/hw/smbios/ipmi.c
@@ -0,0 +1,75 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/ipmi/ipmi.h"
+#include "hw/smbios/ipmi.h"
+#include "hw/smbios/smbios.h"
+#include "qemu/error-report.h"
+#include "smbios_build.h"
+
+/* SMBIOS type 38 - IPMI */
+struct smbios_type_38 {
+struct smbios_structure_header header;
+uint8_t interface_type;
+uint8_t ipmi_spec_revision;
+uint8_t i2c_slave_address;
+uint8_t nv_storage_device_address;
+uint64_t base_address;
+uint8_t base_address_modifier;
+uint8_t interrupt_number;
+} QEMU_PACKED;
+
+static void ipmi_encode_one_smbios(IPMIFwInfo *info)
+{
+uint64_t baseaddr = info->base_address;
+SMBIOS_BUILD_TABLE_PRE(38, 0x3000, true);
+
+t->interface_type = info->interface_type;
+t->ipmi_spec_revision = ((info->ipmi_spec_major_revision << 4)
+ | info->ipmi_spec_minor_revision);
+t->i2c_slave_address = info->i2c_slave_address;
+t->nv_storage_device_address = 0;
+
+/* or 1 to set it to I/O space */
+switch (info->memspace) {
+case IPMI_MEMSPACE_IO: baseaddr |= 1; break;
+case IPMI_MEMSPACE_MEM32: break;
+case IPMI_MEMSPACE_MEM64: break;
+case IPMI_MEMSPACE_SMBUS: baseaddr <<= 1; break;
+}
+
+t->base_address = cpu_to_le64(baseaddr);
+
+t->base_address_modifier = 0;
+if (info->irq_type == IPMI_LEVEL_IRQ) {
+t->base_address_modifier |= 1;
+}
+switch (info->register_spacing) {
+case 1: break;
+case 4: t->base_address_modifier |= 1 << 6; break;
+case 16: t->base_address_modifier |= 2 << 6; break;
+default:
+error_report("IPMI register spacing %d is not compatible with"
+ " SMBIOS, ignoring this entry.", info->register_spacing);
+return;
+}
+t->interrupt_number = info->interrupt_number;
+
+SMBIOS_BUILD_TABLE_POST;
+}
+
+void smbios_build_type_38_table(void)
+{
+IPMIFwInfo *info = ipmi_first_fwinfo();
+
+while (info) {
+ipmi_encode_one_smbios(info);
+info = ipmi_next_fwinfo(info);
+}
+}
diff --git a/hw/smbios/noipmi.c b/hw/smbios/noipmi.c
new file mode 100644
index 000..ad669a4
--- /dev/null
+++ b/hw/smbios/noipmi.c
@@ -0,0 +1,14 @@
+/*
+ * IPMI SMBIOS firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/smbios/ipmi.h"
+
+void smbios_build_type_38_table(void)
+{
+}
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index fe553f9..ebfb077 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -23,6 +23,7 @@
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
 #include "smbios_build.h"
+#include "hw/smbios/ipmi.h"
 
 /* legacy structures and constants for <= 2.0 machines */
 struct smbios_header {
@@ -846,6 +847,7 @@ void smbios_get_tables(const struct smbios_phys_mem_area 
*mem_array,
   

[Qemu-devel] [PATCH v4 17/17] ipmi: Add a force off function

2015-11-12 Thread minyard
From: Corey Minyard 

Allow the IPMI interface to request a forced power off.

Signed-off-by: Corey Minyard 
---
 hw/ipmi/ipmi_bmc_extern.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 05b9121..7ae6294 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -52,6 +52,7 @@
 #define   VM_CAPABILITIES_IRQ  0x04
 #define   VM_CAPABILITIES_NMI  0x08
 #define   VM_CAPABILITIES_ATTN 0x10
+#define VM_CMD_FORCEOFF0x09
 
 #define TYPE_IPMI_BMC_EXTERN "ipmi-bmc-extern"
 #define IPMI_BMC_EXTERN(obj) OBJECT_CHECK(IPMIBmcExtern, (obj), \
@@ -268,6 +269,10 @@ static void handle_hw_op(IPMIBmcExtern *ibe, unsigned char 
hw_op)
 case VM_CMD_SEND_NMI:
 k->do_hw_op(s, IPMI_SEND_NMI, 0);
 break;
+
+case VM_CMD_FORCEOFF:
+exit(0);
+break;
 }
 }
 
-- 
1.8.3.1




[Qemu-devel] [PATCH v4 08/17] ipmi: Add documentation

2015-11-12 Thread minyard
From: Corey Minyard 

Add some basic documentation for the IPMI device.

Signed-off-by: Corey Minyard 
---
 qemu-options.hx | 52 
 1 file changed, 52 insertions(+)

diff --git a/qemu-options.hx b/qemu-options.hx
index 0eea4ee..985d2ab 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -381,6 +381,58 @@ Add device @var{driver}.  @var{prop}=@var{value} sets 
driver
 properties.  Valid properties depend on the driver.  To get help on
 possible drivers and properties, use @code{-device help} and
 @code{-device @var{driver},help}.
+
+Some drivers are:
+@item -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}]
+
+Add an IPMI BMC.  This is a simulation of a hardware management
+interface processor that normally sits on a system.  It provides
+a watchdog and the ability to reset and power control the system.
+You need to connect this to an IPMI interface to make it useful
+
+The IPMI slave address to use for the BMC.  The default is 0x20.
+This address is the BMC's address on the I2C network of management
+controllers.  If you don't know what this means, it is safe to ignore
+it.
+
+@item -device 
ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}]
+
+Add a connection to an external IPMI BMC simulator.  Instead of
+locally emulating the BMC like the above item, instead connect
+to an external entity that provides the IPMI services.
+
+A connection is made to an external BMC simulator.  If you do this, it
+is strongly recommended that you use the "reconnect=" chardev option
+to reconnect to the simulator if the connection is lost.  Note that if
+this is not used carefully, it can be a security issue, as the
+interface has the ability to send resets, NMIs, and power off the VM.
+It's best if QEMU makes a connection to an external simulator running
+on a secure port on localhost, so neither the simulator nor QEMU is
+exposed to any outside network.
+
+See the "lanserv/README.vm" file in the OpenIPMI library for more
+details on the external interface.
+
+@item -device isa-ipmi-kcs,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]
+
+Add a KCS IPMI interafce on the ISA bus.  This also adds a
+corresponding ACPI and SMBIOS entries, if appropriate.
+
+@table @option
+@item bmc=@var{id}
+The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
+@item ioport=@var{val}
+Define the I/O address of the interface.  The default is 0xca0 for KCS.
+@item irq=@var{val}
+Define the interrupt to use.  The default is 5.  To disable interrupts,
+set this to 0.
+@end table
+
+@item -device isa-ipmi-bt,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]
+
+Like the KCS interface, but defines a BT interface.  The default port is
+0xe4 and the default interrupt is 5.
+
 ETEXI
 
 DEF("name", HAS_ARG, QEMU_OPTION_name,
-- 
1.8.3.1




[Qemu-devel] [PATCH v4 05/17] ipmi: Add an ISA KCS low-level interface

2015-11-12 Thread minyard
From: Corey Minyard 

This provides the simulation of the KCS hardware interface.

Signed-off-by: Corey Minyard 
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/ipmi/Makefile.objs  |   1 +
 hw/ipmi/isa_ipmi_kcs.c | 452 +
 4 files changed, 455 insertions(+)
 create mode 100644 hw/ipmi/isa_ipmi_kcs.c

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 077b3c4..1c24aab 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -12,6 +12,7 @@ CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
+CONFIG_ISA_IPMI_KCS=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 81b0cb0..9d1f934 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -12,6 +12,7 @@ CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
+CONFIG_ISA_IPMI_KCS=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
index ddb15ec..28618c5 100644
--- a/hw/ipmi/Makefile.objs
+++ b/hw/ipmi/Makefile.objs
@@ -1,3 +1,4 @@
 common-obj-$(CONFIG_IPMI) += ipmi.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
+common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
new file mode 100644
index 000..750a725
--- /dev/null
+++ b/hw/ipmi/isa_ipmi_kcs.c
@@ -0,0 +1,452 @@
+/*
+ * QEMU ISA IPMI KCS emulation
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw/hw.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/isa/isa.h"
+#include "hw/i386/pc.h"
+
+#define IPMI_KCS_OBF_BIT0
+#define IPMI_KCS_IBF_BIT1
+#define IPMI_KCS_SMS_ATN_BIT2
+#define IPMI_KCS_CD_BIT 3
+
+#define IPMI_KCS_OBF_MASK  (1 << IPMI_KCS_OBF_BIT)
+#define IPMI_KCS_GET_OBF(d)(((d) >> IPMI_KCS_OBF_BIT) & 0x1)
+#define IPMI_KCS_SET_OBF(d, v) (d) = (((d) & ~IPMI_KCS_OBF_MASK) | \
+   (((v) & 1) << IPMI_KCS_OBF_BIT))
+#define IPMI_KCS_IBF_MASK  (1 << IPMI_KCS_IBF_BIT)
+#define IPMI_KCS_GET_IBF(d)(((d) >> IPMI_KCS_IBF_BIT) & 0x1)
+#define IPMI_KCS_SET_IBF(d, v) (d) = (((d) & ~IPMI_KCS_IBF_MASK) | \
+   (((v) & 1) << IPMI_KCS_IBF_BIT))
+#define IPMI_KCS_SMS_ATN_MASK  (1 << IPMI_KCS_SMS_ATN_BIT)
+#define IPMI_KCS_GET_SMS_ATN(d)(((d) >> IPMI_KCS_SMS_ATN_BIT) & 0x1)
+#define IPMI_KCS_SET_SMS_ATN(d, v) (d) = (((d) & ~IPMI_KCS_SMS_ATN_MASK) | \
+   (((v) & 1) << IPMI_KCS_SMS_ATN_BIT))
+#define IPMI_KCS_CD_MASK   (1 << IPMI_KCS_CD_BIT)
+#define IPMI_KCS_GET_CD(d) (((d) >> IPMI_KCS_CD_BIT) & 0x1)
+#define IPMI_KCS_SET_CD(d, v)  (d) = (((d) & ~IPMI_KCS_CD_MASK) | \
+   (((v) & 1) << IPMI_KCS_CD_BIT))
+
+#define IPMI_KCS_IDLE_STATE0
+#define IPMI_KCS_READ_STATE1
+#define IPMI_KCS_WRITE_STATE   2
+#define IPMI_KCS_ERROR_STATE   3
+
+#define IPMI_KCS_GET_STATE(d)(((d) >> 6) & 0x3)
+#define IPMI_KCS_SET_STATE(d, v) ((d) = ((d) & ~0xc0) | (((v) & 0x3) << 6))
+
+#define IPMI_KCS_ABORT_STATUS_CMD   0x60
+#define IPMI_KCS_WRITE_START_CMD0x61
+#define IPMI_KCS_WRITE_END_CMD  0x62
+#define IPMI_KCS_READ_CMD   0x68
+
+#define IPMI_KCS_STATUS_NO_ERR  0x00
+#define IPMI_KCS_STATUS_ABORTED_ERR 0x01
+#define IPMI_KCS_STATUS_BAD_CC_ERR  0x02
+#define IPMI_KCS_STATUS_LENGTH_ERR  0x06
+
+typedef struct IPMIKCS {
+IPMIBmc *bmc;
+
+bool do_wake;
+
+qemu_irq irq;
+
+uint32_t io_base;
+unsi

[Qemu-devel] [PATCH v4 12/17] smbios: Move table build tools into an include file.

2015-11-12 Thread minyard
From: Corey Minyard 

This will let things in other files (like IPMI) build SMBIOS tables.

Signed-off-by: Corey Minyard 
---
 hw/smbios/smbios.c   | 70 ---
 hw/smbios/smbios_build.h | 77 
 2 files changed, 83 insertions(+), 64 deletions(-)
 create mode 100644 hw/smbios/smbios_build.h

diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b81a1d3..fe553f9 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -22,6 +22,7 @@
 #include "hw/smbios/smbios.h"
 #include "hw/loader.h"
 #include "exec/cpu-common.h"
+#include "smbios_build.h"
 
 /* legacy structures and constants for <= 2.0 machines */
 struct smbios_header {
@@ -51,10 +52,10 @@ static bool smbios_uuid_encoded = true;
 /* end: legacy structures & constants for <= 2.0 machines */
 
 
-static uint8_t *smbios_tables;
-static size_t smbios_tables_len;
-static unsigned smbios_table_max;
-static unsigned smbios_table_cnt;
+uint8_t *smbios_tables;
+size_t smbios_tables_len;
+unsigned smbios_table_max;
+unsigned smbios_table_cnt;
 static SmbiosEntryPointType smbios_ep_type = SMBIOS_ENTRY_POINT_21;
 
 static SmbiosEntryPoint ep;
@@ -427,7 +428,7 @@ uint8_t *smbios_get_table_legacy(size_t *length)
 /* end: legacy setup functions for <= 2.0 machines */
 
 
-static bool smbios_skip_table(uint8_t type, bool required_table)
+bool smbios_skip_table(uint8_t type, bool required_table)
 {
 if (test_bit(type, have_binfile_bitmap)) {
 return true; /* user provided their own binary blob(s) */
@@ -441,65 +442,6 @@ static bool smbios_skip_table(uint8_t type, bool 
required_table)
 return true;
 }
 
-#define SMBIOS_BUILD_TABLE_PRE(tbl_type, tbl_handle, tbl_required)\
-struct smbios_type_##tbl_type *t; \
-size_t t_off; /* table offset into smbios_tables */   \
-int str_index = 0;\
-do {  \
-/* should we skip building this table ? */\
-if (smbios_skip_table(tbl_type, tbl_required)) {  \
-return;   \
-} \
-  \
-/* use offset of table t within smbios_tables */  \
-/* (pointer must be updated after each realloc) */\
-t_off = smbios_tables_len;\
-smbios_tables_len += sizeof(*t);  \
-smbios_tables = g_realloc(smbios_tables, smbios_tables_len);  \
-t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
-  \
-t->header.type = tbl_type;\
-t->header.length = sizeof(*t);\
-t->header.handle = cpu_to_le16(tbl_handle);   \
-} while (0)
-
-#define SMBIOS_TABLE_SET_STR(tbl_type, field, value)  \
-do {  \
-int len = (value != NULL) ? strlen(value) + 1 : 0;\
-if (len > 1) {\
-smbios_tables = g_realloc(smbios_tables,  \
-  smbios_tables_len + len);   \
-memcpy(smbios_tables + smbios_tables_len, value, len);\
-smbios_tables_len += len; \
-/* update pointer post-realloc */ \
-t = (struct smbios_type_##tbl_type *)(smbios_tables + t_off); \
-t->field = ++str_index;   \
-} else {  \
-t->field = 0; \
-} \
-} while (0)
-
-#define SMBIOS_BUILD_TABLE_POST   \
-do {  \
-size_t term_cnt, t_size;  \
-  \
-/* add '\0' terminator (add two if no strings defined) */ \
-term_cnt = (str_index == 0) ? 2 : 1;  \
-smbios_tables = g_realloc(smbios_tables,  \
-  smbios_tables_len + term_cnt);  \
-memset(smbios_tables + smbios_tables_len

[Qemu-devel] [PATCH v4 06/17] ipmi: Add a BT low-level interface

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/ipmi/Makefile.objs  |   1 +
 hw/ipmi/isa_ipmi_bt.c  | 489 +
 4 files changed, 492 insertions(+)
 create mode 100644 hw/ipmi/isa_ipmi_bt.c

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 1c24aab..1730fbb 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -13,6 +13,7 @@ CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
 CONFIG_ISA_IPMI_KCS=y
+CONFIG_ISA_IPMI_BT=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 9d1f934..22a99a2 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -13,6 +13,7 @@ CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
 CONFIG_IPMI_EXTERN=y
 CONFIG_ISA_IPMI_KCS=y
+CONFIG_ISA_IPMI_BT=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
index 28618c5..a90318d 100644
--- a/hw/ipmi/Makefile.objs
+++ b/hw/ipmi/Makefile.objs
@@ -2,3 +2,4 @@ common-obj-$(CONFIG_IPMI) += ipmi.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
 common-obj-$(CONFIG_ISA_IPMI_KCS) += isa_ipmi_kcs.o
+common-obj-$(CONFIG_ISA_IPMI_BT) += isa_ipmi_bt.o
diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
new file mode 100644
index 000..70e2c0d
--- /dev/null
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -0,0 +1,489 @@
+/*
+ * QEMU ISA IPMI BT emulation
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "hw/hw.h"
+#include "hw/ipmi/ipmi.h"
+#include "hw/isa/isa.h"
+#include "hw/i386/pc.h"
+
+/* Control register */
+#define IPMI_BT_CLR_WR_BIT 0
+#define IPMI_BT_CLR_RD_BIT 1
+#define IPMI_BT_H2B_ATN_BIT2
+#define IPMI_BT_B2H_ATN_BIT3
+#define IPMI_BT_SMS_ATN_BIT4
+#define IPMI_BT_HBUSY_BIT  6
+#define IPMI_BT_BBUSY_BIT  7
+
+#define IPMI_BT_CLR_WR_MASK(1 << IPMI_BT_CLR_WR_BIT)
+#define IPMI_BT_GET_CLR_WR(d)  (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1)
+#define IPMI_BT_SET_CLR_WR(d, v)   (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \
+   (((v & 1) << IPMI_BT_CLR_WR_BIT)))
+
+#define IPMI_BT_CLR_RD_MASK(1 << IPMI_BT_CLR_RD_BIT)
+#define IPMI_BT_GET_CLR_RD(d)  (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1)
+#define IPMI_BT_SET_CLR_RD(d, v)   (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \
+   (((v & 1) << IPMI_BT_CLR_RD_BIT)))
+
+#define IPMI_BT_H2B_ATN_MASK   (1 << IPMI_BT_H2B_ATN_BIT)
+#define IPMI_BT_GET_H2B_ATN(d) (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1)
+#define IPMI_BT_SET_H2B_ATN(d, v)  (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \
+(((v & 1) << IPMI_BT_H2B_ATN_BIT)))
+
+#define IPMI_BT_B2H_ATN_MASK   (1 << IPMI_BT_B2H_ATN_BIT)
+#define IPMI_BT_GET_B2H_ATN(d) (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1)
+#define IPMI_BT_SET_B2H_ATN(d, v)  (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \
+(((v & 1) << IPMI_BT_B2H_ATN_BIT)))
+
+#define IPMI_BT_SMS_ATN_MASK   (1 << IPMI_BT_SMS_ATN_BIT)
+#define IPMI_BT_GET_SMS_ATN(d) (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1)
+#define IPMI_BT_SET_SMS_ATN(d, v)  (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \
+(((v & 1) << IPMI_BT_SMS_ATN_BIT)))
+
+#define IPMI_BT_HBUSY_MASK (1 << IPMI_BT_HBUSY_BIT)
+#define IPMI_BT_GET_HBUSY(d)   (((d) >> IPMI_BT_HBUSY_BIT) & 0x1)
+#define IPMI_BT_SET_HBUSY(d, v)(d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \
+

[Qemu-devel] [PATCH v4 15/17] acpi: Add IPMI table entries

2015-11-12 Thread minyard
From: Corey Minyard 

Use the new ACPI table construction tools to create an ACPI
entry for IPMI.  This adds a function called from build_ssdt
to add an SSDT entry for IPMI if IPMI is compiled in and has
registered firmware.  It also adds a dummy function if IPMI
is not compiled in.

This conforms to section "C3-2 Locating IPMI System Interfaces in
ACPI Name Space" in the IPMI 2.0 specification.

Signed-off-by: Corey Minyard 
---
 hw/acpi/Makefile.objs  |   2 +
 hw/acpi/ipmi.c | 116 +
 hw/acpi/noipmi.c   |  14 ++
 hw/i386/acpi-build.c   |   4 ++
 include/hw/acpi/ipmi.h |  16 +++
 5 files changed, 152 insertions(+)
 create mode 100644 hw/acpi/ipmi.c
 create mode 100644 hw/acpi/noipmi.c
 create mode 100644 include/hw/acpi/ipmi.h

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 7d3230c..f35ecfc 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -5,3 +5,5 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI) += acpi_interface.o
 common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
 common-obj-$(CONFIG_ACPI) += aml-build.o
+common-obj-$(call land,$(CONFIG_ACPI),$(CONFIG_IPMI)) += ipmi.o
+common-obj-$(call land,$(CONFIG_ACPI),$(call lnot,$(CONFIG_IPMI))) += noipmi.o
diff --git a/hw/acpi/ipmi.c b/hw/acpi/ipmi.c
new file mode 100644
index 000..0f2d06b
--- /dev/null
+++ b/hw/acpi/ipmi.c
@@ -0,0 +1,116 @@
+/*
+ * IPMI ACPI firmware handling
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hw/ipmi/ipmi.h"
+#include "hw/acpi/aml-build.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/ipmi.h"
+
+static Aml *aml_ipmi_crs(IPMIFwInfo *info)
+{
+Aml *crs = aml_resource_template();
+uint8_t regspacing = info->register_spacing;
+
+/*
+ * The base address is fixed and cannot change.  That may be different
+ * if someone does PCI, but we aren't there yet.
+ */
+switch (info->memspace) {
+case IPMI_MEMSPACE_IO:
+aml_append(crs, aml_io(AML_DECODE16, info->base_address,
+   info->base_address + info->register_length - 1,
+   regspacing, info->register_length));
+break;
+case IPMI_MEMSPACE_MEM32:
+aml_append(crs,
+   aml_dword_memory(AML_POS_DECODE,
+AML_MIN_FIXED, AML_MAX_FIXED,
+AML_NON_CACHEABLE, AML_READ_WRITE,
+0x,
+info->base_address,
+info->base_address + info->register_length - 1,
+regspacing, info->register_length));
+break;
+case IPMI_MEMSPACE_MEM64:
+aml_append(crs,
+   aml_qword_memory(AML_POS_DECODE,
+AML_MIN_FIXED, AML_MAX_FIXED,
+AML_NON_CACHEABLE, AML_READ_WRITE,
+0xULL,
+info->base_address,
+info->base_address + info->register_length - 1,
+regspacing, info->register_length));
+break;
+case IPMI_MEMSPACE_SMBUS:
+aml_append(crs, aml_return(aml_int(info->base_address)));
+break;
+default:
+abort();
+}
+
+if (info->interrupt_number) {
+aml_append(crs, aml_irq_no_flags(info->interrupt_number));
+}
+
+return crs;
+}
+
+static void
+ipmi_encode_one_acpi(Aml *ssdt, IPMIFwInfo *info)
+{
+Aml *scope, *dev, *method;
+uint16_t version = ((info->ipmi_spec_major_revision << 8)
+| (info->ipmi_spec_minor_revision << 4));
+
+/*
+ * The ACPI parent is a little bit of a pain.  It could be in
+ * different places depending on the device.  It could be an SMBus,
+ * it could be ISA, it could be PCI, etc.  Only the device really
+ * knows, so it has to pass it in.
+ */
+if (!info->acpi_parent) {
+ipmi_debug("device %s not compatible with ACPI, no parent given.",
+   info->interface_name);
+return;
+}
+
+scope = aml_scope("%s", info->acpi_parent);
+
+dev = aml_device("MI0");
+aml_append(dev, aml_name_decl("_HID", aml_eisaid("IPI0001")));
+aml_append(dev, aml_name_decl("_STR", aml_string("ipmi_%s",
+ info->interface_name)));
+aml_append(dev, aml_name_decl("_UID", aml_int(info->uuid)));
+aml_append(dev, aml_name_decl("_CRS", aml_ipmi_crs(info)));
+
+/*
+ * The spec seems to require these to be methods.  All the examples
+ * show them this way and it doesn't seem to work if they are not.
+ */
+method = aml_method("_IFT", 0);
+aml_append(method, aml_return(aml_int(in

[Qemu-devel] [PATCH v4 09/17] ipmi: Add migration capability to the IPMI devices.

2015-11-12 Thread minyard
From: Corey Minyard 

Signed-off-by: Corey Minyard 
---
 hw/ipmi/ipmi_bmc_extern.c | 34 ++
 hw/ipmi/ipmi_bmc_sim.c| 30 ++
 hw/ipmi/isa_ipmi_bt.c | 24 
 hw/ipmi/isa_ipmi_kcs.c| 26 ++
 4 files changed, 114 insertions(+)

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index d4669f0..05b9121 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -439,11 +439,45 @@ static void ipmi_bmc_extern_realize(DeviceState *dev, 
Error **errp)
 qemu_chr_add_handlers(ibe->chr, can_receive, receive, chr_event, ibe);
 }
 
+static int ipmi_bmc_extern_post_migrate(void *opaque, int version_id)
+{
+IPMIBmcExtern *ibe = opaque;
+
+/*
+ * We don't directly restore waiting_rsp, Instead, we return an
+ * error on the interface if a response was being waited for.
+ */
+if (ibe->waiting_rsp) {
+IPMIInterface *ii = ibe->parent.intf;
+IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii);
+
+ibe->waiting_rsp = false;
+ibe->inbuf[1] = ibe->outbuf[1] | 0x04;
+ibe->inbuf[2] = ibe->outbuf[2];
+ibe->inbuf[3] = IPMI_CC_BMC_INIT_IN_PROGRESS;
+iic->handle_rsp(ii, ibe->outbuf[0], ibe->inbuf + 1, 3);
+}
+return 0;
+}
+
+static const VMStateDescription vmstate_ipmi_bmc_extern = {
+.name = TYPE_IPMI_BMC_EXTERN,
+.version_id = 1,
+.minimum_version_id = 1,
+.post_load = ipmi_bmc_extern_post_migrate,
+.fields  = (VMStateField[]) {
+VMSTATE_BOOL(send_reset, IPMIBmcExtern),
+VMSTATE_BOOL(waiting_rsp, IPMIBmcExtern),
+VMSTATE_END_OF_LIST()
+}
+};
+
 static void ipmi_bmc_extern_init(Object *obj)
 {
 IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
 
 ibe->extern_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, extern_timeout, ibe);
+vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
 }
 
 static Property ipmi_bmc_extern_properties[] = {
diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c
index d246029..c81a19d 100644
--- a/hw/ipmi/ipmi_bmc_sim.c
+++ b/hw/ipmi/ipmi_bmc_sim.c
@@ -1658,6 +1658,34 @@ static const uint8_t init_sdrs[] = {
 0xff, 0xff, 0x00, 0x00, 0x00
 };
 
+static const VMStateDescription vmstate_ipmi_sim = {
+.name = TYPE_IPMI_BMC_SIMULATOR,
+.version_id = 1,
+.minimum_version_id = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_UINT8(bmc_global_enables, IPMIBmcSim),
+VMSTATE_UINT8(msg_flags, IPMIBmcSim),
+VMSTATE_BOOL(watchdog_initialized, IPMIBmcSim),
+VMSTATE_UINT8(watchdog_use, IPMIBmcSim),
+VMSTATE_UINT8(watchdog_action, IPMIBmcSim),
+VMSTATE_UINT8(watchdog_pretimeout, IPMIBmcSim),
+VMSTATE_BOOL(watchdog_expired, IPMIBmcSim),
+VMSTATE_UINT16(watchdog_timeout, IPMIBmcSim),
+VMSTATE_BOOL(watchdog_running, IPMIBmcSim),
+VMSTATE_BOOL(watchdog_preaction_ran, IPMIBmcSim),
+VMSTATE_INT64(watchdog_expiry, IPMIBmcSim),
+VMSTATE_UINT8_ARRAY(evtbuf, IPMIBmcSim, 16),
+VMSTATE_UINT8(sensors[IPMI_WATCHDOG_SENSOR].status, IPMIBmcSim),
+VMSTATE_UINT8(sensors[IPMI_WATCHDOG_SENSOR].reading, IPMIBmcSim),
+VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].states, IPMIBmcSim),
+VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].assert_states, 
IPMIBmcSim),
+VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].deassert_states,
+   IPMIBmcSim),
+VMSTATE_UINT16(sensors[IPMI_WATCHDOG_SENSOR].assert_enable, 
IPMIBmcSim),
+VMSTATE_END_OF_LIST()
+}
+};
+
 static void ipmi_sim_init(Object *obj)
 {
 IPMIBmc *b = IPMI_BMC(obj);
@@ -1706,6 +1734,8 @@ static void ipmi_sim_init(Object *obj)
 register_cmds(ibs);
 
 ibs->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ipmi_timeout, ibs);
+
+vmstate_register(NULL, 0, &vmstate_ipmi_sim, ibs);
 }
 
 static void ipmi_sim_class_init(ObjectClass *oc, void *data)
diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index 70e2c0d..03eb9cc 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -437,11 +437,35 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error 
**errp)
 isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base);
 }
 
+static const VMStateDescription vmstate_ISAIPMIBTDevice = {
+.name = TYPE_IPMI_INTERFACE,
+.version_id = 1,
+.minimum_version_id = 1,
+.fields  = (VMStateField[]) {
+VMSTATE_BOOL(bt.obf_irq_set, ISAIPMIBTDevice),
+VMSTATE_BOOL(bt.atn_irq_set, ISAIPMIBTDevice),
+VMSTATE_BOOL(bt.use_irq, ISAIPMIBTDevice),
+VMSTATE_BOOL(bt.irqs_enabled, ISAIPMIBTDevice),
+VMSTATE_UINT32(bt.outpos, ISAIPMIBTDevice),
+VMSTATE_VBUFFER_UINT32(bt.outmsg, ISAIPMIBTDevice, 1, NULL, 0,
+   bt.outlen),
+VMSTATE_VBUFFER_UINT32(bt.inmsg, ISAIPMIBTDevice, 1, NULL, 0,
+   bt.inlen),

[Qemu-devel] [PATCH v4 07/17] ipmi: Add tests

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 tests/Makefile|   4 +
 tests/ipmi-bt-test.c  | 436 ++
 tests/ipmi-kcs-test.c | 295 ++
 3 files changed, 735 insertions(+)
 create mode 100644 tests/ipmi-bt-test.c
 create mode 100644 tests/ipmi-kcs-test.c

diff --git a/tests/Makefile b/tests/Makefile
index 92969e8..039c440 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -163,6 +163,8 @@ gcov-files-i386-y += hw/block/hd-geometry.c
 check-qtest-i386-y += tests/boot-order-test$(EXESUF)
 check-qtest-i386-y += tests/bios-tables-test$(EXESUF)
 check-qtest-i386-y += tests/rtc-test$(EXESUF)
+check-qtest-i386-y += tests/ipmi-kcs-test$(EXESUF)
+check-qtest-i386-y += tests/ipmi-bt-test$(EXESUF)
 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
 check-qtest-i386-y += tests/drive_del-test$(EXESUF)
@@ -481,6 +483,8 @@ tests/spapr-phb-test$(EXESUF): tests/spapr-phb-test.o 
$(libqos-obj-y)
 tests/fdc-test$(EXESUF): tests/fdc-test.o
 tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
 tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y)
+tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o
+tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o
 tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
 tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
 tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o $(libqos-obj-y)
diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
new file mode 100644
index 000..5b7eb73
--- /dev/null
+++ b/tests/ipmi-bt-test.c
@@ -0,0 +1,436 @@
+/*
+ * IPMI BT test cases, using the external interface for checking
+ *
+ * Copyright (c) 2012 Corey Minyard 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include "libqtest.h"
+#include "qemu-common.h"
+
+#define IPMI_IRQ5
+
+#define IPMI_BT_BASE0xe4
+
+#define IPMI_BT_CTLREG_CLR_WR_PTR  0
+#define IPMI_BT_CTLREG_CLR_RD_PTR  1
+#define IPMI_BT_CTLREG_H2B_ATN 2
+#define IPMI_BT_CTLREG_B2H_ATN 3
+#define IPMI_BT_CTLREG_SMS_ATN 4
+#define IPMI_BT_CTLREG_H_BUSY  6
+#define IPMI_BT_CTLREG_B_BUSY  7
+
+#define IPMI_BT_CTLREG_GET(b) ((bt_get_ctrlreg() >> (b)) & 1)
+#define IPMI_BT_CTLREG_GET_H2B_ATN() IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H2B_ATN)
+#define IPMI_BT_CTLREG_GET_B2H_ATN() IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B2H_ATN)
+#define IPMI_BT_CTLREG_GET_SMS_ATN() IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_SMS_ATN)
+#define IPMI_BT_CTLREG_GET_H_BUSY()  IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_H_BUSY)
+#define IPMI_BT_CTLREG_GET_B_BUSY()  IPMI_BT_CTLREG_GET(IPMI_BT_CTLREG_B_BUSY)
+
+#define IPMI_BT_CTLREG_SET(b) bt_write_ctrlreg(1 << (b))
+#define IPMI_BT_CTLREG_SET_CLR_WR_PTR() IPMI_BT_CTLREG_SET( \
+IPMI_BT_CTLREG_CLR_WR_PTR)
+#define IPMI_BT_CTLREG_SET_CLR_RD_PTR() IPMI_BT_CTLREG_SET( \
+IPMI_BT_CTLREG_CLR_RD_PTR)
+#define IPMI_BT_CTLREG_SET_H2B_ATN()  
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H2B_ATN)
+#define IPMI_BT_CTLREG_SET_B2H_ATN()  
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_B2H_ATN)
+#define IPMI_BT_CTLREG_SET_SMS_ATN()  
IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_SMS_ATN)
+#define IPMI_BT_CTLREG_SET_H_BUSY()   IPMI_BT_CTLREG_SET(IPMI_BT_CTLREG_H_BUSY)
+
+static int bt_ints_enabled;
+
+static uint8_t bt_get_ctrlreg(void)
+{
+return inb(IPMI_BT_BASE);
+}
+
+static void bt_write_ctrlreg(uint8_t val)
+{
+outb(IPMI_BT_BASE, val);
+}
+
+static uint8_t bt_get_buf(void)
+{
+return inb(IPMI_BT_BASE + 1);
+}
+
+static void bt_write_buf(uint8_t val)
+{
+outb(IPMI_BT_BASE + 1, val);
+}
+
+static uint8_t bt_get_irqreg(void)
+{
+return inb(IPMI_BT_BASE + 2)

[Qemu-devel] [PATCH v4 13/17] pc: Postpone SMBIOS table installation to post machine init

2015-11-12 Thread minyard
From: Corey Minyard 

This is the same place that the ACPI SSDT table gets added, so that
devices can add themselves to the SMBIOS table.

Signed-off-by: Corey Minyard 
---
 hw/i386/pc.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 0cb8afd..47faef7 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -781,8 +781,6 @@ static FWCfgState *bochs_bios_init(AddressSpace *as)
  acpi_tables, acpi_tables_len);
 fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override());
 
-pc_build_smbios(fw_cfg);
-
 fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE,
  &e820_reserve, sizeof(e820_reserve));
 fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
@@ -1174,6 +1172,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void 
*data)
 PcGuestInfoState *guest_info_state = container_of(notifier,
   PcGuestInfoState,
   machine_done);
+FWCfgState *fw_cfg = guest_info_state->info.fw_cfg;
 PCIBus *bus = find_i440fx();
 
 if (bus) {
@@ -1185,15 +1184,17 @@ void pc_guest_info_machine_done(Notifier *notifier, 
void *data)
 extra_hosts++;
 }
 }
-if (extra_hosts && guest_info_state->info.fw_cfg) {
+if (extra_hosts && fw_cfg) {
 uint64_t *val = g_malloc(sizeof(*val));
 *val = cpu_to_le64(extra_hosts);
-fw_cfg_add_file(guest_info_state->info.fw_cfg,
-"etc/extra-pci-roots", val, sizeof(*val));
+fw_cfg_add_file(fw_cfg, "etc/extra-pci-roots", val, sizeof(*val));
 }
 }
 
 acpi_setup(&guest_info_state->info);
+if (fw_cfg) {
+pc_build_smbios(fw_cfg);
+}
 }
 
 PcGuestInfo *pc_guest_info_init(PCMachineState *pcms)
-- 
1.8.3.1




[Qemu-devel] [PATCH v4 00/17] Add an IPMI device to QEMU

2015-11-12 Thread minyard
This is a long delayed patch set, but I think I have things reworked
to make Igor happy with the way ACPI and SMBIOS work.  This is more
consistent with the way most other things work, anyway.  It did
require adding stubs for systems without IPMI.

The first nine patches are unchanged.

The IPMI firmware configuration storage now holds the firmware information
in a data structure and lets it be iterated.

SMBIOS and ACPI build the tables with their existing building
functions and call out to the IPMI one (or the stub) when the time
comes.  This required pulling some code out of smbios.c into an
include file and making some things global, as IPMI has to be
configurable.

The BIOS table tests were also modified since the ACPI info is
now in the existing SSDT.

I've also added a force-off function for external BMCs; an external
BMC needs a way to do a hard power-off of the system if the soft
power offs fail.

Thanks all!

-corey




[Qemu-devel] [PATCH v2 6/7] stubs: gtk_display_init() stub

2015-11-12 Thread Eduardo Habkost
This reduces the number of CONFIG_GTK #ifdefs in vl.c.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/gtk.c | 10 ++
 vl.c   |  4 
 3 files changed, 11 insertions(+), 4 deletions(-)
 create mode 100644 stubs/ui/gtk.c

diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
index ce9a0ce..cdf87fe 100644
--- a/stubs/ui/Makefile.objs
+++ b/stubs/ui/Makefile.objs
@@ -2,3 +2,4 @@ stub-obj-y += vnc.o
 stub-obj-y += curses.o
 stub-obj-y += sdl.o
 stub-obj-y += cocoa.o
+stub-obj-y += gtk.o
diff --git a/stubs/ui/gtk.c b/stubs/ui/gtk.c
new file mode 100644
index 000..a46ef0c
--- /dev/null
+++ b/stubs/ui/gtk.c
@@ -0,0 +1,10 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
+{
+/* This must never be called if CONFIG_GTK is disabled */
+error_report("GTK support is disabled");
+abort();
+}
diff --git a/vl.c b/vl.c
index ea83e17..d4191d6 100644
--- a/vl.c
+++ b/vl.c
@@ -151,9 +151,7 @@ int vga_interface_type = VGA_NONE;
 static int full_screen = 0;
 static int no_frame = 0;
 int no_quit = 0;
-#ifdef CONFIG_GTK
 static bool grab_on_hover;
-#endif
 CharDriverState *serial_hds[MAX_SERIAL_PORTS];
 CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
@@ -4576,11 +4574,9 @@ int main(int argc, char **argv, char **envp)
 case DT_COCOA:
 cocoa_display_init(ds, full_screen);
 break;
-#if defined(CONFIG_GTK)
 case DT_GTK:
 gtk_display_init(ds, full_screen, grab_on_hover);
 break;
-#endif
 default:
 break;
 }
-- 
2.1.0




[Qemu-devel] [PATCH v4 04/17] ipmi: Add an external connection simulation interface

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/ipmi/Makefile.objs  |   1 +
 hw/ipmi/ipmi_bmc_extern.c  | 478 +
 4 files changed, 481 insertions(+)
 create mode 100644 hw/ipmi/ipmi_bmc_extern.c

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 00a0346..077b3c4 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -11,6 +11,7 @@ CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
+CONFIG_IPMI_EXTERN=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index 39a619f..81b0cb0 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -11,6 +11,7 @@ CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
 CONFIG_IPMI=y
 CONFIG_IPMI_LOCAL=y
+CONFIG_IPMI_EXTERN=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
index 875271c..ddb15ec 100644
--- a/hw/ipmi/Makefile.objs
+++ b/hw/ipmi/Makefile.objs
@@ -1,2 +1,3 @@
 common-obj-$(CONFIG_IPMI) += ipmi.o
 common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_sim.o
+common-obj-$(CONFIG_IPMI_LOCAL) += ipmi_bmc_extern.o
diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
new file mode 100644
index 000..d4669f0
--- /dev/null
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -0,0 +1,478 @@
+/*
+ * IPMI BMC external connection
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/*
+ * This is designed to connect with OpenIPMI's lanserv serial interface
+ * using the "VM" connection type.  See that for details.
+ */
+
+#include 
+#include "qemu/timer.h"
+#include "sysemu/char.h"
+#include "hw/ipmi/ipmi.h"
+
+#define VM_MSG_CHAR0xA0 /* Marks end of message */
+#define VM_CMD_CHAR0xA1 /* Marks end of a command */
+#define VM_ESCAPE_CHAR 0xAA /* Set bit 4 from the next byte to 0 */
+
+#define VM_PROTOCOL_VERSION1
+#define VM_CMD_VERSION 0xff /* A version number byte follows */
+#define VM_CMD_NOATTN  0x00
+#define VM_CMD_ATTN0x01
+#define VM_CMD_ATTN_IRQ0x02
+#define VM_CMD_POWEROFF0x03
+#define VM_CMD_RESET   0x04
+#define VM_CMD_ENABLE_IRQ  0x05 /* Enable/disable the messaging irq */
+#define VM_CMD_DISABLE_IRQ 0x06
+#define VM_CMD_SEND_NMI0x07
+#define VM_CMD_CAPABILITIES0x08
+#define   VM_CAPABILITIES_POWER0x01
+#define   VM_CAPABILITIES_RESET0x02
+#define   VM_CAPABILITIES_IRQ  0x04
+#define   VM_CAPABILITIES_NMI  0x08
+#define   VM_CAPABILITIES_ATTN 0x10
+
+#define TYPE_IPMI_BMC_EXTERN "ipmi-bmc-extern"
+#define IPMI_BMC_EXTERN(obj) OBJECT_CHECK(IPMIBmcExtern, (obj), \
+TYPE_IPMI_BMC_EXTERN)
+typedef struct IPMIBmcExtern {
+IPMIBmc parent;
+
+CharDriverState *chr;
+
+bool connected;
+
+unsigned char inbuf[MAX_IPMI_MSG_SIZE + 2];
+unsigned int inpos;
+bool in_escape;
+bool in_too_many;
+bool waiting_rsp;
+bool sending_cmd;
+
+unsigned char outbuf[(MAX_IPMI_MSG_SIZE + 2) * 2 + 1];
+unsigned int outpos;
+unsigned int outlen;
+
+struct QEMUTimer *extern_timer;
+
+/* A reset event is pending to be sent upstream. */
+bool send_reset;
+} IPMIBmcExtern;
+
+static int can_receive(void *opaque);
+static void receive(void *opaque, const uint8_t *buf, int size);
+static void chr_event(void *opaque, int event);
+
+static unsigned char
+ipmb_che

[Qemu-devel] [PATCH v2 5/7] stubs: cocoa_display_init() stub

2015-11-12 Thread Eduardo Habkost
One less #ifdef in vl.c.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/cocoa.c   | 10 ++
 vl.c   |  2 --
 3 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 stubs/ui/cocoa.c

diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
index 2e4c924..ce9a0ce 100644
--- a/stubs/ui/Makefile.objs
+++ b/stubs/ui/Makefile.objs
@@ -1,3 +1,4 @@
 stub-obj-y += vnc.o
 stub-obj-y += curses.o
 stub-obj-y += sdl.o
+stub-obj-y += cocoa.o
diff --git a/stubs/ui/cocoa.c b/stubs/ui/cocoa.c
new file mode 100644
index 000..ef07a8a
--- /dev/null
+++ b/stubs/ui/cocoa.c
@@ -0,0 +1,10 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+void cocoa_display_init(DisplayState *ds, int full_screen)
+{
+/* This must never be called if CONFIG_COCA is disabled */
+error_report("Cocoa support is disabled");
+abort();
+}
diff --git a/vl.c b/vl.c
index 5292648..ea83e17 100644
--- a/vl.c
+++ b/vl.c
@@ -4573,11 +4573,9 @@ int main(int argc, char **argv, char **envp)
 case DT_SDL:
 sdl_display_init(ds, full_screen, no_frame);
 break;
-#if defined(CONFIG_COCOA)
 case DT_COCOA:
 cocoa_display_init(ds, full_screen);
 break;
-#endif
 #if defined(CONFIG_GTK)
 case DT_GTK:
 gtk_display_init(ds, full_screen, grab_on_hover);
-- 
2.1.0




[Qemu-devel] [PATCH v4 11/17] ipmi: Add firmware registration to the ISA interface

2015-11-12 Thread minyard
From: Corey Minyard 

Signed-off-by: Corey Minyard 
---
 hw/ipmi/isa_ipmi_bt.c  | 15 +++
 hw/ipmi/isa_ipmi_kcs.c | 15 +++
 2 files changed, 30 insertions(+)

diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c
index 03eb9cc..21fa4a7 100644
--- a/hw/ipmi/isa_ipmi_bt.c
+++ b/hw/ipmi/isa_ipmi_bt.c
@@ -407,6 +407,7 @@ typedef struct ISAIPMIBTDevice {
 ISADevice dev;
 int32 isairq;
 IPMIBT bt;
+IPMIFwInfo fwinfo;
 } ISAIPMIBTDevice;
 
 static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp)
@@ -435,6 +436,20 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error 
**errp)
 qdev_set_legacy_instance_id(dev, iib->bt.io_base, iib->bt.io_length);
 
 isa_register_ioport(isadev, &iib->bt.io, iib->bt.io_base);
+
+iib->fwinfo.interface_name = "bt";
+iib->fwinfo.interface_type = IPMI_SMBIOS_BT;
+iib->fwinfo.ipmi_spec_major_revision = 2;
+iib->fwinfo.ipmi_spec_minor_revision = 0;
+iib->fwinfo.base_address = iib->bt.io_base;
+iib->fwinfo.register_length = iib->bt.io_length;
+iib->fwinfo.register_spacing = 1;
+iib->fwinfo.memspace = IPMI_MEMSPACE_IO;
+iib->fwinfo.irq_type = IPMI_LEVEL_IRQ;
+iib->fwinfo.interrupt_number = iib->isairq;
+iib->fwinfo.acpi_parent = "\\_SB.PCI0.ISA";
+iib->fwinfo.i2c_slave_address = iib->bt.bmc->slave_addr;
+ipmi_add_fwinfo(&iib->fwinfo, errp);
 }
 
 static const VMStateDescription vmstate_ISAIPMIBTDevice = {
diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c
index b588711..c662aee 100644
--- a/hw/ipmi/isa_ipmi_kcs.c
+++ b/hw/ipmi/isa_ipmi_kcs.c
@@ -370,6 +370,7 @@ typedef struct ISAIPMIKCSDevice {
 ISADevice dev;
 int32 isairq;
 IPMIKCS kcs;
+IPMIFwInfo fwinfo;
 } ISAIPMIKCSDevice;
 
 static void ipmi_isa_realize(DeviceState *dev, Error **errp)
@@ -398,6 +399,20 @@ static void ipmi_isa_realize(DeviceState *dev, Error 
**errp)
 qdev_set_legacy_instance_id(dev, iik->kcs.io_base, iik->kcs.io_length);
 
 isa_register_ioport(isadev, &iik->kcs.io, iik->kcs.io_base);
+
+iik->fwinfo.interface_name = "kcs";
+iik->fwinfo.interface_type = IPMI_SMBIOS_KCS;
+iik->fwinfo.ipmi_spec_major_revision = 2;
+iik->fwinfo.ipmi_spec_minor_revision = 0;
+iik->fwinfo.base_address = iik->kcs.io_base;
+iik->fwinfo.i2c_slave_address = iik->kcs.bmc->slave_addr;
+iik->fwinfo.register_length = iik->kcs.io_length;
+iik->fwinfo.register_spacing = 1;
+iik->fwinfo.memspace = IPMI_MEMSPACE_IO;
+iik->fwinfo.irq_type = IPMI_LEVEL_IRQ;
+iik->fwinfo.interrupt_number = iik->isairq;
+iik->fwinfo.acpi_parent = "\\_SB.PCI0.ISA";
+ipmi_add_fwinfo(&iik->fwinfo, errp);
 }
 
 const VMStateDescription vmstate_ISAIPMIKCSDevice = {
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 7/7] spice: Initialization stubs on qemu-spice.h

2015-11-12 Thread Eduardo Habkost
This reduces the number of CONFIG_SPICE #ifdefs in vl.c.

Cc: Gerd Hoffmann 
Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stubs to qemu-spice.h, as the header file already
  had a separate section for !CONFIG_SPICE
---
 include/ui/qemu-spice.h | 13 +
 vl.c|  4 
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index f9ce357..da01273 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -52,6 +52,8 @@ static inline CharDriverState *qemu_chr_open_spice_port(const 
char *name)
 
 #else  /* CONFIG_SPICE */
 
+#include "qemu/error-report.h"
+
 #define using_spice 0
 #define spice_displays 0
 static inline int qemu_spice_set_passwd(const char *passwd,
@@ -76,6 +78,17 @@ static inline int qemu_spice_display_add_client(int csock, 
int skipauth,
 return -1;
 }
 
+static inline void qemu_spice_display_init(void)
+{
+/* This must never be called if CONFIG_SPICE is disabled */
+error_report("spice support is disabled");
+abort();
+}
+
+static inline void qemu_spice_init(void)
+{
+}
+
 #endif /* CONFIG_SPICE */
 
 static inline bool qemu_using_spice(Error **errp)
diff --git a/vl.c b/vl.c
index d4191d6..57064ea 100644
--- a/vl.c
+++ b/vl.c
@@ -4386,10 +4386,8 @@ int main(int argc, char **argv, char **envp)
 
 os_set_line_buffering();
 
-#ifdef CONFIG_SPICE
 /* spice needs the timers to be initialized by this point */
 qemu_spice_init();
-#endif
 
 cpu_ticks_init();
 if (icount_opts) {
@@ -4593,11 +4591,9 @@ int main(int argc, char **argv, char **envp)
 g_free(ret);
 }
 
-#ifdef CONFIG_SPICE
 if (using_spice) {
 qemu_spice_display_init();
 }
-#endif
 
 if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
 exit(1);
-- 
2.1.0




[Qemu-devel] [PATCH v4 02/17] Add a base IPMI interface

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 default-configs/i386-softmmu.mak   |   1 +
 default-configs/x86_64-softmmu.mak |   1 +
 hw/Makefile.objs   |   1 +
 hw/ipmi/Makefile.objs  |   1 +
 hw/ipmi/ipmi.c | 125 ++
 include/hw/ipmi/ipmi.h | 178 +
 qemu-doc.texi  |   2 +
 7 files changed, 309 insertions(+)
 create mode 100644 hw/ipmi/Makefile.objs
 create mode 100644 hw/ipmi/ipmi.c
 create mode 100644 include/hw/ipmi/ipmi.h

diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
index 43c96d1..8fa751a 100644
--- a/default-configs/i386-softmmu.mak
+++ b/default-configs/i386-softmmu.mak
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
+CONFIG_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/default-configs/x86_64-softmmu.mak 
b/default-configs/x86_64-softmmu.mak
index dfb8095..6767f4f 100644
--- a/default-configs/x86_64-softmmu.mak
+++ b/default-configs/x86_64-softmmu.mak
@@ -9,6 +9,7 @@ CONFIG_VGA_CIRRUS=y
 CONFIG_VMWARE_VGA=y
 CONFIG_VIRTIO_VGA=y
 CONFIG_VMMOUSE=y
+CONFIG_IPMI=y
 CONFIG_SERIAL=y
 CONFIG_PARALLEL=y
 CONFIG_I8254=y
diff --git a/hw/Makefile.objs b/hw/Makefile.objs
index 7e7c241..4a07ed4 100644
--- a/hw/Makefile.objs
+++ b/hw/Makefile.objs
@@ -13,6 +13,7 @@ devices-dirs-$(CONFIG_SOFTMMU) += ide/
 devices-dirs-$(CONFIG_SOFTMMU) += input/
 devices-dirs-$(CONFIG_SOFTMMU) += intc/
 devices-dirs-$(CONFIG_IPACK) += ipack/
+devices-dirs-$(CONFIG_IPMI) += ipmi/
 devices-dirs-$(CONFIG_SOFTMMU) += isa/
 devices-dirs-$(CONFIG_SOFTMMU) += misc/
 devices-dirs-$(CONFIG_SOFTMMU) += net/
diff --git a/hw/ipmi/Makefile.objs b/hw/ipmi/Makefile.objs
new file mode 100644
index 000..65bde11
--- /dev/null
+++ b/hw/ipmi/Makefile.objs
@@ -0,0 +1 @@
+common-obj-$(CONFIG_IPMI) += ipmi.o
diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
new file mode 100644
index 000..7d17469
--- /dev/null
+++ b/hw/ipmi/ipmi.c
@@ -0,0 +1,125 @@
+/*
+ * QEMU IPMI emulation
+ *
+ * Copyright (c) 2015 Corey Minyard, MontaVista Software, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "hw/hw.h"
+#include "hw/ipmi/ipmi.h"
+#include "sysemu/sysemu.h"
+#include "qmp-commands.h"
+#include "qom/object_interfaces.h"
+#include "qapi/visitor.h"
+
+static int ipmi_do_hw_op(IPMIInterface *s, enum ipmi_op op, int checkonly)
+{
+switch (op) {
+case IPMI_RESET_CHASSIS:
+if (checkonly) {
+return 0;
+}
+qemu_system_reset_request();
+return 0;
+
+case IPMI_POWEROFF_CHASSIS:
+if (checkonly) {
+return 0;
+}
+qemu_system_powerdown_request();
+return 0;
+
+case IPMI_SEND_NMI:
+if (checkonly) {
+return 0;
+}
+qemu_mutex_lock_iothread();
+qmp_inject_nmi(NULL);
+qemu_mutex_unlock_iothread();
+return 0;
+
+case IPMI_POWERCYCLE_CHASSIS:
+case IPMI_PULSE_DIAG_IRQ:
+case IPMI_SHUTDOWN_VIA_ACPI_OVERTEMP:
+case IPMI_POWERON_CHASSIS:
+default:
+return IPMI_CC_COMMAND_NOT_SUPPORTED;
+}
+}
+
+static void ipmi_interface_class_init(ObjectClass *class, void *data)
+{
+IPMIInterfaceClass *ik = IPMI_INTERFACE_CLASS(class);
+
+ik->do_hw_op = ipmi_do_hw_op;
+}
+
+static TypeInfo ipmi_interface_type_info = {
+.name = TYPE_IPMI_INTERFACE,
+.parent = TYPE_INTERFACE,
+.class_size = sizeof(IPMIInterfaceClass),
+.class_init = ipmi_interface_class_init,
+};
+
+static void isa_ipmi_bmc_check(Object *obj, const char *name,
+   Object *val, Error **errp)
+{
+IPMIBmc *bmc = I

[Qemu-devel] [PATCH v2 4/7] stubs: SDL initialization stubs

2015-11-12 Thread Eduardo Habkost
This reduces the number of CONFIG_SDL #ifdefs in vl.c.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/sdl.c | 17 +
 vl.c   |  6 ++
 3 files changed, 20 insertions(+), 4 deletions(-)
 create mode 100644 stubs/ui/sdl.c

diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
index 2f63c58..2e4c924 100644
--- a/stubs/ui/Makefile.objs
+++ b/stubs/ui/Makefile.objs
@@ -1,2 +1,3 @@
 stub-obj-y += vnc.o
 stub-obj-y += curses.o
+stub-obj-y += sdl.o
diff --git a/stubs/ui/sdl.c b/stubs/ui/sdl.c
new file mode 100644
index 000..f5ab668
--- /dev/null
+++ b/stubs/ui/sdl.c
@@ -0,0 +1,17 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+void sdl_display_early_init(int opengl)
+{
+/* This must never be called if CONFIG_SDL is disabled */
+error_report("SDL support is disabled");
+abort();
+}
+
+void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+{
+/* This must never be called if CONFIG_SDL is disabled */
+error_report("SDL support is disabled");
+abort();
+}
diff --git a/vl.c b/vl.c
index 3ca1c11..5292648 100644
--- a/vl.c
+++ b/vl.c
@@ -4261,11 +4261,10 @@ int main(int argc, char **argv, char **envp)
 early_gtk_display_init(request_opengl);
 }
 #endif
-#if defined(CONFIG_SDL)
 if (display_type == DT_SDL) {
 sdl_display_early_init(request_opengl);
 }
-#endif
+
 if (request_opengl == 1 && display_opengl == 0) {
 #if defined(CONFIG_OPENGL)
 error_report("OpenGL is not supported by the display");
@@ -4571,11 +4570,10 @@ int main(int argc, char **argv, char **envp)
 case DT_CURSES:
 curses_display_init(ds, full_screen);
 break;
-#if defined(CONFIG_SDL)
 case DT_SDL:
 sdl_display_init(ds, full_screen, no_frame);
 break;
-#elif defined(CONFIG_COCOA)
+#if defined(CONFIG_COCOA)
 case DT_COCOA:
 cocoa_display_init(ds, full_screen);
 break;
-- 
2.1.0




[Qemu-devel] [PATCH v2 2/7] stubs: VNC initialization stubs

2015-11-12 Thread Eduardo Habkost
This reduces the number of CONFIG_VNC #ifdefs in the vl.c code.

The only user-visible difference is that this will make QEMU
complain about syntax when using "-display vnc" ("VNC requires a
display argument vnc=") even if CONFIG_VNC is disabled.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 include/ui/console.h   |  4 ++--
 stubs/Makefile.objs|  1 +
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/vnc.c | 22 ++
 vl.c   | 15 +--
 5 files changed, 27 insertions(+), 16 deletions(-)
 create mode 100644 stubs/ui/Makefile.objs
 create mode 100644 stubs/ui/vnc.c

diff --git a/include/ui/console.h b/include/ui/console.h
index c249db4..30e5305 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -413,11 +413,11 @@ void vnc_display_init(const char *id);
 void vnc_display_open(const char *id, Error **errp);
 void vnc_display_add_client(const char *id, int csock, bool skipauth);
 char *vnc_display_local_addr(const char *id);
+QemuOpts *vnc_parse(const char *str, Error **errp);
+int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
 #ifdef CONFIG_VNC
 int vnc_display_password(const char *id, const char *password);
 int vnc_display_pw_expire(const char *id, time_t expires);
-QemuOpts *vnc_parse(const char *str, Error **errp);
-int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp);
 #else
 static inline int vnc_display_password(const char *id, const char *password)
 {
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index d7898a0..ecf06ae 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -38,3 +38,4 @@ 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
+stub-obj-y += ui/
diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
new file mode 100644
index 000..16ea29a
--- /dev/null
+++ b/stubs/ui/Makefile.objs
@@ -0,0 +1 @@
+stub-obj-y += vnc.o
diff --git a/stubs/ui/vnc.c b/stubs/ui/vnc.c
new file mode 100644
index 000..de89858
--- /dev/null
+++ b/stubs/ui/vnc.c
@@ -0,0 +1,22 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+QemuOpts *vnc_parse(const char *str, Error **errp)
+{
+error_setg(errp, "VNC support is disabled");
+return NULL;
+}
+
+int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
+{
+error_setg(errp, "VNC support is disabled");
+return -1;
+}
+
+char *vnc_display_local_addr(const char *id)
+{
+/* This must never be called if CONFIG_VNC is disabled */
+error_report("VNC support is disabled");
+abort();
+}
diff --git a/vl.c b/vl.c
index bba1b0a..0558e87 100644
--- a/vl.c
+++ b/vl.c
@@ -2145,7 +2145,6 @@ static DisplayType select_display(const char *p)
 exit(1);
 #endif
 } else if (strstart(p, "vnc", &opts)) {
-#ifdef CONFIG_VNC
 if (*opts == '=') {
 Error *err = NULL;
 if (vnc_parse(opts + 1, &err) == NULL) {
@@ -2156,10 +2155,6 @@ static DisplayType select_display(const char *p)
 error_report("VNC requires a display argument vnc=");
 exit(1);
 }
-#else
-error_report("VNC support is disabled");
-exit(1);
-#endif
 } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
 display = DT_CURSES;
@@ -2984,9 +2979,7 @@ int main(int argc, char **argv, char **envp)
 const char *qtest_log = NULL;
 const char *pid_file = NULL;
 const char *incoming = NULL;
-#ifdef CONFIG_VNC
 int show_vnc_port = 0;
-#endif
 bool defconfig = true;
 bool userconfig = true;
 const char *log_mask = NULL;
@@ -3726,17 +3719,12 @@ int main(int argc, char **argv, char **envp)
 break;
 case QEMU_OPTION_vnc:
 {
-#ifdef CONFIG_VNC
 Error *local_err = NULL;
 
 if (vnc_parse(optarg, &local_err) == NULL) {
 error_report_err(local_err);
 exit(1);
 }
-#else
-error_report("VNC support is disabled");
-exit(1);
-#endif
 break;
 }
 case QEMU_OPTION_no_acpi:
@@ -4606,7 +4594,6 @@ int main(int argc, char **argv, char **envp)
 /* must be after terminal init, SDL library changes signal handlers */
 os_setup_signal_handling();
 
-#ifdef CONFIG_VNC
 /* init remote displays */
 qemu_opts_foreach(qemu_find_opts("vnc"),
   vnc_init_func, NULL, NULL);
@@ -4615,7 +4602,7 @@ int main(int argc, char **argv, char **envp)
 printf("VNC server running on '%s'\n", ret);
 g_free(ret);
 }
-#endif
+
 #ifdef CONFIG_SPICE
 if (using_spice) {
 qemu_spice_display_init();
-- 
2.1.0




[Qemu-devel] [PATCH v4 10/17] ipmi: Add a firmware configuration repository

2015-11-12 Thread minyard
From: Corey Minyard 

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

Signed-off-by: Corey Minyard 
---
 hw/ipmi/ipmi.c | 27 +++
 include/hw/ipmi/ipmi.h | 35 +++
 2 files changed, 62 insertions(+)

diff --git a/hw/ipmi/ipmi.c b/hw/ipmi/ipmi.c
index 7d17469..52aba1e 100644
--- a/hw/ipmi/ipmi.c
+++ b/hw/ipmi/ipmi.c
@@ -123,3 +123,30 @@ static void ipmi_register_types(void)
 }
 
 type_init(ipmi_register_types)
+
+static IPMIFwInfo *ipmi_fw_info;
+static unsigned int ipmi_fw_info_len;
+
+static uint32_t current_uuid = 1;
+
+void ipmi_add_fwinfo(IPMIFwInfo *info, Error **errp)
+{
+info->uuid = current_uuid++;
+ipmi_fw_info = g_realloc(ipmi_fw_info,
+ sizeof(*ipmi_fw_info) * (ipmi_fw_info_len + 1));
+ipmi_fw_info[ipmi_fw_info_len] = *info;
+}
+
+IPMIFwInfo *ipmi_first_fwinfo(void)
+{
+return ipmi_fw_info;
+}
+
+IPMIFwInfo *ipmi_next_fwinfo(IPMIFwInfo *current)
+{
+current++;
+if (current >= &ipmi_fw_info[ipmi_fw_info_len]) {
+return NULL;
+}
+return current;
+}
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index e4f7738..74e84a0 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -168,6 +168,41 @@ typedef struct IPMIBmcClass {
  */
 void ipmi_bmc_find_and_link(Object *obj, Object **bmc);
 
+/*
+ * Used for transferring information to interfaces that add 
+ * entries to firmware tables.
+ */
+typedef struct IPMIFwInfo {
+const char *interface_name;
+int interface_type;
+uint8_t ipmi_spec_major_revision;
+uint8_t ipmi_spec_minor_revision;
+uint8_t i2c_slave_address;
+uint32_t uuid;
+
+uint64_t base_address;
+uint64_t register_length;
+uint8_t register_spacing;
+enum {
+IPMI_MEMSPACE_IO,
+IPMI_MEMSPACE_MEM32,
+IPMI_MEMSPACE_MEM64,
+IPMI_MEMSPACE_SMBUS
+} memspace;
+
+int interrupt_number;
+enum {
+IPMI_LEVEL_IRQ,
+IPMI_EDGE_IRQ
+} irq_type;
+
+const char *acpi_parent;
+} IPMIFwInfo;
+
+void ipmi_add_fwinfo(IPMIFwInfo *info, Error **errp);
+IPMIFwInfo *ipmi_first_fwinfo(void);
+IPMIFwInfo *ipmi_next_fwinfo(IPMIFwInfo *current);
+
 #ifdef IPMI_DEBUG
 #define ipmi_debug(fs, ...) \
 fprintf(stderr, "IPMI (%s): " fs, __func__, ##__VA_ARGS__)
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 0/7] vl: graphics stubs + #ifdef cleanup

2015-11-12 Thread Eduardo Habkost
Clean up the graphics initialization code to reduce the number of

Changes v1 -> v2:
* Patches 2-6: Move stub files to stubs/ui/
* Patch 7: Move stubs to qemu-spice.h, as the header file
  already had a separate section for !CONFIG_SPICE
* Removed DT_NOGRAPHIC patches from the series (they will be sent
  as a separate series)

Eduardo Habkost (7):
  vl: Add DT_COCOA DisplayType value
  stubs: VNC initialization stubs
  stubs: curses_display_init() stub
  stubs: SDL initialization stubs
  stubs: cocoa_display_init() stub
  stubs: gtk_display_init() stub
  spice: Initialization stubs on qemu-spice.h

 include/sysemu/sysemu.h |  1 +
 include/ui/console.h|  4 ++--
 include/ui/qemu-spice.h | 13 +
 stubs/Makefile.objs |  1 +
 stubs/ui/Makefile.objs  |  5 +
 stubs/ui/cocoa.c| 10 ++
 stubs/ui/curses.c   | 10 ++
 stubs/ui/gtk.c  | 10 ++
 stubs/ui/sdl.c  | 17 +
 stubs/ui/vnc.c  | 22 ++
 vl.c| 37 ++---
 11 files changed, 97 insertions(+), 33 deletions(-)
 create mode 100644 stubs/ui/Makefile.objs
 create mode 100644 stubs/ui/cocoa.c
 create mode 100644 stubs/ui/curses.c
 create mode 100644 stubs/ui/gtk.c
 create mode 100644 stubs/ui/sdl.c
 create mode 100644 stubs/ui/vnc.c

-- 
2.1.0




[Qemu-devel] [PATCH v2 3/7] stubs: curses_display_init() stub

2015-11-12 Thread Eduardo Habkost
One less #ifdef in vl.c.

Signed-off-by: Eduardo Habkost 
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
---
 stubs/ui/Makefile.objs |  1 +
 stubs/ui/curses.c  | 10 ++
 vl.c   |  2 --
 3 files changed, 11 insertions(+), 2 deletions(-)
 create mode 100644 stubs/ui/curses.c

diff --git a/stubs/ui/Makefile.objs b/stubs/ui/Makefile.objs
index 16ea29a..2f63c58 100644
--- a/stubs/ui/Makefile.objs
+++ b/stubs/ui/Makefile.objs
@@ -1 +1,2 @@
 stub-obj-y += vnc.o
+stub-obj-y += curses.o
diff --git a/stubs/ui/curses.c b/stubs/ui/curses.c
new file mode 100644
index 000..2115c77
--- /dev/null
+++ b/stubs/ui/curses.c
@@ -0,0 +1,10 @@
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/error-report.h"
+
+void curses_display_init(DisplayState *ds, int full_screen)
+{
+/* This must never be called if CONFIG_CURSES is disabled */
+error_report("curses support is disabled");
+abort();
+}
diff --git a/vl.c b/vl.c
index 0558e87..3ca1c11 100644
--- a/vl.c
+++ b/vl.c
@@ -4568,11 +4568,9 @@ int main(int argc, char **argv, char **envp)
 case DT_NOGRAPHIC:
 (void)ds;  /* avoid warning if no display is configured */
 break;
-#if defined(CONFIG_CURSES)
 case DT_CURSES:
 curses_display_init(ds, full_screen);
 break;
-#endif
 #if defined(CONFIG_SDL)
 case DT_SDL:
 sdl_display_init(ds, full_screen, no_frame);
-- 
2.1.0




[Qemu-devel] [PATCH v2 1/7] vl: Add DT_COCOA DisplayType value

2015-11-12 Thread Eduardo Habkost
Instead of reusing DT_SDL for Cocoa, use DT_COCOA to indicate
that a Cocoa display was requested.

configure already ensures CONFIG_COCOA and CONFIG_SDL are never
set at the same time. The only case where DT_SDL is used outside
a #ifdef CONFIG_SDL block is in the no_frame/alt_grab/ctrl_grab
check. That means the only user-visible change is that we will
start printing a warning if the SDL-specific options are used in
Cocoa mode. This is a bugfix, because no_frame/alt_grab/ctrl_grab
are not used by Cocoa code.

Cc: Andreas Färber 
Cc: Peter Maydell 
Signed-off-by: Eduardo Habkost 
---
 include/sysemu/sysemu.h | 1 +
 vl.c| 6 --
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index f992494..0f4e520 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -137,6 +137,7 @@ typedef enum DisplayType
 DT_DEFAULT,
 DT_CURSES,
 DT_SDL,
+DT_COCOA,
 DT_GTK,
 DT_NOGRAPHIC,
 DT_NONE,
diff --git a/vl.c b/vl.c
index 7d993a5..bba1b0a 100644
--- a/vl.c
+++ b/vl.c
@@ -4247,8 +4247,10 @@ int main(int argc, char **argv, char **envp)
 if (display_type == DT_DEFAULT && !display_remote) {
 #if defined(CONFIG_GTK)
 display_type = DT_GTK;
-#elif defined(CONFIG_SDL) || defined(CONFIG_COCOA)
+#elif defined(CONFIG_SDL)
 display_type = DT_SDL;
+#elif defined(CONFIG_COCOA)
+display_type = DT_COCOA;
 #elif defined(CONFIG_VNC)
 vnc_parse("localhost:0,to=99,id=default", &error_abort);
 show_vnc_port = 1;
@@ -4588,7 +4590,7 @@ int main(int argc, char **argv, char **envp)
 sdl_display_init(ds, full_screen, no_frame);
 break;
 #elif defined(CONFIG_COCOA)
-case DT_SDL:
+case DT_COCOA:
 cocoa_display_init(ds, full_screen);
 break;
 #endif
-- 
2.1.0




Re: [Qemu-devel] [PATCH 1/4] spapr: Extend rtas-blob

2015-11-12 Thread Aravinda Prasad


On Thursday 12 November 2015 01:56 PM, Thomas Huth wrote:
> On 11/11/15 18:15, Aravinda Prasad wrote:
>> Extend rtas-blob to accommodate error log. Error log
>> structure is saved in rtas space upon a machine check
>> exception.
>>
>> Signed-off-by: Aravinda Prasad 
>> ---
>>  hw/ppc/spapr.c |4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 05926a3..b7b9e09 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -1556,6 +1556,10 @@ static void ppc_spapr_init(MachineState *machine)
>>  exit(1);
>>  }
>>  spapr->rtas_size = get_image_size(filename);
>> +
>> +/* Resize blob to accommodate error log. */
>> +spapr->rtas_size = TARGET_PAGE_ALIGN(spapr->rtas_size);
>> +
>>  spapr->rtas_blob = g_malloc(spapr->rtas_size);
>>  if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
>>  error_report("Could not load LPAR rtas '%s'", filename);
> 
> Sorry to say that, but this patch is horrible!
> 
> 1) If the rtas blob ever gets bigger than 512 bytes, we will get
> "random" corruption of the RTAS code later when an NMI occurs since the
> mc log is blindly copied into the RTAS area later!
> ==> Please add an "assert(spapr->rtas_size < RTAS_ERRLOG_OFFSET)" at the
> beginning of your patch.

It is good to add an assert. Will include in next revision.

> 
> 2) Why resizing with TARGET_PAGE_ALIGN() ? In the very worst case, this
> would not change the size at all (if the rtas_size is already a multiple
> of PAGE_SIZE)
> ==> Please set the size to a proper value like
>  RTAS_ERRLOG_OFFSET + sizeof(struct rtas_mc_log)
> instead!

sure will add it.

Regards,
Aravinda

> 
>  Thomas
> 

-- 
Regards,
Aravinda




Re: [Qemu-devel] [PULL 0/6] Migration pull request

2015-11-12 Thread Peter Maydell
On 12 November 2015 at 17:20, Juan Quintela  wrote:
> Hi
>
> - fix for mutex initialzation (dave)
> - different page sizes fixes (dave)
> - better text (dave)
> - Migration 32bits fixes (myself)
>
> Please, apply.
>
> The following changes since commit ed6c64489ef11d9ac5fb4b4c89d455a4f1ae8083:
>
>   target-arm: Update PC before calling gen_helper_check_breakpoints() 
> (2015-11-12 16:16:02 +)
>
> are available in the git repository at:
>
>   git://github.com/juanquintela/qemu.git tags/migration/20151112
>
> for you to fetch changes up to 389775d1f67b2c8f44f9473b1e5363735972e389:
>
>   migration_init: Fix lock initialisation/make it explicit (2015-11-12 
> 17:55:27 +0100)
>
> ----
> migration/next for 20151112
>
> 

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCH 3/4] spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls

2015-11-12 Thread Aravinda Prasad


On Thursday 12 November 2015 02:53 PM, Thomas Huth wrote:
> On 11/11/15 18:15, Aravinda Prasad wrote:
>> This patch adds support in QEMU to handle "ibm,nmi-register"
>> and "ibm,nmi-interlock" RTAS calls.
>>
>> The machine check notification address is saved when the
>> OS issues "ibm,nmi-register" RTAS call.
>>
>> This patch also handles the case when multiple processors
>> experience machine check at or about the same time by
>> handling "ibm,nmi-interlock" call. In such cases, as per
>> PAPR, subsequent processors serialize waiting for the first
>> processor to issue the "ibm,nmi-interlock" call. The second
>> processor waits till the first processor, which also
>> received a machine check error, is done reading the error
>> log. The first processor issues "ibm,nmi-interlock" call
>> when the error log is consumed. This patch implements the
>> releasing part of the error-log while subsequent patch
>> (which builds error log) handles the locking part.
>>
>> Signed-off-by: Aravinda Prasad 
>> ---
>>  hw/ppc/spapr_rtas.c|   29 +
>>  include/hw/ppc/spapr.h |8 +++-
>>  2 files changed, 36 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr_rtas.c b/hw/ppc/spapr_rtas.c
>> index 9869bc9..fd4d2af 100644
>> --- a/hw/ppc/spapr_rtas.c
>> +++ b/hw/ppc/spapr_rtas.c
>> @@ -597,6 +597,31 @@ out:
>>  rtas_st(rets, 0, rc);
>>  }
>>  
>> +static void rtas_ibm_nmi_register(PowerPCCPU *cpu,
>> +  sPAPRMachineState *spapr,
>> +  uint32_t token, uint32_t nargs,
>> +  target_ulong args,
>> +  uint32_t nret, target_ulong rets)
>> +{
>> +qemu_mutex_init(&spapr->mc_in_progress);
>> +spapr->guest_machine_check_addr = rtas_ld(args, 1);
>> +rtas_st(rets, 0, RTAS_OUT_SUCCESS);
>> +}
>> +
>> +static void rtas_ibm_nmi_interlock(PowerPCCPU *cpu,
>> +   sPAPRMachineState *spapr,
>> +   uint32_t token, uint32_t nargs,
>> +   target_ulong args,
>> +   uint32_t nret, target_ulong rets)
>> +{
>> +/*
>> + * VCPU issuing "ibm,nmi-interlock" is done with NMI handling,
>> + * hence unlock mc_in_progress.
>> + */
>> +qemu_mutex_unlock(&spapr->mc_in_progress);
>> +rtas_st(rets, 0, RTAS_OUT_SUCCESS);
>> +}
> 
> Maybe the interlock function should return an error if the nmi_register
> function has not been called before? OTOH, RTAS is not supposed to do
> excessive parameter checking, so this is maybe not worth the effort.

This will be a simple check to see if spapr->guest_machine_check_addr is
set. I will include it.

Regards,
Aravinda

> 
>  Thomas
> 
> 

-- 
Regards,
Aravinda




[Qemu-devel] [PATCH for-2.5 v2] input: Document why x-input-send-event is still experimental

2015-11-12 Thread Eric Blake
The x-input-send-event command was introduced in 2.2 with mention
that it is experimental, but now that several releases have elapsed
without any changes, it would be nice to document why that was done
and should still remain experimental in 2.5.

Meanwhile, our documentation states that we prefer 'lower-case',
rather than 'CamelCase', for qapi enum values.  The InputButton and
InputAxis enums violate this convention.  However, because they are
currently used primarily for generating code that is used internally;
and their only exposure through QMP is via the experimental
'x-input-send-event' command, we are free to change their spelling.
Of course, it would be nicer to delay such a change until the same
time we promote the command to non-experimental.  Adding
documentation will help us remember to do that rename.

We have plans to tighten the qapi generator to flag instances of
inconsistent use of naming conventions; if that lands first, it
will just need to whitelist these exceptions until the time we
settle on the final interface.

Fix a typo in the docs for InputAxis while at it.

Signed-off-by: Eric Blake 
---
v2: Rather than changing spelling, just document things

 qapi-schema.json | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index 36e59b8..323d8ea 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3577,16 +3577,22 @@
 # Button of a pointer input device (mouse, tablet).
 #
 # Since: 2.0
+#
+# Note that the spelling of these values may change when the
+# x-input-send-event is promoted out of experimental status.
 ##
 { 'enum'  : 'InputButton',
   'data'  : [ 'Left', 'Middle', 'Right', 'WheelUp', 'WheelDown' ] }

 ##
-# @InputButton
+# @InputAxis
 #
 # Position axis of a pointer input device (mouse, tablet).
 #
 # Since: 2.0
+#
+# Note that the spelling of these values may change when the
+# x-input-send-event is promoted out of experimental status.
 ##
 { 'enum'  : 'InputAxis',
   'data'  : [ 'X', 'Y' ] }
@@ -3677,7 +3683,10 @@
 #
 # Since: 2.2
 #
-# Note: this command is experimental, and not a stable API.
+# Note: this command is experimental, and not a stable API.  Things that
+# might change before it becomes stable include the spelling of enum
+# values for InputButton and InputAxis, and the notion of how to designate
+# which console will receive the event.
 #
 ##
 { 'command': 'x-input-send-event',
-- 
2.4.3




Re: [Qemu-devel] [PATCH 4/4] target-ppc: Handle NMI guest exit

2015-11-12 Thread Aravinda Prasad


On Thursday 12 November 2015 03:10 PM, Thomas Huth wrote:
> On 12/11/15 09:09, Thomas Huth wrote:
>> On 11/11/15 18:16, Aravinda Prasad wrote:
>>> Memory error such as bit flips that cannot be corrected
>>> by hardware are passed on to the kernel for handling.
>>> If the memory address in error belongs to guest then
>>> guest kernel is responsible for taking suitable action.
>>> Patch [1] enhances KVM to exit guest with exit reason
>>> set to KVM_EXIT_NMI in such cases.
>>>
>>> This patch handles KVM_EXIT_NMI exit. If the guest OS
>>> has registered the machine check handling routine by
>>> calling "ibm,nmi-register", then the handler builds
>>> the error log and invokes the registered handler else
>>> invokes the handler at 0x200.
>>>
>>> [1] http://marc.info/?l=kvm-ppc&m=144726114408289
>>>
>>> Signed-off-by: Aravinda Prasad 
>>> ---
>>>  target-ppc/kvm.c |   69 +++
>>>  target-ppc/kvm_ppc.h |   81 
>>> ++
>>>  2 files changed, 150 insertions(+)
>>>
>>> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
>>> index 110436d..e2e5170 100644
>>> --- a/target-ppc/kvm.c
>>> +++ b/target-ppc/kvm.c
>>> @@ -1665,6 +1665,11 @@ int kvm_arch_handle_exit(CPUState *cs, struct 
>>> kvm_run *run)
>>>  ret = 0;
>>>  break;
>>>  
>>> +case KVM_EXIT_NMI:
>>> +DPRINTF("handle NMI exception\n");
>>> +ret = kvm_handle_nmi(cpu);
>>> +break;
>>> +
>>>  default:
>>>  fprintf(stderr, "KVM: unknown exit reason %d\n", run->exit_reason);
>>>  ret = -1;
>>> @@ -2484,3 +2489,67 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
>>>  {
>>>  return data & 0x;
>>>  }
>>> +
>>> +int kvm_handle_nmi(PowerPCCPU *cpu)
>>> +{
>>> +struct rtas_mc_log mc_log;
>>> +CPUPPCState *env = &cpu->env;
>>> +sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
>>> +PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
>>> +
>>> +cpu_synchronize_state(CPU(ppc_env_get_cpu(env)));
>>> +
>>> +/* Properly set bits in MSR before we invoke the handler */
>>> +env->msr = 0;
>>> +
>>> +if (!(*pcc->interrupts_big_endian)(cpu)) {
>>> +env->msr |= (1ULL << MSR_LE);
>>> +}
>>> +
>>> +#ifdef TARGET_PPC64
>>> +env->msr |= (1ULL << MSR_SF);
>>> +#endif
>>> +
>>> +if (!spapr->guest_machine_check_addr) {
>>> +/*
>>> + * If OS has not registered with "ibm,nmi-register"
>>> + * jump to 0x200
>>> + */
>>
>> Shouldn't you also check MSR_ME here first and enter checkstop when
>> machine checks are disabled?
>> Also I think you have to set up some more registers for machine check
>> interrupts, like SRR0 and SRR1?
>>
>>> +env->nip = 0x200;
>>> +return 0;
>>> +}
>>> +
>>> +qemu_mutex_lock(&spapr->mc_in_progress);
>>
>> Using a mutex here is definitely wrong. The kvm_arch_handle_exit() code
>> is run under the Big QEMU Lock™ (see qemu_mutex_lock_iothread() in
>> kvm_cpu_exec()),
> 
> In case you're looking for the calls, I just noticed that the
> qemu_mutex_lock_iothread() have recently been pushed into
> kvm_arch_handle_exit() itself.

ok thanks for pointing out.

> 
>> so if you would ever get one thread waiting for this
>> mutex here, it could never be unlocked again in rtas_ibm_nmi_interlock()
>> because the other code would wait forever to get the BQL ==> Deadlock.
>>
>> I think if you want to be able to handle multiple NMIs at once, you
>> likely need something like an error log per CPU instead. And if an NMI
>> happens one CPU while there is already a NMI handler running on the very
>> same CPU, you could likely simply track this with an boolean variable
>> and put the CPU into checkstop if this happens?
> 
> Ok, I now had a look into the LoPAPR spec, and if I've got that right,
> you really have to serialize the NMIs in case they happen at multiple
> CPUs at the same time. So I guess the best thing you can do here is
> something like:
> 
>while (spapr->mc_in_progress) {
>/*
> * There is already another NMI in progress, thus we need
> * to yield here to wait until it has been finsihed
> */
>qemu_mutex_unlock_iothread();
>usleep(10);
>qemu_mutex_lock_iothread();
>}
>spapr->mc_in_progress = true;

Above piece of code should help. I will modify accordingly in the next
revision.

> 
> Also LoPAPR talks about 'subsequent processors report "fatal error
> previously reported"', so maybe the other processors should report that
> condition in this case?

I feel guest kernel is responsible for that or does that mean that qemu
should report the same error, which first processor encountered, for
subsequent processors? In that case what if the error encountered by
first processor was recovered.

> And of course you've also got to check that the same CPU is not getting
> multiple NMIs before the interlock function has been called again.

I think it is g

Re: [Qemu-devel] [OpenBIOS] CUDA has problems with Mac OS 10.4

2015-11-12 Thread BALATON Zoltan

On Thu, 12 Nov 2015, Programmingkid wrote:

On Nov 11, 2015, at 6:14 PM, BALATON Zoltan wrote:
better but some OSes may depend on ADB for now. I've noticed Finnix had 
no keyboard in debug mode without ADB (which may be a bug in Finnix, I 
could not verify if it works on real hardware or has the same problem 
there).


Interesting. Did you use "-usb -device usb-keyboard" to enable usb 
support in QEMU when running Finnix?


Yes (or more exactly I had a patch always adding usb keyboard instead of 
adb one to match hardware) and I think it worked once booted fully but 
with debug I could only type with ADB keyboard. Maybe it's only that ADB 
driver is compiled in the Finnix kernel while OHCI is not. I did not 
investigate.


Regards,
BALATON Zoltan



[Qemu-devel] [PATCH] tests: Ignore test-blockjob-txn

2015-11-12 Thread Eric Blake
Commit 6c6f312d added a new test, but did not mark it for
exclusion in .gitignore.

Signed-off-by: Eric Blake 
---

Yeah, I know this affects only non-VPATH builds, which we don't
recommend, but we might as well be consistent.

 tests/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/.gitignore b/tests/.gitignore
index e96f569..de5e793 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,6 +9,7 @@ check-qom-proplist
 rcutorture
 test-aio
 test-bitops
+test-blockjob-txn
 test-coroutine
 test-crypto-cipher
 test-crypto-hash
-- 
2.4.3




Re: [Qemu-devel] [PULL 17/24] qom/object: fix 2 comment typos

2015-11-12 Thread Michael Tokarev
12.11.2015 20:53, Andreas Färber wrote:
> Am 06.11.2015 um 13:43 schrieb Michael Tokarev:
>> From: Cao jin 
>>
>> Also change the misleading definition of macro OBJECT_CLASS_CHECK
>>
>> Signed-off-by: Cao jin 
>> Signed-off-by: Michael Tokarev 
> 
> Michael, please *STOP* queuing QOM patches! You merged the unfixed

I think I do more harm to the project than good, these days.

> version now - it's supposed to have just "qom:", and the parenthesis and
> full stop are missing, too, that I had on qom-next before it disappeared
> with today's rebase...
> 
> And why was I not CC'ed on this submission as include/qom/object.h
> maintainer? You did not reply to the patch either, where I did.

I didn't reply there because I wanted to remove the patch, exactly
because you replied to the thread.  It looks like I forgot to remove
it from the -trivial tree.

Now, in the original thread, you said you only tweaked the commit
(subject) message.  Is it really that bad in the original submission?

Thanks,

/mjt



Re: [Qemu-devel] [PULL 23/44] tests: add BlockJobTxn unit test

2015-11-12 Thread Eric Blake
On 11/10/2015 07:14 AM, Stefan Hajnoczi wrote:
> The BlockJobTxn unit test verifies that both single jobs and pairs of
> jobs behave as a transaction group.  Either all jobs complete
> successfully or the group is cancelled.
> 
> Signed-off-by: Stefan Hajnoczi 
> Reviewed-by: Max Reitz 
> Reviewed-by: John Snow 
> Signed-off-by: Fam Zheng 
> Signed-off-by: John Snow 
> Message-id: 1446765200-3054-15-git-send-email-js...@redhat.com
> Signed-off-by: Stefan Hajnoczi 
> ---

> @@ -390,6 +392,7 @@ tests/test-coroutine$(EXESUF): tests/test-coroutine.o 
> $(test-block-obj-y)
>  tests/test-aio$(EXESUF): tests/test-aio.o $(test-block-obj-y)
>  tests/test-rfifolock$(EXESUF): tests/test-rfifolock.o $(test-util-obj-y)
>  tests/test-throttle$(EXESUF): tests/test-throttle.o $(test-block-obj-y)
> +tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o 
> $(test-block-obj-y) $(test-util-obj-y)

This commit creates a tests/test-blockjob-txn binary, but doesn't add it
to tests/.gitignore.  When doing a non-VPATH build, that results in an
unclean tree (yeah, I know we recommend VPATH builds, but we already
have precedence for ignoring all other test binaries when doing
non-VPATH builds).

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



signature.asc
Description: OpenPGP digital signature


  1   2   3   4   >