Re: [Qemu-devel] [PATCH 11/12] qdev: add enum property types to QAPI schema

2014-01-31 Thread Markus Armbruster
Paolo Bonzini pbonz...@redhat.com writes:

 Prepare for when QOM introspection will be able to piggyback on the QAPI
 schema for describing property types.

 Signed-off-by: Paolo Bonzini pbonz...@redhat.com
 ---
  hw/core/qdev-properties.c | 18 +++
  hw/i386/kvm/i8254.c   |  6 ++---
  hw/timer/mc146818rtc.c| 14 ++--
  include/hw/block/block.h  |  6 -
  include/qemu-common.h |  8 ---
  qapi-schema.json  | 58 
 +++
  6 files changed, 71 insertions(+), 39 deletions(-)

 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
 index 2c3a756..0a2ca05 100644
 --- a/hw/core/qdev-properties.c
 +++ b/hw/core/qdev-properties.c
 @@ -449,34 +449,22 @@ PropertyInfo qdev_prop_macaddr = {
  
  /* --- lost tick policy --- */
  
 -static const char *lost_tick_policy_table[LOST_TICK_MAX+1] = {
 -[LOST_TICK_DISCARD] = discard,
 -[LOST_TICK_DELAY] = delay,
 -[LOST_TICK_MERGE] = merge,
 -[LOST_TICK_SLEW] = slew,
 -[LOST_TICK_MAX] = NULL,
 -};
 -
  QEMU_BUILD_BUG_ON(sizeof(LostTickPolicy) != sizeof(int));
  
  PropertyInfo qdev_prop_losttickpolicy = {
  .name  = LostTickPolicy,
 -.enum_table  = lost_tick_policy_table,
 +.enum_table  = LostTickPolicy_lookup,
  .get   = get_enum,
  .set   = set_enum,
  };
  
  /* --- BIOS CHS translation */
  
 -static const char *bios_chs_trans_table[] = {
 -[BIOS_ATA_TRANSLATION_AUTO] = auto,
 -[BIOS_ATA_TRANSLATION_NONE] = none,
 -[BIOS_ATA_TRANSLATION_LBA]  = lba,
 -};
 +QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));

Recognized values before your patch: auto, none, lba.

  
  PropertyInfo qdev_prop_bios_chs_trans = {
  .name = bios-chs-trans,
 -.enum_table = bios_chs_trans_table,
 +.enum_table = BiosAtaTranslation_lookup,
  .get = get_enum,
  .set = set_enum,
  };
 diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
 index f8f3021..59373aa 100644
 --- a/hw/i386/kvm/i8254.c
 +++ b/hw/i386/kvm/i8254.c
 @@ -268,9 +268,9 @@ static void kvm_pit_realizefn(DeviceState *dev, Error 
 **errp)
  return;
  }
  switch (s-lost_tick_policy) {
 -case LOST_TICK_DELAY:
 +case LOST_TICK_POLICY_DELAY:
  break; /* enabled by default */
 -case LOST_TICK_DISCARD:
 +case LOST_TICK_POLICY_DISCARD:
  if (kvm_check_extension(kvm_state, KVM_CAP_REINJECT_CONTROL)) {
  struct kvm_reinject_control control = { .pit_reinject = 0 };
  
 @@ -300,7 +300,7 @@ static void kvm_pit_realizefn(DeviceState *dev, Error 
 **errp)
  static Property kvm_pit_properties[] = {
  DEFINE_PROP_UINT32(iobase, PITCommonState, iobase,  -1),
  DEFINE_PROP_LOSTTICKPOLICY(lost_tick_policy, KVMPITState,
 -   lost_tick_policy, LOST_TICK_DELAY),
 +   lost_tick_policy, LOST_TICK_POLICY_DELAY),
  DEFINE_PROP_END_OF_LIST(),
  };
  
 diff --git a/hw/timer/mc146818rtc.c b/hw/timer/mc146818rtc.c
 index 6fb124f..8509309 100644
 --- a/hw/timer/mc146818rtc.c
 +++ b/hw/timer/mc146818rtc.c
 @@ -185,7 +185,7 @@ static void rtc_periodic_timer(void *opaque)
  if (s-cmos_data[RTC_REG_B]  REG_B_PIE) {
  s-cmos_data[RTC_REG_C] |= REG_C_IRQF;
  #ifdef TARGET_I386
 -if (s-lost_tick_policy == LOST_TICK_SLEW) {
 +if (s-lost_tick_policy == LOST_TICK_POLICY_SLEW) {
  if (s-irq_reinject_on_ack_count = RTC_REINJECT_ON_ACK_COUNT)
  s-irq_reinject_on_ack_count = 0;
  apic_reset_irq_delivered();
 @@ -708,7 +708,7 @@ static int rtc_post_load(void *opaque, int version_id)
  
  #ifdef TARGET_I386
  if (version_id = 2) {
 -if (s-lost_tick_policy == LOST_TICK_SLEW) {
 +if (s-lost_tick_policy == LOST_TICK_POLICY_SLEW) {
  rtc_coalesced_timer_update(s);
  }
  }
 @@ -749,7 +749,7 @@ static void rtc_notify_clock_reset(Notifier *notifier, 
 void *data)
  periodic_timer_update(s, now);
  check_update_timer(s);
  #ifdef TARGET_I386
 -if (s-lost_tick_policy == LOST_TICK_SLEW) {
 +if (s-lost_tick_policy == LOST_TICK_POLICY_SLEW) {
  rtc_coalesced_timer_update(s);
  }
  #endif
 @@ -774,7 +774,7 @@ static void rtc_reset(void *opaque)
  qemu_irq_lower(s-irq);
  
  #ifdef TARGET_I386
 -if (s-lost_tick_policy == LOST_TICK_SLEW) {
 +if (s-lost_tick_policy == LOST_TICK_POLICY_SLEW) {
  s-irq_coalesced = 0;
  }
  #endif
 @@ -835,11 +835,11 @@ static void rtc_realizefn(DeviceState *dev, Error 
 **errp)
  
  #ifdef TARGET_I386
  switch (s-lost_tick_policy) {
 -case LOST_TICK_SLEW:
 +case LOST_TICK_POLICY_SLEW:
  s-coalesced_timer =
  timer_new_ns(rtc_clock, rtc_coalesced_timer, s);
  break;
 -case LOST_TICK_DISCARD:
 +case LOST_TICK_POLICY_DISCARD:
  break;
  default:
  error_setg(errp, Invalid lost tick policy.);
 @@ -890,7 +890,7 @@ ISADevice 

Re: [Qemu-devel] [PATCH v2] block: handle rechs and large translation options

2014-01-31 Thread Markus Armbruster
Paolo Bonzini pbonz...@redhat.com writes:

 Sure, CHS translation is an obscure topic, and legacy options for
 hard-disk geometries are obscure as well.  But since QEMU does nothing
 with it except telling the BIOS, and since there large and rechs
 are listed in the enums, parsing them seems to be the bare minimum.

 Signed-off-by: Paolo Bonzini pbonz...@redhat.com

This is semantically on top of [PATCH 00/12] qdev: cleanup legacy
properties, which adds these two values to isa-hd property
bios-chs-trans.  Here, you add them to the two obsolete ways to specify
the property.  While I don't think that's necessary, I don't object to
it either.

Despite my doubts on the need for the patch:

Reviewed-by: Markus Armbruster arm...@redhat.com



Re: [Qemu-devel] [PATCHv7 1/5] block: add native support for NFS

2014-01-31 Thread Stefan Hajnoczi
On Thu, Jan 30, 2014 at 10:35 PM, Peter Lieven p...@kamp.de wrote:

 Am 30.01.2014 um 15:22 schrieb Stefan Hajnoczi stefa...@gmail.com:

 On Wed, Jan 29, 2014 at 05:19:59PM +0100, Benoît Canet wrote:
 Le Wednesday 29 Jan 2014 à 09:50:21 (+0100), Peter Lieven a écrit :
 +static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
 + Error **errp) {
 +NFSClient *client = bs-opaque;
 +int64_t ret;
 +QemuOpts *opts;
 +Error *local_err = NULL;
 +
 +opts = qemu_opts_create(runtime_opts, NULL, 0, error_abort);
 +qemu_opts_absorb_qdict(opts, options, local_err);
 +if (error_is_set(local_err)) {
 +qerror_report_err(local_err);
 I have seen more usage of error_propagate(errp, local_err); in QEMU code.
 Maybe I am missing the point.

 Yes, I think you are right.  The Error should be propagated to the
 caller.  It's not clear to me whether we can ever get an error from
 qemu_opts_absorb_qdict() in this call site though.

 Is there any action I should take here? If yes, can you advise what
 to do please.

The issue is that nfs_file_open() takes an Error **errp argument.
This means the function should report detailed errors using the Error
object.

The patch prints and then discards the local_error instead of
propagating it to the caller's errp.

We should just propagate the error instead of printing it:
if (error_is_set(local_err)) {
error_propagate(errp, local_err);
goto ...;
}

Stefan



Re: [Qemu-devel] [PATCHv7 1/5] block: add native support for NFS

2014-01-31 Thread Peter Lieven

On 31.01.2014 09:57, Stefan Hajnoczi wrote:

On Thu, Jan 30, 2014 at 10:35 PM, Peter Lieven p...@kamp.de wrote:

Am 30.01.2014 um 15:22 schrieb Stefan Hajnoczi stefa...@gmail.com:


On Wed, Jan 29, 2014 at 05:19:59PM +0100, Benoît Canet wrote:

Le Wednesday 29 Jan 2014 à 09:50:21 (+0100), Peter Lieven a écrit :

+static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
+ Error **errp) {
+NFSClient *client = bs-opaque;
+int64_t ret;
+QemuOpts *opts;
+Error *local_err = NULL;
+
+opts = qemu_opts_create(runtime_opts, NULL, 0, error_abort);
+qemu_opts_absorb_qdict(opts, options, local_err);
+if (error_is_set(local_err)) {
+qerror_report_err(local_err);

I have seen more usage of error_propagate(errp, local_err); in QEMU code.
Maybe I am missing the point.

Yes, I think you are right.  The Error should be propagated to the
caller.  It's not clear to me whether we can ever get an error from
qemu_opts_absorb_qdict() in this call site though.

Is there any action I should take here? If yes, can you advise what
to do please.

The issue is that nfs_file_open() takes an Error **errp argument.
This means the function should report detailed errors using the Error
object.

The patch prints and then discards the local_error instead of
propagating it to the caller's errp.

We should just propagate the error instead of printing it:
if (error_is_set(local_err)) {
 error_propagate(errp, local_err);
 goto ...;


Ok, you are just referring to this part in nfs_file_open:

if (error_is_set(local_err)) {
qerror_report_err(local_err);
error_free(local_err);
return -EINVAL;
}

which I would change to:

if (error_is_set(local_err)) {
error_propagate(errp, local_err);
return -EINVAL;
}

The use of error_setg in nfs_client_open is ok?

Peter



[Qemu-devel] [PULL 0/5] s390/kvm: fixes and features

2014-01-31 Thread Christian Borntraeger
Anthony, Peter,

The following changes since commit 1cf892ca2689c84960b4ce4d2723b6bee453711c:

  SPARC: Fix LEON3 power down instruction (2014-01-15 15:37:33 +1000)

are available in the git repository at:

  git://github.com/borntraeger/qemu.git tags/kvm-s390-20140131

for you to fetch changes up to 44c68de0445677728700651ed4e2d2063f36f9ed:

  s390x/kvm: cleanup partial register handling (2014-01-31 09:43:44 +0100)


This patch set contains the sclp defines and events for cpu hotplug,
the initial sclp defines (without code yet) for standby memory (some
sort of memory hotplug) as well as a cleanup of the kvm register
synchronization.


Dominik Dingel (1):
  s390x/kvm: cleanup partial register handling

Jason J. Herne (3):
  s390-sclp: Define New SCLP Codes
  s390-sclp: SCLP CPU Info
  s390-sclp: SCLP Event integration

Matthew Rosato (1):
  sclp-s390: Define new SCLP codes and structures

 hw/s390x/Makefile.objs|   1 +
 hw/s390x/event-facility.c |   6 ++
 hw/s390x/sclp.c   |  53 ++-
 hw/s390x/sclpcpu.c| 112 +++
 include/hw/s390x/event-facility.h |   5 ++
 include/hw/s390x/sclp.h   |  75 +
 target-s390x/cpu.h|  17 -
 target-s390x/kvm.c| 136 +++---
 8 files changed, 304 insertions(+), 101 deletions(-)
 create mode 100644 hw/s390x/sclpcpu.c




[Qemu-devel] [PULL 3/5] s390-sclp: SCLP Event integration

2014-01-31 Thread Christian Borntraeger
From: Jason J. Herne jjhe...@us.ibm.com

Add an sclp event for cpu was hot plugged.  This allows Qemu to deliver an
SCLP interrupt to the guest stating that the requested cpu hotplug was
completed.

Signed-off-by: Jason J. Herne jjhe...@us.ibm.com
Reviewed-by: Andreas Färber afaer...@suse.de
Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 hw/s390x/Makefile.objs|   1 +
 hw/s390x/event-facility.c |   6 ++
 hw/s390x/sclpcpu.c| 112 ++
 include/hw/s390x/event-facility.h |   5 ++
 include/hw/s390x/sclp.h   |   1 +
 5 files changed, 125 insertions(+)
 create mode 100644 hw/s390x/sclpcpu.c

diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
index 77e1218..1ba6c3a 100644
--- a/hw/s390x/Makefile.objs
+++ b/hw/s390x/Makefile.objs
@@ -3,6 +3,7 @@ obj-y += s390-virtio-hcall.o
 obj-y += sclp.o
 obj-y += event-facility.o
 obj-y += sclpquiesce.o
+obj-y += sclpcpu.o
 obj-y += ipl.o
 obj-y += css.o
 obj-y += s390-virtio-ccw.o
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 25951a0..a73c0b9 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -32,6 +32,8 @@ struct SCLPEventFacility {
 unsigned int receive_mask;
 };
 
+SCLPEvent cpu_hotplug;
+
 /* return true if any child has event pending set */
 static bool event_pending(SCLPEventFacility *ef)
 {
@@ -335,6 +337,10 @@ static int init_event_facility(S390SCLPDevice *sdev)
 }
 qdev_init_nofail(quiesce);
 
+object_initialize(cpu_hotplug, sizeof(cpu_hotplug), 
TYPE_SCLP_CPU_HOTPLUG);
+qdev_set_parent_bus(DEVICE(cpu_hotplug), BUS(event_facility-sbus));
+object_property_set_bool(OBJECT(cpu_hotplug), true, realized, NULL);
+
 return 0;
 }
 
diff --git a/hw/s390x/sclpcpu.c b/hw/s390x/sclpcpu.c
new file mode 100644
index 000..b9c238a
--- /dev/null
+++ b/hw/s390x/sclpcpu.c
@@ -0,0 +1,112 @@
+/*
+ * SCLP event type
+ *Signal CPU - Trigger SCLP interrupt for system CPU configure or
+ *de-configure
+ *
+ * Copyright IBM, Corp. 2013
+ *
+ * Authors:
+ *  Thang Pham thang.p...@us.ibm.com
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at your
+ * option) any later version.  See the COPYING file in the top-level directory.
+ *
+ */
+#include sysemu/sysemu.h
+#include hw/s390x/sclp.h
+#include hw/s390x/event-facility.h
+#include cpu.h
+#include sysemu/cpus.h
+#include sysemu/kvm.h
+
+typedef struct ConfigMgtData {
+EventBufferHeader ebh;
+uint8_t reserved;
+uint8_t event_qualifier;
+} QEMU_PACKED ConfigMgtData;
+
+static qemu_irq irq_cpu_hotplug; /* Only used in this file */
+
+#define EVENT_QUAL_CPU_CHANGE  1
+
+void raise_irq_cpu_hotplug(void)
+{
+qemu_irq_raise(irq_cpu_hotplug);
+}
+
+static unsigned int send_mask(void)
+{
+return SCLP_EVENT_MASK_CONFIG_MGT_DATA;
+}
+
+static unsigned int receive_mask(void)
+{
+return 0;
+}
+
+static int read_event_data(SCLPEvent *event, EventBufferHeader *evt_buf_hdr,
+   int *slen)
+{
+ConfigMgtData *cdata = (ConfigMgtData *) evt_buf_hdr;
+if (*slen  sizeof(ConfigMgtData)) {
+return 0;
+}
+
+/* Event is no longer pending */
+if (!event-event_pending) {
+return 0;
+}
+event-event_pending = false;
+
+/* Event header data */
+cdata-ebh.length = cpu_to_be16(sizeof(ConfigMgtData));
+cdata-ebh.type = SCLP_EVENT_CONFIG_MGT_DATA;
+cdata-ebh.flags |= SCLP_EVENT_BUFFER_ACCEPTED;
+
+/* Trigger a rescan of CPUs by setting event qualifier */
+cdata-event_qualifier = EVENT_QUAL_CPU_CHANGE;
+*slen -= sizeof(ConfigMgtData);
+
+return 1;
+}
+
+static void trigger_signal(void *opaque, int n, int level)
+{
+SCLPEvent *event = opaque;
+event-event_pending = true;
+
+/* Trigger SCLP read operation */
+sclp_service_interrupt(0);
+}
+
+static int irq_cpu_hotplug_init(SCLPEvent *event)
+{
+irq_cpu_hotplug = *qemu_allocate_irqs(trigger_signal, event, 1);
+return 0;
+}
+
+static void cpu_class_init(ObjectClass *oc, void *data)
+{
+SCLPEventClass *k = SCLP_EVENT_CLASS(oc);
+
+k-init = irq_cpu_hotplug_init;
+k-get_send_mask = send_mask;
+k-get_receive_mask = receive_mask;
+k-read_event_data = read_event_data;
+k-write_event_data = NULL;
+}
+
+static const TypeInfo sclp_cpu_info = {
+.name  = sclp-cpu-hotplug,
+.parent= TYPE_SCLP_EVENT,
+.instance_size = sizeof(SCLPEvent),
+.class_init= cpu_class_init,
+.class_size= sizeof(SCLPEventClass),
+};
+
+static void sclp_cpu_register_types(void)
+{
+type_register_static(sclp_cpu_info);
+}
+
+type_init(sclp_cpu_register_types)
diff --git a/include/hw/s390x/event-facility.h 
b/include/hw/s390x/event-facility.h
index 7ce7079..870edd4 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -17,10 +17,12 @@
 
 #include hw/qdev.h
 #include qemu/thread.h
+#include hw/s390x/sclp.h
 

[Qemu-devel] [PULL 5/5] s390x/kvm: cleanup partial register handling

2014-01-31 Thread Christian Borntraeger
From: Dominik Dingel din...@linux.vnet.ibm.com

The partial register handling (introduced with commits
420840e58b85f7f4e5493dca3f273566f261090a and
3474b679486caa8f6448bae974e131370f360c13 ) aimed to improve intercept
handling performance.

It made the code more complicated though. During development for life
migration/init/reset etc it turned out that this might cause several
hard to debug programming errors. With the introduction of ioeventfd
(and future irqfd patches) the qemu intercept handlers are no longer
hot-path. And therefore the partial register handling can be
removed to simplify the code.

Signed-off-by: Dominik Dingel din...@linux.vnet.ibm.com
CC: Jason J. Herne jjhe...@us.ibm.com
Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
Acked-by: Alexander Graf ag...@suse.de
---
 target-s390x/cpu.h |  17 ---
 target-s390x/kvm.c | 136 +
 2 files changed, 53 insertions(+), 100 deletions(-)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 68b5ab7..96c2b4a 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -78,11 +78,6 @@ typedef struct MchkQueue {
 uint16_t type;
 } MchkQueue;
 
-/* Defined values for CPUS390XState.runtime_reg_dirty_mask */
-#define KVM_S390_RUNTIME_DIRTY_NONE 0
-#define KVM_S390_RUNTIME_DIRTY_PARTIAL  1
-#define KVM_S390_RUNTIME_DIRTY_FULL 2
-
 typedef struct CPUS390XState {
 uint64_t regs[16]; /* GP registers */
 CPU_DoubleU fregs[16]; /* FP registers */
@@ -126,13 +121,6 @@ typedef struct CPUS390XState {
 uint64_t cputm;
 uint32_t todpr;
 
-/* on S390 the runtime register set has two dirty states:
- * a partial dirty state in which only the registers that
- * are needed all the time are fetched. And a fully dirty
- * state in which all runtime registers are fetched.
- */
-uint32_t runtime_reg_dirty_mask;
-
 CPU_COMMON
 
 /* reset does memset(0) up to here */
@@ -1076,7 +1064,6 @@ void kvm_s390_io_interrupt(S390CPU *cpu, uint16_t 
subchannel_id,
uint32_t io_int_word);
 void kvm_s390_crw_mchk(S390CPU *cpu);
 void kvm_s390_enable_css_support(S390CPU *cpu);
-int kvm_s390_get_registers_partial(CPUState *cpu);
 int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
 int vq, bool assign);
 int kvm_s390_cpu_restart(S390CPU *cpu);
@@ -1094,10 +1081,6 @@ static inline void kvm_s390_crw_mchk(S390CPU *cpu)
 static inline void kvm_s390_enable_css_support(S390CPU *cpu)
 {
 }
-static inline int kvm_s390_get_registers_partial(CPUState *cpu)
-{
-return -ENOSYS;
-}
 static inline int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier,
   uint32_t sch, int vq,
   bool assign)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index f7b7726..f60ccdc 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -152,33 +152,30 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 }
 }
 
-if (env-runtime_reg_dirty_mask == KVM_S390_RUNTIME_DIRTY_FULL) {
-reg.id = KVM_REG_S390_CPU_TIMER;
-reg.addr = (__u64)(env-cputm);
-ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
-if (ret  0) {
-return ret;
-}
+/* Do we need to save more than that? */
+if (level == KVM_PUT_RUNTIME_STATE) {
+return 0;
+}
 
-reg.id = KVM_REG_S390_CLOCK_COMP;
-reg.addr = (__u64)(env-ckc);
-ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
-if (ret  0) {
-return ret;
-}
+reg.id = KVM_REG_S390_CPU_TIMER;
+reg.addr = (__u64)(env-cputm);
+ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
+if (ret  0) {
+return ret;
+}
 
-reg.id = KVM_REG_S390_TODPR;
-reg.addr = (__u64)(env-todpr);
-ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
-if (ret  0) {
-return ret;
-}
+reg.id = KVM_REG_S390_CLOCK_COMP;
+reg.addr = (__u64)(env-ckc);
+ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
+if (ret  0) {
+return ret;
 }
-env-runtime_reg_dirty_mask = KVM_S390_RUNTIME_DIRTY_NONE;
 
-/* Do we need to save more than that? */
-if (level == KVM_PUT_RUNTIME_STATE) {
-return 0;
+reg.id = KVM_REG_S390_TODPR;
+reg.addr = (__u64)(env-todpr);
+ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, reg);
+if (ret  0) {
+return ret;
 }
 
 if (cap_sync_regs 
@@ -216,50 +213,9 @@ int kvm_arch_get_registers(CPUState *cs)
 S390CPU *cpu = S390_CPU(cs);
 CPUS390XState *env = cpu-env;
 struct kvm_one_reg reg;
-int r;
-
-r = kvm_s390_get_registers_partial(cs);
-if (r  0) {
-return r;
-}
-
-reg.id = KVM_REG_S390_CPU_TIMER;
-reg.addr = (__u64)(env-cputm);
-r = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, reg);
-if (r  0) {
-  

[Qemu-devel] [PULL 1/5] s390-sclp: Define New SCLP Codes

2014-01-31 Thread Christian Borntraeger
From: Jason J. Herne jjhe...@us.ibm.com

Define new SCLP codes to improve code readability.

Signed-off-by: Jason J. Herne jjhe...@us.ibm.com
Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 hw/s390x/sclp.c | 2 +-
 include/hw/s390x/sclp.h | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 86d6ae0..cb035e9 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -45,7 +45,7 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 {
 S390SCLPDevice *sdev = get_event_facility();
 
-switch (code) {
+switch (code  SCLP_CMD_CODE_MASK) {
 case SCLP_CMDW_READ_SCP_INFO:
 case SCLP_CMDW_READ_SCP_INFO_FORCED:
 read_SCP_info(sccb);
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 231a38a..74e8d94 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -17,6 +17,8 @@
 #include hw/sysbus.h
 #include hw/qdev.h
 
+#define SCLP_CMD_CODE_MASK  0x00ff
+
 /* SCLP command codes */
 #define SCLP_CMDW_READ_SCP_INFO 0x00020001
 #define SCLP_CMDW_READ_SCP_INFO_FORCED  0x00120001
@@ -26,6 +28,12 @@
 #define SCLP_CMD_WRITE_EVENT_DATA   0x00760005
 #define SCLP_CMD_WRITE_EVENT_MASK   0x00780005
 
+/* CPU hotplug SCLP codes */
+#define SCLP_HAS_CPU_INFO   0x0C00ULL
+#define SCLP_CMDW_READ_CPU_INFO 0x00010001
+#define SCLP_CMDW_CONFIGURE_CPU 0x00110001
+#define SCLP_CMDW_DECONFIGURE_CPU   0x0011
+
 /* SCLP response codes */
 #define SCLP_RC_NORMAL_READ_COMPLETION  0x0010
 #define SCLP_RC_NORMAL_COMPLETION   0x0020
-- 
1.8.4.2




[Qemu-devel] [PULL 2/5] s390-sclp: SCLP CPU Info

2014-01-31 Thread Christian Borntraeger
From: Jason J. Herne jjhe...@us.ibm.com

Implement the CPU data in SCLP Read SCP Info.  And implement Read CPU Info
SCLP command. This data will be used by the guest to get information about hot
plugged cpus.

Signed-off-by: Jason J. Herne jjhe...@us.ibm.com
Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 hw/s390x/sclp.c | 51 +
 include/hw/s390x/sclp.h | 32 +++
 2 files changed, 83 insertions(+)

diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index cb035e9..4e0c564 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -15,6 +15,7 @@
 #include cpu.h
 #include sysemu/kvm.h
 #include exec/memory.h
+#include sysemu/sysemu.h
 
 #include hw/s390x/sclp.h
 
@@ -31,7 +32,26 @@ static inline S390SCLPDevice *get_event_facility(void)
 static void read_SCP_info(SCCB *sccb)
 {
 ReadInfo *read_info = (ReadInfo *) sccb;
+CPUState *cpu;
 int shift = 0;
+int cpu_count = 0;
+int i = 0;
+
+CPU_FOREACH(cpu) {
+cpu_count++;
+}
+
+/* CPU information */
+read_info-entries_cpu = cpu_to_be16(cpu_count);
+read_info-offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
+read_info-highest_cpu = cpu_to_be16(max_cpus);
+
+for (i = 0; i  cpu_count; i++) {
+read_info-entries[i].address = i;
+read_info-entries[i].type = 0;
+}
+
+read_info-facilities = cpu_to_be64(SCLP_HAS_CPU_INFO);
 
 while ((ram_size  (20 + shift))  65535) {
 shift++;
@@ -41,6 +61,34 @@ static void read_SCP_info(SCCB *sccb)
 sccb-h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
 }
 
+/* Provide information about the CPU */
+static void sclp_read_cpu_info(SCCB *sccb)
+{
+ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
+CPUState *cpu;
+int cpu_count = 0;
+int i = 0;
+
+CPU_FOREACH(cpu) {
+cpu_count++;
+}
+
+cpu_info-nr_configured = cpu_to_be16(cpu_count);
+cpu_info-offset_configured = cpu_to_be16(offsetof(ReadCpuInfo, entries));
+cpu_info-nr_standby = cpu_to_be16(0);
+
+/* The standby offset is 16-byte for each CPU */
+cpu_info-offset_standby = cpu_to_be16(cpu_info-offset_configured
++ cpu_info-nr_configured*sizeof(CPUEntry));
+
+for (i = 0; i  cpu_count; i++) {
+cpu_info-entries[i].address = i;
+cpu_info-entries[i].type = 0;
+}
+
+sccb-h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
+}
+
 static void sclp_execute(SCCB *sccb, uint64_t code)
 {
 S390SCLPDevice *sdev = get_event_facility();
@@ -50,6 +98,9 @@ static void sclp_execute(SCCB *sccb, uint64_t code)
 case SCLP_CMDW_READ_SCP_INFO_FORCED:
 read_SCP_info(sccb);
 break;
+case SCLP_CMDW_READ_CPU_INFO:
+sclp_read_cpu_info(sccb);
+break;
 default:
 sdev-sclp_command_handler(sdev-ef, sccb, code);
 break;
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 74e8d94..a625098 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -79,12 +79,44 @@ typedef struct SCCBHeader {
 
 #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader))
 
+/* CPU information */
+typedef struct CPUEntry {
+uint8_t address;
+uint8_t reserved0[13];
+uint8_t type;
+uint8_t reserved1;
+} QEMU_PACKED CPUEntry;
+
 typedef struct ReadInfo {
 SCCBHeader h;
 uint16_t rnmax;
 uint8_t rnsize;
+uint8_t  _reserved1[16 - 11];   /* 11-15 */
+uint16_t entries_cpu;   /* 16-17 */
+uint16_t offset_cpu;/* 18-19 */
+uint8_t  _reserved2[24 - 20];   /* 20-23 */
+uint8_t  loadparm[8];   /* 24-31 */
+uint8_t  _reserved3[48 - 32];   /* 32-47 */
+uint64_t facilities;/* 48-55 */
+uint8_t  _reserved0[100 - 56];
+uint32_t rnsize2;
+uint64_t rnmax2;
+uint8_t  _reserved4[120-112];   /* 112-119 */
+uint16_t highest_cpu;
+uint8_t  _reserved5[128 - 122]; /* 122-127 */
+struct CPUEntry entries[0];
 } QEMU_PACKED ReadInfo;
 
+typedef struct ReadCpuInfo {
+SCCBHeader h;
+uint16_t nr_configured; /* 8-9 */
+uint16_t offset_configured; /* 10-11 */
+uint16_t nr_standby;/* 12-13 */
+uint16_t offset_standby;/* 14-15 */
+uint8_t reserved0[24-16];   /* 16-23 */
+struct CPUEntry entries[0];
+} QEMU_PACKED ReadCpuInfo;
+
 typedef struct SCCB {
 SCCBHeader h;
 char data[SCCB_DATA_LEN];
-- 
1.8.4.2




[Qemu-devel] [PULL 4/5] sclp-s390: Define new SCLP codes and structures

2014-01-31 Thread Christian Borntraeger
From: Matthew Rosato mjros...@linux.vnet.ibm.com

Define new SCLP codes and structures that will be needed for
s390 memory hotplug.

Signed-off-by: Matthew Rosato mjros...@linux.vnet.ibm.com
Signed-off-by: Christian Borntraeger borntrae...@de.ibm.com
---
 include/hw/s390x/sclp.h | 34 ++
 1 file changed, 34 insertions(+)

diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index 2fec2f8..35112d9 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -22,12 +22,22 @@
 /* SCLP command codes */
 #define SCLP_CMDW_READ_SCP_INFO 0x00020001
 #define SCLP_CMDW_READ_SCP_INFO_FORCED  0x00120001
+#define SCLP_READ_STORAGE_ELEMENT_INFO  0x00040001
+#define SCLP_ATTACH_STORAGE_ELEMENT 0x00080001
+#define SCLP_ASSIGN_STORAGE 0x000D0001
+#define SCLP_UNASSIGN_STORAGE   0x000C0001
 #define SCLP_CMD_READ_EVENT_DATA0x00770005
 #define SCLP_CMD_WRITE_EVENT_DATA   0x00760005
 #define SCLP_CMD_READ_EVENT_DATA0x00770005
 #define SCLP_CMD_WRITE_EVENT_DATA   0x00760005
 #define SCLP_CMD_WRITE_EVENT_MASK   0x00780005
 
+/* SCLP Memory hotplug codes */
+#define SCLP_FC_ASSIGN_ATTACH_READ_STOR 0xE000ULL
+#define SCLP_STARTING_SUBINCREMENT_ID   0x10001
+#define SCLP_INCREMENT_UNIT 0x1
+#define MAX_AVAIL_SLOTS 32
+
 /* CPU hotplug SCLP codes */
 #define SCLP_HAS_CPU_INFO   0x0C00ULL
 #define SCLP_CMDW_READ_CPU_INFO 0x00010001
@@ -37,9 +47,11 @@
 /* SCLP response codes */
 #define SCLP_RC_NORMAL_READ_COMPLETION  0x0010
 #define SCLP_RC_NORMAL_COMPLETION   0x0020
+#define SCLP_RC_SCCB_BOUNDARY_VIOLATION 0x0100
 #define SCLP_RC_INVALID_SCLP_COMMAND0x01f0
 #define SCLP_RC_CONTAINED_EQUIPMENT_CHECK   0x0340
 #define SCLP_RC_INSUFFICIENT_SCCB_LENGTH0x0300
+#define SCLP_RC_STANDBY_READ_COMPLETION 0x0410
 #define SCLP_RC_INVALID_FUNCTION0x40f0
 #define SCLP_RC_NO_EVENT_BUFFERS_STORED 0x60f0
 #define SCLP_RC_INVALID_SELECTION_MASK  0x70f0
@@ -117,6 +129,28 @@ typedef struct ReadCpuInfo {
 struct CPUEntry entries[0];
 } QEMU_PACKED ReadCpuInfo;
 
+typedef struct ReadStorageElementInfo {
+SCCBHeader h;
+uint16_t max_id;
+uint16_t assigned;
+uint16_t standby;
+uint8_t _reserved0[16 - 14]; /* 14-15 */
+uint32_t entries[0];
+} QEMU_PACKED ReadStorageElementInfo;
+
+typedef struct AttachStorageElement {
+SCCBHeader h;
+uint8_t _reserved0[10 - 8];  /* 8-9 */
+uint16_t assigned;
+uint8_t _reserved1[16 - 12]; /* 12-15 */
+uint32_t entries[0];
+} QEMU_PACKED AttachStorageElement;
+
+typedef struct AssignStorage {
+SCCBHeader h;
+uint16_t rn;
+} QEMU_PACKED AssignStorage;
+
 typedef struct SCCB {
 SCCBHeader h;
 char data[SCCB_DATA_LEN];
-- 
1.8.4.2




[Qemu-devel] [PATCH v2] qga: Don't require 'time' argument in guest-set-time command

2014-01-31 Thread Michal Privoznik
As the description to the guest-set-time states, the command is
there to ease time synchronization after resume. If guest was
suspended for longer period of time, its system time can go off
so badly, that even NTP refuses to set it. That's why the command
was invented: to give users chance to set the time (not
necessarily 100% correct). However, there's is no real need for
us to require users to pass an arbitrary time. Especially if we
can read the correct value from RTC (boiling down to reading
host's time). Hence this commit enables logic:

guest-set-time() == guest-set-time($now_from_rtc)

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
diff to v1:
-Fix checkpatch.pl warnings 

 qga/commands-posix.c | 41 +
 qga/commands-win32.c | 34 +++---
 qga/qapi-schema.json |  9 +
 3 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 8100bee..7d6665a 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -142,7 +142,7 @@ int64_t qmp_guest_get_time(Error **errp)
return time_ns;
 }
 
-void qmp_guest_set_time(int64_t time_ns, Error **errp)
+void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 {
 int ret;
 int status;
@@ -150,22 +150,28 @@ void qmp_guest_set_time(int64_t time_ns, Error **errp)
 Error *local_err = NULL;
 struct timeval tv;
 
-/* year-2038 will overflow in case time_t is 32bit */
-if (time_ns / 10 != (time_t)(time_ns / 10)) {
-error_setg(errp, Time % PRId64  is too large, time_ns);
-return;
+/* If user has passed a time, validate and set it. */
+if (has_time) {
+/* year-2038 will overflow in case time_t is 32bit */
+if (time_ns / 10 != (time_t)(time_ns / 10)) {
+error_setg(errp, Time % PRId64  is too large, time_ns);
+return;
+}
+
+tv.tv_sec = time_ns / 10;
+tv.tv_usec = (time_ns % 10) / 1000;
+
+ret = settimeofday(tv, NULL);
+if (ret  0) {
+error_setg_errno(errp, errno, Failed to set time to guest);
+return;
+}
 }
 
-tv.tv_sec = time_ns / 10;
-tv.tv_usec = (time_ns % 10) / 1000;
-
-ret = settimeofday(tv, NULL);
-if (ret  0) {
-error_setg_errno(errp, errno, Failed to set time to guest);
-return;
-}
-
-/* Set the Hardware Clock to the current System Time. */
+/* Now, if user has passed a time to set and the system time is set, we
+ * just need to synchronize the hardware clock. However, if no time was
+ * passed, user is requesting the opposite: set the system time from the
+ * hardware clock. */
 pid = fork();
 if (pid == 0) {
 setsid();
@@ -173,7 +179,10 @@ void qmp_guest_set_time(int64_t time_ns, Error **errp)
 reopen_fd_to_null(1);
 reopen_fd_to_null(2);
 
-execle(/sbin/hwclock, hwclock, -w, NULL, environ);
+/* Use '/sbin/hwclock -w' to set RTC from the system time,
+ * or '/sbin/hwclock -s' to set the system time from RTC. */
+execle(/sbin/hwclock, hwclock, has_time ? -w : -s,
+   NULL, environ);
 _exit(EXIT_FAILURE);
 } else if (pid  0) {
 error_setg_errno(errp, errno, failed to create child process);
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index a6a0af2..8245f95 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -370,25 +370,37 @@ int64_t qmp_guest_get_time(Error **errp)
 return time_ns;
 }
 
-void qmp_guest_set_time(int64_t time_ns, Error **errp)
+void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
 {
 SYSTEMTIME ts;
 FILETIME tf;
 LONGLONG time;
 
-if (time_ns  0 || time_ns / 100  INT64_MAX - W32_FT_OFFSET) {
-error_setg(errp, Time % PRId64 is invalid, time_ns);
-return;
-}
+if (has_time) {
+/* Okay, user passed a time to set. Validate it. */
+if (time_ns  0 || time_ns / 100  INT64_MAX - W32_FT_OFFSET) {
+error_setg(errp, Time % PRId64 is invalid, time_ns);
+return;
+}
 
-time = time_ns / 100 + W32_FT_OFFSET;
+time = time_ns / 100 + W32_FT_OFFSET;
 
-tf.dwLowDateTime = (DWORD) time;
-tf.dwHighDateTime = (DWORD) (time  32);
+tf.dwLowDateTime = (DWORD) time;
+tf.dwHighDateTime = (DWORD) (time  32);
 
-if (!FileTimeToSystemTime(tf, ts)) {
-error_setg(errp, Failed to convert system time %d, 
(int)GetLastError());
-return;
+if (!FileTimeToSystemTime(tf, ts)) {
+error_setg(errp, Failed to convert system time %d,
+   (int)GetLastError());
+return;
+}
+} else {
+/* Otherwise read the time from RTC which contains the correct value.
+ * Hopefully. */
+GetSystemTime(ts);
+if 

[Qemu-devel] [PATCH] qmp: expose list of supported character device backends

2014-01-31 Thread Martin Kletzander
Introduce 'query-chardev-backends' QMP command which lists all
supported character device backends.

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 qapi-schema.json | 22 ++
 qemu-char.c  | 19 +++
 qmp-commands.hx  | 41 +
 3 files changed, 82 insertions(+)

diff --git a/qapi-schema.json b/qapi-schema.json
index 05ced9d..ac1061f 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -437,6 +437,28 @@
 { 'command': 'query-chardev', 'returns': ['ChardevInfo'] }

 ##
+# @ChardevBackendInfo:
+#
+# Information about a character device backend
+#
+# @name: The backend name
+#
+# Since: 1.8.0
+##
+{ 'type': 'ChardevBackendInfo', 'data': {'name': 'str'} }
+
+##
+# @query-chardev-backends:
+#
+# Returns information about character device backends.
+#
+# Returns: a list of @ChardevBackendInfo
+#
+# Since: 1.8.0
+##
+{ 'command': 'query-chardev-backends', 'returns': ['ChardevBackendInfo'] }
+
+##
 # @DataFormat:
 #
 # An enumeration of data format.
diff --git a/qemu-char.c b/qemu-char.c
index 30c5a6a..c88f1c4 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3432,6 +3432,25 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
 return chr_list;
 }

+ChardevBackendInfoList *qmp_query_chardev_backends(Error **errp)
+{
+ChardevBackendInfoList *backend_list = NULL;
+CharDriver *c = NULL;
+GSList *i = NULL;
+
+for (i = backends; i; i = i-next) {
+ChardevBackendInfoList *info = g_malloc0(sizeof(*info));
+c = i-data;
+info-value = g_malloc0(sizeof(*info-value));
+info-value-name = g_strdup(c-name);
+
+info-next = backend_list;
+backend_list = info;
+}
+
+return backend_list;
+}
+
 CharDriverState *qemu_chr_find(const char *name)
 {
 CharDriverState *chr;
diff --git a/qmp-commands.hx b/qmp-commands.hx
index cce6b81..c38964d 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1924,6 +1924,47 @@ EQMP
 },

 SQMP
+query-chardev-backends
+-
+
+List available character device backends.
+
+Each backend is represented by a json-object, the returned value is a 
json-array
+of all backends.
+
+Each json-object contains:
+
+- name: backend name (json-string)
+
+Example:
+
+- { execute: query-chardev-backends }
+- {
+  return:[
+ {
+name:udp,
+ },
+ {
+name:tcp,
+ },
+ {
+name:unix,
+ },
+ {
+name:spiceport,
+ }
+  ]
+   }
+
+EQMP
+
+{
+.name   = query-chardev-backends,
+.args_type  = ,
+.mhandler.cmd_new = qmp_marshal_input_query_chardev_backends,
+},
+
+SQMP
 query-block
 ---

-- 
1.8.5.3




Re: [Qemu-devel] [PATCH] trace backend: introduce multi tracing backend

2014-01-31 Thread Stefan Hajnoczi
On Tue, Jan 28, 2014 at 01:35:20PM +0900, Kazuya Saito wrote:

Okay, more feedback after looking at the rest of the patch.

I think ust backend support will simplify the patch a little (see
details below).

Looking forward to the next revision.  Let me know if you have any
questions about my feedback.

 diff --git a/scripts/tracetool/backend/__init__.py 
 b/scripts/tracetool/backend/__init__.py
 index f0314ee..40efcb5 100644
 --- a/scripts/tracetool/backend/__init__.py
 +++ b/scripts/tracetool/backend/__init__.py
 @@ -110,20 +110,28 @@ def compatible(backend, format):
  def _empty(events):
  pass
 
 -def generate(backend, format, events):
 +def generate(backends, format, events):
  Generate the per-event output for the given (backend, format) pair.

Please update the doc comment to reflect the new argument.

 -if not compatible(backend, format):
 +compat = False
 +for backend in backends:
 +compat |= compatible(backend, format)
 +if not compat:
  raise ValueError(backend '%s' not compatible with format '%s' %
   (backend, format))
 
 -backend = backend.replace(-, _)
 +backends = map(lambda x: x.replace(-, _), backends)
  format = format.replace(-, _)
 
 -if backend == nop:
 +if backends == [nop]:
  func = tracetool.try_import(tracetool.format. + format,
  nop, _empty)[1]
 +func(events)
 +elif set(backends).issubset([dtrace, ftrace, simple, stderr]):
 +func = tracetool.try_import(tracetool.backend.common,
 +format, None)[1]
 +func(backends, events)
  else:
  func = tracetool.try_import(tracetool.backend. + backend,
  format, None)[1]

This extra case exists because ust isn't converted yet?

backend/__init__.py should not know about all backends (it's a pain to
hardcode the backend names and keep them up-to-date).  I hope this
change can be dropped in the next revision of the patch since the ust
backend will no longer be different.

 +def c(backends, events):
 +func_head_lst = []
 +func_body_lst = []
 +for backend in backends:
 +func_head_lst.append(tracetool.try_import(tracetool.backend. + 
 backend,
 +  c_head, None)[1])
 +func_body_lst.append(tracetool.try_import(tracetool.backend. + 
 backend,
 +  c_body, None)[1])
 +
 +out('#include trace/control.h',
 +'#ifndef CONFIG_TRACE_DTRACE',
 +'#include trace.h',
 +'#endif'
 +'',
 +)
 +for func_head in func_head_lst:
 +func_head()

Can the CONFIG_TRACE_DTRACE include be emitted by dtrace.c_head()?  Then
we don't need to hardcode it into this generic file (it shouldn't know
about specific backends).

Perhaps you could even make a c_include() interface, if necessary.

  def h(events):
 +pass

I thought all code generation now happens in backends.common.h(), so
this function will not be called anymore?

The same is true for c() defined in this file.

  def d(events):
 +d_head()
  out('provider qemu {')
 -
  for e in events:
 -args = str(e.args)
 +d_body(e)
 +out('',
 +'};')
 +
 +def d_head():
 +pass

This function seems unnecessary.  Can you drop it?

 @@ -86,24 +99,30 @@ RESERVED_WORDS = (
  )
 
  def stap(events):
 +stap_head()
  for e in events:
 -# Define prototype for probe arguments
 -out('probe %(probeprefix)s.%(name)s = 
 process(%(binary)s).mark(%(name)s)',
 -'{',
 -probeprefix = _probeprefix(),
 -name = e.name,
 -binary = _binary(),
 -)
 -
 -i = 1
 -if len(e.args)  0:
 -for name in e.args.names():
 -# Append underscore to reserved keywords
 -if name in RESERVED_WORDS:
 -name += '_'
 -out('  %s = $arg%d;' % (name, i))
 -i += 1
 -
 -out('}')
 -
 +stap_body(e)
  out()
 +
 +def stap_head():
 +pass

Same here, I think it can be dropped.

  ##
  # Backend code
 
  util-obj-$(CONFIG_TRACE_DEFAULT) += default.o
 -util-obj-$(CONFIG_TRACE_SIMPLE) += simple.o
 -util-obj-$(CONFIG_TRACE_STDERR) += stderr.o
 -util-obj-$(CONFIG_TRACE_FTRACE) += ftrace.o
 +util-obj-$(CONFIG_TRACE_SIMPLE) += multi.o simple.o
 +util-obj-$(CONFIG_TRACE_STDERR) += multi.o

What happened to stderr.o?

 +util-obj-$(CONFIG_TRACE_FTRACE) += multi.o ftrace.o

How about adding multi.o to util-obj-y just like control.o below?  All
these object files are added to libqemuutil.a.  The linker will only
pull in object files that are needed (based on symbol dependencies) so
there is no harm in uncoditionally building multi.o.

(In fact, I think it's better to 

Re: [Qemu-devel] [PATCH v5 0/2] target-ppc: CPU device tree id

2014-01-31 Thread Thomas Huth
On Fri, 31 Jan 2014 17:07:36 +1100
Alexey Kardashevskiy a...@ozlabs.ru wrote:

 On 01/22/2014 03:20 PM, Alexey Kardashevskiy wrote:
  On 01/10/2014 07:20 PM, Alexey Kardashevskiy wrote:
  On 12/20/2013 12:16 AM, Alexey Kardashevskiy wrote:
  On 12/10/2013 07:16 PM, Alexey Kardashevskiy wrote:
  On 12/03/2013 02:30 PM, Alexey Kardashevskiy wrote:
  Hi!
 
  This is some cleanup. Please, comment. Thanks!
 
 
  Ping, anyone?
 
 
  Ping?
 
 
 
  Ping, anyone?
  
  Ping, anyone?
 
 
 Please, anybody, say something.

Maybe poke the maintainers on IRC?

 Thomas




Re: [Qemu-devel] [PATCHv7 1/5] block: add native support for NFS

2014-01-31 Thread Stefan Hajnoczi
On Fri, Jan 31, 2014 at 10:11 AM, Peter Lieven p...@kamp.de wrote:
 On 31.01.2014 09:57, Stefan Hajnoczi wrote:

 On Thu, Jan 30, 2014 at 10:35 PM, Peter Lieven p...@kamp.de wrote:

 Am 30.01.2014 um 15:22 schrieb Stefan Hajnoczi stefa...@gmail.com:

 On Wed, Jan 29, 2014 at 05:19:59PM +0100, Benoīt Canet wrote:

 Le Wednesday 29 Jan 2014 ą 09:50:21 (+0100), Peter Lieven a écrit :

 +static int nfs_file_open(BlockDriverState *bs, QDict *options, int
 flags,
 + Error **errp) {
 +NFSClient *client = bs-opaque;
 +int64_t ret;
 +QemuOpts *opts;
 +Error *local_err = NULL;
 +
 +opts = qemu_opts_create(runtime_opts, NULL, 0, error_abort);
 +qemu_opts_absorb_qdict(opts, options, local_err);
 +if (error_is_set(local_err)) {
 +qerror_report_err(local_err);

 I have seen more usage of error_propagate(errp, local_err); in QEMU
 code.
 Maybe I am missing the point.

 Yes, I think you are right.  The Error should be propagated to the
 caller.  It's not clear to me whether we can ever get an error from
 qemu_opts_absorb_qdict() in this call site though.

 Is there any action I should take here? If yes, can you advise what
 to do please.

 The issue is that nfs_file_open() takes an Error **errp argument.
 This means the function should report detailed errors using the Error
 object.

 The patch prints and then discards the local_error instead of
 propagating it to the caller's errp.

 We should just propagate the error instead of printing it:
 if (error_is_set(local_err)) {
  error_propagate(errp, local_err);
  goto ...;


 Ok, you are just referring to this part in nfs_file_open:

 if (error_is_set(local_err)) {
 qerror_report_err(local_err);
 error_free(local_err);
 return -EINVAL;
 }

 which I would change to:

 if (error_is_set(local_err)) {
 error_propagate(errp, local_err);
 return -EINVAL;
 }

Yes.

 The use of error_setg in nfs_client_open is ok?

Yes, it's fine.

The Error API is not 100% obvious when you first see it, but once you
learn the conventions it's pretty usable:

Functions take an Error **errp argument.  This argument is optional,
so a caller that doesn't care about detailed error messages may pass
NULL.  This has implications...

error_setg(errp, fmt, ...) handles errp == NULL internally so you can
call it unconditionally.

The tricky thing is that error_is_set() only works if errp is non-NULL
(otherwise error_setg() skips creating an Error object).  So it means
you cannot rely on your errp argument and often functions will declare
Error *local_err = NULL, so they can pass local_err to child
functions.  Finally, error_propagate(errp, local_err) is used to pass
out the Error object to our caller.

Hope this summary makes the Error API clear.

Stefan



Re: [Qemu-devel] [PATCH 0/2] qtest: don't leak pid files and UNIX domain sockets

2014-01-31 Thread Stefan Hajnoczi
On Fri, Jan 31, 2014 at 1:07 AM, Peter Maydell peter.mayd...@linaro.org wrote:
 On 21 November 2013 11:03, Stefan Hajnoczi stefa...@redhat.com wrote:
 GLib uses abort(3) to exit failed test cases.  As a result, the pid file and
 UNIX domain sockets for a running test are leaked upon failure.

 Since abort(3) does not call atexit(3) handler functions, we could set up a
 SIGABRT handler that performs cleanup.  But there are other conditions where
 processes die, like SIGSEGV or SIGBUS.

 Let's unlink pid files and UNIX domain sockets as soon as the QEMU process 
 has
 initialized and connections have been made.  This eliminates the possibility 
 of
 leaking these files.

 So looking back through mailing list history suggests that these patches
 are supposed to avoid intermittent make check failures like:

 TEST: tests/qom-test... (pid=5078)
   /i386/qom/none:  **
 ERROR:/home/petmay01/linaro/qemu-for-merges/tests/libqtest.c:71:init_socket:
 assertion failed (ret != -1): (-1 != -1)
 FAIL
 GTester: last random seed: R02S79ea313790bc9a8b21d9af5ed55c2fff
 (pid=5080)
   /i386/qom/pc:OK
   /i386/qom/isapc: OK
   /i386/qom/q35:   OK
 FAIL: tests/qom-test

 but this patch series doesn't actually say that's what it's for,
 so does it fix that kind of error?

I might help but I'm not sure.  The assertion failure you posted
happened on Gerd's buildslaves, I haven't reproduced it myself and
don't really understand what's wrong there.

However, I noticed that my /tmp is getting cluttered with pid files
and UNIX domain sockets from qtest.  I also noticed that QEMU
processes are left running (this is not fixed by my series) when tests
fail.

So this series at least stops us from cluttering /tmp.

I haven't reproduced the init_socket() assertion failure so I'm not
sure what the root cause is.

Stefan



Re: [Qemu-devel] [PULL v2 00/35] acpi, pci, pc, virtio fixes and enhancements

2014-01-31 Thread Peter Maydell
On 28 January 2014 11:21, Michael S. Tsirkin m...@redhat.com wrote:
 Hi Peter,
 could you merge the below please?
 Thanks in advance!

 On Sun, Jan 26, 2014 at 06:05:14PM +0200, Michael S. Tsirkin wrote:
 Hi Anthony,
 I forgot to Cc you on the previous version of this pull request.
 So here's v2 - it also includes some more changes that
 got merged since then.
 I also used this opportunity for smash in a compat bugfix.
 Please ignore the previous pull request.

 The following changes since commit 0169c511554cb0014a00290b0d3d26c31a49818f:

   Merge remote-tracking branch 'qemu-kvm/uq/master' into staging (2014-01-24 
 15:52:44 -0800)

 are available in the git repository at:


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

 for you to fetch changes up to a75143eda2ddf581b51e96c000974bcdfe2cbd10:

   MAINTAINERS: add self as virtio co-maintainer (2014-01-26 13:11:45 +0200)

 
 acpi,pci,pc,virtio fixes and enhancements

Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCHv7 1/5] block: add native support for NFS

2014-01-31 Thread Peter Lieven

On 31.01.2014 11:46, Stefan Hajnoczi wrote:

On Fri, Jan 31, 2014 at 10:11 AM, Peter Lieven p...@kamp.de wrote:

On 31.01.2014 09:57, Stefan Hajnoczi wrote:

On Thu, Jan 30, 2014 at 10:35 PM, Peter Lieven p...@kamp.de wrote:

Am 30.01.2014 um 15:22 schrieb Stefan Hajnoczi stefa...@gmail.com:


On Wed, Jan 29, 2014 at 05:19:59PM +0100, Benoīt Canet wrote:

Le Wednesday 29 Jan 2014 ą 09:50:21 (+0100), Peter Lieven a écrit :

+static int nfs_file_open(BlockDriverState *bs, QDict *options, int
flags,
+ Error **errp) {
+NFSClient *client = bs-opaque;
+int64_t ret;
+QemuOpts *opts;
+Error *local_err = NULL;
+
+opts = qemu_opts_create(runtime_opts, NULL, 0, error_abort);
+qemu_opts_absorb_qdict(opts, options, local_err);
+if (error_is_set(local_err)) {
+qerror_report_err(local_err);

I have seen more usage of error_propagate(errp, local_err); in QEMU
code.
Maybe I am missing the point.

Yes, I think you are right.  The Error should be propagated to the
caller.  It's not clear to me whether we can ever get an error from
qemu_opts_absorb_qdict() in this call site though.

Is there any action I should take here? If yes, can you advise what
to do please.

The issue is that nfs_file_open() takes an Error **errp argument.
This means the function should report detailed errors using the Error
object.

The patch prints and then discards the local_error instead of
propagating it to the caller's errp.

We should just propagate the error instead of printing it:
if (error_is_set(local_err)) {
  error_propagate(errp, local_err);
  goto ...;


Ok, you are just referring to this part in nfs_file_open:

 if (error_is_set(local_err)) {
 qerror_report_err(local_err);
 error_free(local_err);
 return -EINVAL;
 }

which I would change to:

 if (error_is_set(local_err)) {
 error_propagate(errp, local_err);
 return -EINVAL;
 }

Yes.


The use of error_setg in nfs_client_open is ok?

Yes, it's fine.

The Error API is not 100% obvious when you first see it, but once you
learn the conventions it's pretty usable:

Functions take an Error **errp argument.  This argument is optional,
so a caller that doesn't care about detailed error messages may pass
NULL.  This has implications...

error_setg(errp, fmt, ...) handles errp == NULL internally so you can
call it unconditionally.

The tricky thing is that error_is_set() only works if errp is non-NULL
(otherwise error_setg() skips creating an Error object).  So it means
you cannot rely on your errp argument and often functions will declare
Error *local_err = NULL, so they can pass local_err to child
functions.  Finally, error_propagate(errp, local_err) is used to pass
out the Error object to our caller.

Hope this summary makes the Error API clear.

Stefan

Thanks for the explanation. I will sent you an updated series shortly.

Peter


--

Mit freundlichen Grüßen

Peter Lieven

...

  KAMP Netzwerkdienste GmbH
  Vestische Str. 89-91 | 46117 Oberhausen
  Tel: +49 (0) 208.89 402-50 | Fax: +49 (0) 208.89 402-40
  p...@kamp.de | http://www.kamp.de

  Geschäftsführer: Heiner Lante | Michael Lante
  Amtsgericht Duisburg | HRB Nr. 12154
  USt-Id-Nr.: DE 120607556

...




Re: [Qemu-devel] [PULL 0/4] Tracing patches

2014-01-31 Thread Peter Maydell
On 27 January 2014 14:53, Stefan Hajnoczi stefa...@redhat.com wrote:
 The following changes since commit 0169c511554cb0014a00290b0d3d26c31a49818f:

   Merge remote-tracking branch 'qemu-kvm/uq/master' into staging (2014-01-24 
 15:52:44 -0800)

 are available in the git repository at:


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

 for you to fetch changes up to 736ec1677f1ae7e64f2f3436ca3775c48f79678c:

   trace: fix simple trace disable keyword (2014-01-27 15:49:39 +0100)

 
 Tracing pull request


Applied, thanks.

-- PMM



Re: [Qemu-devel] [PATCH 11/12] qdev: add enum property types to QAPI schema

2014-01-31 Thread Paolo Bonzini

Il 31/01/2014 09:05, Markus Armbruster ha scritto:


If you want the obsolete ways to specify translation accept the new
values, too, then the patch to do that (currently [PATCH v2] block:
handle rechs and large translation options) should immediately
follow the first one, or be squashed into it.


I can squash it and put it in this series with an ack from the block 
maintainers.


Paolo




Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Andreas Färber
Am 30.01.2014 22:47, schrieb Paolo Bonzini:
 Il 30/01/2014 20:48, Eduardo Habkost ha scritto:
 Is there any hope to get this into QEMU 2.0, or it is now too late? I got
 almost no feedback on take 6 (submitted November 27).
 
 It's not too late, not for me at least.  I wanted to send the next
 uq/master pull request tomorrow or Tuesday, after I've done some more
 testing on enlightenments.  I can squeeze this in too.

Negative, not without my review. It's clearly a CPU series, and apart
from having been on vacation pretty much all of December, Eduardo and
others have objected to my subclass series the last 2 *years*, so 2
months is peanuts by comparison.

Further, I was under the impression that this series depends on Igor's
feature property series, which I haven't found time to rework and
haven't noticed anyone else do either. So if there's no prereqs (why
uq/master?) I'll happily start reviewing and queuing it.

As Eduardo points out below the commit message in the final patch, his
conversion is very similar to one of my earlier patch series, so
committing that with Eduardo as author via uq/master without crediting
me via uq/master would leave a bad taste.

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCHv7 1/5] block: add native support for NFS

2014-01-31 Thread Peter Lieven

On 29.01.2014 17:19, Benoît Canet wrote:

Le Wednesday 29 Jan 2014 à 09:50:21 (+0100), Peter Lieven a écrit :

This patch adds native support for accessing images on NFS
shares without the requirement to actually mount the entire
NFS share on the host.

NFS Images can simply be specified by an url of the form:
nfs://host/export/filename[?param=value[param2=value2[...]]]

For example:
qemu-img create -f qcow2 nfs://10.0.0.1/qemu-images/test.qcow2

You need LibNFS from Ronnie Sahlberg available at:
git://github.com/sahlberg/libnfs.git
for this to work.

During configure it is automatically probed for libnfs and support
is enabled on-the-fly. You can forbid or enforce libnfs support
with --disable-libnfs or --enable-libnfs respectively.

Due to NFS restrictions you might need to execute your binaries
as root, allow them to open priviledged ports (1024) or specify
insecure option on the NFS server.

For additional information on ROOT vs. non-ROOT operation and URL
format + parameters see:
https://raw.github.com/sahlberg/libnfs/master/README

Supported by qemu are the uid, gid and tcp-syncnt URL parameters.

LibNFS currently support NFS version 3 only.

Signed-off-by: Peter Lieven p...@kamp.de
---
  MAINTAINERS |5 +
  block/Makefile.objs |1 +
  block/nfs.c |  440 +++
  configure   |   26 +++
  qapi-schema.json|1 +
  5 files changed, 473 insertions(+)
  create mode 100644 block/nfs.c

diff --git a/MAINTAINERS b/MAINTAINERS
index fb53242..f8411f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -936,6 +936,11 @@ M: Peter Lieven p...@kamp.de
  S: Supported
  F: block/iscsi.c
  
+NFS

+M: Peter Lieven p...@kamp.de
+S: Maintained
+F: block/nfs.c
+
  SSH
  M: Richard W.M. Jones rjo...@redhat.com
  S: Supported
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4e8c91e..e254a21 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -12,6 +12,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
  ifeq ($(CONFIG_POSIX),y)
  block-obj-y += nbd.o nbd-client.o sheepdog.o
  block-obj-$(CONFIG_LIBISCSI) += iscsi.o
+block-obj-$(CONFIG_LIBNFS) += nfs.o
  block-obj-$(CONFIG_CURL) += curl.o
  block-obj-$(CONFIG_RBD) += rbd.o
  block-obj-$(CONFIG_GLUSTERFS) += gluster.o
diff --git a/block/nfs.c b/block/nfs.c
new file mode 100644
index 000..2bbf7a2
--- /dev/null
+++ b/block/nfs.c
@@ -0,0 +1,440 @@
+/*
+ * QEMU Block driver for native access to files on NFS shares
+ *
+ * Copyright (c) 2014 Peter Lieven p...@kamp.de
+ *
+ * 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 config-host.h
+
+#include poll.h
+#include qemu-common.h
+#include qemu/config-file.h
+#include qemu/error-report.h
+#include block/block_int.h
+#include trace.h
+#include qemu/iov.h
+#include qemu/uri.h
+#include sysemu/sysemu.h
+#include nfsc/libnfs.h
+
+typedef struct NFSClient {
+struct nfs_context *context;
+struct nfsfh *fh;
+int events;
+bool has_zero_init;
+} NFSClient;
+
+typedef struct NFSRPC {
+int status;
+int complete;
+QEMUIOVector *iov;
+struct stat *st;
+Coroutine *co;
+QEMUBH *bh;
+} NFSRPC;
+
+static void nfs_process_read(void *arg);
+static void nfs_process_write(void *arg);
+
+static void nfs_set_events(NFSClient *client)
+{
+int ev = nfs_which_events(client-context);
+if (ev != client-events) {
+qemu_aio_set_fd_handler(nfs_get_fd(client-context),
+  (ev  POLLIN) ? nfs_process_read : NULL,
+  (ev  POLLOUT) ? nfs_process_write : NULL,
+  client);
+
+}
+client-events = ev;
+}
+
+static void nfs_process_read(void *arg)
+{
+NFSClient *client = arg;
+nfs_service(client-context, POLLIN);
+nfs_set_events(client);
+}
+
+static void nfs_process_write(void *arg)
+{
+NFSClient *client = arg;
+nfs_service(client-context, POLLOUT);
+nfs_set_events(client);
+}
+
+static 

Re: [Qemu-devel] [uq/master PATCH 2/7] target-i386: Don't change x86_def_t struct on cpu_x86_register()

2014-01-31 Thread Paolo Bonzini

Il 30/01/2014 20:48, Eduardo Habkost ha scritto:

As eventually the x86_def_t data is going to be provided by the CPU
class, it's better to not touch it, and handle the special cases on the
X86CPU object itself.

Current behavior of the code should stay exactly the same.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 target-i386/cpu.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 8425212..be54f84 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1841,11 +1841,6 @@ static void cpu_x86_register(X86CPU *cpu, const char 
*name, Error **errp)
 return;
 }

-if (kvm_enabled()) {
-def-features[FEAT_KVM] |= kvm_default_features;
-}
-def-features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
-
 object_property_set_str(OBJECT(cpu), def-vendor, vendor, errp);
 object_property_set_int(OBJECT(cpu), def-level, level, errp);
 object_property_set_int(OBJECT(cpu), def-family, family, errp);
@@ -1864,6 +1859,12 @@ static void cpu_x86_register(X86CPU *cpu, const char 
*name, Error **errp)
 cpu-cache_info_passthrough = def-cache_info_passthrough;

 object_property_set_str(OBJECT(cpu), def-model_id, model-id, errp);
+
+/* Special cases not set in the x86_def_t structs: */
+if (kvm_enabled()) {
+env-features[FEAT_KVM] |= kvm_default_features;
+}
+env-features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
 }

 X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,



Reviewed-by: Paolo Bonzini pbonz...@redhat.com



[Qemu-devel] [PATCHv8 5/5] qemu-iotests: blacklist test 020 for NFS protocol

2014-01-31 Thread Peter Lieven
reopening is currently not supported.

Signed-off-by: Peter Lieven p...@kamp.de
---
 tests/qemu-iotests/020 |5 +
 1 file changed, 5 insertions(+)

diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
index 73a0429..2f258dc 100755
--- a/tests/qemu-iotests/020
+++ b/tests/qemu-iotests/020
@@ -49,6 +49,11 @@ _unsupported_imgopts subformat=monolithicFlat \
  subformat=twoGbMaxExtentFlat \
  subformat=twoGbMaxExtentSparse
 
+# NFS does not support bdrv_reopen_prepare thus qemu-img commit fails.
+if [ $IMGPROTO = nfs ]; then
+_notrun image protocol $IMGPROTO does not support bdrv_commit
+fi
+
 TEST_OFFSETS=0 4294967296
 
 _make_test_img 6G
-- 
1.7.9.5




[Qemu-devel] [PATCHv8 3/5] qemu-iotests: enable support for NFS protocol

2014-01-31 Thread Peter Lieven
Signed-off-by: Peter Lieven p...@kamp.de
---
 tests/qemu-iotests/common|   22 +++---
 tests/qemu-iotests/common.rc |3 +++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
index 8b4e22c..5795358 100644
--- a/tests/qemu-iotests/common
+++ b/tests/qemu-iotests/common
@@ -144,10 +144,12 @@ check options
 -vpctest vpc
 -vhdx   test vhdx
 -vmdk   test vmdk
+-file   test file (default)
 -rbdtest rbd
 -sheepdog   test sheepdog
 -nbdtest nbd
 -sshtest ssh
+-nfstest nfs
 -xdiff  graphical mode diff
 -nocacheuse O_DIRECT on backing file
 -misalign   misalign memory allocations
@@ -211,22 +213,36 @@ testlist options
 xpand=false
 ;;
 
+-file)
+IMGPROTO=file
+xpand=false
+;;
+
 -rbd)
 IMGPROTO=rbd
 xpand=false
 ;;
+
 -sheepdog)
 IMGPROTO=sheepdog
 xpand=false
 ;;
+
 -nbd)
 IMGPROTO=nbd
 xpand=false
 ;;
+
 -ssh)
 IMGPROTO=ssh
 xpand=false
 ;;
+
+-nfs)
+IMGPROTO=nfs
+xpand=false
+;;
+
 -nocache)
 CACHEMODE=none
 CACHEMODE_IS_DEFAULT=false
@@ -238,10 +254,10 @@ testlist options
 xpand=false
 ;;
 
--valgrind)
-valgrind=true
+-valgrind)
+valgrind=true
 xpand=false
-;;
+;;
 
 -g)# -g group ... pick from group file
 group=true
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 0f68156..71e9a74 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -61,6 +61,9 @@ elif [ $IMGPROTO = nbd ]; then
 elif [ $IMGPROTO = ssh ]; then
 TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
 TEST_IMG=ssh://127.0.0.1$TEST_IMG_FILE
+elif [ $IMGPROTO = nfs ]; then
+TEST_DIR=nfs://127.0.0.1/$TEST_DIR
+TEST_IMG=$TEST_DIR/t.$IMGFMT
 else
 TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
 fi
-- 
1.7.9.5




Re: [Qemu-devel] [uq/master PATCH 3/7] target-i386: Move KVM default-vendor hack to instance_init

2014-01-31 Thread Paolo Bonzini

Il 30/01/2014 20:48, Eduardo Habkost ha scritto:

As we will not have a cpu_x86_find_by_name() function anymore,
move the KVM default-vendor hack to instance_init.

Unfortunately we can't move that code to class_init because it depends
on KVM being initialized.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 target-i386/cpu.c | 32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index be54f84..0e8812a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1601,18 +1601,6 @@ static int cpu_x86_find_by_name(X86CPU *cpu, x86_def_t 
*x86_cpu_def,
 def = builtin_x86_defs[i];
 if (strcmp(name, def-name) == 0) {
 memcpy(x86_cpu_def, def, sizeof(*def));
-/* sysenter isn't supported in compatibility mode on AMD,
- * syscall isn't supported in compatibility mode on Intel.
- * Normally we advertise the actual CPU vendor, but you can
- * override this using the 'vendor' property if you want to use
- * KVM's sysenter/syscall emulation in compatibility mode and
- * when doing cross vendor migration
- */
-if (kvm_enabled()) {
-uint32_t  ebx = 0, ecx = 0, edx = 0;
-host_cpuid(0, 0, NULL, ebx, ecx, edx);
-x86_cpu_vendor_words2str(x86_cpu_def-vendor, ebx, edx, ecx);
-}
 return 0;
 }
 }
@@ -1841,7 +1829,6 @@ static void cpu_x86_register(X86CPU *cpu, const char 
*name, Error **errp)
 return;
 }

-object_property_set_str(OBJECT(cpu), def-vendor, vendor, errp);
 object_property_set_int(OBJECT(cpu), def-level, level, errp);
 object_property_set_int(OBJECT(cpu), def-family, family, errp);
 object_property_set_int(OBJECT(cpu), def-model, model, errp);
@@ -1865,6 +1852,25 @@ static void cpu_x86_register(X86CPU *cpu, const char 
*name, Error **errp)
 env-features[FEAT_KVM] |= kvm_default_features;
 }
 env-features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
+
+/* sysenter isn't supported in compatibility mode on AMD,
+ * syscall isn't supported in compatibility mode on Intel.
+ * Normally we advertise the actual CPU vendor, but you can
+ * override this using the 'vendor' property if you want to use
+ * KVM's sysenter/syscall emulation in compatibility mode and
+ * when doing cross vendor migration
+ */
+const char *vendor = def-vendor;
+char host_vendor[CPUID_VENDOR_SZ + 1];
+if (kvm_enabled()) {
+uint32_t  ebx = 0, ecx = 0, edx = 0;
+host_cpuid(0, 0, NULL, ebx, ecx, edx);
+x86_cpu_vendor_words2str(host_vendor, ebx, edx, ecx);
+vendor = host_vendor;
+}
+
+object_property_set_str(OBJECT(cpu), vendor, vendor, errp);
+
 }

 X86CPU *cpu_x86_create(const char *cpu_model, DeviceState *icc_bridge,



Reviewed-by: Paolo Bonzini pbonz...@redhat.com



Re: [Qemu-devel] [uq/master PATCH 6/7] target-i386: Rename x86_def_t to X86CPUDefinition

2014-01-31 Thread Paolo Bonzini

Il 30/01/2014 20:48, Eduardo Habkost ha scritto:

As the new X86CPU subclass code is going to change lots of the code
invoving x86_def_t, let's rename the struct to match coding style first.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 target-i386/cpu.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 5c13ed6..6659527 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -484,7 +484,7 @@ static void add_flagname_to_bitmaps(const char *flagname,
 }
 }

-typedef struct x86_def_t {
+typedef struct X86CPUDefinition {
 const char *name;
 uint32_t level;
 uint32_t xlevel;
@@ -497,7 +497,7 @@ typedef struct x86_def_t {
 FeatureWordArray features;
 char model_id[48];
 bool cache_info_passthrough;
-} x86_def_t;
+} X86CPUDefinition;

 #define I486_FEATURES (CPUID_FP87 | CPUID_VME | CPUID_PSE)
 #define PENTIUM_FEATURES (I486_FEATURES | CPUID_DE | CPUID_TSC | \
@@ -549,7 +549,7 @@ typedef struct x86_def_t {

 /* built-in CPU model definitions
  */
-static x86_def_t builtin_x86_defs[] = {
+static X86CPUDefinition builtin_x86_defs[] = {
 {
 .name = qemu64,
 .level = 4,
@@ -1108,7 +1108,7 @@ static x86_def_t builtin_x86_defs[] = {
 void x86_cpu_compat_set_features(const char *cpu_model, FeatureWord w,
  uint32_t feat_add, uint32_t feat_remove)
 {
-x86_def_t *def;
+X86CPUDefinition *def;
 int i;
 for (i = 0; i  ARRAY_SIZE(builtin_x86_defs); i++) {
 def = builtin_x86_defs[i];
@@ -1134,12 +1134,12 @@ static int cpu_x86_fill_model_id(char *str)
 return 0;
 }

-/* Fill a x86_def_t struct with information about the host CPU, and
+/* Fill a X86CPUDefinition struct with information about the host CPU, and
  * the CPU features supported by the host hardware + host kernel
  *
  * This function may be called only if KVM is enabled.
  */
-static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
+static void kvm_cpu_fill_host(X86CPUDefinition *x86_cpu_def)
 {
 KVMState *s = kvm_state;
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -1582,10 +1582,10 @@ static PropertyInfo qdev_prop_spinlocks = {
 .set   = x86_set_hv_spinlocks,
 };

-static int cpu_x86_find_by_name(X86CPU *cpu, x86_def_t *x86_cpu_def,
+static int cpu_x86_find_by_name(X86CPU *cpu, X86CPUDefinition *x86_cpu_def,
 const char *name)
 {
-x86_def_t *def;
+X86CPUDefinition *def;
 int i;

 if (name == NULL) {
@@ -1753,7 +1753,7 @@ static void listflags(char *buf, int bufsize, uint32_t 
fbits,
 /* generate CPU information. */
 void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 {
-x86_def_t *def;
+X86CPUDefinition *def;
 char buf[256];
 int i;

@@ -1780,7 +1780,7 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf)
 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
 {
 CpuDefinitionInfoList *cpu_list = NULL;
-x86_def_t *def;
+X86CPUDefinition *def;
 int i;

 for (i = 0; i  ARRAY_SIZE(builtin_x86_defs); i++) {
@@ -1822,7 +1822,7 @@ static void filter_features_for_kvm(X86CPU *cpu)
 static void x86_cpu_load_def(X86CPU *cpu, const char *name, Error **errp)
 {
 CPUX86State *env = cpu-env;
-x86_def_t def1, *def = def1;
+X86CPUDefinition def1, *def = def1;

 memset(def, 0, sizeof(*def));

@@ -1849,7 +1849,7 @@ static void x86_cpu_load_def(X86CPU *cpu, const char 
*name, Error **errp)

 object_property_set_str(OBJECT(cpu), def-model_id, model-id, errp);

-/* Special cases not set in the x86_def_t structs: */
+/* Special cases not set in the X86CPUDefinition structs: */
 if (kvm_enabled()) {
 env-features[FEAT_KVM] |= kvm_default_features;
 }
@@ -1971,7 +1971,7 @@ void x86_cpudef_setup(void)
 static const char *model_with_versions[] = { qemu32, qemu64, athlon 
};

 for (i = 0; i  ARRAY_SIZE(builtin_x86_defs); ++i) {
-x86_def_t *def = builtin_x86_defs[i];
+X86CPUDefinition *def = builtin_x86_defs[i];

 /* Look for specific cpudef models that */
 /* have the QEMU version in .model_id */



Reviewed-by: Paolo Bonzini pbonz...@redhat.com



Re: [Qemu-devel] [PATCH v17 00/10] Shared library module support

2014-01-31 Thread Paolo Bonzini

Il 28/01/2014 10:33, Fam Zheng ha scritto:

Ping?

This version has a slight conflict with current qemu.git. Do you want a respin,
Paolo?


I was waiting for test results from Peter.  I can rebase myself.

Paolo



Re: [Qemu-devel] [uq/master PATCH 1/7] target-i386: Eliminate CONFIG_KVM #ifdefs

2014-01-31 Thread Paolo Bonzini

Il 30/01/2014 20:48, Eduardo Habkost ha scritto:

The compiler is already able to eliminate the kvm_arch_get_supported_cpuid()
calls in kvm_cpu_fill_host() and filter_features_for_kvm(), so we can
eliminate the CONFIG_KVM #ifdefs there.

Also, kvm_cpu_fill_host() and host_cpuid() don't need to check
CONFIG_KVM, as they don't have any KVM-specific function calls.

Tested to build successfully with CONFIG_KVM disabled, using the
following CFLAGS combinations: -DNDEBUG, -DNDEBUG -O', -DNDEBUG
-O0, -DNDEBUG -O1, -DNDEBUG -O2.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
Changes v2:
 * Check for __i386__ on host_cpuid() so the code compiles properly
   on non-x86 hosts.
   Suggested-by: Paolo Bonzini pbonz...@redhat.com

Change v3:
 * Don't add assert(kvm_enabled()) line, which is not necessary to help
   the compiler (and wouldn't help it if using -DNDEBUG, anyway).
   Reported-by: Richard Henderson r...@twiddle.net
 * Commit message update
---
 target-i386/cpu.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 1f30efd..8425212 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -374,7 +374,6 @@ void disable_kvm_pv_eoi(void)
 void host_cpuid(uint32_t function, uint32_t count,
 uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
 {
-#if defined(CONFIG_KVM)
 uint32_t vec[4];

 #ifdef __x86_64__
@@ -382,7 +381,7 @@ void host_cpuid(uint32_t function, uint32_t count,
  : =a(vec[0]), =b(vec[1]),
=c(vec[2]), =d(vec[3])
  : 0(function), c(count) : cc);
-#else
+#elif defined(__i386__)
 asm volatile(pusha \n\t
  cpuid \n\t
  mov %%eax, 0(%2) \n\t
@@ -392,6 +391,8 @@ void host_cpuid(uint32_t function, uint32_t count,
  popa
  : : a(function), c(count), S(vec)
  : memory, cc);
+#else
+abort();
 #endif

 if (eax)
@@ -402,7 +403,6 @@ void host_cpuid(uint32_t function, uint32_t count,
 *ecx = vec[2];
 if (edx)
 *edx = vec[3];
-#endif
 }

 #define iswhite(c) ((c)  ((c) = ' ' || '~'  (c)))
@@ -1119,7 +1119,6 @@ void x86_cpu_compat_set_features(const char *cpu_model, 
FeatureWord w,
 }
 }

-#ifdef CONFIG_KVM
 static int cpu_x86_fill_model_id(char *str)
 {
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
@@ -1134,7 +1133,6 @@ static int cpu_x86_fill_model_id(char *str)
 }
 return 0;
 }
-#endif

 /* Fill a x86_def_t struct with information about the host CPU, and
  * the CPU features supported by the host hardware + host kernel
@@ -1143,7 +1141,6 @@ static int cpu_x86_fill_model_id(char *str)
  */
 static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 {
-#ifdef CONFIG_KVM
 KVMState *s = kvm_state;
 uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;

@@ -1173,8 +1170,6 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
 kvm_arch_get_supported_cpuid(s, wi-cpuid_eax, wi-cpuid_ecx,
  wi-cpuid_reg);
 }
-
-#endif /* CONFIG_KVM */
 }

 static int unavailable_host_feature(FeatureWordInfo *f, uint32_t mask)
@@ -1817,7 +1812,6 @@ CpuDefinitionInfoList *arch_query_cpu_definitions(Error 
**errp)
 return cpu_list;
 }

-#ifdef CONFIG_KVM
 static void filter_features_for_kvm(X86CPU *cpu)
 {
 CPUX86State *env = cpu-env;
@@ -1834,7 +1828,6 @@ static void filter_features_for_kvm(X86CPU *cpu)
 cpu-filtered_features[w] = requested_features  ~env-features[w];
 }
 }
-#endif

 static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
 {
@@ -2545,9 +2538,7 @@ static void x86_cpu_realizefn(DeviceState *dev, Error 
**errp)
Host's CPU doesn't support requested features);
 goto out;
 }
-#ifdef CONFIG_KVM
 filter_features_for_kvm(cpu);
-#endif
 }

 #ifndef CONFIG_USER_ONLY



Reviewed-by: Paolo Bonzini pbonz...@redhat.com



[Qemu-devel] [PATCHv8 2/5] qemu-iotests: change _supported_proto to file for various tests

2014-01-31 Thread Peter Lieven
all these tests do anything of the following and thus fail with any
protocol other than file:
 - the tests use rm, cp or mv shell commands which only work on file
 - the tests use qcow2.py
 - the images construct new filenames (e.g. backing file names) and
   the logic is broken for anything else than file

Signed-off-by: Peter Lieven p...@kamp.de
---
 tests/qemu-iotests/013 |2 +-
 tests/qemu-iotests/014 |2 +-
 tests/qemu-iotests/018 |2 +-
 tests/qemu-iotests/019 |2 +-
 tests/qemu-iotests/023 |2 +-
 tests/qemu-iotests/024 |2 +-
 tests/qemu-iotests/026 |2 +-
 tests/qemu-iotests/028 |2 +-
 tests/qemu-iotests/031 |2 +-
 tests/qemu-iotests/034 |2 +-
 tests/qemu-iotests/036 |2 +-
 tests/qemu-iotests/037 |2 +-
 tests/qemu-iotests/038 |2 +-
 tests/qemu-iotests/039 |2 +-
 tests/qemu-iotests/043 |2 +-
 tests/qemu-iotests/046 |2 +-
 tests/qemu-iotests/052 |2 +-
 tests/qemu-iotests/054 |2 +-
 tests/qemu-iotests/059 |2 +-
 tests/qemu-iotests/060 |2 +-
 tests/qemu-iotests/061 |2 +-
 tests/qemu-iotests/063 |2 +-
 tests/qemu-iotests/069 |2 +-
 23 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013
index 389f4b8..ea3cab9 100755
--- a/tests/qemu-iotests/013
+++ b/tests/qemu-iotests/013
@@ -41,7 +41,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # much of this could be generic for any format supporting compression.
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS=0 4294967296
diff --git a/tests/qemu-iotests/014 b/tests/qemu-iotests/014
index 0edeb4b..b23c2db 100755
--- a/tests/qemu-iotests/014
+++ b/tests/qemu-iotests/014
@@ -43,7 +43,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # much of this could be generic for any format supporting snapshots
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS=0 4294967296
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
index 6f7f054..d8a7d43 100755
--- a/tests/qemu-iotests/018
+++ b/tests/qemu-iotests/018
@@ -41,7 +41,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # Any format supporting backing files
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts subformat=monolithicFlat subformat=twoGbMaxExtentFlat
 
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
index b43e70f..e67445c 100755
--- a/tests/qemu-iotests/019
+++ b/tests/qemu-iotests/019
@@ -45,7 +45,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # Any format supporting backing files
 _supported_fmt qcow qcow2 vmdk qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _unsupported_imgopts subformat=monolithicFlat \
  subformat=twoGbMaxExtentFlat \
diff --git a/tests/qemu-iotests/023 b/tests/qemu-iotests/023
index 090ed23..9ad06b9 100755
--- a/tests/qemu-iotests/023
+++ b/tests/qemu-iotests/023
@@ -41,7 +41,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # much of this could be generic for any format supporting compression.
 _supported_fmt qcow qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 TEST_OFFSETS=0 4294967296
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
index be974f0..9bf99e1 100755
--- a/tests/qemu-iotests/024
+++ b/tests/qemu-iotests/024
@@ -43,7 +43,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # Currently only qcow2 and qed support rebasing
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=65536
diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026
index c9c5f83..df2884b 100755
--- a/tests/qemu-iotests/026
+++ b/tests/qemu-iotests/026
@@ -42,7 +42,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # Currently only qcow2 supports rebasing
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 _default_cache_mode writethrough
 _supported_cache_modes writethrough none
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
index 93a9fa6..a99e4fa 100755
--- a/tests/qemu-iotests/028
+++ b/tests/qemu-iotests/028
@@ -45,7 +45,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 # Any format supporting backing files except vmdk and qcow which do not support
 # smaller backing files.
 _supported_fmt qcow2 qed
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 # Choose a size that is not necessarily a cluster size multiple for image
diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031
index c9070b0..1d920ea 100755
--- a/tests/qemu-iotests/031
+++ b/tests/qemu-iotests/031
@@ -41,7 +41,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 
 # This tests qcow2-specific low-level functionality
 _supported_fmt qcow2
-_supported_proto generic
+_supported_proto file
 _supported_os Linux
 
 CLUSTER_SIZE=65536
diff --git a/tests/qemu-iotests/034 

Re: [Qemu-devel] [PATCH v5 0/2] target-ppc: CPU device tree id

2014-01-31 Thread Andreas Färber
Am 31.01.2014 07:07, schrieb Alexey Kardashevskiy:
 On 01/22/2014 03:20 PM, Alexey Kardashevskiy wrote:
 On 01/10/2014 07:20 PM, Alexey Kardashevskiy wrote:
 On 12/20/2013 12:16 AM, Alexey Kardashevskiy wrote:
 On 12/10/2013 07:16 PM, Alexey Kardashevskiy wrote:
 On 12/03/2013 02:30 PM, Alexey Kardashevskiy wrote:
 Hi!

 This is some cleanup. Please, comment. Thanks!


 Ping, anyone?


 Ping?



 Ping, anyone?

 Ping, anyone?
 
 
 Please, anybody, say something.

No objection from my side, but I'm not really familiar with the topic,
so leaving that to Alex et al.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [uq/master PATCH 4/7] target-i386: Rename cpu_x86_register() to x86_cpu_load_def()

2014-01-31 Thread Paolo Bonzini

Il 30/01/2014 20:48, Eduardo Habkost ha scritto:

There isn't any kind of registration involved in cpu_x86_register()
anymore: it is simply looking up a CPU model name and loading the model
definition data into the X86CPU object. Rename it to x86_cpu_load_def()
to reflect what it does.

Signed-off-by: Eduardo Habkost ehabk...@redhat.com
---
 target-i386/cpu.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 0e8812a..58b4c71 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1817,7 +1817,9 @@ static void filter_features_for_kvm(X86CPU *cpu)
 }
 }

-static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
+/* Load CPU definition for a given CPU model name
+ */
+static void x86_cpu_load_def(X86CPU *cpu, const char *name, Error **errp)
 {
 CPUX86State *env = cpu-env;
 x86_def_t def1, *def = def1;
@@ -1900,7 +1902,7 @@ X86CPU *cpu_x86_create(const char *cpu_model, DeviceState 
*icc_bridge,
 object_unref(OBJECT(cpu));
 #endif

-cpu_x86_register(cpu, name, error);
+x86_cpu_load_def(cpu, name, error);
 if (error) {
 goto out;
 }



Reviewed-by: Paolo Bonzini pbonz...@redhat.com




[Qemu-devel] [PATCHv8 4/5] qemu-iotests: enable test 016 and 025 to work with NFS protocol

2014-01-31 Thread Peter Lieven
Signed-off-by: Peter Lieven p...@kamp.de
---
 tests/qemu-iotests/016 |2 +-
 tests/qemu-iotests/025 |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/016 b/tests/qemu-iotests/016
index b87a32b..7ea9e94 100755
--- a/tests/qemu-iotests/016
+++ b/tests/qemu-iotests/016
@@ -39,7 +39,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 . ./common.filter
 
 _supported_fmt raw
-_supported_proto file sheepdog
+_supported_proto file sheepdog nfs
 _supported_os Linux
 
 
diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025
index 9426c93..a5f45b4 100755
--- a/tests/qemu-iotests/025
+++ b/tests/qemu-iotests/025
@@ -40,7 +40,7 @@ trap _cleanup; exit \$status 0 1 2 3 15
 . ./common.pattern
 
 _supported_fmt raw qcow2 qed
-_supported_proto file sheepdog rbd
+_supported_proto file sheepdog rbd nfs
 _supported_os Linux
 
 echo === Creating image
-- 
1.7.9.5




Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Paolo Bonzini

Il 31/01/2014 12:30, Andreas Färber ha scritto:

Further, I was under the impression that this series depends on Igor's
feature property series, which I haven't found time to rework and
haven't noticed anyone else do either. So if there's no prereqs (why
uq/master?) I'll happily start reviewing and queuing it.


Yeah, I was also wondering why uq/master too, mostly for patches 5 and 7.

The first 3 patches are KVM-ish, and I can apply them if you prefer.

Patches 4 and 6 are mostly trivial, but I'll leave them to you.


As Eduardo points out below the commit message in the final patch, his
conversion is very similar to one of my earlier patch series, so
committing that with Eduardo as author via uq/master without crediting
me via uq/master would leave a bad taste.


I'll leave this to you to sort out.

Paolo



Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Eduardo Habkost
On Fri, Jan 31, 2014 at 12:30:17PM +0100, Andreas Färber wrote:
 Am 30.01.2014 22:47, schrieb Paolo Bonzini:
  Il 30/01/2014 20:48, Eduardo Habkost ha scritto:
  Is there any hope to get this into QEMU 2.0, or it is now too late? I got
  almost no feedback on take 6 (submitted November 27).
  
  It's not too late, not for me at least.  I wanted to send the next
  uq/master pull request tomorrow or Tuesday, after I've done some more
  testing on enlightenments.  I can squeeze this in too.
 
 Negative, not without my review. It's clearly a CPU series, and apart
 from having been on vacation pretty much all of December, Eduardo and
 others have objected to my subclass series the last 2 *years*, so 2
 months is peanuts by comparison.

I don't remember objecting to your approach, but we simply had lots of
details to understand and questions settle. Then in February we
(Andreas, Igor, and me) stopped submitting new versions while we focused
in other stuff.

I was also not aware how the lack of subclasses would badly affect
libvirt's ability to use the new QOM properties we have added. I only
noticed that while talking to Jiri last November, that's why I resumed
the subclass work after months, to try to get it into QEMU 2.0.

 
 Further, I was under the impression that this series depends on Igor's
 feature property series, which I haven't found time to rework and
 haven't noticed anyone else do either. So if there's no prereqs (why
 uq/master?) I'll happily start reviewing and queuing it.

It doesn't depend on the feature properties at all.

But the series is based on uq/master only because it depends on
KVM-specific patches that are already on uq/master (that's why I added
uq/master to the Subject. It doesn't mean it has to be pulled through
uq/master necessarily).


 
 As Eduardo points out below the commit message in the final patch, his
 conversion is very similar to one of my earlier patch series, so
 committing that with Eduardo as author via uq/master without crediting
 me via uq/master would leave a bad taste.

Sorry, what would be the proper way to give proper attribution on the
commit message in this case? I often don't know if it is appropriate to
keep a Signed-off-by line if most of the code is new.

Also, I was incorrectly assuming the whole patch was re-written from
scratch by me, but now I have noticed I have copied
x86_cpu_list_compare() (and other parts) from your code without proper
attribution, I am very sorry for that. My poor excuse is that I have 3
or 4 local git branches where I was experimenting with different
approaches, and it was hard to keep track of everything.

-- 
Eduardo



[Qemu-devel] [PATCHv8 0/5] block: add native support for NFS

2014-01-31 Thread Peter Lieven
This adds v6 of the NFS protocol driver + qemu-iotest adjustments.

v7-v8:
 - bump libnfs requirement to 1.9.2
 - renamed NFSRPC-status to NFSRPC-ret [Benoit]
 - avoid double invocation of nfs_client_close in nfs_file_create [Benoit]
 - fixed error propagation in nfs_file_open [Benoit]

v6-v7:
 - removed unsused and partially non-existing libnfs header file includes 
[Stefan]
 - adjusted usage of qemu_opts_create_nofail [Stefan]
 - removed patch to fix output of qemu-iotest 067
 - only blacklist qemu-iotest 020 for NFS do not change proto from generic to 
file [Fam]

v5-v6:
 - use internal qemu function to parse the NFS url [Kevin]
 - zero pad short reads [Kevin, Paolo]
 - added qemu-iotests patches for basic nfs protocol support

v4-v5:
 - disussed with Ronnie and decided to move URL + Paramter parsing to LibNFS.
   This allows for URL parameter processing directly in LibNFS without altering
   the qemu NFS block driver. This bumps the version requirement for LibNFS
   to 1.9.0 though.
 - added a pointer to the LibNFS readme where additional information about
   ROOT privilidge requirements can be found as this raised a few concerns.
 - removed a trailing dot in an error statement [Fam].

v3-v4:
 - finally added full implementation of bdrv_get_allocated_file_size [Stefan]
 - removed trailing \n from error statements [Stefan]

v2-v3:
 - rebased the stefanha/block
 - use pkg_config to check for libnfs (ignoring cflags which are broken in 
1.8.0) [Stefan]
 - fixed NFSClient declaration [Stefan]
 - renamed Task variables to task [Stefan]
 - renamed NFSTask to NFSRPC [Ronnie]
 - do not update bs-total_sectors in nfs_co_writev [Stefan]
 - return -ENOMEM on all async call failures [Stefan,Ronnie]
 - fully implement ftruncate
 - use util/uri.c for URL parsing [Stefan]
 - reworked nfs_file_open_common to nfs_client_open which works on NFSClient 
[Stefan]
 - added a comment ot the connect message that libnfs support NFSv3 only at the 
moment.
 - DID NOT add full implementation of bdrv_get_allocated_file_size because
   we are not in a coroutine context and I cannot do an async call here.
   I could do a sync call if there would be a guarantee that no requests
   are in flight. [Stefan]

v1-v2:
 - fixed block/Makefile.objs [Ronnie]
 - do not always register a read handler [Ronnie]
 - add support for reading beyond EOF [Fam]
 - fixed struct and paramter naming [Fam]
 - fixed overlong lines and whitespace errors [Fam]
 - return return status from libnfs whereever possible [Fam]
 - added comment why we set allocated_file_size to -ENOTSUP after write [Fam]
 - avoid segfault when parsing filname [Fam]
 - remove unused close_bh from NFSClient [Fam]
 - avoid dividing and mutliplying total_size by BDRV_SECTOR_SIZE in 
nfs_file_create [Fam] 

Peter Lieven (5):
  block: add native support for NFS
  qemu-iotests: change _supported_proto to file for various tests
  qemu-iotests: enable support for NFS protocol
  qemu-iotests: enable test 016 and 025 to work with NFS protocol
  qemu-iotests: blacklist test 020 for NFS protocol

 MAINTAINERS  |5 +
 block/Makefile.objs  |1 +
 block/nfs.c  |  439 ++
 configure|   26 +++
 qapi-schema.json |1 +
 tests/qemu-iotests/013   |2 +-
 tests/qemu-iotests/014   |2 +-
 tests/qemu-iotests/016   |2 +-
 tests/qemu-iotests/018   |2 +-
 tests/qemu-iotests/019   |2 +-
 tests/qemu-iotests/020   |5 +
 tests/qemu-iotests/023   |2 +-
 tests/qemu-iotests/024   |2 +-
 tests/qemu-iotests/025   |2 +-
 tests/qemu-iotests/026   |2 +-
 tests/qemu-iotests/028   |2 +-
 tests/qemu-iotests/031   |2 +-
 tests/qemu-iotests/034   |2 +-
 tests/qemu-iotests/036   |2 +-
 tests/qemu-iotests/037   |2 +-
 tests/qemu-iotests/038   |2 +-
 tests/qemu-iotests/039   |2 +-
 tests/qemu-iotests/043   |2 +-
 tests/qemu-iotests/046   |2 +-
 tests/qemu-iotests/052   |2 +-
 tests/qemu-iotests/054   |2 +-
 tests/qemu-iotests/059   |2 +-
 tests/qemu-iotests/060   |2 +-
 tests/qemu-iotests/061   |2 +-
 tests/qemu-iotests/063   |2 +-
 tests/qemu-iotests/069   |2 +-
 tests/qemu-iotests/common|   22 ++-
 tests/qemu-iotests/common.rc |3 +
 33 files changed, 524 insertions(+), 28 deletions(-)
 create mode 100644 block/nfs.c

-- 
1.7.9.5




Re: [Qemu-devel] [PATCH] dataplane: Comment fix

2014-01-31 Thread Stefan Hajnoczi
On Thu, Jan 30, 2014 at 04:34:12PM +0100, Markus Armbruster wrote:
 
 Signed-off-by: Markus Armbruster arm...@redhat.com
 ---
  hw/block/dataplane/virtio-blk.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan



Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Eduardo Habkost
On Fri, Jan 31, 2014 at 12:42:08PM +0100, Paolo Bonzini wrote:
 Il 31/01/2014 12:30, Andreas Färber ha scritto:
 Further, I was under the impression that this series depends on Igor's
 feature property series, which I haven't found time to rework and
 haven't noticed anyone else do either. So if there's no prereqs (why
 uq/master?) I'll happily start reviewing and queuing it.
 
 Yeah, I was also wondering why uq/master too, mostly for patches 5 and 7.

I just wanted to indicate that the series can't be applied into
master yet because it depends on patches that are still on uq/master.

(In the past I have sent patches without a branch identifier in the
Subject, and started receiving notifications from some robot saying that
the patch doesn't apply to master. I don't know if that robot still
exists.)

-- 
Eduardo



[Qemu-devel] [PATCHv8 1/5] block: add native support for NFS

2014-01-31 Thread Peter Lieven
This patch adds native support for accessing images on NFS
shares without the requirement to actually mount the entire
NFS share on the host.

NFS Images can simply be specified by an url of the form:
nfs://host/export/filename[?param=value[param2=value2[...]]]

For example:
qemu-img create -f qcow2 nfs://10.0.0.1/qemu-images/test.qcow2

You need LibNFS from Ronnie Sahlberg available at:
   git://github.com/sahlberg/libnfs.git
for this to work.

During configure it is automatically probed for libnfs and support
is enabled on-the-fly. You can forbid or enforce libnfs support
with --disable-libnfs or --enable-libnfs respectively.

Due to NFS restrictions you might need to execute your binaries
as root, allow them to open priviledged ports (1024) or specify
insecure option on the NFS server.

For additional information on ROOT vs. non-ROOT operation and URL
format + parameters see:
   https://raw.github.com/sahlberg/libnfs/master/README

Supported by qemu are the uid, gid and tcp-syncnt URL parameters.

LibNFS currently support NFS version 3 only.

Signed-off-by: Peter Lieven p...@kamp.de
---
 MAINTAINERS |5 +
 block/Makefile.objs |1 +
 block/nfs.c |  439 +++
 configure   |   26 +++
 qapi-schema.json|1 +
 5 files changed, 472 insertions(+)
 create mode 100644 block/nfs.c

diff --git a/MAINTAINERS b/MAINTAINERS
index fb53242..f8411f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -936,6 +936,11 @@ M: Peter Lieven p...@kamp.de
 S: Supported
 F: block/iscsi.c
 
+NFS
+M: Peter Lieven p...@kamp.de
+S: Maintained
+F: block/nfs.c
+
 SSH
 M: Richard W.M. Jones rjo...@redhat.com
 S: Supported
diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4e8c91e..e254a21 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -12,6 +12,7 @@ block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 ifeq ($(CONFIG_POSIX),y)
 block-obj-y += nbd.o nbd-client.o sheepdog.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
+block-obj-$(CONFIG_LIBNFS) += nfs.o
 block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
 block-obj-$(CONFIG_GLUSTERFS) += gluster.o
diff --git a/block/nfs.c b/block/nfs.c
new file mode 100644
index 000..ef731f0
--- /dev/null
+++ b/block/nfs.c
@@ -0,0 +1,439 @@
+/*
+ * QEMU Block driver for native access to files on NFS shares
+ *
+ * Copyright (c) 2014 Peter Lieven p...@kamp.de
+ *
+ * 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 config-host.h
+
+#include poll.h
+#include qemu-common.h
+#include qemu/config-file.h
+#include qemu/error-report.h
+#include block/block_int.h
+#include trace.h
+#include qemu/iov.h
+#include qemu/uri.h
+#include sysemu/sysemu.h
+#include nfsc/libnfs.h
+
+typedef struct NFSClient {
+struct nfs_context *context;
+struct nfsfh *fh;
+int events;
+bool has_zero_init;
+} NFSClient;
+
+typedef struct NFSRPC {
+int ret;
+int complete;
+QEMUIOVector *iov;
+struct stat *st;
+Coroutine *co;
+QEMUBH *bh;
+} NFSRPC;
+
+static void nfs_process_read(void *arg);
+static void nfs_process_write(void *arg);
+
+static void nfs_set_events(NFSClient *client)
+{
+int ev = nfs_which_events(client-context);
+if (ev != client-events) {
+qemu_aio_set_fd_handler(nfs_get_fd(client-context),
+  (ev  POLLIN) ? nfs_process_read : NULL,
+  (ev  POLLOUT) ? nfs_process_write : NULL,
+  client);
+
+}
+client-events = ev;
+}
+
+static void nfs_process_read(void *arg)
+{
+NFSClient *client = arg;
+nfs_service(client-context, POLLIN);
+nfs_set_events(client);
+}
+
+static void nfs_process_write(void *arg)
+{
+NFSClient *client = arg;
+nfs_service(client-context, POLLOUT);
+nfs_set_events(client);
+}
+
+static void nfs_co_init_task(NFSClient *client, NFSRPC *task)
+{
+*task = (NFSRPC) {
+.co = qemu_coroutine_self(),
+};
+}

Re: [Qemu-devel] [PATCH] qemu-iotests: only run 071 on qcow2

2014-01-31 Thread Stefan Hajnoczi
On Wed, Jan 29, 2014 at 04:33:54PM +0100, Stefan Hajnoczi wrote:
 The 071 test is designed for IMGFMT=qcow2 because it uses the l2_load
 blkdebug event.  Its output filtering also assumes that IMGFMT is not
 raw since 071.out contains format=raw but IMGFMT=raw would filter the
 output to format=IMGFMT.
 
 Perhaps the test case can be rewritten to be more generic, but for now
 let's document that it was only supposed to work with qcow2.
 
 Signed-off-by: Stefan Hajnoczi stefa...@redhat.com
 ---
  tests/qemu-iotests/071 | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan



Re: [Qemu-devel] [PATCH 1/2] qom-test: Run for all available machines

2014-01-31 Thread Andreas Färber
Am 10.01.2014 14:31, schrieb arm...@redhat.com:
 From: Markus Armbruster arm...@redhat.com
 
 Get available machines via QMP instead of hardcoding a list that's
 perpetually out of date.
 
 A few machines don't work out of the box:
 
 * Several ppcemb machines can't initialize their CPU.
 
 * Xen machines can work only when running under the Xen hypervisor.
 
 Blacklist them.
 
 Signed-off-by: Markus Armbruster arm...@redhat.com

I've rebased this, queing it without the ppcemb blacklist (and adjusted
commit message) while waiting for Alex' ppc pull.

Thanks a lot,

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH] qmp: expose list of supported character device backends

2014-01-31 Thread Eric Blake
On 01/31/2014 03:35 AM, Martin Kletzander wrote:
 Introduce 'query-chardev-backends' QMP command which lists all
 supported character device backends.
 
 Signed-off-by: Martin Kletzander mklet...@redhat.com
 ---
  qapi-schema.json | 22 ++
  qemu-char.c  | 19 +++
  qmp-commands.hx  | 41 +
  3 files changed, 82 insertions(+)
 
 diff --git a/qapi-schema.json b/qapi-schema.json
 index 05ced9d..ac1061f 100644
 --- a/qapi-schema.json
 +++ b/qapi-schema.json
 @@ -437,6 +437,28 @@
  { 'command': 'query-chardev', 'returns': ['ChardevInfo'] }
 
  ##
 +# @ChardevBackendInfo:
 +#
 +# Information about a character device backend
 +#
 +# @name: The backend name
 +#
 +# Since: 1.8.0

2.0 will be the next release.

 +##
 +{ 'type': 'ChardevBackendInfo', 'data': {'name': 'str'} }
 +
 +##
 +# @query-chardev-backends:
 +#
 +# Returns information about character device backends.
 +#
 +# Returns: a list of @ChardevBackendInfo
 +#
 +# Since: 1.8.0

Again, 2.0.


 +
 +- { execute: query-chardev-backends }
 +- {
 +  return:[
 + {
 +name:udp,
 + },

This is somewhat complex, but allows us the option of future addition of
other items to return in addition to the name, if it proves useful
(returning a straight array of strings instead of an array of structs
prevents such future expansion).  So I think you made the right choice.

With the fixes to the version number:

Reviewed-by: Eric Blake ebl...@redhat.com

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



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH v3 3/5] pcihp: make pci_read() mmio calback compatible with legacy ACPI hotplug

2014-01-31 Thread Igor Mammedov
due to recent change introduced by:
pcihp: reduce number of device check events

'up' field is cleared right after it's read.
This is incompatible with legacy BIOS ACPI code
where PCNF ACPI method reads this field 32 times.

To make pci_read mmio callback compatible with legacy
'up' behavior, pcihp code will need to know in which
mode it runs so move 'use_acpi_pci_hotplug' into
AcpiPciHpState structure and alter register behavior
accordingly.

PS:
And since field 'use_acpi_pci_hotplug' is touched
anyway rename it to reflect its meaning more crearly
to 'legacy_piix' and corresponding property to
'legacy-acpi-pci-hotplug'.

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
 hw/acpi/pcihp.c |4 +++-
 hw/acpi/piix4.c |   15 +++
 include/hw/acpi/pcihp.h |1 +
 include/hw/i386/pc.h|4 ++--
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 64c8cf2..a7353f6 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -215,7 +215,9 @@ static uint64_t pci_read(void *opaque, hwaddr addr, 
unsigned int size)
 switch (addr) {
 case PCI_UP_BASE:
 val = s-acpi_pcihp_pci_status[bsel].up;
-s-acpi_pcihp_pci_status[bsel].up = 0;
+if (!s-legacy_piix) {
+s-acpi_pcihp_pci_status[bsel].up = 0;
+}
 ACPI_PCIHP_DPRINTF(pci_up_read % PRIu32 \n, val);
 break;
 case PCI_DOWN_BASE:
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 5d55a3c..33c9516 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -88,7 +88,6 @@ typedef struct PIIX4PMState {
 
 /* for new pci hotplug (with PCI2PCI bridge support) */
 AcpiPciHpState acpi_pci_hotplug;
-bool use_acpi_pci_hotplug;
 
 uint8_t disable_s3;
 uint8_t disable_s4;
@@ -263,13 +262,13 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int 
version_id)
 static bool vmstate_test_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
 PIIX4PMState *s = opaque;
-return s-use_acpi_pci_hotplug;
+return !s-acpi_pci_hotplug.legacy_piix;
 }
 
 static bool vmstate_test_no_use_acpi_pci_hotplug(void *opaque, int version_id)
 {
 PIIX4PMState *s = opaque;
-return !s-use_acpi_pci_hotplug;
+return s-acpi_pci_hotplug.legacy_piix;
 }
 
 /* qemu-kvm 1.2 uses version 3 but advertised as 2
@@ -377,7 +376,7 @@ static void piix4_reset(void *opaque)
 pci_conf[0x5B] = 0x02;
 }
 pm_io_space_update(s);
-if (s-use_acpi_pci_hotplug) {
+if (!s-acpi_pci_hotplug.legacy_piix) {
 acpi_pcihp_reset(s-acpi_pci_hotplug);
 } else {
 piix4_update_hotplug(s);
@@ -426,7 +425,7 @@ static void piix4_pm_machine_ready(Notifier *n, void 
*opaque)
 pci_conf[0x67] = (memory_region_present(io_as, 0x3f8) ? 0x08 : 0) |
 (memory_region_present(io_as, 0x2f8) ? 0x90 : 0);
 
-if (s-use_acpi_pci_hotplug) {
+if (!s-acpi_pci_hotplug.legacy_piix) {
 pci_for_each_bus(d-bus, piix4_update_bus_hotplug, s);
 }
 }
@@ -550,8 +549,8 @@ static Property piix4_pm_properties[] = {
 DEFINE_PROP_UINT8(ACPI_PM_PROP_S3_DISABLED, PIIX4PMState, disable_s3, 0),
 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_DISABLED, PIIX4PMState, disable_s4, 0),
 DEFINE_PROP_UINT8(ACPI_PM_PROP_S4_VAL, PIIX4PMState, s4_val, 2),
-DEFINE_PROP_BOOL(acpi-pci-hotplug-with-bridge-support, PIIX4PMState,
- use_acpi_pci_hotplug, true),
+DEFINE_PROP_BOOL(legacy-acpi-pci-hotplug, PIIX4PMState,
+ acpi_pci_hotplug.legacy_piix, false),
 DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -694,7 +693,7 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion 
*parent,
   acpi-gpe0, GPE_LEN);
 memory_region_add_subregion(parent, GPE_BASE, s-io_gpe);
 
-if (s-use_acpi_pci_hotplug) {
+if (!s-acpi_pci_hotplug.legacy_piix) {
 acpi_pcihp_init(s-acpi_pci_hotplug, bus, parent);
 } else {
 memory_region_init_io(s-io_pci, OBJECT(s), piix4_pci_ops, s,
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index aa297c2..6877892 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -46,6 +46,7 @@ typedef struct AcpiPciHpState {
 uint32_t hotplug_select;
 PCIBus *root;
 MemoryRegion io;
+bool legacy_piix;
 } AcpiPciHpState;
 
 void acpi_pcihp_init(AcpiPciHpState *, PCIBus *root,
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3e1e81b..68d75d8 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -268,8 +268,8 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 },\
 {\
 .driver   = PIIX4_PM,\
-.property = acpi-pci-hotplug-with-bridge-support,\
-.value= off,\
+.property = legacy-acpi-pci-hotplug,\
+.value= on,\
 }
 
 #define PC_COMPAT_1_6 \
-- 
1.7.1




[Qemu-devel] [PATCH v3 2/5] pcihp: make PCI hotplug mmio handlers indifferent to PCI_HOTPLUG_ADDR

2014-01-31 Thread Igor Mammedov
... removes dependency of mmio handler on PCI_HOTPLUG_ADDR.
It will be needed in case of Q35 where base could be different.

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
 hw/acpi/pcihp.c |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 464739a..64c8cf2 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -48,11 +48,11 @@
 
 #define PCI_HOTPLUG_ADDR 0xae00
 #define PCI_HOTPLUG_SIZE 0x0014
-#define PCI_UP_BASE 0xae00
-#define PCI_DOWN_BASE 0xae04
-#define PCI_EJ_BASE 0xae08
-#define PCI_RMV_BASE 0xae0c
-#define PCI_SEL_BASE 0xae10
+#define PCI_UP_BASE 0x
+#define PCI_DOWN_BASE 0x0004
+#define PCI_EJ_BASE 0x0008
+#define PCI_RMV_BASE 0x000c
+#define PCI_SEL_BASE 0x0010
 
 typedef struct AcpiPciHpFind {
 int bsel;
@@ -213,24 +213,24 @@ static uint64_t pci_read(void *opaque, hwaddr addr, 
unsigned int size)
 }
 
 switch (addr) {
-case PCI_UP_BASE - PCI_HOTPLUG_ADDR:
+case PCI_UP_BASE:
 val = s-acpi_pcihp_pci_status[bsel].up;
 s-acpi_pcihp_pci_status[bsel].up = 0;
 ACPI_PCIHP_DPRINTF(pci_up_read % PRIu32 \n, val);
 break;
-case PCI_DOWN_BASE - PCI_HOTPLUG_ADDR:
+case PCI_DOWN_BASE:
 val = s-acpi_pcihp_pci_status[bsel].down;
 ACPI_PCIHP_DPRINTF(pci_down_read % PRIu32 \n, val);
 break;
-case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
+case PCI_EJ_BASE:
 /* No feature defined yet */
 ACPI_PCIHP_DPRINTF(pci_features_read % PRIu32 \n, val);
 break;
-case PCI_RMV_BASE - PCI_HOTPLUG_ADDR:
+case PCI_RMV_BASE:
 val = s-acpi_pcihp_pci_status[bsel].hotplug_enable;
 ACPI_PCIHP_DPRINTF(pci_rmv_read % PRIu32 \n, val);
 break;
-case PCI_SEL_BASE - PCI_HOTPLUG_ADDR:
+case PCI_SEL_BASE:
 val = s-hotplug_select;
 ACPI_PCIHP_DPRINTF(pci_sel_read % PRIu32 \n, val);
 default:
@@ -245,7 +245,7 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t 
data,
 {
 AcpiPciHpState *s = opaque;
 switch (addr) {
-case PCI_EJ_BASE - PCI_HOTPLUG_ADDR:
+case PCI_EJ_BASE:
 if (s-hotplug_select = ACPI_PCIHP_MAX_HOTPLUG_BUS) {
 break;
 }
@@ -253,7 +253,7 @@ static void pci_write(void *opaque, hwaddr addr, uint64_t 
data,
 ACPI_PCIHP_DPRINTF(pciej write % HWADDR_PRIx  == % PRIu64 \n,
   addr, data);
 break;
-case PCI_SEL_BASE - PCI_HOTPLUG_ADDR:
+case PCI_SEL_BASE:
 s-hotplug_select = data;
 ACPI_PCIHP_DPRINTF(pcisel write % HWADDR_PRIx  == % PRIu64 \n,
   addr, data);
-- 
1.7.1




[Qemu-devel] [PATCH v3 0/5] pc: make ACPI pcihp more reusable

2014-01-31 Thread Igor Mammedov
changes since v2:
 - rename 'use_acpi_pci_hotplug' field to 'legacy_piix'
   and corresponding properties 
 - drop excessive checks for legacy mode
 - rework legacy vmstate handling to use AcpiPciHpPciStatus[0] structure
   which reduced acpi/piix4.c by another 50 LOC
 - move legacy initialization to pcihp.c
changes since v1:
 - add BSEL property to root bus when in compatibility mode
 as result dropped hw:acpi:pcihp: assume root PCI bus if bus has no 
ACPI_PCIHP_PROP_BSEL property
 - rebasing on top of pcihp: reduce number of device check events
   added patch 3/4.

Reuses new pcihp code for handling legacy PCI hotplug in
acpi/piix4_pm, which significantly reduces code duplication
between piix4_pm and pcihp reducing codebase by ~200 LOC.

It also allows cleaner rebase of generic hotplug refactoring,
by not increasing code duplication since it will need to be
done only for pcihp.

Git tree for testing based on mst's PCI tree:
https://github.com/imammedo/qemu/commits/pcihp_cleanup_v3

Igor Mammedov (5):
  pcihp: replace enable|disable_device() with oneliners
  pcihp: make PCI hotplug mmio handlers indifferent to PCI_HOTPLUG_ADDR
  pcihp: make pci_read() mmio calback compatible with legacy ACPI
hotplug
  pcihp: remove unused AcpiPciHpPciStatus.device_present field
  hw:piix4:acpi: reuse pcihp code for legacy PCI hotplug

 hw/acpi/pcihp.c |   64 +++---
 hw/acpi/piix4.c |  220 ---
 include/hw/acpi/pcihp.h |3 +-
 include/hw/i386/pc.h|4 +-
 4 files changed, 57 insertions(+), 234 deletions(-)




[Qemu-devel] [PATCH v3 1/5] pcihp: replace enable|disable_device() with oneliners

2014-01-31 Thread Igor Mammedov
enable_device() and disable_device() functions aren't reused anywere,
so replace them with respective oneliners at call sites.

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
 hw/acpi/pcihp.c |   14 ++
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 4345f5d..464739a 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -177,16 +177,6 @@ void acpi_pcihp_reset(AcpiPciHpState *s)
 acpi_pcihp_update(s);
 }
 
-static void enable_device(AcpiPciHpState *s, unsigned bsel, int slot)
-{
-s-acpi_pcihp_pci_status[bsel].up |= (1U  slot);
-}
-
-static void disable_device(AcpiPciHpState *s, unsigned bsel, int slot)
-{
-s-acpi_pcihp_pci_status[bsel].down |= (1U  slot);
-}
-
 int acpi_pcihp_device_hotplug(AcpiPciHpState *s, PCIDevice *dev,
   PCIHotplugState state)
 {
@@ -204,9 +194,9 @@ int acpi_pcihp_device_hotplug(AcpiPciHpState *s, PCIDevice 
*dev,
 }
 
 if (state == PCI_HOTPLUG_ENABLED) {
-enable_device(s, bsel, slot);
+s-acpi_pcihp_pci_status[bsel].up |= (1U  slot);
 } else {
-disable_device(s, bsel, slot);
+s-acpi_pcihp_pci_status[bsel].down |= (1U  slot);
 }
 
 return 0;
-- 
1.7.1




[Qemu-devel] [PATCH v3 4/5] pcihp: remove unused AcpiPciHpPciStatus.device_present field

2014-01-31 Thread Igor Mammedov
Remove now unused 'device_present' field wich was obsoleted by
patch pcihp: reduce number of device check events

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
 include/hw/acpi/pcihp.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 6877892..bbd789f 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -35,7 +35,6 @@ typedef struct AcpiPciHpPciStatus {
 uint32_t up;
 uint32_t down;
 uint32_t hotplug_enable;
-uint32_t device_present;
 } AcpiPciHpPciStatus;
 
 #define ACPI_PCIHP_PROP_BSEL acpi-pcihp-bsel
-- 
1.7.1




[Qemu-devel] [PATCH v3 5/5] hw:piix4:acpi: reuse pcihp code for legacy PCI hotplug

2014-01-31 Thread Igor Mammedov
reduces acpi PCI hotplug code duplication by ~200LOC

Signed-off-by: Igor Mammedov imamm...@redhat.com
---
v3:
 - remove exessive checks for compat mode
 - replace up/down fields of pci_status with corresponding fields
   form AcpiPciHpPciStatus in vmstate wich allow to remove extra
   50 LOC of legacy code
 - move legacy initialization logic to pcihp.c
v2:
 - replace obsolete 'device_present' with 'up' field
 - add/set ACPI_PCIHP_PROP_BSEL to 0 when running in compatibility
   mode with old machine types.
---
 hw/acpi/pcihp.c |   22 -
 hw/acpi/piix4.c |  209 +++---
 include/hw/acpi/pcihp.h |1 +
 3 files changed, 32 insertions(+), 200 deletions(-)

diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index a7353f6..527d39e 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -46,8 +46,9 @@
 # define ACPI_PCIHP_DPRINTF(format, ...) do { } while (0)
 #endif
 
-#define PCI_HOTPLUG_ADDR 0xae00
-#define PCI_HOTPLUG_SIZE 0x0014
+#define ACPI_PCIHP_ADDR 0xae00
+#define ACPI_PCIHP_SIZE 0x0014
+#define ACPI_PCIHP_LEGACY_SIZE 0x000f
 #define PCI_UP_BASE 0x
 #define PCI_DOWN_BASE 0x0004
 #define PCI_EJ_BASE 0x0008
@@ -277,11 +278,22 @@ static const MemoryRegionOps acpi_pcihp_io_ops = {
 void acpi_pcihp_init(AcpiPciHpState *s, PCIBus *root_bus,
  MemoryRegion *address_space_io)
 {
+uint16_t io_size = ACPI_PCIHP_SIZE;
+
+if (s-legacy_piix) {
+unsigned *bus_bsel = g_malloc(sizeof *bus_bsel);
+
+io_size = ACPI_PCIHP_LEGACY_SIZE;
+
+*bus_bsel = ACPI_PCIHP_BSEL_DEFAULT;
+object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PROP_BSEL,
+   bus_bsel, NULL);
+}
+
 s-root= root_bus;
 memory_region_init_io(s-io, NULL, acpi_pcihp_io_ops, s,
-  acpi-pci-hotplug,
-  PCI_HOTPLUG_SIZE);
-memory_region_add_subregion(address_space_io, PCI_HOTPLUG_ADDR, s-io);
+  acpi-pci-hotplug, io_size);
+memory_region_add_subregion(address_space_io, ACPI_PCIHP_ADDR, s-io);
 }
 
 const VMStateDescription vmstate_acpi_pcihp_pci_status = {
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 33c9516..2365014 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -44,13 +44,6 @@
 #define GPE_BASE 0xafe0
 #define GPE_LEN 4
 
-#define PCI_HOTPLUG_ADDR 0xae00
-#define PCI_HOTPLUG_SIZE 0x000f
-#define PCI_UP_BASE 0xae00
-#define PCI_DOWN_BASE 0xae04
-#define PCI_EJ_BASE 0xae08
-#define PCI_RMV_BASE 0xae0c
-
 #define PIIX4_PCI_HOTPLUG_STATUS 2
 
 struct pci_status {
@@ -80,13 +73,6 @@ typedef struct PIIX4PMState {
 Notifier machine_ready;
 Notifier powerdown_notifier;
 
-/* for legacy pci hotplug (compatible with qemu 1.6 and older) */
-MemoryRegion io_pci;
-struct pci_status pci0_status;
-uint32_t pci0_hotplug_enable;
-uint32_t pci0_slot_device_present;
-
-/* for new pci hotplug (with PCI2PCI bridge support) */
 AcpiPciHpState acpi_pci_hotplug;
 
 uint8_t disable_s3;
@@ -169,17 +155,6 @@ static void pm_write_config(PCIDevice *d,
 }
 }
 
-static void vmstate_pci_status_pre_save(void *opaque)
-{
-struct pci_status *pci0_status = opaque;
-PIIX4PMState *s = container_of(pci0_status, PIIX4PMState, pci0_status);
-
-/* We no longer track up, so build a safe value for migrating
- * to a version that still does... of course these might get lost
- * by an old buggy implementation, but we try. */
-pci0_status-up = s-pci0_slot_device_present  s-pci0_hotplug_enable;
-}
-
 static int vmstate_acpi_post_load(void *opaque, int version_id)
 {
 PIIX4PMState *s = opaque;
@@ -215,10 +190,9 @@ static const VMStateDescription vmstate_pci_status = {
 .version_id = 1,
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
-.pre_save = vmstate_pci_status_pre_save,
 .fields  = (VMStateField []) {
-VMSTATE_UINT32(up, struct pci_status),
-VMSTATE_UINT32(down, struct pci_status),
+VMSTATE_UINT32(up, struct AcpiPciHpPciStatus),
+VMSTATE_UINT32(down, struct AcpiPciHpPciStatus),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -255,7 +229,8 @@ static int acpi_load_old(QEMUFile *f, void *opaque, int 
version_id)
 qemu_get_be16s(f, temp);
 }
 
-ret = vmstate_load_state(f, vmstate_pci_status, s-pci0_status, 1);
+ret = vmstate_load_state(f, vmstate_pci_status,
+s-acpi_pci_hotplug.acpi_pcihp_pci_status[ACPI_PCIHP_BSEL_DEFAULT], 
1);
 return ret;
 }
 
@@ -293,70 +268,18 @@ static const VMStateDescription vmstate_acpi = {
 VMSTATE_TIMER(ar.tmr.timer, PIIX4PMState),
 VMSTATE_INT64(ar.tmr.overflow_time, PIIX4PMState),
 VMSTATE_STRUCT(ar.gpe, PIIX4PMState, 2, vmstate_gpe, ACPIGPE),
-VMSTATE_STRUCT_TEST(pci0_status, PIIX4PMState,
-vmstate_test_no_use_acpi_pci_hotplug,
-2, vmstate_pci_status,
-   

Re: [Qemu-devel] [PATCH 1/2] qom-test: Run for all available machines

2014-01-31 Thread Markus Armbruster
Andreas Färber afaer...@suse.de writes:

 Am 10.01.2014 14:31, schrieb arm...@redhat.com:
 From: Markus Armbruster arm...@redhat.com
 
 Get available machines via QMP instead of hardcoding a list that's
 perpetually out of date.
 
 A few machines don't work out of the box:
 
 * Several ppcemb machines can't initialize their CPU.
 
 * Xen machines can work only when running under the Xen hypervisor.
 
 Blacklist them.
 
 Signed-off-by: Markus Armbruster arm...@redhat.com

 I've rebased this, queing it without the ppcemb blacklist (and adjusted
 commit message) while waiting for Alex' ppc pull.

 Thanks a lot,

Where's your tree again?  I'd like to have a look.



[Qemu-devel] [PATCH v2] Define the architecture for compressed dump format.

2014-01-31 Thread Ekaterina Tumanova
Signed-off-by: Ekaterina Tumanova tuman...@linux.vnet.ibm.com
---
 dump.c | 7 +--
 target-i386/cpu.h  | 2 ++
 target-s390x/cpu.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dump.c b/dump.c
index 8f64aab..25503bc 100644
--- a/dump.c
+++ b/dump.c
@@ -32,6 +32,9 @@
 #ifdef CONFIG_SNAPPY
 #include snappy-c.h
 #endif
+#ifndef ELF_MACHINE_UNAME
+#define ELF_MACHINE_UNAME Unknown
+#endif
 
 static uint16_t cpu_convert_to_target16(uint16_t val, int endian)
 {
@@ -817,7 +820,7 @@ static int create_header32(DumpState *s)
 dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
 bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
 dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
-memcpy((dh-utsname.machine), i686, 4);
+strncpy((char *)(dh-utsname.machine), ELF_MACHINE_UNAME, 
sizeof(dh-utsname.machine));
 
 if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
 status |= DUMP_DH_COMPRESSED_ZLIB;
@@ -924,7 +927,7 @@ static int create_header64(DumpState *s)
 dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
 bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
 dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
-memcpy((dh-utsname.machine), x86_64, 6);
+strncpy((char *)(dh-utsname.machine), ELF_MACHINE_UNAME, 
sizeof(dh-utsname.machine));
 
 if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
 status |= DUMP_DH_COMPRESSED_ZLIB;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 1fcbc82..198743c 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -38,8 +38,10 @@
 
 #ifdef TARGET_X86_64
 #define ELF_MACHINE EM_X86_64
+#define ELF_MACHINE_UNAME x86_64
 #else
 #define ELF_MACHINE EM_386
+#define ELF_MACHINE_UNAME i686
 #endif
 
 #define CPUArchState struct CPUX86State
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 68b5ab7..bf7ae4c 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -28,6 +28,7 @@
 #define TARGET_LONG_BITS 64
 
 #define ELF_MACHINEEM_S390
+#define ELF_MACHINE_UNAME S390X
 
 #define CPUArchState struct CPUS390XState
 
-- 
1.8.4.5




[Qemu-devel] [PATCH v2] Define guest architecture for the compressed dump header.

2014-01-31 Thread Ekaterina Tumanova
You're right about the warning. I removed it. I also added the
cast for the destination argument, which caused a warning as well.

I tested on s390 and i386 laptop.

If you ok with the patch, can you push it on top of this series?

Thank you,

Regards,
Kate.

Ekaterina Tumanova (1):
  Define the architecture for compressed dump format.

 dump.c | 7 +--
 target-i386/cpu.h  | 2 ++
 target-s390x/cpu.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

-- 
1.8.4.5




Re: [Qemu-devel] [PATCH v2] Define the architecture for compressed dump format.

2014-01-31 Thread Christian Borntraeger
On 31/01/14 14:45, Ekaterina Tumanova wrote:
 Signed-off-by: Ekaterina Tumanova tuman...@linux.vnet.ibm.com
Acked-by:  Christian Borntraeger borntrae...@de.ibm.com

 ---
  dump.c | 7 +--
  target-i386/cpu.h  | 2 ++
  target-s390x/cpu.h | 1 +
  3 files changed, 8 insertions(+), 2 deletions(-)
 
 diff --git a/dump.c b/dump.c
 index 8f64aab..25503bc 100644
 --- a/dump.c
 +++ b/dump.c
 @@ -32,6 +32,9 @@
  #ifdef CONFIG_SNAPPY
  #include snappy-c.h
  #endif
 +#ifndef ELF_MACHINE_UNAME
 +#define ELF_MACHINE_UNAME Unknown
 +#endif
 
  static uint16_t cpu_convert_to_target16(uint16_t val, int endian)
  {
 @@ -817,7 +820,7 @@ static int create_header32(DumpState *s)
  dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
  bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
  dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
 -memcpy((dh-utsname.machine), i686, 4);
 +strncpy((char *)(dh-utsname.machine), ELF_MACHINE_UNAME, 
 sizeof(dh-utsname.machine));
 
  if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
  status |= DUMP_DH_COMPRESSED_ZLIB;
 @@ -924,7 +927,7 @@ static int create_header64(DumpState *s)
  dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
  bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
  dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
 -memcpy((dh-utsname.machine), x86_64, 6);
 +strncpy((char *)(dh-utsname.machine), ELF_MACHINE_UNAME, 
 sizeof(dh-utsname.machine));
 
  if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
  status |= DUMP_DH_COMPRESSED_ZLIB;
 diff --git a/target-i386/cpu.h b/target-i386/cpu.h
 index 1fcbc82..198743c 100644
 --- a/target-i386/cpu.h
 +++ b/target-i386/cpu.h
 @@ -38,8 +38,10 @@
 
  #ifdef TARGET_X86_64
  #define ELF_MACHINE EM_X86_64
 +#define ELF_MACHINE_UNAME x86_64
  #else
  #define ELF_MACHINE EM_386
 +#define ELF_MACHINE_UNAME i686
  #endif
 
  #define CPUArchState struct CPUX86State
 diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
 index 68b5ab7..bf7ae4c 100644
 --- a/target-s390x/cpu.h
 +++ b/target-s390x/cpu.h
 @@ -28,6 +28,7 @@
  #define TARGET_LONG_BITS 64
 
  #define ELF_MACHINE  EM_S390
 +#define ELF_MACHINE_UNAME S390X
 
  #define CPUArchState struct CPUS390XState
 




Re: [Qemu-devel] [Qemu-ppc] [PATCH v5 2/2] target-ppc: spapr: e500: fix to use cpu_dt_id

2014-01-31 Thread Alexander Graf

On 03.12.2013, at 04:30, Alexey Kardashevskiy a...@ozlabs.ru wrote:

 This makes use of @cpu_dt_id and related API in:
 1. emulated XICS hypercall handlers as they receive fixed CPU indexes;
 2. XICS-KVM to enable in-kernel XICS on right CPU;
 3. device-tree renderer.
 
 This removes @cpu_index fixup as @cpu_dt_id is used instead so QEMU monitor
 can accept command-line CPU indexes again.
 
 This changes kvm_arch_vcpu_id() to use ppc_get_vcpu_dt_id() as at the moment
 KVM CPU id and device tree ID are calculated using the same algorithm.
 
 Signed-off-by: Alexey Kardashevskiy a...@ozlabs.ru
 ---
 hw/intc/openpic_kvm.c   |  2 +-
 hw/intc/xics.c  | 15 +--
 hw/intc/xics_kvm.c  | 10 +-
 hw/ppc/e500.c   |  7 +--
 hw/ppc/spapr.c  |  9 +
 hw/ppc/spapr_hcall.c|  6 +++---
 hw/ppc/spapr_rtas.c | 14 +++---
 target-ppc/kvm.c| 10 +-
 target-ppc/translate_init.c |  2 ++
 9 files changed, 42 insertions(+), 33 deletions(-)
 
 diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
 index c7f7b84..87fdb12 100644
 --- a/hw/intc/openpic_kvm.c
 +++ b/hw/intc/openpic_kvm.c
 @@ -228,7 +228,7 @@ int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *cs)
 
 encap.cap = KVM_CAP_IRQ_MPIC;
 encap.args[0] = opp-fd;
 -encap.args[1] = cs-cpu_index;
 +encap.args[1] = kvm_arch_vcpu_id(cs);
 
 return kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, encap);
 }
 diff --git a/hw/intc/xics.c b/hw/intc/xics.c
 index b437563..64aabe7 100644
 --- a/hw/intc/xics.c
 +++ b/hw/intc/xics.c
 @@ -33,6 +33,17 @@
 #include qemu/error-report.h
 #include qapi/visitor.h
 
 +static int get_cpu_index_by_dt_id(int cpu_dt_id)
 +{
 +PowerPCCPU *cpu = ppc_get_vcpu_by_dt_id(cpu_dt_id);
 +
 +if (cpu) {
 +return cpu-parent_obj.cpu_index;
 +}
 +
 +return -1;
 +}
 +
 void xics_cpu_setup(XICSState *icp, PowerPCCPU *cpu)
 {
 CPUState *cs = CPU(cpu);
 @@ -659,7 +670,7 @@ static target_ulong h_cppr(PowerPCCPU *cpu, 
 sPAPREnvironment *spapr,
 static target_ulong h_ipi(PowerPCCPU *cpu, sPAPREnvironment *spapr,
   target_ulong opcode, target_ulong *args)
 {
 -target_ulong server = args[0];
 +target_ulong server = get_cpu_index_by_dt_id(args[0]);
 target_ulong mfrr = args[1];
 
 if (server = spapr-icp-nr_servers) {
 @@ -728,7 +739,7 @@ static void rtas_set_xive(PowerPCCPU *cpu, 
 sPAPREnvironment *spapr,
 }
 
 nr = rtas_ld(args, 0);
 -server = rtas_ld(args, 1);
 +server = get_cpu_index_by_dt_id(rtas_ld(args, 1));
 priority = rtas_ld(args, 2);
 
 if (!ics_valid_irq(ics, nr) || (server = ics-icp-nr_servers)
 diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
 index c203646..a5bbc24 100644
 --- a/hw/intc/xics_kvm.c
 +++ b/hw/intc/xics_kvm.c
 @@ -65,7 +65,7 @@ static void icp_get_kvm_state(ICPState *ss)
 ret = kvm_vcpu_ioctl(ss-cs, KVM_GET_ONE_REG, reg);
 if (ret != 0) {
 error_report(Unable to retrieve KVM interrupt controller state
 - for CPU %d: %s, ss-cs-cpu_index, strerror(errno));
 + for CPU %ld: %s, kvm_arch_vcpu_id(ss-cs), 
 strerror(errno));
 exit(1);
 }
 
 @@ -97,7 +97,7 @@ static int icp_set_kvm_state(ICPState *ss, int version_id)
 ret = kvm_vcpu_ioctl(ss-cs, KVM_SET_ONE_REG, reg);
 if (ret != 0) {
 error_report(Unable to restore KVM interrupt controller state (0x%
 -PRIx64 ) for CPU %d: %s, state, ss-cs-cpu_index,
 +PRIx64 ) for CPU %ld: %s, state, kvm_arch_vcpu_id(ss-cs),
 strerror(errno));
 return ret;
 }
 @@ -325,15 +325,15 @@ static void xics_kvm_cpu_setup(XICSState *icp, 
 PowerPCCPU *cpu)
 struct kvm_enable_cap xics_enable_cap = {
 .cap = KVM_CAP_IRQ_XICS,
 .flags = 0,
 -.args = {icpkvm-kernel_xics_fd, cs-cpu_index, 0, 0},
 +.args = {icpkvm-kernel_xics_fd, kvm_arch_vcpu_id(cs), 0, 0},
 };
 
 ss-cs = cs;
 
 ret = kvm_vcpu_ioctl(ss-cs, KVM_ENABLE_CAP, xics_enable_cap);
 if (ret  0) {
 -error_report(Unable to connect CPU%d to kernel XICS: %s,
 -cs-cpu_index, strerror(errno));
 +error_report(Unable to connect CPU%ld to kernel XICS: %s,
 +kvm_arch_vcpu_id(cs), strerror(errno));
 exit(1);
 }
 }
 diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
 index cfdd84b..256ac22 100644
 --- a/hw/ppc/e500.c
 +++ b/hw/ppc/e500.c
 @@ -238,6 +238,7 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs 
 *args,
the first node as boot node and be happy */
 for (i = smp_cpus - 1; i = 0; i--) {
 CPUState *cpu;
 +PowerPCCPU *pcpu;
 char cpu_name[128];
 uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20);
 
 @@ -246,14 +247,16 @@ static int ppce500_load_device_tree(QEMUMachineInitArgs 
 *args,
 

Re: [Qemu-devel] [PATCH v2] Define the architecture for compressed dump format.

2014-01-31 Thread Laszlo Ersek
one not-so-important comment below:

On 01/31/14 14:45, Ekaterina Tumanova wrote:
 Signed-off-by: Ekaterina Tumanova tuman...@linux.vnet.ibm.com
 ---
  dump.c | 7 +--
  target-i386/cpu.h  | 2 ++
  target-s390x/cpu.h | 1 +
  3 files changed, 8 insertions(+), 2 deletions(-)
 
 diff --git a/dump.c b/dump.c
 index 8f64aab..25503bc 100644
 --- a/dump.c
 +++ b/dump.c
 @@ -32,6 +32,9 @@
  #ifdef CONFIG_SNAPPY
  #include snappy-c.h
  #endif
 +#ifndef ELF_MACHINE_UNAME
 +#define ELF_MACHINE_UNAME Unknown
 +#endif
  
  static uint16_t cpu_convert_to_target16(uint16_t val, int endian)
  {
 @@ -817,7 +820,7 @@ static int create_header32(DumpState *s)
  dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
  bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
  dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
 -memcpy((dh-utsname.machine), i686, 4);
 +strncpy((char *)(dh-utsname.machine), ELF_MACHINE_UNAME, 
 sizeof(dh-utsname.machine));

dh-utsname.machine is actually an array of characters, if I recall
correctly (see NewUtsname in patch 08).

The expression in the first argument takes the address of the entire
array (the resultant pointer has type pointer-to-array). I didn't call
it out with memcpy(), because it didn't really matter. But now it looks
a bit gross, because as 2nd step we convert the pointer-to-array back to
pointer-to-char. It would be simpler to write

strncpy(dh-utsname.machine, ELF_MACHINE_UNAME,
sizeof(dh-utsname.machine))

where dh-utsname.machine decays to a pointer to its first element:

6.  Language
6.3 Conversions
6.3.2   Other operands
6.3.2.1 Lvalues, arrays, and function designators

  3  Except when it is the operand of the sizeof operator or the unary
  operator, or is a string literal used to initialize an array, an
 expression that has type ‘‘array of type’’ is converted to an
 expression with type ‘‘pointer to type’’ that points to the
 initial element of the array object and is not an lvalue. If the
 array object has register storage class, the behavior is undefined.

I should have probably noticed this in v1 of the followup patch. I don't
insist on upating it of course.

Reviewed-by: Laszlo Ersek ler...@redhat.com

Nonetheless, if you want to fix that up in a v3, please keep my R-b.

Thanks
Laszlo



Re: [Qemu-devel] [PATCH v4 0/4] Create ARM KVM VGIC with device control API

2014-01-31 Thread Peter Maydell
On 29 January 2014 13:21, Peter Maydell peter.mayd...@linaro.org wrote:
 On 28 January 2014 20:28, Christoffer Dall christoffer.d...@linaro.org 
 wrote:
 This patch series adds generic support for issuing device control
 related ioctls and supports creating the ARM KVM-accelerated VGIC using
 the device control API while maintaining backwards compatibility for
 older kernels.

 Changelogs in the individual patches.

 Thanks, applied to target-arm.next. Git complains about trailing
 whitespace in the kernel header patch; dunno if you care about
 fixing that kind of thing in the kernel upstream.

I slightly belatedly discovered that these patches break
the build on aarch64 hosts, because your new kernel defines
only exist in the arm KVM headers and not the arm64 ones:

/home/petmay01/linaro/qemu-from-laptop/qemu/hw/intc/arm_gic_kvm.c: In
function 'kvm_arm_gic_realize':
/home/petmay01/linaro/qemu-from-laptop/qemu/hw/intc/arm_gic_kvm.c:141:29:
error: 'KVM_DEV_ARM_VGIC_GRP_ADDR' undeclared (first use in this
function)
/home/petmay01/linaro/qemu-from-laptop/qemu/hw/intc/arm_gic_kvm.c:141:29:
note: each undeclared identifier is reported only once for each
function it appears in

I've dropped the patches from target-arm.next. The
simplest fix is probably to get the arm64 headers to
also support this API and then resubmit.

thanks
-- PMM



[Qemu-devel] [PATCH 08/11] lm832x: QOM'ify

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/input/lm832x.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/hw/input/lm832x.c b/hw/input/lm832x.c
index f583cf0..4ae1cd9 100644
--- a/hw/input/lm832x.c
+++ b/hw/input/lm832x.c
@@ -23,8 +23,12 @@
 #include qemu/timer.h
 #include ui/console.h
 
+#define TYPE_LM8323 lm8323
+#define LM8323(obj) OBJECT_CHECK(LM823KbdState, (obj), TYPE_LM8323)
+
 typedef struct {
-I2CSlave i2c;
+I2CSlave parent_obj;
+
 uint8_t i2c_dir;
 uint8_t i2c_cycle;
 uint8_t reg;
@@ -380,7 +384,7 @@ static void lm_kbd_write(LM823KbdState *s, int reg, int 
byte, uint8_t value)
 
 static void lm_i2c_event(I2CSlave *i2c, enum i2c_event event)
 {
-LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+LM823KbdState *s = LM8323(i2c);
 
 switch (event) {
 case I2C_START_RECV:
@@ -396,14 +400,14 @@ static void lm_i2c_event(I2CSlave *i2c, enum i2c_event 
event)
 
 static int lm_i2c_rx(I2CSlave *i2c)
 {
-LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+LM823KbdState *s = LM8323(i2c);
 
 return lm_kbd_read(s, s-reg, s-i2c_cycle ++);
 }
 
 static int lm_i2c_tx(I2CSlave *i2c, uint8_t data)
 {
-LM823KbdState *s = (LM823KbdState *) i2c;
+LM823KbdState *s = LM8323(i2c);
 
 if (!s-i2c_cycle)
 s-reg = data;
@@ -431,7 +435,7 @@ static const VMStateDescription vmstate_lm_kbd = {
 .minimum_version_id_old = 0,
 .post_load = lm_kbd_post_load,
 .fields  = (VMStateField []) {
-VMSTATE_I2C_SLAVE(i2c, LM823KbdState),
+VMSTATE_I2C_SLAVE(parent_obj, LM823KbdState),
 VMSTATE_UINT8(i2c_dir, LM823KbdState),
 VMSTATE_UINT8(i2c_cycle, LM823KbdState),
 VMSTATE_UINT8(reg, LM823KbdState),
@@ -460,13 +464,13 @@ static const VMStateDescription vmstate_lm_kbd = {
 
 static int lm8323_init(I2CSlave *i2c)
 {
-LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, i2c);
+LM823KbdState *s = LM8323(i2c);
 
 s-model = 0x8323;
 s-pwm.tm[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm0_tick, s);
 s-pwm.tm[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm1_tick, s);
 s-pwm.tm[2] = timer_new_ns(QEMU_CLOCK_VIRTUAL, lm_kbd_pwm2_tick, s);
-qdev_init_gpio_out(i2c-qdev, s-nirq, 1);
+qdev_init_gpio_out(DEVICE(i2c), s-nirq, 1);
 
 lm_kbd_reset(s);
 
@@ -476,7 +480,7 @@ static int lm8323_init(I2CSlave *i2c)
 
 void lm832x_key_event(DeviceState *dev, int key, int state)
 {
-LM823KbdState *s = FROM_I2C_SLAVE(LM823KbdState, I2C_SLAVE(dev));
+LM823KbdState *s = LM8323(dev);
 
 if ((s-status  INT_ERROR)  (s-error  ERR_FIFOOVR))
 return;
@@ -507,7 +511,7 @@ static void lm8323_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo lm8323_info = {
-.name  = lm8323,
+.name  = TYPE_LM8323,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(LM823KbdState),
 .class_init= lm8323_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 03/11] tosa: QOM'ify DAC

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/arm/tosa.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
index dd224d3..2069f55 100644
--- a/hw/arm/tosa.c
+++ b/hw/arm/tosa.c
@@ -132,15 +132,20 @@ static int tosa_ssp_init(SSISlave *dev)
 return 0;
 }
 
+#define TYPE_TOSA_DAC tosa_dac
+#define TOSA_DAC(obj) OBJECT_CHECK(TosaDACState, (obj), TYPE_TOSA_DAC)
+
 typedef struct {
-I2CSlave i2c;
+I2CSlave parent_obj;
+
 int len;
 char buf[3];
 } TosaDACState;
 
 static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
 {
-TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+TosaDACState *s = TOSA_DAC(i2c);
+
 s-buf[s-len] = data;
 if (s-len ++  2) {
 #ifdef VERBOSE
@@ -159,7 +164,8 @@ static int tosa_dac_send(I2CSlave *i2c, uint8_t data)
 
 static void tosa_dac_event(I2CSlave *i2c, enum i2c_event event)
 {
-TosaDACState *s = FROM_I2C_SLAVE(TosaDACState, i2c);
+TosaDACState *s = TOSA_DAC(i2c);
+
 s-len = 0;
 switch (event) {
 case I2C_START_SEND:
@@ -195,7 +201,7 @@ static int tosa_dac_init(I2CSlave *i2c)
 static void tosa_tg_init(PXA2xxState *cpu)
 {
 I2CBus *bus = pxa2xx_i2c_bus(cpu-i2c[0]);
-i2c_create_slave(bus, tosa_dac, DAC_BASE);
+i2c_create_slave(bus, TYPE_TOSA_DAC, DAC_BASE);
 ssi_create_slave(cpu-ssp[1], tosa-ssp);
 }
 
@@ -271,7 +277,7 @@ static void tosa_dac_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo tosa_dac_info = {
-.name  = tosa_dac,
+.name  = TYPE_TOSA_DAC,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(TosaDACState),
 .class_init= tosa_dac_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 00/11] I2C QOM'ification, part 1

2014-01-31 Thread Andreas Färber
Hello,

This series prepares for converting I2C to QOM realize.

Didn't finish that so far, but I'd like to apply this to qom-next before it
starts to conflict.

Regards,
Andreas

Cc: Anthony Liguori anth...@codemonkey.ws
Cc: Peter Maydell peter.mayd...@linaro.org

Andreas Färber (11):
  i2c: Rename i2c_bus to I2CBus
  pxa2xx: QOM'ify I2C slave
  tosa: QOM'ify DAC
  z2: QOM'ify AER915
  wm8750: QOM'ify
  ssd0303: QOM'ify
  max7310: QOM'ify
  lm832x: QOM'ify
  ds1338: QOM'ify
  twl92230: QOM'ify
  i2c: Drop FROM_I2C_SLAVE() macro

 hw/acpi/piix4.c |  6 +++---
 hw/arm/exynos4210.c |  2 +-
 hw/arm/musicpal.c   |  4 ++--
 hw/arm/nseries.c|  2 +-
 hw/arm/pxa2xx.c | 44 
 hw/arm/realview.c   |  4 ++--
 hw/arm/spitz.c  |  2 +-
 hw/arm/stellaris.c  |  8 
 hw/arm/tosa.c   | 18 --
 hw/arm/versatilepb.c|  4 ++--
 hw/arm/z2.c | 20 +---
 hw/audio/wm8750.c   | 33 -
 hw/display/ssd0303.c| 18 --
 hw/gpio/max7310.c   | 23 ++-
 hw/i2c/bitbang_i2c.c|  6 +++---
 hw/i2c/bitbang_i2c.h|  2 +-
 hw/i2c/core.c   | 32 
 hw/i2c/exynos4210_i2c.c |  2 +-
 hw/i2c/omap_i2c.c   |  4 ++--
 hw/i2c/pm_smbus.c   |  2 +-
 hw/i2c/smbus.c  | 18 +-
 hw/i2c/smbus_eeprom.c   |  2 +-
 hw/i2c/smbus_ich9.c |  2 +-
 hw/i2c/versatile_i2c.c  |  2 +-
 hw/i386/pc_piix.c   |  2 +-
 hw/input/lm832x.c   | 22 +-
 hw/isa/vt82c686.c   |  4 ++--
 hw/mips/mips_fulong2e.c |  2 +-
 hw/mips/mips_malta.c|  2 +-
 hw/timer/ds1338.c   | 21 +
 hw/timer/twl92230.c | 35 +--
 include/hw/arm/exynos4210.h |  2 +-
 include/hw/arm/omap.h   |  2 +-
 include/hw/arm/pxa.h|  2 +-
 include/hw/i2c/i2c.h| 20 +---
 include/hw/i2c/pm_smbus.h   |  2 +-
 include/hw/i2c/smbus.h  | 20 ++--
 include/hw/i386/ich9.h  |  2 +-
 include/hw/i386/pc.h|  6 +++---
 include/hw/isa/vt82c686.h   |  4 ++--
 include/qemu/typedefs.h |  2 +-
 41 files changed, 233 insertions(+), 177 deletions(-)

-- 
1.8.4.5




[Qemu-devel] [PATCH 01/11] i2c: Rename i2c_bus to I2CBus

2014-01-31 Thread Andreas Färber
Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/acpi/piix4.c |  6 +++---
 hw/arm/exynos4210.c |  2 +-
 hw/arm/musicpal.c   |  4 ++--
 hw/arm/nseries.c|  2 +-
 hw/arm/pxa2xx.c |  6 +++---
 hw/arm/realview.c   |  4 ++--
 hw/arm/spitz.c  |  2 +-
 hw/arm/stellaris.c  |  8 
 hw/arm/tosa.c   |  2 +-
 hw/arm/versatilepb.c|  4 ++--
 hw/arm/z2.c |  2 +-
 hw/i2c/bitbang_i2c.c|  6 +++---
 hw/i2c/bitbang_i2c.h|  2 +-
 hw/i2c/core.c   | 32 
 hw/i2c/exynos4210_i2c.c |  2 +-
 hw/i2c/omap_i2c.c   |  4 ++--
 hw/i2c/pm_smbus.c   |  2 +-
 hw/i2c/smbus.c  | 18 +-
 hw/i2c/smbus_eeprom.c   |  2 +-
 hw/i2c/smbus_ich9.c |  2 +-
 hw/i2c/versatile_i2c.c  |  2 +-
 hw/i386/pc_piix.c   |  2 +-
 hw/isa/vt82c686.c   |  4 ++--
 hw/mips/mips_fulong2e.c |  2 +-
 hw/mips/mips_malta.c|  2 +-
 include/hw/arm/exynos4210.h |  2 +-
 include/hw/arm/omap.h   |  2 +-
 include/hw/arm/pxa.h|  2 +-
 include/hw/i2c/i2c.h| 16 
 include/hw/i2c/pm_smbus.h   |  2 +-
 include/hw/i2c/smbus.h  | 20 ++--
 include/hw/i386/ich9.h  |  2 +-
 include/hw/i386/pc.h|  6 +++---
 include/hw/isa/vt82c686.h   |  4 ++--
 include/qemu/typedefs.h |  2 +-
 35 files changed, 91 insertions(+), 91 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 5d55a3c..33e812d 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -517,9 +517,9 @@ Object *piix4_pm_find(void)
 return o;
 }
 
-i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
-   qemu_irq sci_irq, qemu_irq smi_irq,
-   int kvm_enabled, FWCfgState *fw_cfg)
+I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
+  qemu_irq sci_irq, qemu_irq smi_irq,
+  int kvm_enabled, FWCfgState *fw_cfg)
 {
 DeviceState *dev;
 PIIX4PMState *s;
diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c
index 4ebb938..9f137e9 100644
--- a/hw/arm/exynos4210.c
+++ b/hw/arm/exynos4210.c
@@ -326,7 +326,7 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,
 busdev = SYS_BUS_DEVICE(dev);
 sysbus_connect_irq(busdev, 0, i2c_irq);
 sysbus_mmio_map(busdev, 0, addr);
-s-i2c_if[n] = (i2c_bus *)qdev_get_child_bus(dev, i2c);
+s-i2c_if[n] = (I2CBus *)qdev_get_child_bus(dev, i2c);
 }
 
 
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 023e875..50a3b8f 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1593,7 +1593,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
 DeviceState *key_dev;
 DeviceState *wm8750_dev;
 SysBusDevice *s;
-i2c_bus *i2c;
+I2CBus *i2c;
 int i;
 unsigned long flash_size;
 DriveInfo *dinfo;
@@ -1687,7 +1687,7 @@ static void musicpal_init(QEMUMachineInitArgs *args)
 dev = sysbus_create_simple(TYPE_MUSICPAL_GPIO, MP_GPIO_BASE,
pic[MP_GPIO_IRQ]);
 i2c_dev = sysbus_create_simple(gpio_i2c, -1, NULL);
-i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, i2c);
+i2c = (I2CBus *)qdev_get_child_bus(i2c_dev, i2c);
 
 lcd_dev = sysbus_create_simple(TYPE_MUSICPAL_LCD, MP_LCD_BASE, NULL);
 key_dev = sysbus_create_simple(TYPE_MUSICPAL_KEY, -1, NULL);
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
index 9ef31ca..c28f895 100644
--- a/hw/arm/nseries.c
+++ b/hw/arm/nseries.c
@@ -202,7 +202,7 @@ static void n8x0_i2c_setup(struct n800_s *s)
 {
 DeviceState *dev;
 qemu_irq tmp_irq = qdev_get_gpio_in(s-mpu-gpio, N8X0_TMP105_GPIO);
-i2c_bus *i2c = omap_i2c_bus(s-mpu-i2c[0]);
+I2CBus *i2c = omap_i2c_bus(s-mpu-i2c[0]);
 
 /* Attach a menelaus PM chip */
 dev = i2c_create_slave(i2c, twl92230, N8X0_MENELAUS_ADDR);
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 02b7016..daf60e8 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1238,7 +1238,7 @@ struct PXA2xxI2CState {
 
 MemoryRegion iomem;
 PXA2xxI2CSlaveState *slave;
-i2c_bus *bus;
+I2CBus *bus;
 qemu_irq irq;
 uint32_t offset;
 uint32_t region_size;
@@ -1482,7 +1482,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
 DeviceState *dev;
 SysBusDevice *i2c_dev;
 PXA2xxI2CState *s;
-i2c_bus *i2cbus;
+I2CBus *i2cbus;
 
 dev = qdev_create(NULL, TYPE_PXA2XX_I2C);
 qdev_prop_set_uint32(dev, size, region_size + 1);
@@ -1518,7 +1518,7 @@ static int pxa2xx_i2c_initfn(SysBusDevice *sbd)
 return 0;
 }
 
-i2c_bus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
+I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s)
 {
 return s-bus;
 }
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 8d845dd..6ef7646 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -60,7 +60,7 @@ static void 

[Qemu-devel] [PATCH 07/11] max7310: QOM'ify

2014-01-31 Thread Andreas Färber
Replace FROM_I2C_SLAVE() usages with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/gpio/max7310.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/hw/gpio/max7310.c b/hw/gpio/max7310.c
index 59b2877..cfcd89c 100644
--- a/hw/gpio/max7310.c
+++ b/hw/gpio/max7310.c
@@ -9,8 +9,12 @@
 
 #include hw/i2c/i2c.h
 
-typedef struct {
-I2CSlave i2c;
+#define TYPE_MAX7310 max7310
+#define MAX7310(obj) OBJECT_CHECK(MAX7310State, (obj), TYPE_MAX7310)
+
+typedef struct MAX7310State {
+I2CSlave parent_obj;
+
 int i2c_command_byte;
 int len;
 
@@ -25,7 +29,8 @@ typedef struct {
 
 static void max7310_reset(DeviceState *dev)
 {
-MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, I2C_SLAVE(dev));
+MAX7310State *s = MAX7310(dev);
+
 s-level = s-direction;
 s-direction = 0xff;
 s-polarity = 0xf0;
@@ -35,7 +40,7 @@ static void max7310_reset(DeviceState *dev)
 
 static int max7310_rx(I2CSlave *i2c)
 {
-MAX7310State *s = (MAX7310State *) i2c;
+MAX7310State *s = MAX7310(i2c);
 
 switch (s-command) {
 case 0x00: /* Input port */
@@ -70,7 +75,7 @@ static int max7310_rx(I2CSlave *i2c)
 
 static int max7310_tx(I2CSlave *i2c, uint8_t data)
 {
-MAX7310State *s = (MAX7310State *) i2c;
+MAX7310State *s = MAX7310(i2c);
 uint8_t diff;
 int line;
 
@@ -125,7 +130,7 @@ static int max7310_tx(I2CSlave *i2c, uint8_t data)
 
 static void max7310_event(I2CSlave *i2c, enum i2c_event event)
 {
-MAX7310State *s = (MAX7310State *) i2c;
+MAX7310State *s = MAX7310(i2c);
 s-len = 0;
 
 switch (event) {
@@ -156,7 +161,7 @@ static const VMStateDescription vmstate_max7310 = {
 VMSTATE_UINT8(polarity, MAX7310State),
 VMSTATE_UINT8(status, MAX7310State),
 VMSTATE_UINT8(command, MAX7310State),
-VMSTATE_I2C_SLAVE(i2c, MAX7310State),
+VMSTATE_I2C_SLAVE(parent_obj, MAX7310State),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -177,7 +182,7 @@ static void max7310_gpio_set(void *opaque, int line, int 
level)
  * but also accepts sequences that are not SMBus so return an I2C device.  */
 static int max7310_init(I2CSlave *i2c)
 {
-MAX7310State *s = FROM_I2C_SLAVE(MAX7310State, i2c);
+MAX7310State *s = MAX7310(i2c);
 
 qdev_init_gpio_in(i2c-qdev, max7310_gpio_set, 8);
 qdev_init_gpio_out(i2c-qdev, s-handler, 8);
@@ -199,7 +204,7 @@ static void max7310_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo max7310_info = {
-.name  = max7310,
+.name  = TYPE_MAX7310,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(MAX7310State),
 .class_init= max7310_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 02/11] pxa2xx: QOM'ify I2C slave

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro and rename parent
field to assure we caught all.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/arm/pxa2xx.c | 38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index daf60e8..e5f1e10 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -1222,8 +1222,14 @@ static const TypeInfo pxa2xx_rtc_sysbus_info = {
 };
 
 /* I2C Interface */
-typedef struct {
-I2CSlave i2c;
+
+#define TYPE_PXA2XX_I2C_SLAVE pxa2xx-i2c-slave
+#define PXA2XX_I2C_SLAVE(obj) \
+OBJECT_CHECK(PXA2xxI2CSlaveState, (obj), TYPE_PXA2XX_I2C_SLAVE)
+
+typedef struct PXA2xxI2CSlaveState {
+I2CSlave parent_obj;
+
 PXA2xxI2CState *host;
 } PXA2xxI2CSlaveState;
 
@@ -1268,7 +1274,7 @@ static void pxa2xx_i2c_update(PXA2xxI2CState *s)
 /* These are only stubs now.  */
 static void pxa2xx_i2c_event(I2CSlave *i2c, enum i2c_event event)
 {
-PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
 PXA2xxI2CState *s = slave-host;
 
 switch (event) {
@@ -1292,10 +1298,12 @@ static void pxa2xx_i2c_event(I2CSlave *i2c, enum 
i2c_event event)
 
 static int pxa2xx_i2c_rx(I2CSlave *i2c)
 {
-PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
 PXA2xxI2CState *s = slave-host;
-if ((s-control  (1  14)) || !(s-control  (1  6)))
+
+if ((s-control  (1  14)) || !(s-control  (1  6))) {
 return 0;
+}
 
 if (s-status  (1  0)) {/* RWM */
 s-status |= 1  6;   /* set ITE */
@@ -1307,10 +1315,12 @@ static int pxa2xx_i2c_rx(I2CSlave *i2c)
 
 static int pxa2xx_i2c_tx(I2CSlave *i2c, uint8_t data)
 {
-PXA2xxI2CSlaveState *slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, i2c);
+PXA2xxI2CSlaveState *slave = PXA2XX_I2C_SLAVE(i2c);
 PXA2xxI2CState *s = slave-host;
-if ((s-control  (1  14)) || !(s-control  (1  6)))
+
+if ((s-control  (1  14)) || !(s-control  (1  6))) {
 return 1;
+}
 
 if (!(s-status  (1  0))) { /* RWM */
 s-status |= 1  7;   /* set IRF */
@@ -1325,6 +1335,7 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
 unsigned size)
 {
 PXA2xxI2CState *s = (PXA2xxI2CState *) opaque;
+I2CSlave *slave;
 
 addr -= s-offset;
 switch (addr) {
@@ -1333,7 +1344,8 @@ static uint64_t pxa2xx_i2c_read(void *opaque, hwaddr addr,
 case ISR:
 return s-status | (i2c_bus_busy(s-bus)  2);
 case ISAR:
-return s-slave-i2c.address;
+slave = I2C_SLAVE(s-slave);
+return slave-address;
 case IDBR:
 return s-data;
 case IBMR:
@@ -1408,7 +1420,7 @@ static void pxa2xx_i2c_write(void *opaque, hwaddr addr,
 break;
 
 case ISAR:
-i2c_set_slave_address(s-slave-i2c, value  0x7f);
+i2c_set_slave_address(I2C_SLAVE(s-slave), value  0x7f);
 break;
 
 case IDBR:
@@ -1432,7 +1444,7 @@ static const VMStateDescription vmstate_pxa2xx_i2c_slave 
= {
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .fields  = (VMStateField []) {
-VMSTATE_I2C_SLAVE(i2c, PXA2xxI2CSlaveState),
+VMSTATE_I2C_SLAVE(parent_obj, PXA2xxI2CSlaveState),
 VMSTATE_END_OF_LIST()
 }
 };
@@ -1470,7 +1482,7 @@ static void pxa2xx_i2c_slave_class_init(ObjectClass 
*klass, void *data)
 }
 
 static const TypeInfo pxa2xx_i2c_slave_info = {
-.name  = pxa2xx-i2c-slave,
+.name  = TYPE_PXA2XX_I2C_SLAVE,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(PXA2xxI2CSlaveState),
 .class_init= pxa2xx_i2c_slave_class_init,
@@ -1496,8 +1508,8 @@ PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
 s = PXA2XX_I2C(i2c_dev);
 /* FIXME: Should the slave device really be on a separate bus?  */
 i2cbus = i2c_init_bus(dev, dummy);
-dev = i2c_create_slave(i2cbus, pxa2xx-i2c-slave, 0);
-s-slave = FROM_I2C_SLAVE(PXA2xxI2CSlaveState, I2C_SLAVE(dev));
+dev = i2c_create_slave(i2cbus, TYPE_PXA2XX_I2C_SLAVE, 0);
+s-slave = PXA2XX_I2C_SLAVE(dev);
 s-slave-host = s;
 
 return s;
-- 
1.8.4.5




[Qemu-devel] [PATCH 04/11] z2: QOM'ify AER915

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/arm/z2.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 97ec381..69c4d38 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -193,15 +193,20 @@ static const TypeInfo zipit_lcd_info = {
 .class_init= zipit_lcd_class_init,
 };
 
-typedef struct {
-I2CSlave i2c;
+#define TYPE_AER915 aer915
+#define AER915(obj) OBJECT_CHECK(AER915State, (obj), TYPE_AER915)
+
+typedef struct AER915State {
+I2CSlave parent_obj;
+
 int len;
 uint8_t buf[3];
 } AER915State;
 
 static int aer915_send(I2CSlave *i2c, uint8_t data)
 {
-AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+AER915State *s = AER915(i2c);
+
 s-buf[s-len] = data;
 if (s-len++  2) {
 DPRINTF(%s: message too long (%i bytes)\n,
@@ -219,7 +224,8 @@ static int aer915_send(I2CSlave *i2c, uint8_t data)
 
 static void aer915_event(I2CSlave *i2c, enum i2c_event event)
 {
-AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+AER915State *s = AER915(i2c);
+
 switch (event) {
 case I2C_START_SEND:
 s-len = 0;
@@ -238,8 +244,8 @@ static void aer915_event(I2CSlave *i2c, enum i2c_event 
event)
 
 static int aer915_recv(I2CSlave *slave)
 {
+AER915State *s = AER915(slave);
 int retval = 0x00;
-AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
 
 switch (s-buf[0]) {
 /* Return hardcoded battery voltage,
@@ -290,7 +296,7 @@ static void aer915_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo aer915_info = {
-.name  = aer915,
+.name  = TYPE_AER915,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(AER915State),
 .class_init= aer915_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 09/11] ds1338: QOM'ify

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/ds1338.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/hw/timer/ds1338.c b/hw/timer/ds1338.c
index 8987cdc..bb2f8ee 100644
--- a/hw/timer/ds1338.c
+++ b/hw/timer/ds1338.c
@@ -23,8 +23,12 @@
 #define HOURS_PM   0x20
 #define CTRL_OSF   0x20
 
-typedef struct {
-I2CSlave i2c;
+#define TYPE_DS1338 ds1338
+#define DS1338(obj) OBJECT_CHECK(DS1338State, (obj), TYPE_DS1338)
+
+typedef struct DS1338State {
+I2CSlave parent_obj;
+
 int64_t offset;
 uint8_t wday_offset;
 uint8_t nvram[NVRAM_SIZE];
@@ -38,7 +42,7 @@ static const VMStateDescription vmstate_ds1338 = {
 .minimum_version_id = 1,
 .minimum_version_id_old = 1,
 .fields = (VMStateField[]) {
-VMSTATE_I2C_SLAVE(i2c, DS1338State),
+VMSTATE_I2C_SLAVE(parent_obj, DS1338State),
 VMSTATE_INT64(offset, DS1338State),
 VMSTATE_UINT8_V(wday_offset, DS1338State, 2),
 VMSTATE_UINT8_ARRAY(nvram, DS1338State, NVRAM_SIZE),
@@ -90,7 +94,7 @@ static void inc_regptr(DS1338State *s)
 
 static void ds1338_event(I2CSlave *i2c, enum i2c_event event)
 {
-DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+DS1338State *s = DS1338(i2c);
 
 switch (event) {
 case I2C_START_RECV:
@@ -111,7 +115,7 @@ static void ds1338_event(I2CSlave *i2c, enum i2c_event 
event)
 
 static int ds1338_recv(I2CSlave *i2c)
 {
-DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+DS1338State *s = DS1338(i2c);
 uint8_t res;
 
 res  = s-nvram[s-ptr];
@@ -121,7 +125,8 @@ static int ds1338_recv(I2CSlave *i2c)
 
 static int ds1338_send(I2CSlave *i2c, uint8_t data)
 {
-DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c);
+DS1338State *s = DS1338(i2c);
+
 if (s-addr_byte) {
 s-ptr = data  (NVRAM_SIZE - 1);
 s-addr_byte = false;
@@ -198,7 +203,7 @@ static int ds1338_init(I2CSlave *i2c)
 
 static void ds1338_reset(DeviceState *dev)
 {
-DS1338State *s = FROM_I2C_SLAVE(DS1338State, I2C_SLAVE(dev));
+DS1338State *s = DS1338(dev);
 
 /* The clock is running and synchronized with the host */
 s-offset = 0;
@@ -222,7 +227,7 @@ static void ds1338_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo ds1338_info = {
-.name  = ds1338,
+.name  = TYPE_DS1338,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(DS1338State),
 .class_init= ds1338_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 11/11] i2c: Drop FROM_I2C_SLAVE() macro

2014-01-31 Thread Andreas Färber
Use type-specific QOM cast macros instead.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 include/hw/i2c/i2c.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
index 9df987b..4986ebc 100644
--- a/include/hw/i2c/i2c.h
+++ b/include/hw/i2c/i2c.h
@@ -59,8 +59,6 @@ void i2c_nack(I2CBus *bus);
 int i2c_send(I2CBus *bus, uint8_t data);
 int i2c_recv(I2CBus *bus);
 
-#define FROM_I2C_SLAVE(type, dev) DO_UPCAST(type, i2c, dev)
-
 DeviceState *i2c_create_slave(I2CBus *bus, const char *name, uint8_t addr);
 
 /* wm8750.c */
-- 
1.8.4.5




[Qemu-devel] [PATCH 05/11] wm8750: QOM'ify

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/audio/wm8750.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/hw/audio/wm8750.c b/hw/audio/wm8750.c
index 6b5a349..c18f245 100644
--- a/hw/audio/wm8750.c
+++ b/hw/audio/wm8750.c
@@ -23,8 +23,12 @@ typedef struct {
 int dac_hz;
 } WMRate;
 
-typedef struct {
-I2CSlave i2c;
+#define TYPE_WM8750 wm8750
+#define WM8750(obj) OBJECT_CHECK(WM8750State, (obj), TYPE_WM8750)
+
+typedef struct WM8750State {
+I2CSlave parent_obj;
+
 uint8_t i2c_data[2];
 int i2c_len;
 QEMUSoundCard card;
@@ -256,7 +260,8 @@ static void wm8750_clk_update(WM8750State *s, int ext)
 
 static void wm8750_reset(I2CSlave *i2c)
 {
-WM8750State *s = (WM8750State *) i2c;
+WM8750State *s = WM8750(i2c);
+
 s-rate = wm_rate_table[0];
 s-enable = 0;
 wm8750_clk_update(s, 1);
@@ -299,7 +304,7 @@ static void wm8750_reset(I2CSlave *i2c)
 
 static void wm8750_event(I2CSlave *i2c, enum i2c_event event)
 {
-WM8750State *s = (WM8750State *) i2c;
+WM8750State *s = WM8750(i2c);
 
 switch (event) {
 case I2C_START_SEND:
@@ -356,7 +361,7 @@ static void wm8750_event(I2CSlave *i2c, enum i2c_event 
event)
 
 static int wm8750_tx(I2CSlave *i2c, uint8_t data)
 {
-WM8750State *s = (WM8750State *) i2c;
+WM8750State *s = WM8750(i2c);
 uint8_t cmd;
 uint16_t value;
 
@@ -542,7 +547,7 @@ static int wm8750_tx(I2CSlave *i2c, uint8_t data)
 break;
 
 case WM8750_RESET: /* Reset */
-wm8750_reset(s-i2c);
+wm8750_reset(I2C_SLAVE(s));
 break;
 
 #ifdef VERBOSE
@@ -604,17 +609,17 @@ static const VMStateDescription vmstate_wm8750 = {
 VMSTATE_UINT8(format, WM8750State),
 VMSTATE_UINT8(power, WM8750State),
 VMSTATE_UINT8(rate_vmstate, WM8750State),
-VMSTATE_I2C_SLAVE(i2c, WM8750State),
+VMSTATE_I2C_SLAVE(parent_obj, WM8750State),
 VMSTATE_END_OF_LIST()
 }
 };
 
 static int wm8750_init(I2CSlave *i2c)
 {
-WM8750State *s = FROM_I2C_SLAVE(WM8750State, i2c);
+WM8750State *s = WM8750(i2c);
 
 AUD_register_card(CODEC, s-card);
-wm8750_reset(s-i2c);
+wm8750_reset(I2C_SLAVE(s));
 
 return 0;
 }
@@ -622,8 +627,9 @@ static int wm8750_init(I2CSlave *i2c)
 #if 0
 static void wm8750_fini(I2CSlave *i2c)
 {
-WM8750State *s = (WM8750State *) i2c;
-wm8750_reset(s-i2c);
+WM8750State *s = WM8750(i2c);
+
+wm8750_reset(I2C_SLAVE(s));
 AUD_remove_card(s-card);
 g_free(s);
 }
@@ -632,7 +638,8 @@ static void wm8750_fini(I2CSlave *i2c)
 void wm8750_data_req_set(DeviceState *dev,
 void (*data_req)(void *, int, int), void *opaque)
 {
-WM8750State *s = FROM_I2C_SLAVE(WM8750State, I2C_SLAVE(dev));
+WM8750State *s = WM8750(dev);
+
 s-data_req = data_req;
 s-opaque = opaque;
 }
@@ -702,7 +709,7 @@ static void wm8750_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo wm8750_info = {
-.name  = wm8750,
+.name  = TYPE_WM8750,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(WM8750State),
 .class_init= wm8750_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH 0/5] tcg/i386 support for bmi

2014-01-31 Thread Richard Henderson
There are three separate architecture extensions for logical operations,
BMI, BMI2, and TBM.  The first two are supported on Intel Haswell and
AMD Excavator, while slightly earlier AMD support only BMI and TBM.

The following adds support for the interesting BMI and BMI2 instructions,
where it is easy to do so.  Most of the rest of the new instructions are
irrelevant to TCG.

When I added support for the ANDC opcode, I noticed some optimization
regressions when looking at ppc64 guest dumps.  I will address these
in a separate patch set.


r~


Richard Henderson (5):
  disas/i386: Disassemble ANDN/SHLX/SHRX/SHAX
  tcg/i386: Move TCG_CT_CONST_* to tcg-target.c
  tcg/i386: Add tcg_out_vex_modrm
  tcg/i386: Use ANDN instruction
  tcg/i386: Use SHLX/SHRX/SARX instructions

 disas/i386.c  | 146 +-
 tcg/i386/tcg-target.c | 156 ++
 tcg/i386/tcg-target.h |   9 ++-
 3 files changed, 268 insertions(+), 43 deletions(-)

-- 
1.8.5.3




[Qemu-devel] [PATCH 1/5] disas/i386: Disassemble ANDN/SHLX/SHRX/SHAX

2014-01-31 Thread Richard Henderson
Signed-off-by: Richard Henderson r...@twiddle.net
---
 disas/i386.c | 146 +--
 1 file changed, 132 insertions(+), 14 deletions(-)

diff --git a/disas/i386.c b/disas/i386.c
index 044e02c..104524f 100644
--- a/disas/i386.c
+++ b/disas/i386.c
@@ -171,6 +171,7 @@ static void print_operand_value (char *buf, size_t bufsize, 
int hex, bfd_vma dis
 static void print_displacement (char *, bfd_vma);
 static void OP_E (int, int);
 static void OP_G (int, int);
+static void OP_ (int, int);
 static bfd_vma get64 (void);
 static bfd_signed_vma get32 (void);
 static bfd_signed_vma get32s (void);
@@ -264,6 +265,9 @@ static int rex_used;
current instruction.  */
 static int used_prefixes;
 
+/* The VEX. register, unencoded.  */
+static int vex_reg;
+
 /* Flags stored in PREFIXES.  */
 #define PREFIX_REPZ 1
 #define PREFIX_REPNZ 2
@@ -278,6 +282,10 @@ static int used_prefixes;
 #define PREFIX_ADDR 0x400
 #define PREFIX_FWAIT 0x800
 
+#define PREFIX_VEX_0F0x1000
+#define PREFIX_VEX_0F38  0x2000
+#define PREFIX_VEX_0F3A  0x4000
+
 /* Make sure that bytes from INFO-PRIVATE_DATA-BUFFER (inclusive)
to ADDR (exclusive) are valid.  Returns 1 for success, longjmps
on error.  */
@@ -323,6 +331,7 @@ fetch_data(struct disassemble_info *info, bfd_byte *addr)
 
 #define XX { NULL, 0 }
 
+#define Bv { OP_, v_mode }
 #define Eb { OP_E, b_mode }
 #define Ev { OP_E, v_mode }
 #define Ed { OP_E, d_mode }
@@ -671,7 +680,8 @@ fetch_data(struct disassemble_info *info, bfd_byte *addr)
 #define PREGRP102 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 102 } }
 #define PREGRP103 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 103 } }
 #define PREGRP104 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 104 } }
-
+#define PREGRP105 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 105 } }
+#define PREGRP106 NULL, { { NULL, USE_PREFIX_USER_TABLE }, { NULL, 106 } }
 
 #define X86_64_0  NULL, { { NULL, X86_64_SPECIAL }, { NULL, 0 } }
 #define X86_64_1  NULL, { { NULL, X86_64_SPECIAL }, { NULL, 1 } }
@@ -1449,7 +1459,7 @@ static const unsigned char 
threebyte_0x38_uses_DATA_prefix[256] = {
   /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
   /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1, /* df */
   /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
-  /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
+  /* f0 */ 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
   /*   ---*/
   /*   0 1 2 3 4 5 6 7 8 9 a b c d e f*/
 };
@@ -1473,7 +1483,7 @@ static const unsigned char 
threebyte_0x38_uses_REPNZ_prefix[256] = {
   /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
   /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
   /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
-  /* f0 */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
+  /* f0 */ 1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
   /*   ---*/
   /*   0 1 2 3 4 5 6 7 8 9 a b c d e f*/
 };
@@ -1497,7 +1507,7 @@ static const unsigned char 
threebyte_0x38_uses_REPZ_prefix[256] = {
   /* c0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* cf */
   /* d0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* df */
   /* e0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ef */
-  /* f0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* ff */
+  /* f0 */ 0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, /* ff */
   /*   ---*/
   /*   0 1 2 3 4 5 6 7 8 9 a b c d e f*/
 };
@@ -2774,6 +2784,22 @@ static const struct dis386 prefix_user_table[][4] = {
 { (bad), { XX } },
   },
 
+  /* PREGRP105 */
+  {
+{ andnS, { Gv, Bv, Ev } },
+{ (bad), { XX } },
+{ (bad), { XX } },
+{ (bad), { XX } },
+  },
+
+  /* PREGRP106 */
+  {
+{ bextrS,{ Gv, Ev, Bv } },
+{ sarxS, { Gv, Ev, Bv } },
+{ shlxS, { Gv, Ev, Bv } },
+{ shrxS, { Gv, Ev, Bv } },
+  },
+
 };
 
 static const struct dis386 x86_64_table[][2] = {
@@ -3071,12 +3097,12 @@ static const struct dis386 three_byte_table[][256] = {
 /* f0 */
 { PREGRP87 },
 { PREGRP88 },
+{ PREGRP105 },
 { (bad), { XX } },
 { (bad), { XX } },
 { (bad), { XX } },
 { (bad), { XX } },
-{ (bad), { XX } },
-{ (bad), { XX } },
+{ PREGRP106 },
 /* f8 */
 { (bad), { XX } },
 { (bad), { XX } },
@@ -3477,6 +3503,74 @@ ckprefix (void)
 }
 }
 
+static void
+ckvexprefix (void)
+{
+int op, vex2, vex3, newrex = REX_OPCODE, newpfx = prefixes;
+
+if (address_mode == mode_16bit) {
+return;
+}
+
+fetch_data(the_info, codep + 1);
+op = *codep;
+
+if (op != 0xc4  op != 0xc5) {
+return;
+}
+
+fetch_data(the_info, codep + 2);
+vex2 = codep[1];
+
+if (address_mode == mode_32bit  (vex2  0xc0) != 0xc0) {
+return;
+}
+
+if (op == 0xc4) {
+/* Three byte VEX prefix.  */
+fetch_data(the_info, codep + 3);
+vex3 = codep[2];
+
+newrex |= (vex2  0x80 ? 0 : 

[Qemu-devel] [PATCH 2/5] tcg/i386: Move TCG_CT_CONST_* to tcg-target.c

2014-01-31 Thread Richard Henderson
These are not needed by users of tcg-target.h.  No need to recompile
when we adjust them.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/i386/tcg-target.c | 4 
 tcg/i386/tcg-target.h | 3 ---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 5d4cf93..7008b0e 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -88,6 +88,10 @@ static const int tcg_target_call_oarg_regs[] = {
 #endif
 };
 
+/* Constants we accept.  */
+#define TCG_CT_CONST_S32 0x100
+#define TCG_CT_CONST_U32 0x200
+
 /* Registers used with L constraint, which are the first argument 
registers on x86_64, and two random call clobbered registers on
i386. */
diff --git a/tcg/i386/tcg-target.h b/tcg/i386/tcg-target.h
index 92c0fcd..747b797 100644
--- a/tcg/i386/tcg-target.h
+++ b/tcg/i386/tcg-target.h
@@ -64,9 +64,6 @@ typedef enum {
 TCG_REG_RDI = TCG_REG_EDI,
 } TCGReg;
 
-#define TCG_CT_CONST_S32 0x100
-#define TCG_CT_CONST_U32 0x200
-
 /* used for function call generation */
 #define TCG_REG_CALL_STACK TCG_REG_ESP 
 #define TCG_TARGET_STACK_ALIGN 16
-- 
1.8.5.3




[Qemu-devel] [PATCH 5/5] tcg/i386: Use SHLX/SHRX/SARX instructions

2014-01-31 Thread Richard Henderson
These three-operand shift instructions do not require the shift count
to be placed into ECX.  This reduces the number of mov insns required,
with the mere addition of a new register constraint.

Don't attempt to get rid of the matching constraint, as that's impossible
to manipulate with just a new constraint.  In addition, constant shifts
still need the matching constraint.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/i386/tcg-target.c | 61 +--
 1 file changed, 50 insertions(+), 11 deletions(-)

diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 4f6b9c1..fef1717 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -133,6 +133,12 @@ static bool have_movbe;
it there.  Therefore we always define the variable.  */
 bool have_bmi1;
 
+#if defined(CONFIG_CPUID_H)  defined(bit_BMI2)
+static bool have_bmi2;
+#else
+# define have_bmi2 0
+#endif
+
 static uint8_t *tb_ret_addr;
 
 static void patch_reloc(uint8_t *code_ptr, int type,
@@ -175,6 +181,7 @@ static int target_parse_constraint(TCGArgConstraint *ct, 
const char **pct_str)
 tcg_regset_set_reg(ct-u.regs, TCG_REG_EBX);
 break;
 case 'c':
+case_c:
 ct-ct |= TCG_CT_REG;
 tcg_regset_set_reg(ct-u.regs, TCG_REG_ECX);
 break;
@@ -203,6 +210,7 @@ static int target_parse_constraint(TCGArgConstraint *ct, 
const char **pct_str)
 tcg_regset_set32(ct-u.regs, 0, 0xf);
 break;
 case 'r':
+case_r:
 ct-ct |= TCG_CT_REG;
 if (TCG_TARGET_REG_BITS == 64) {
 tcg_regset_set32(ct-u.regs, 0, 0x);
@@ -210,6 +218,13 @@ static int target_parse_constraint(TCGArgConstraint *ct, 
const char **pct_str)
 tcg_regset_set32(ct-u.regs, 0, 0xff);
 }
 break;
+case 'C':
+/* With SHRX et al, we need not use ECX as shift count register.  */
+if (have_bmi2) {
+goto case_r;
+} else {
+goto case_c;
+}
 
 /* qemu_ld/st address constraint */
 case 'L':
@@ -283,6 +298,8 @@ static inline int tcg_target_const_match(tcg_target_long 
val,
 # define P_REXB_RM 0
 # define P_GS   0
 #endif
+#define P_SIMDF30x1 /* 0xf3 opcode prefix */
+#define P_SIMDF20x2 /* 0xf2 opcode prefix */
 
 #define OPC_ARITH_EvIz (0x81)
 #define OPC_ARITH_EvIb (0x83)
@@ -325,6 +342,9 @@ static inline int tcg_target_const_match(tcg_target_long 
val,
 #define OPC_SHIFT_1(0xd1)
 #define OPC_SHIFT_Ib   (0xc1)
 #define OPC_SHIFT_cl   (0xd3)
+#define OPC_SARX(0xf7 | P_EXT38 | P_SIMDF3)
+#define OPC_SHLX(0xf7 | P_EXT38 | P_DATA16)
+#define OPC_SHRX(0xf7 | P_EXT38 | P_SIMDF2)
 #define OPC_TESTL  (0x85)
 #define OPC_XCHG_ax_r32(0x90)
 
@@ -493,7 +513,14 @@ static void tcg_out_vex_modrm(TCGContext *s, int opc, int 
r, int v, int rm)
 
 tmp = (r  8 ? 0 : 0x80);  /* VEX.R */
 }
-tmp |= (opc  P_DATA16 ? 1 : 0);   /* VEX.pp */
+/* VEX.pp */
+if (opc  P_DATA16) {
+tmp |= 1;  /* 0x66 */
+} else if (opc  P_SIMDF3) {
+tmp |= 2;  /* 0xf3 */
+} else if (opc  P_SIMDF2) {
+tmp |= 3;  /* 0xf2 */
+}
 tmp |= (~v  15)  3; /* VEX. */
 tcg_out8(s, tmp);
 tcg_out8(s, opc);
@@ -1689,7 +1716,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg 
*args, bool is64)
 static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
   const TCGArg *args, const int *const_args)
 {
-int c, rexw = 0;
+int c, vexop, rexw = 0;
 
 #if TCG_TARGET_REG_BITS == 64
 # define OP_32_64(x) \
@@ -1860,19 +1887,28 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode 
opc,
 
 OP_32_64(shl):
 c = SHIFT_SHL;
-goto gen_shift;
+vexop = OPC_SHLX;
+goto gen_shift_maybe_vex;
 OP_32_64(shr):
 c = SHIFT_SHR;
-goto gen_shift;
+vexop = OPC_SHRX;
+goto gen_shift_maybe_vex;
 OP_32_64(sar):
 c = SHIFT_SAR;
-goto gen_shift;
+vexop = OPC_SARX;
+goto gen_shift_maybe_vex;
 OP_32_64(rotl):
 c = SHIFT_ROL;
 goto gen_shift;
 OP_32_64(rotr):
 c = SHIFT_ROR;
 goto gen_shift;
+gen_shift_maybe_vex:
+if (have_bmi2  !const_args[2]) {
+tcg_out_vex_modrm(s, vexop + rexw, args[0], args[2], args[1]);
+break;
+}
+/* FALLTHRU */
 gen_shift:
 if (const_args[2]) {
 tcg_out_shifti(s, c + rexw, args[0], args[2]);
@@ -2065,9 +2101,9 @@ static const TCGTargetOpDef x86_op_defs[] = {
 { INDEX_op_xor_i32, { r, 0, ri } },
 { INDEX_op_andc_i32, { r, r, ri } },
 
-{ INDEX_op_shl_i32, { r, 0, ci } },
-{ INDEX_op_shr_i32, { r, 0, ci } },
-{ INDEX_op_sar_i32, { r, 0, ci } },
+{ 

[Qemu-devel] [PATCH 3/5] tcg/i386: Add tcg_out_vex_modrm

2014-01-31 Thread Richard Henderson
Prepare for emitting BMI insns which require VEX encoding.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/i386/tcg-target.c | 41 ++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index 7008b0e..00dbc3b 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -402,9 +402,9 @@ static void tcg_out_opc(TCGContext *s, int opc, int r, int 
rm, int x)
 
 rex = 0;
 rex |= (opc  P_REXW) ? 0x8 : 0x0;  /* REX.W */
-rex |= (r  8)  1;   /* REX.R */
-rex |= (x  8)  2;   /* REX.X */
-rex |= (rm  8)  3;  /* REX.B */
+rex |= (r  8)  1;/* REX.R */
+rex |= (x  8)  2;/* REX.X */
+rex |= (rm  8)  3;   /* REX.B */
 
 /* P_REXB_{R,RM} indicates that the given register is the low byte.
For %[abcd]l we need no REX prefix, but for %{si,di,bp,sp}l we do,
@@ -453,6 +453,41 @@ static void tcg_out_modrm(TCGContext *s, int opc, int r, 
int rm)
 tcg_out8(s, 0xc0 | (LOWREGMASK(r)  3) | LOWREGMASK(rm));
 }
 
+static void tcg_out_vex_modrm(TCGContext *s, int opc, int r, int v, int rm)
+{
+int tmp;
+
+if ((opc  (P_REXW | P_EXT | P_EXT38)) || (rm  8)) {
+/* Three byte VEX prefix.  */
+tcg_out8(s, 0xc4);
+
+/* VEX.m- */
+if (opc  P_EXT38) {
+tmp = 2;
+} else if (opc  P_EXT) {
+tmp = 1;
+} else {
+tcg_abort();
+}
+tmp |= 0x40;   /* VEX.X */
+tmp |= (r  8 ? 0 : 0x80); /* VEX.R */
+tmp |= (rm  8 ? 0 : 0x20);/* VEX.B */
+tcg_out8(s, tmp);
+
+tmp = (opc  P_REXW ? 0x80 : 0);   /* VEX.W */
+} else {
+/* Two byte VEX prefix.  */
+tcg_out8(s, 0xc5);
+
+tmp = (r  8 ? 0 : 0x80);  /* VEX.R */
+}
+tmp |= (opc  P_DATA16 ? 1 : 0);   /* VEX.pp */
+tmp |= (~v  15)  3; /* VEX. */
+tcg_out8(s, tmp);
+tcg_out8(s, opc);
+tcg_out8(s, 0xc0 | (LOWREGMASK(r)  3) | LOWREGMASK(rm));
+}
+
 /* Output an opcode with a full rm + (indexshift) + offset address mode.
We handle either RM and INDEX missing with a negative value.  In 64-bit
mode for absolute addresses, ~RM is the size of the immediate operand
-- 
1.8.5.3




[Qemu-devel] [PATCH 8/8] tcg/optimize: Add more identity simplifications

2014-01-31 Thread Richard Henderson
Recognize 0 operand to andc, and -1 operands to and, orc, eqv.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 39 ---
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index a703f8c..8d7100e 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -716,7 +716,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t 
*tcg_opc_ptr,
 break;
 }
 
-/* Simplify expression for op r, a, 0 = mov r, a cases */
+/* Simplify expression for op r, a, const = mov r, a cases */
 switch (op) {
 CASE_OP_32_64(add):
 CASE_OP_32_64(sub):
@@ -727,23 +727,32 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 CASE_OP_32_64(rotr):
 CASE_OP_32_64(or):
 CASE_OP_32_64(xor):
-if (temps[args[1]].state == TCG_TEMP_CONST) {
-/* Proceed with possible constant folding. */
-break;
-}
-if (temps[args[2]].state == TCG_TEMP_CONST
+CASE_OP_32_64(andc):
+if (temps[args[1]].state != TCG_TEMP_CONST
+ temps[args[2]].state == TCG_TEMP_CONST
  temps[args[2]].val == 0) {
-if (temps_are_copies(args[0], args[1])) {
-s-gen_opc_buf[op_index] = INDEX_op_nop;
-} else {
-s-gen_opc_buf[op_index] = op_to_mov(op);
-tcg_opt_gen_mov(s, gen_args, args[0], args[1]);
-gen_args += 2;
-}
-args += 3;
-continue;
+goto do_mov3;
 }
 break;
+CASE_OP_32_64(and):
+CASE_OP_32_64(orc):
+CASE_OP_32_64(eqv):
+if (temps[args[1]].state != TCG_TEMP_CONST
+ temps[args[2]].state == TCG_TEMP_CONST
+ temps[args[2]].val == -1) {
+goto do_mov3;
+}
+break;
+do_mov3:
+if (temps_are_copies(args[0], args[1])) {
+s-gen_opc_buf[op_index] = INDEX_op_nop;
+} else {
+s-gen_opc_buf[op_index] = op_to_mov(op);
+tcg_opt_gen_mov(s, gen_args, args[0], args[1]);
+gen_args += 2;
+}
+args += 3;
+continue;
 default:
 break;
 }
-- 
1.8.5.3




[Qemu-devel] [PATCH 4/8] tcg/optimize: add known-zero bits compute for load ops

2014-01-31 Thread Richard Henderson
From: Aurelien Jarno aurel...@aurel32.net

Cc: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Aurelien Jarno aurel...@aurel32.net
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 1cf017a..d3b099a 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -779,13 +779,35 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 mask = temps[args[3]].mask | temps[args[4]].mask;
 break;
 
+CASE_OP_32_64(ld8u):
+case INDEX_op_qemu_ld8u:
+mask = 0xff;
+break;
+CASE_OP_32_64(ld16u):
+case INDEX_op_qemu_ld16u:
+mask = 0x;
+break;
+case INDEX_op_ld32u_i64:
+case INDEX_op_qemu_ld32u:
+mask = 0xu;
+break;
+
+CASE_OP_32_64(qemu_ld):
+{
+TCGMemOp mop = args[def-nb_oargs + def-nb_iargs];
+if (!(mop  MO_SIGN)) {
+mask = (2ULL  ((8  (mop  MO_SIZE)) - 1)) - 1;
+}
+}
+break;
+
 default:
 break;
 }
 
 /* 32-bit ops (non 64-bit ops and non load/store ops) generate 32-bit
results */
-if (!(tcg_op_defs[op].flags  (TCG_OPF_CALL_CLOBBER | TCG_OPF_64BIT))) 
{
+if (!(def-flags  (TCG_OPF_CALL_CLOBBER | TCG_OPF_64BIT))) {
 mask = 0xu;
 }
 
-- 
1.8.5.3




[Qemu-devel] [PATCH 7/8] tcg/optimize: Optmize ANDC X, Y, Y to MOV X, 0

2014-01-31 Thread Richard Henderson
Like we already do for SUB and XOR.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index cdfc746..a703f8c 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -945,6 +945,7 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t 
*tcg_opc_ptr,
 
 /* Simplify expression for op r, a, a = movi r, 0 cases */
 switch (op) {
+CASE_OP_32_64(andc):
 CASE_OP_32_64(sub):
 CASE_OP_32_64(xor):
 if (temps_are_copies(args[1], args[2])) {
-- 
1.8.5.3




[Qemu-devel] [PATCH v18 01/10] util: Split out qemu_exec_dir from os_find_datadir

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

This can be reused by module loading routines.

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 include/qemu/osdep.h |  4 
 os-posix.c   | 40 ++--
 os-win32.c   | 19 +--
 util/oslib-posix.c   | 45 +
 util/oslib-win32.c   | 24 
 5 files changed, 80 insertions(+), 52 deletions(-)

diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index eac7172..9e329ca 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -215,6 +215,10 @@ bool fips_get_state(void);
  */
 char *qemu_get_local_state_pathname(const char *relative_pathname);
 
+/* Find program directory with best effort. Try platform API first, then parse
+ * argv0 if it's not NULL. The returned string needs to be g_free'ed */
+char *qemu_exec_dir(const char *argv0);
+
 /**
  * qemu_getauxval:
  * @type: the auxiliary vector key to lookup
diff --git a/os-posix.c b/os-posix.c
index d39261d..c5e0722 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -86,44 +86,15 @@ void os_setup_signal_handling(void)
 #define BUILD_SUFFIX /pc-bios
 char *os_find_datadir(const char *argv0)
 {
-char *dir;
-char *p = NULL;
+char *dir, *exec_dir;
 char *res;
-char buf[PATH_MAX];
 size_t max_len;
 
-#if defined(__linux__)
-{
-int len;
-len = readlink(/proc/self/exe, buf, sizeof(buf) - 1);
-if (len  0) {
-buf[len] = 0;
-p = buf;
-}
-}
-#elif defined(__FreeBSD__)
-{
-static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
-size_t len = sizeof(buf) - 1;
-
-*buf = '\0';
-if (!sysctl(mib, ARRAY_SIZE(mib), buf, len, NULL, 0) 
-*buf) {
-buf[sizeof(buf) - 1] = '\0';
-p = buf;
-}
-}
-#endif
-/* If we don't have any way of figuring out the actual executable
-   location then try argv[0].  */
-if (!p) {
-p = realpath(argv0, buf);
-if (!p) {
-return NULL;
-}
+exec_dir = qemu_exec_dir(argv0);
+if (exec_dir == NULL) {
+return NULL;
 }
-dir = dirname(p);
-dir = dirname(dir);
+dir = dirname(exec_dir);
 
 max_len = strlen(dir) +
 MAX(strlen(SHARE_SUFFIX), strlen(BUILD_SUFFIX)) + 1;
@@ -137,6 +108,7 @@ char *os_find_datadir(const char *argv0)
 }
 }
 
+g_free(exec_dir);
 return res;
 }
 #undef SHARE_SUFFIX
diff --git a/os-win32.c b/os-win32.c
index 50b7f6f..564d5b4 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -86,24 +86,7 @@ void os_setup_early_signal_handling(void)
 /* Look for support files in the same directory as the executable.  */
 char *os_find_datadir(const char *argv0)
 {
-char *p;
-char buf[MAX_PATH];
-DWORD len;
-
-len = GetModuleFileName(NULL, buf, sizeof(buf) - 1);
-if (len == 0) {
-return NULL;
-}
-
-buf[len] = 0;
-p = buf + len - 1;
-while (p != buf  *p != '\\')
-p--;
-*p = 0;
-if (access(buf, R_OK) == 0) {
-return g_strdup(buf);
-}
-return NULL;
+return qemu_exec_dir(argv0);
 }
 
 void os_set_line_buffering(void)
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index d5dca47..372b2f9 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -57,6 +57,7 @@ extern int daemon(int, int);
 #include trace.h
 #include qemu/sockets.h
 #include sys/mman.h
+#include libgen.h
 
 #ifdef CONFIG_LINUX
 #include sys/syscall.h
@@ -274,3 +275,47 @@ void qemu_set_tty_echo(int fd, bool echo)
 
 tcsetattr(fd, TCSANOW, tty);
 }
+
+char *qemu_exec_dir(const char *argv0)
+{
+char *dir;
+char *p = NULL;
+char buf[PATH_MAX];
+
+#if defined(__linux__)
+{
+int len;
+len = readlink(/proc/self/exe, buf, sizeof(buf) - 1);
+if (len  0) {
+buf[len] = 0;
+p = buf;
+}
+}
+#elif defined(__FreeBSD__)
+{
+static int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
+size_t len = sizeof(buf) - 1;
+
+*buf = '\0';
+if (!sysctl(mib, ARRAY_SIZE(mib), buf, len, NULL, 0) 
+*buf) {
+buf[sizeof(buf) - 1] = '\0';
+p = buf;
+}
+}
+#endif
+/* If we don't have any way of figuring out the actual executable
+   location then try argv[0].  */
+if (!p) {
+if (!argv0) {
+return NULL;
+}
+p = realpath(argv0, buf);
+if (!p) {
+return NULL;
+}
+}
+dir = dirname(p);
+
+return g_strdup(dir);
+}
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 50be044..9ce22a1 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -208,3 +208,27 @@ void qemu_set_tty_echo(int fd, bool echo)
dwMode  ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT));
 }
 }
+
+char 

[Qemu-devel] [PATCH v18 06/10] rules.mak: introduce DSO rules

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

Add necessary rules and flags for shared object generation.
The new rules introduced here are:

1) %.o in $(common-obj-m) is compiled to %.o, then linked to %.so.

2) %.mo in $(common-obj-m) is the placeholder for %.so for pattern
matching in Makefile. It's linked to -shared with all its dependencies
(multiple *.o) as input. Which means the list of depended objects must
be specified in each sub-Makefile.objs:

foo.mo-objs := bar.o baz.o qux.o

in the same style with foo.o-cflags and foo.o-libs. The objects here
will be prefixed with $(obj)/ if it's a subdirectory Makefile.objs.

3) For all files ending up in %.so, the following is added automatically:

foo.o-cflags += -fPIC -DBUILD_DSO

Also introduce --enable-modules in configure, the option will enable
support of shared object build. Otherwise objects are static linked to
executables.

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 .gitignore |  3 +++
 Makefile   |  4 +++-
 configure  | 15 +++
 rules.mak  | 52 +++-
 4 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1c9d63d..7702b0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -64,6 +64,9 @@ fsdev/virtfs-proxy-helper.pod
 *.cp
 *.dvi
 *.exe
+*.dll
+*.so
+*.mo
 *.fn
 *.ky
 *.log
diff --git a/Makefile b/Makefile
index 52b1958..9d53117 100644
--- a/Makefile
+++ b/Makefile
@@ -138,7 +138,7 @@ ifeq ($(CONFIG_SMARTCARD_NSS),y)
 include $(SRC_PATH)/libcacard/Makefile
 endif
 
-all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
+all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all modules
 
 vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
 
@@ -256,6 +256,8 @@ clean:
rm -f qemu-options.def
find . -name '*.[oda]' -type f -exec rm -f {} +
find . -name '*.l[oa]' -type f -exec rm -f {} +
+   find . -name '*$(DSOSUF)' -type f -exec rm -f {} +
+   find . -name '*.mo' -type f -exec rm -f {} +
rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* 
*.pod *~ */*~
rm -f fsdev/*.pod
rm -rf .libs */.libs
diff --git a/configure b/configure
index 0e62059..14f4501 100755
--- a/configure
+++ b/configure
@@ -205,6 +205,9 @@ mingw32=no
 gcov=no
 gcov_tool=gcov
 EXESUF=
+DSOSUF=.so
+LDFLAGS_SHARED=-shared
+modules=no
 prefix=/usr/local
 mandir=\${prefix}/share/man
 datadir=\${prefix}/share
@@ -514,6 +517,7 @@ OpenBSD)
 Darwin)
   bsd=yes
   darwin=yes
+  LDFLAGS_SHARED=-bundle -undefined dynamic_lookup
   if [ $cpu = x86_64 ] ; then
 QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS
 LDFLAGS=-arch x86_64 $LDFLAGS
@@ -607,6 +611,7 @@ fi
 
 if test $mingw32 = yes ; then
   EXESUF=.exe
+  DSOSUF=.dll
   QEMU_CFLAGS=-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS
   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
   QEMU_CFLAGS=-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS
@@ -673,6 +678,9 @@ for opt do
   ;;
   --disable-debug-info)
   ;;
+  --enable-modules)
+  modules=yes
+  ;;
   --cpu=*)
   ;;
   --target-list=*) target_list=$optarg
@@ -1125,6 +1133,7 @@ Advanced options (experts only):
   --sysconfdir=PATHinstall config in PATH$confsuffix
   --localstatedir=PATH install local state in PATH (set at runtime on 
win32)
   --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir 
[$confsuffix]
+  --enable-modules enable modules support
   --enable-debug-tcg   enable TCG debugging
   --disable-debug-tcg  disable TCG debugging (default)
   --enable-debug-info   enable debugging information (default)
@@ -3740,6 +3749,7 @@ echo python$python
 if test $slirp = yes ; then
 echo smbd  $smbd
 fi
+echo module support$modules
 echo host CPU  $cpu
 echo host big endian   $bigendian
 echo target list   $target_list
@@ -3983,6 +3993,9 @@ echo TARGET_DIRS=$target_list  $config_host_mak
 if [ $docs = yes ] ; then
   echo BUILD_DOCS=yes  $config_host_mak
 fi
+if test $modules = yes; then
+  echo CONFIG_MODULES=y  $config_host_mak
+fi
 if test $sdl = yes ; then
   echo CONFIG_SDL=y  $config_host_mak
   echo SDL_CFLAGS=$sdl_cflags  $config_host_mak
@@ -4361,6 +4374,8 @@ echo LIBTOOLFLAGS=$LIBTOOLFLAGS  $config_host_mak
 echo LIBS+=$LIBS  $config_host_mak
 echo LIBS_TOOLS+=$libs_tools  $config_host_mak
 echo EXESUF=$EXESUF  $config_host_mak
+echo DSOSUF=$DSOSUF  $config_host_mak
+echo LDFLAGS_SHARED=$LDFLAGS_SHARED  $config_host_mak
 echo LIBS_QGA+=$libs_qga  $config_host_mak
 echo POD2MAN=$POD2MAN  $config_host_mak
 echo TRANSLATE_OPT_CFLAGS=$TRANSLATE_OPT_CFLAGS  $config_host_mak
diff --git a/rules.mak b/rules.mak
index 9398268..55db767 100644
--- a/rules.mak
+++ b/rules.mak
@@ -21,7 +21,12 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 # Same as -I$(SRC_PATH) -I., but for the nested source/object directories
 QEMU_INCLUDES += -I$(D) -I$(@D)
 
-extract-libs = $(strip $(foreach 

[Qemu-devel] [PATCH v18 10/10] block: convert block drivers linked with libs to modules

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

The converted block drivers are:

curl
iscsi
rbd
ssh
glusterfs

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 configure | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 7aff69e..a30ec76 100755
--- a/configure
+++ b/configure
@@ -4089,7 +4089,7 @@ if test $bswap_h = yes ; then
   echo CONFIG_MACHINE_BSWAP_H=y  $config_host_mak
 fi
 if test $curl = yes ; then
-  echo CONFIG_CURL=y  $config_host_mak
+  echo CONFIG_CURL=m  $config_host_mak
   echo CURL_CFLAGS=$curl_cflags  $config_host_mak
   echo CURL_LIBS=$curl_libs  $config_host_mak
 fi
@@ -4180,7 +4180,7 @@ if test $glx = yes ; then
 fi
 
 if test $libiscsi = yes ; then
-  echo CONFIG_LIBISCSI=y  $config_host_mak
+  echo CONFIG_LIBISCSI=m  $config_host_mak
   if test $libiscsi_version = 1.4.0; then
 echo CONFIG_LIBISCSI_1_4=y  $config_host_mak
   fi
@@ -4206,7 +4206,7 @@ if test $qom_cast_debug = yes ; then
   echo CONFIG_QOM_CAST_DEBUG=y  $config_host_mak
 fi
 if test $rbd = yes ; then
-  echo CONFIG_RBD=y  $config_host_mak
+  echo CONFIG_RBD=m  $config_host_mak
   echo RBD_CFLAGS=$rbd_cflags  $config_host_mak
   echo RBD_LIBS=$rbd_libs  $config_host_mak
 fi
@@ -4251,7 +4251,7 @@ if test $getauxval = yes ; then
 fi
 
 if test $glusterfs = yes ; then
-  echo CONFIG_GLUSTERFS=y  $config_host_mak
+  echo CONFIG_GLUSTERFS=m  $config_host_mak
   echo GLUSTERFS_CFLAGS=$glusterfs_cflags  $config_host_mak
   echo GLUSTERFS_LIBS=$glusterfs_libs  $config_host_mak
 fi
@@ -4265,7 +4265,7 @@ if test $glusterfs_zerofill = yes ; then
 fi
 
 if test $libssh2 = yes ; then
-  echo CONFIG_LIBSSH2=y  $config_host_mak
+  echo CONFIG_LIBSSH2=m  $config_host_mak
   echo LIBSSH2_CFLAGS=$libssh2_cflags  $config_host_mak
   echo LIBSSH2_LIBS=$libssh2_libs  $config_host_mak
 fi
-- 
1.8.3.1




[Qemu-devel] [PATCH 3/8] tcg/optimize: improve known-zero bits for 32-bit ops

2014-01-31 Thread Richard Henderson
From: Aurelien Jarno aurel...@aurel32.net

The shl_i32 op might set some bits of the unused 32 high bits of the
mask. Fix that by clearing the unused 32 high bits for all 32-bit ops
except load/store which operate on tl values.

Cc: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Aurelien Jarno aurel...@aurel32.net
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 7838be2..1cf017a 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -783,6 +783,12 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 break;
 }
 
+/* 32-bit ops (non 64-bit ops and non load/store ops) generate 32-bit
+   results */
+if (!(tcg_op_defs[op].flags  (TCG_OPF_CALL_CLOBBER | TCG_OPF_64BIT))) 
{
+mask = 0xu;
+}
+
 if (mask == 0) {
 assert(def-nb_oargs == 1);
 s-gen_opc_buf[op_index] = op_to_movi(op);
-- 
1.8.5.3




[Qemu-devel] [PATCH v18 09/10] Makefile: introduce common-obj-m and block-obj-m for DSO

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

$(common-obj-m) will include $(block-obj-m), like $(common-obj-y) does
for $(block-obj-y).

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile| 4 +++-
 Makefile.objs   | 2 ++
 Makefile.target | 6 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b434b2e..83f080e 100644
--- a/Makefile
+++ b/Makefile
@@ -129,7 +129,9 @@ dummy := $(call unnest-vars,, \
 util-obj-y \
 qga-obj-y \
 block-obj-y \
-common-obj-y)
+block-obj-m \
+common-obj-y \
+common-obj-m)
 
 ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/tests/Makefile
diff --git a/Makefile.objs b/Makefile.objs
index 1914080..4a62913 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -19,6 +19,8 @@ block-obj-y += qemu-coroutine.o qemu-coroutine-lock.o 
qemu-coroutine-io.o
 block-obj-y += qemu-coroutine-sleep.o
 block-obj-y += coroutine-$(CONFIG_COROUTINE_BACKEND).o
 
+block-obj-m = block/
+
 ifeq ($(CONFIG_VIRTIO)$(CONFIG_VIRTFS)$(CONFIG_PCI),yyy)
 # Lots of the fsdev/9pcode is pulled in by vl.c via qemu_fsdev_add.
 # only pull in the actual virtio-9p device if we also enabled virtio.
diff --git a/Makefile.target b/Makefile.target
index 9a6e7dd..3945260 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -148,7 +148,11 @@ obj-y-save := $(obj-y)
 block-obj-y :=
 common-obj-y :=
 include $(SRC_PATH)/Makefile.objs
-dummy := $(call unnest-vars,..,block-obj-y common-obj-y)
+dummy := $(call unnest-vars,.., \
+   block-obj-y \
+   block-obj-m \
+   common-obj-y \
+   common-obj-m)
 
 # Now restore obj-y
 obj-y := $(obj-y-save)
-- 
1.8.3.1





[Qemu-devel] [PATCH v18 04/10] block: use per-object cflags and libs

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

No longer adds flags and libs for them to global variables, instead
create config-host.mak variables like FOO_CFLAGS and FOO_LIBS, which is
used as per object cflags and libs.

This removes unwanted dependencies from libcacard.

Signed-off-by: Fam Zheng f...@redhat.com
[Split from Fam's patch to enable modules. - Paolo]
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 block/Makefile.objs | 13 -
 configure   | 25 ++---
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/block/Makefile.objs b/block/Makefile.objs
index 4e8c91e..a1db63f 100644
--- a/block/Makefile.objs
+++ b/block/Makefile.objs
@@ -23,4 +23,15 @@ common-obj-y += commit.o
 common-obj-y += mirror.o
 common-obj-y += backup.o
 
-$(obj)/curl.o: QEMU_CFLAGS+=$(CURL_CFLAGS)
+iscsi.o-cflags := $(LIBISCSI_CFLAGS)
+iscsi.o-libs   := $(LIBISCSI_LIBS)
+curl.o-cflags  := $(CURL_CFLAGS)
+curl.o-libs:= $(CURL_LIBS)
+rbd.o-cflags   := $(RBD_CFLAGS)
+rbd.o-libs := $(RBD_LIBS)
+gluster.o-cflags   := $(GLUSTERFS_CFLAGS)
+gluster.o-libs := $(GLUSTERFS_LIBS)
+ssh.o-cflags   := $(LIBSSH2_CFLAGS)
+ssh.o-libs := $(LIBSSH2_LIBS)
+qcow.o-libs:= -lz
+linux-aio.o-libs   := -laio
diff --git a/configure b/configure
index afff201..bfc8636 100755
--- a/configure
+++ b/configure
@@ -2304,8 +2304,6 @@ EOF
   curl_libs=`$curlconfig --libs 2/dev/null`
   if compile_prog $curl_cflags $curl_libs ; then
 curl=yes
-libs_tools=$curl_libs $libs_tools
-libs_softmmu=$curl_libs $libs_softmmu
   else
 if test $curl = yes ; then
   feature_not_found curl
@@ -2461,8 +2459,6 @@ EOF
   rbd_libs=-lrbd -lrados
   if compile_prog  $rbd_libs ; then
 rbd=yes
-libs_tools=$rbd_libs $libs_tools
-libs_softmmu=$rbd_libs $libs_softmmu
   else
 if test $rbd = yes ; then
   feature_not_found rados block device
@@ -2479,9 +2475,6 @@ if test $libssh2 != no ; then
 libssh2_cflags=`$pkg_config libssh2 --cflags`
 libssh2_libs=`$pkg_config libssh2 --libs`
 libssh2=yes
-libs_tools=$libssh2_libs $libs_tools
-libs_softmmu=$libssh2_libs $libs_softmmu
-QEMU_CFLAGS=$QEMU_CFLAGS $libssh2_cflags
   else
 if test $libssh2 = yes ; then
   error_exit libssh2 = $min_libssh2_version required for 
--enable-libssh2
@@ -2527,8 +2520,6 @@ int main(void) { io_setup(0, NULL); io_set_eventfd(NULL, 
0); eventfd(0, 0); retu
 EOF
   if compile_prog  -laio ; then
 linux_aio=yes
-libs_softmmu=$libs_softmmu -laio
-libs_tools=$libs_tools -laio
   else
 if test $linux_aio = yes ; then
   feature_not_found linux AIO
@@ -2697,9 +2688,6 @@ if test $glusterfs != no ; then
 glusterfs=yes
 glusterfs_cflags=`$pkg_config --cflags glusterfs-api`
 glusterfs_libs=`$pkg_config --libs glusterfs-api`
-CFLAGS=$CFLAGS $glusterfs_cflags
-libs_tools=$glusterfs_libs $libs_tools
-libs_softmmu=$glusterfs_libs $libs_softmmu
 if $pkg_config --atleast-version=5 glusterfs-api; then
   glusterfs_discard=yes
 fi
@@ -3070,11 +3058,9 @@ EOF
 libiscsi=yes
 libiscsi_cflags=$($pkg_config --cflags libiscsi)
 libiscsi_libs=$($pkg_config --libs libiscsi)
-CFLAGS=$CFLAGS $libiscsi_cflags
-LIBS=$LIBS $libiscsi_libs
   elif compile_prog  -liscsi ; then
 libiscsi=yes
-LIBS=$LIBS -liscsi
+libiscsi_libs=-liscsi
   else
 if test $libiscsi = yes ; then
   feature_not_found libiscsi
@@ -4072,6 +4058,7 @@ fi
 if test $curl = yes ; then
   echo CONFIG_CURL=y  $config_host_mak
   echo CURL_CFLAGS=$curl_cflags  $config_host_mak
+  echo CURL_LIBS=$curl_libs  $config_host_mak
 fi
 if test $brlapi = yes ; then
   echo CONFIG_BRLAPI=y  $config_host_mak
@@ -4164,6 +4151,8 @@ if test $libiscsi = yes ; then
   if test $libiscsi_version = 1.4.0; then
 echo CONFIG_LIBISCSI_1_4=y  $config_host_mak
   fi
+  echo LIBISCSI_CFLAGS=$libiscsi_cflags  $config_host_mak
+  echo LIBISCSI_LIBS=$libiscsi_libs  $config_host_mak
 fi
 
 if test $seccomp = yes; then
@@ -4185,6 +4174,8 @@ if test $qom_cast_debug = yes ; then
 fi
 if test $rbd = yes ; then
   echo CONFIG_RBD=y  $config_host_mak
+  echo RBD_CFLAGS=$rbd_cflags  $config_host_mak
+  echo RBD_LIBS=$rbd_libs  $config_host_mak
 fi
 
 echo CONFIG_COROUTINE_BACKEND=$coroutine  $config_host_mak
@@ -4228,6 +4219,8 @@ fi
 
 if test $glusterfs = yes ; then
   echo CONFIG_GLUSTERFS=y  $config_host_mak
+  echo GLUSTERFS_CFLAGS=$glusterfs_cflags  $config_host_mak
+  echo GLUSTERFS_LIBS=$glusterfs_libs  $config_host_mak
 fi
 
 if test $glusterfs_discard = yes ; then
@@ -4240,6 +4233,8 @@ fi
 
 if test $libssh2 = yes ; then
   echo CONFIG_LIBSSH2=y  $config_host_mak
+  echo LIBSSH2_CFLAGS=$libssh2_cflags  $config_host_mak
+  echo LIBSSH2_LIBS=$libssh2_libs  $config_host_mak
 fi
 
 if test $virtio_blk_data_plane = yes ; then
-- 
1.8.3.1





[Qemu-devel] [PATCH v18 08/10] Makefile: install modules with make install

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

Install all the modules to ${MODDIR}.

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/Makefile b/Makefile
index 07d1ed7..b434b2e 100644
--- a/Makefile
+++ b/Makefile
@@ -368,6 +368,12 @@ install-datadir install-localstatedir
 ifneq ($(TOOLS),)
$(INSTALL_PROG) $(STRIP_OPT) $(TOOLS) $(DESTDIR)$(bindir)
 endif
+ifneq ($(CONFIG_MODULES),)
+   $(INSTALL_DIR) $(DESTDIR)$(qemu_moddir)
+   for s in $(patsubst %.mo,%$(DSOSUF),$(modules-m)); do \
+   $(INSTALL_PROG) $(STRIP_OPT) $$s 
$(DESTDIR)$(qemu_moddir)/$${s//\//-}; \
+   done
+endif
 ifneq ($(HELPERS-y),)
$(INSTALL_DIR) $(DESTDIR)$(libexecdir)
$(INSTALL_PROG) $(STRIP_OPT) $(HELPERS-y) $(DESTDIR)$(libexecdir)
-- 
1.8.3.1





[Qemu-devel] [PATCH v18 05/10] darwin: do not use -mdynamic-no-pic

2014-01-31 Thread Paolo Bonzini
While -mdynamic-no-pic can speed up the code somewhat, it is only used
on the legacy PowerPC Mac OS X, and I am not sure if anyone is still
testing that.  Disabling PIC can cause problems when enabling modules,
so do not do that.

Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 configure | 2 --
 1 file changed, 2 deletions(-)

diff --git a/configure b/configure
index bfc8636..0e62059 100755
--- a/configure
+++ b/configure
@@ -517,8 +517,6 @@ Darwin)
   if [ $cpu = x86_64 ] ; then
 QEMU_CFLAGS=-arch x86_64 $QEMU_CFLAGS
 LDFLAGS=-arch x86_64 $LDFLAGS
-  else
-QEMU_CFLAGS=-mdynamic-no-pic $QEMU_CFLAGS
   fi
   cocoa=yes
   audio_drv_list=coreaudio
-- 
1.8.3.1





[Qemu-devel] [PATCH v18 07/10] module: implement module loading

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

This patch adds loading, stamp checking and initialization of modules.

The init function of dynamic module is no longer directly called as
__attribute__((constructor)) in static linked version, it is called
only after passed the checking of presense of stamp symbol:

qemu_stamp_$RELEASEHASH

where $RELEASEHASH is generated by hashing version strings and content
of configure script.

With this, modules built from a different tree/version/configure will
not be loaded.

The module loading code requires gmodule-2.0.

Modules are searched under
 - CONFIG_MODDIR
 - executable folder (to allow running qemu-{img,io} in the build
   directory)
 - ../ of executable folder (to allow running system emulator in the
   build directory)

Modules are linked under their subdir respectively, then copied to top
level of build directory for above convinience, e.g.:
$(BUILD_DIR)/block/curl.so - $(BUILD_DIR)/block-curl.so

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile  |   3 ++
 configure |  40 ++
 include/qemu/module.h |  34 +++-
 module-common.c   |  10 
 rules.mak |   3 ++
 scripts/create_config |   3 ++
 util/module.c | 145 +-
 7 files changed, 226 insertions(+), 12 deletions(-)
 create mode 100644 module-common.c

diff --git a/Makefile b/Makefile
index 9d53117..07d1ed7 100644
--- a/Makefile
+++ b/Makefile
@@ -201,6 +201,9 @@ Makefile: $(version-obj-y) $(version-lobj-y)
 libqemustub.a: $(stub-obj-y)
 libqemuutil.a: $(util-obj-y) qapi-types.o qapi-visit.o
 
+block-modules = $(foreach o,$(block-obj-m),$(basename $(subst /,-,$o)),) NULL
+util/module.o-cflags = -D'CONFIG_BLOCK_MODULES=$(block-modules)'
+
 ##
 
 qemu-img.o: qemu-img-cmds.h
diff --git a/configure b/configure
index 14f4501..7aff69e 100755
--- a/configure
+++ b/configure
@@ -1132,7 +1132,7 @@ Advanced options (experts only):
   --libdir=PATHinstall libraries in PATH
   --sysconfdir=PATHinstall config in PATH$confsuffix
   --localstatedir=PATH install local state in PATH (set at runtime on 
win32)
-  --with-confsuffix=SUFFIX suffix for QEMU data inside datadir and sysconfdir 
[$confsuffix]
+  --with-confsuffix=SUFFIX suffix for QEMU data inside 
datadir/libdir/sysconfdir [$confsuffix]
   --enable-modules enable modules support
   --enable-debug-tcg   enable TCG debugging
   --disable-debug-tcg  disable TCG debugging (default)
@@ -2348,14 +2348,32 @@ if test $mingw32 = yes; then
 else
 glib_req_ver=2.12
 fi
-if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then
-glib_cflags=`$pkg_config --cflags gthread-2.0`
-glib_libs=`$pkg_config --libs gthread-2.0`
-CFLAGS=$glib_cflags $CFLAGS
-LIBS=$glib_libs $LIBS
-libs_qga=$glib_libs $libs_qga
-else
-error_exit glib-$glib_req_ver required to compile QEMU
+
+for i in gthread-2.0 gmodule-2.0; do
+if $pkg_config --atleast-version=$glib_req_ver $i; then
+glib_cflags=`$pkg_config --cflags $i`
+glib_libs=`$pkg_config --libs $i`
+CFLAGS=$glib_cflags $CFLAGS
+LIBS=$glib_libs $LIBS
+libs_qga=$glib_libs $libs_qga
+else
+error_exit glib-$glib_req_ver $i is required to compile QEMU
+fi
+done
+
+##
+# SHA command probe for modules
+if test $modules = yes; then
+shacmd_probe=sha1sum sha1 shasum
+for c in $shacmd_probe; do
+if which $c /dev/null; then
+shacmd=$c
+break
+fi
+done
+if test $shacmd = ; then
+error_exit one of the checksum commands is required to enable 
modules: $shacmd_probe
+fi
 fi
 
 ##
@@ -3633,6 +3651,7 @@ if test $mingw32 = yes ; then
 fi
 
 qemu_confdir=$sysconfdir$confsuffix
+qemu_moddir=$libdir$confsuffix
 qemu_datadir=$datadir$confsuffix
 qemu_localedir=$datadir/locale
 
@@ -3723,6 +3742,7 @@ echo Install prefix$prefix
 echo BIOS directory`eval echo $qemu_datadir`
 echo binary directory  `eval echo $bindir`
 echo library directory `eval echo $libdir`
+echo module directory  `eval echo $qemu_moddir`
 echo libexec directory `eval echo $libexecdir`
 echo include directory `eval echo $includedir`
 echo config directory  `eval echo $sysconfdir`
@@ -3861,6 +3881,7 @@ echo sysconfdir=$sysconfdir  $config_host_mak
 echo qemu_confdir=$qemu_confdir  $config_host_mak
 echo qemu_datadir=$qemu_datadir  $config_host_mak
 echo qemu_docdir=$qemu_docdir  $config_host_mak
+echo qemu_moddir=$qemu_moddir  $config_host_mak
 if test $mingw32 = no ; then
   echo qemu_localstatedir=$local_statedir  $config_host_mak
 fi
@@ -3994,6 +4015,7 @@ if [ $docs = yes ] ; then
   echo BUILD_DOCS=yes  $config_host_mak
 fi
 if test $modules = yes; then
+  echo CONFIG_STAMP=`(echo 

[Qemu-devel] [PATCH 0/8] tcg optimization improvements

2014-01-31 Thread Richard Henderson
The first 4 of these are ones that Aurelien posted some time ago,
and I reviewed, but never seemed to get committed.

The second 4 address optimization issues that I noticed with the
BMI instruction set extension, adding ANDC support to x86_64.


r~


Aurelien Jarno (4):
  tcg/optimize: fix known-zero bits for right shift ops
  tcg/optimize: fix known-zero bits optimization
  tcg/optimize: improve known-zero bits for 32-bit ops
  tcg/optimize: add known-zero bits compute for load ops

Richard Henderson (4):
  tcg/optimize: Handle known-zeros masks for ANDC
  tcg/optimize: Simply some logical ops to NOT
  tcg/optimize: Optmize ANDC X,Y,Y to MOV X,0
  tcg/optimize: Add more identity simplifications

 tcg/optimize.c | 163 +
 1 file changed, 142 insertions(+), 21 deletions(-)

-- 
1.8.5.3




[Qemu-devel] [PATCH 10/11] twl92230: QOM'ify

2014-01-31 Thread Andreas Färber
Replace usages of FROM_I2C_SLAVE() with QOM cast macro.
Rename parent field.

Signed-off-by: Andreas Färber afaer...@suse.de
---
 hw/timer/twl92230.c | 35 +--
 1 file changed, 21 insertions(+), 14 deletions(-)

diff --git a/hw/timer/twl92230.c b/hw/timer/twl92230.c
index f3ea365..85d5990 100644
--- a/hw/timer/twl92230.c
+++ b/hw/timer/twl92230.c
@@ -27,8 +27,11 @@
 
 #define VERBOSE 1
 
-typedef struct {
-I2CSlave i2c;
+#define TYPE_TWL92230 twl92230
+#define TWL92230(obj) OBJECT_CHECK(MenelausState, (obj), TYPE_TWL92230)
+
+typedef struct MenelausState {
+I2CSlave parent_obj;
 
 int firstbyte;
 uint8_t reg;
@@ -127,7 +130,8 @@ static void menelaus_rtc_hz(void *opaque)
 
 static void menelaus_reset(I2CSlave *i2c)
 {
-MenelausState *s = (MenelausState *) i2c;
+MenelausState *s = TWL92230(i2c);
+
 s-reg = 0x00;
 
 s-vcore[0] = 0x0c;/* XXX: X-loader needs 0x8c? check!  */
@@ -492,8 +496,9 @@ static void menelaus_write(void *opaque, uint8_t addr, 
uint8_t value)
 break;
 
 case MENELAUS_DEVICE_OFF:
-if (value  1)
-menelaus_reset(s-i2c);
+if (value  1) {
+menelaus_reset(I2C_SLAVE(s));
+}
 break;
 
 case MENELAUS_OSC_CTRL:
@@ -708,7 +713,7 @@ static void menelaus_write(void *opaque, uint8_t addr, 
uint8_t value)
 
 static void menelaus_event(I2CSlave *i2c, enum i2c_event event)
 {
-MenelausState *s = (MenelausState *) i2c;
+MenelausState *s = TWL92230(i2c);
 
 if (event == I2C_START_SEND)
 s-firstbyte = 1;
@@ -716,7 +721,8 @@ static void menelaus_event(I2CSlave *i2c, enum i2c_event 
event)
 
 static int menelaus_tx(I2CSlave *i2c, uint8_t data)
 {
-MenelausState *s = (MenelausState *) i2c;
+MenelausState *s = TWL92230(i2c);
+
 /* Interpret register address byte */
 if (s-firstbyte) {
 s-reg = data;
@@ -729,7 +735,7 @@ static int menelaus_tx(I2CSlave *i2c, uint8_t data)
 
 static int menelaus_rx(I2CSlave *i2c)
 {
-MenelausState *s = (MenelausState *) i2c;
+MenelausState *s = TWL92230(i2c);
 
 return menelaus_read(s, s-reg ++);
 }
@@ -834,23 +840,24 @@ static const VMStateDescription vmstate_menelaus = {
 VMSTATE_STRUCT(rtc.alm, MenelausState, 0, vmstate_menelaus_tm,
struct tm),
 VMSTATE_UINT8(pwrbtn_state, MenelausState),
-VMSTATE_I2C_SLAVE(i2c, MenelausState),
+VMSTATE_I2C_SLAVE(parent_obj, MenelausState),
 VMSTATE_END_OF_LIST()
 }
 };
 
 static int twl92230_init(I2CSlave *i2c)
 {
-MenelausState *s = FROM_I2C_SLAVE(MenelausState, i2c);
+DeviceState *dev = DEVICE(i2c);
+MenelausState *s = TWL92230(i2c);
 
 s-rtc.hz_tm = timer_new_ms(rtc_clock, menelaus_rtc_hz, s);
 /* Three output pins plus one interrupt pin.  */
-qdev_init_gpio_out(i2c-qdev, s-out, 4);
+qdev_init_gpio_out(dev, s-out, 4);
 
 /* Three input pins plus one power-button pin.  */
-qdev_init_gpio_in(i2c-qdev, menelaus_gpio_set, 4);
+qdev_init_gpio_in(dev, menelaus_gpio_set, 4);
 
-menelaus_reset(s-i2c);
+menelaus_reset(i2c);
 
 return 0;
 }
@@ -868,7 +875,7 @@ static void twl92230_class_init(ObjectClass *klass, void 
*data)
 }
 
 static const TypeInfo twl92230_info = {
-.name  = twl92230,
+.name  = TYPE_TWL92230,
 .parent= TYPE_I2C_SLAVE,
 .instance_size = sizeof(MenelausState),
 .class_init= twl92230_class_init,
-- 
1.8.4.5




[Qemu-devel] [PATCH v3 0/1] Detect arch for dump compressed header.

2014-01-31 Thread Ekaterina Tumanova
True! Fixed. Tested.

Can you please put it into push-queue?

Thanks,
Kate.

Ekaterina Tumanova (1):
  Define the architecture for compressed dump format.

 dump.c | 7 +--
 target-i386/cpu.h  | 2 ++
 target-s390x/cpu.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

-- 
1.8.4.5




[Qemu-devel] [PATCH v3 1/1] Define the architecture for compressed dump format.

2014-01-31 Thread Ekaterina Tumanova
Signed-off-by: Ekaterina Tumanova tuman...@linux.vnet.ibm.com
---
 dump.c | 7 +--
 target-i386/cpu.h  | 2 ++
 target-s390x/cpu.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dump.c b/dump.c
index 8f64aab..8d85255 100644
--- a/dump.c
+++ b/dump.c
@@ -32,6 +32,9 @@
 #ifdef CONFIG_SNAPPY
 #include snappy-c.h
 #endif
+#ifndef ELF_MACHINE_UNAME
+#define ELF_MACHINE_UNAME Unknown
+#endif
 
 static uint16_t cpu_convert_to_target16(uint16_t val, int endian)
 {
@@ -817,7 +820,7 @@ static int create_header32(DumpState *s)
 dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
 bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
 dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
-memcpy((dh-utsname.machine), i686, 4);
+strncpy(dh-utsname.machine, ELF_MACHINE_UNAME, 
sizeof(dh-utsname.machine));
 
 if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
 status |= DUMP_DH_COMPRESSED_ZLIB;
@@ -924,7 +927,7 @@ static int create_header64(DumpState *s)
 dh-nr_cpus = cpu_convert_to_target32(s-nr_cpus, endian);
 bitmap_blocks = DIV_ROUND_UP(s-len_dump_bitmap, block_size) * 2;
 dh-bitmap_blocks = cpu_convert_to_target32(bitmap_blocks, endian);
-memcpy((dh-utsname.machine), x86_64, 6);
+strncpy(dh-utsname.machine, ELF_MACHINE_UNAME, 
sizeof(dh-utsname.machine));
 
 if (s-flag_compress  DUMP_DH_COMPRESSED_ZLIB) {
 status |= DUMP_DH_COMPRESSED_ZLIB;
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 1fcbc82..198743c 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -38,8 +38,10 @@
 
 #ifdef TARGET_X86_64
 #define ELF_MACHINE EM_X86_64
+#define ELF_MACHINE_UNAME x86_64
 #else
 #define ELF_MACHINE EM_386
+#define ELF_MACHINE_UNAME i686
 #endif
 
 #define CPUArchState struct CPUX86State
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 68b5ab7..bf7ae4c 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -28,6 +28,7 @@
 #define TARGET_LONG_BITS 64
 
 #define ELF_MACHINEEM_S390
+#define ELF_MACHINE_UNAME S390X
 
 #define CPUArchState struct CPUS390XState
 
-- 
1.8.4.5




[Qemu-devel] [PULL v2 00/34] target-arm queue

2014-01-31 Thread Peter Maydell
v2 of target-arm queue, with the KVM irqchip creation patchset dropped;
since the other 34 patches are unchanged I'm not retransmitting them.
Please pull.

thanks
-- PMM

The following changes since commit 89e4a51ca9546a7bbe1998c4e3d4a3ac3a0c19be:

  Merge remote-tracking branch 'stefanha/tags/tracing-pull-request' into 
staging (2014-01-31 11:13:08 +)

are available in the git repository at:


  git://git.linaro.org/people/pmaydell/qemu-arm.git 
tags/pull-target-arm-20140131

for you to fetch changes up to 5b0adce156216fb24dcc5f1683e8b686f3793fff:

  arm_gic: Fix GICD_ICPENDR and GICD_ISPENDR writes (2014-01-31 14:47:38 +)


target-arm queue:
 * implementation of first part of the A64 Neon instruction set
 * v8 AArch32 rounding and 16-64 fp conversion instructions
 * fix MIDR value on Zynq boards
 * some minor bugfixes/code cleanups


Alex Bennée (5):
  target-arm: A64: Add SIMD ld/st multiple
  target-arm: A64: Add decode skeleton for SIMD data processing insns
  target-arm: A64: Add SIMD copy operations
  target-arm: A64: Add SIMD modified immediate group
  target-arm: A64: Add SIMD shift by immediate

Alistair Francis (2):
  ARM: Convert MIDR to a property
  ZYNQ: Implement board MIDR control for Zynq

Christoffer Dall (2):
  arm_gic: Introduce define for GIC_NR_SGIS
  arm_gic: Fix GICD_ICPENDR and GICD_ISPENDR writes

Michael Matz (3):
  target-arm: A64: Add SIMD TBL/TBLX
  target-arm: A64: Add SIMD ZIP/UZP/TRN
  target-arm: A64: Add SIMD across-lanes instructions

Paolo Bonzini (1):
  display: avoid multi-statement macro

Peter Maydell (11):
  target-arm: A64: Add SIMD ld/st single
  target-arm: A64: Add SIMD EXT
  target-arm: A64: Add SIMD scalar copy instructions
  hw/arm/boot: Don't set up ATAGS for autogenerated dtb booting
  target-arm: A64: Add SIMD three-different multiply accumulate insns
  target-arm: A64: Add SIMD three-different ABDL instructions
  target-arm: A64: Add SIMD scalar 3 same add, sub and compare ops
  target-arm: A64: Add top level decode for SIMD 3-same group
  target-arm: A64: Add logic ops from SIMD 3 same group
  target-arm: A64: Add integer ops from SIMD 3-same group
  target-arm: A64: Add simple SIMD 3-same floating point ops

Will Newton (10):
  target-arm: Move arm_rmode_to_sf to a shared location.
  target-arm: Add AArch32 FP VRINTA, VRINTN, VRINTP and VRINTM
  target-arm: Add support for AArch32 FP VRINTR
  target-arm: Add support for AArch32 FP VRINTZ
  target-arm: Add support for AArch32 FP VRINTX
  target-arm: Add support for AArch32 SIMD VRINTX
  target-arm: Add set_neon_rmode helper
  target-arm: Add AArch32 SIMD VRINTA, VRINTN, VRINTP, VRINTM, VRINTZ
  target-arm: Add AArch32 FP VCVTA, VCVTN, VCVTP and VCVTM
  target-arm: Add AArch32 SIMD VCVTA, VCVTN, VCVTP and VCVTM

 hw/arm/boot.c|9 +-
 hw/arm/xilinx_zynq.c |7 +
 hw/display/blizzard_template.h   |   40 +-
 hw/display/pl110_template.h  |   12 +-
 hw/display/pxa2xx_template.h |   22 +-
 hw/display/tc6393xb_template.h   |   14 +-
 hw/intc/arm_gic.c|   21 +-
 include/hw/intc/arm_gic_common.h |1 +
 target-arm/cpu.c |1 +
 target-arm/cpu.h |2 +
 target-arm/helper-a64.c  |   31 +
 target-arm/helper-a64.h  |1 +
 target-arm/helper.c  |   45 +
 target-arm/helper.h  |1 +
 target-arm/translate-a64.c   | 2707 +-
 target-arm/translate.c   |  251 
 16 files changed, 3091 insertions(+), 74 deletions(-)



Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Eduardo Habkost
(CCing Luiz, in case he can give some advice about the expectations of
QMP semantics stability)

On Fri, Jan 31, 2014 at 03:48:53PM +0100, Igor Mammedov wrote:
 On Thu, 30 Jan 2014 17:48:52 -0200
 Eduardo Habkost ehabk...@redhat.com wrote:
 
  Is there any hope to get this into QEMU 2.0, or it is now too late? I got
  almost no feedback on take 6 (submitted November 27).
  
  This is the main blocker to allow libvirt finally implement an equivalent 
  to the
  enforce flag, finally making the CPU configuration safe and sane (today
  libvirt simply ignores GET_SUPPORTED_CPUID information, and features are
  silently disabled because enforce is not used).
  
  This blocks libvirt because the current available interfaces requires 
  re-running
  QEMU for each CPU model to be probed. Having the x86 CPU subclasses allow
  libvirt to simply create and destroy CPU objects from each available CPU 
  class,
  and query for the results using QMP.
  
  Demonstration of how this can be used, below:
  
  Running QEMU as:
  $ qemu-system-x86_64 -enable-kvm -machine none -monitor stdio -qmp 
  unix:/tmp/qmp,server,nowait -nographic
  
  Then running qmp-shell as:
  $ ./scripts/qmp/qmp-shell /tmp/qmp
  [...]
  (QEMU) object-add qom-type=host-x86_64-cpu id=probing-host-cpu-type
 [...]
  (QEMU) qom-list path=/objects/
 that's abusing of object-add interface and due to recent changes, object-add
 won't accept arbitrary objects.
 
 see [PATCH v1 3/4] add optional 2nd stage initialization to
 -object/object-add commands
 
 libvirt probably could use device_add instead to the same effect.

I don't mind which command is used, as long as we have the same effect.
I used object-add in my example because device_add rejects the CPU
classes by now (because they have cannot_instantiate_with_device_add_yet=true).

But now I have one question: how can people know which parts of the QMP
semantics will be stable, and which parts are subject to change?


 
 BTW how libvirt would discover values for qom-type=foo?

I don't know, but I assume there's an appropriate command to list qdev
and/or QOM classes, already?

In the worst case, libvirt can already use the query-cpu-definitions
command. But in this case, libvirt would have to encode the assumption
that the CPU class names will be model-arch-cpu. Or we could
provide a new property on the query-cpu-definitions output containing
the class name (that sounds appropriate, considering that the -cpu
option doesn't get a class name (yet?)).

The specifics are not set in stone, and I expect other developers to
help me guide the libvirt developers and give them recommendations on
how to query for the needed information (because there are multiple ways
to do the same thing in QMP, as far as I can see).


 
  {u'return': [{u'type': u'childHaswell-x86_64-cpu', u'name': 
  u'probing-cpu-type-Haswell'}, {u'type': u'childWestmere-x86_64-cpu', 
  u'name': u'probing-cpu-type-Westmere'}, {u'type': 
  u'childNehalem-x86_64-cpu', u'name': u'probing-cpu-type-Nehalem'}, 
  {u'type': u'childhost-x86_64-cpu', u'name': u'probing-host-cpu-type'}, 
  {u'type': u'string', u'name': u'type'}]}
  (QEMU) qom-list path=/objects/probing-cpu-type-Haswell/
  {u'return': [{u'type': u'X86CPUFeatureWordInfo', u'name': 
  u'filtered-features'}, {u'type': u'X86CPUFeatureWordInfo', u'name': 
  u'feature-words'}, {u'type': u'int', u'name': u'apic-id'}, {u'type': 
  u'int', u'name': u'tsc-frequency'}, {u'type': u'string', u'name': 
  u'model-id'}, {u'type': u'string', u'name': u'vendor'}, {u'type': u'int', 
  u'name': u'xlevel'}, {u'type': u'int', u'name': u'level'}, {u'type': 
  u'int', u'name': u'stepping'}, {u'type': u'int', u'name': u'model'}, 
  {u'type': u'int', u'name': u'family'}, {u'type': u'linkbus', u'name': 
  u'parent_bus'}, {u'type': u'boolean', u'name': u'enforce'}, {u'type': 
  u'boolean', u'name': u'check'}, {u'type': u'boolean', u'name': u'hv-time'}, 
  {u'type': u'boolean', u'name': u'hv-vapic'}, {u'type': u'boolean', u'name': 
  u'hv-relaxed'}, {u'type': u'int', u'name': u'hv-spinlocks'}, {u'type': 
  u'boolean', u'name': u'pmu'}, {u'type': u'bool', u'name': u'realized'}, 
  {u'type': u'string', u'name': u'type'}]}
  (QEMU) qom-get path=/objects/probing-cpu-type-Haswell property=feature-words
  {u'return': [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, 
  u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 
  1073741825, u'features': 16777339}, {u'cpuid-register': u'EDX', 
  u'cpuid-input-eax': 3221225473, u'features': 0}, {u'cpuid-register': 
  u'ECX', u'cpuid-input-eax': 2147483649, u'features': 1}, 
  {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, u'features': 
  672139264}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, u'features': 
  4025, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', 
  u'cpuid-input-eax': 1, u'features': 2549756419}, {u'cpuid-register': 
  u'EDX', u'cpuid-input-eax': 1, u'features': 126614525}]}
  (QEMU) qom-get 

Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Paolo Bonzini

Il 31/01/2014 16:10, Eduardo Habkost ha scritto:

I don't mind which command is used, as long as we have the same effect.
I used object-add in my example because device_add rejects the CPU
classes by now (because they have cannot_instantiate_with_device_add_yet=true).

But now I have one question: how can people know which parts of the QMP
semantics will be stable, and which parts are subject to change?


object-add was added in 2.0, so it was never stable.

Paolo




Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Paolo Bonzini

Il 31/01/2014 15:48, Igor Mammedov ha scritto:

that's abusing of object-add interface and due to recent changes, object-add
won't accept arbitrary objects.


I hope that sooner or later device hotplug will be doable with 
object-add too.  But yes, in the meanwhile device_add could work, and 
this patch series is in the right direction anyway.



see [PATCH v1 3/4] add optional 2nd stage initialization to
-object/object-add commands

libvirt probably could use device_add instead to the same effect.

BTW how libvirt would discover values for qom-type=foo?



With qom-list-types.

Paolo



Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Eduardo Habkost
On Fri, Jan 31, 2014 at 03:50:23PM +0100, Paolo Bonzini wrote:
 Il 31/01/2014 15:48, Igor Mammedov ha scritto:
 that's abusing of object-add interface and due to recent changes, object-add
 won't accept arbitrary objects.
 
 I hope that sooner or later device hotplug will be doable with
 object-add too.  But yes, in the meanwhile device_add could work,
 and this patch series is in the right direction anyway.

In that case, what is holding us from setting
cannot_instantiate_with_device_add_yet on TYPE_X86_CPU? I don't think we
can recommend using -device for CPUs just yet, but we would need to
allow it in case object-add doesn't work.

(But I liked the fact that object-add worked and (it looks like) it
didn't run realize(). All libvirt needs is to be able to create the
object and get instance_init() run, no need for realize() to run.)

I still need to read the reasoning behind the object-add changes. But is
there some chance we could allow object-add to work for TYPE_X86_CPU
subclasses, to avoid the device_add/cannot_instantiate_with_device_add_yet 
issues?

-- 
Eduardo



[Qemu-devel] [PATCH 5/8] tcg/optimize: Handle known-zeros masks for ANDC

2014-01-31 Thread Richard Henderson
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index d3b099a..3291a08 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -727,6 +727,17 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 mask = temps[args[1]].mask  mask;
 break;
 
+CASE_OP_32_64(andc):
+/* Known-zeros does not imply known-ones.  Therefore unless
+   args[2] is constant, we can't infer anything from it.  */
+if (temps[args[2]].state == TCG_TEMP_CONST) {
+mask = ~temps[args[2]].mask;
+goto and_const;
+}
+/* But we certainly know nothing outside args[1] may be set. */
+mask = temps[args[1]].mask;
+break;
+
 case INDEX_op_sar_i32:
 if (temps[args[2]].state == TCG_TEMP_CONST) {
 mask = (int32_t)temps[args[1]].mask  temps[args[2]].val;
-- 
1.8.5.3




Re: [Qemu-devel] [uq/master PATCH 0/7] x86 CPU subclasses, take 7

2014-01-31 Thread Igor Mammedov
On Thu, 30 Jan 2014 17:48:52 -0200
Eduardo Habkost ehabk...@redhat.com wrote:

 Is there any hope to get this into QEMU 2.0, or it is now too late? I got
 almost no feedback on take 6 (submitted November 27).
 
 This is the main blocker to allow libvirt finally implement an equivalent to 
 the
 enforce flag, finally making the CPU configuration safe and sane (today
 libvirt simply ignores GET_SUPPORTED_CPUID information, and features are
 silently disabled because enforce is not used).
 
 This blocks libvirt because the current available interfaces requires 
 re-running
 QEMU for each CPU model to be probed. Having the x86 CPU subclasses allow
 libvirt to simply create and destroy CPU objects from each available CPU 
 class,
 and query for the results using QMP.
 
 Demonstration of how this can be used, below:
 
 Running QEMU as:
 $ qemu-system-x86_64 -enable-kvm -machine none -monitor stdio -qmp 
 unix:/tmp/qmp,server,nowait -nographic
 
 Then running qmp-shell as:
 $ ./scripts/qmp/qmp-shell /tmp/qmp
 [...]
 (QEMU) object-add qom-type=host-x86_64-cpu id=probing-host-cpu-type
[...]
 (QEMU) qom-list path=/objects/
that's abusing of object-add interface and due to recent changes, object-add
won't accept arbitrary objects.

see [PATCH v1 3/4] add optional 2nd stage initialization to
-object/object-add commands

libvirt probably could use device_add instead to the same effect.

BTW how libvirt would discover values for qom-type=foo?

 {u'return': [{u'type': u'childHaswell-x86_64-cpu', u'name': 
 u'probing-cpu-type-Haswell'}, {u'type': u'childWestmere-x86_64-cpu', 
 u'name': u'probing-cpu-type-Westmere'}, {u'type': 
 u'childNehalem-x86_64-cpu', u'name': u'probing-cpu-type-Nehalem'}, 
 {u'type': u'childhost-x86_64-cpu', u'name': u'probing-host-cpu-type'}, 
 {u'type': u'string', u'name': u'type'}]}
 (QEMU) qom-list path=/objects/probing-cpu-type-Haswell/
 {u'return': [{u'type': u'X86CPUFeatureWordInfo', u'name': 
 u'filtered-features'}, {u'type': u'X86CPUFeatureWordInfo', u'name': 
 u'feature-words'}, {u'type': u'int', u'name': u'apic-id'}, {u'type': u'int', 
 u'name': u'tsc-frequency'}, {u'type': u'string', u'name': u'model-id'}, 
 {u'type': u'string', u'name': u'vendor'}, {u'type': u'int', u'name': 
 u'xlevel'}, {u'type': u'int', u'name': u'level'}, {u'type': u'int', u'name': 
 u'stepping'}, {u'type': u'int', u'name': u'model'}, {u'type': u'int', 
 u'name': u'family'}, {u'type': u'linkbus', u'name': u'parent_bus'}, 
 {u'type': u'boolean', u'name': u'enforce'}, {u'type': u'boolean', u'name': 
 u'check'}, {u'type': u'boolean', u'name': u'hv-time'}, {u'type': u'boolean', 
 u'name': u'hv-vapic'}, {u'type': u'boolean', u'name': u'hv-relaxed'}, 
 {u'type': u'int', u'name': u'hv-spinlocks'}, {u'type': u'boolean', u'name': 
 u'pmu'}, {u'type': u'bool', u'name': u'realized'}, {u'type': u'string', 
 u'name': u'type'}]}
 (QEMU) qom-get path=/objects/probing-cpu-type-Haswell property=feature-words
 {u'return': [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, 
 u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, 
 u'features': 16777339}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 
 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 
 2147483649, u'features': 1}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 
 2147483649, u'features': 672139264}, {u'cpuid-register': u'EBX', 
 u'cpuid-input-eax': 7, u'features': 4025, u'cpuid-input-ecx': 0}, 
 {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 2549756419}, 
 {u'cpuid-register': u'EDX', u'cpuid-input-eax': 1, u'features': 126614525}]}
 (QEMU) qom-get path=/objects/probing-cpu-type-Haswell 
 property=filtered-features
 {u'return': [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, 
 u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, 
 u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 3221225473, 
 u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 2147483649, 
 u'features': 0}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483649, 
 u'features': 0}, {u'cpuid-register': u'EBX', u'cpuid-input-eax': 7, 
 u'features': 0, u'cpuid-input-ecx': 0}, {u'cpuid-register': u'ECX', 
 u'cpuid-input-eax': 1, u'features': 0}, {u'cpuid-register': u'EDX', 
 u'cpuid-input-eax': 1, u'features': 0}]}
 (QEMU) qom-get path=/objects/probing-host-cpu-type property=feature-words
 {u'return': [{u'cpuid-register': u'EDX', u'cpuid-input-eax': 2147483658, 
 u'features': 0}, {u'cpuid-register': u'EAX', u'cpuid-input-eax': 1073741825, 
 u'features': 16777467}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 
 3221225473, u'features': 0}, {u'cpuid-register': u'ECX', u'cpuid-input-eax': 
 2147483649, u'features': 1}, {u'cpuid-register': u'EDX', u'cpuid-input-eax': 
 2147483649, u'features': 697564159}, {u'cpuid-register': u'EBX', 
 u'cpuid-input-eax': 7, u'features': 2, u'cpuid-input-ecx': 0}, 
 {u'cpuid-register': u'ECX', u'cpuid-input-eax': 1, u'features': 

[Qemu-devel] [PATCH v18 02/10] rules.mak: fix $(obj) to a real relative path

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

Makefile.target includes rule.mak and unnested common-obj-y, then prefix
them with '../', this will ignore object specific QEMU_CFLAGS in subdir
Makefile.objs:

$(obj)/curl.o: QEMU_CFLAGS += $(CURL_CFLAGS)

Because $(obj) here is './block', instead of '../block'. This doesn't
hurt compiling because we basically build all .o from top Makefile,
before entering Makefile.target, but it will affact arriving per-object
libs support.

The starting point of $(obj) is passed in as argument of unnest-vars, as
well as nested variables, so that different Makefiles can pass in a
right value.

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 Makefile| 14 ++
 Makefile.objs   | 17 +
 Makefile.target | 17 +
 configure   |  1 +
 rules.mak   | 14 +-
 5 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/Makefile b/Makefile
index 807054b..52b1958 100644
--- a/Makefile
+++ b/Makefile
@@ -122,6 +122,16 @@ defconfig:
 
 ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/Makefile.objs
+endif
+
+dummy := $(call unnest-vars,, \
+stub-obj-y \
+util-obj-y \
+qga-obj-y \
+block-obj-y \
+common-obj-y)
+
+ifneq ($(wildcard config-host.mak),)
 include $(SRC_PATH)/tests/Makefile
 endif
 ifeq ($(CONFIG_SMARTCARD_NSS),y)
@@ -130,6 +140,10 @@ endif
 
 all: $(DOCS) $(TOOLS) $(HELPERS-y) recurse-all
 
+vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
+
+vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
+
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
 qemu-options.def: $(SRC_PATH)/qemu-options.hx
diff --git a/Makefile.objs b/Makefile.objs
index ac1d0e1..1914080 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -41,7 +41,7 @@ libcacard-y += libcacard/vcardt.o
 # single QEMU executable should support all CPUs and machines.
 
 ifeq ($(CONFIG_SOFTMMU),y)
-common-obj-y = $(block-obj-y) blockdev.o blockdev-nbd.o block/
+common-obj-y = blockdev.o blockdev-nbd.o block/
 common-obj-y += net/
 common-obj-y += qdev-monitor.o device-hotplug.o
 common-obj-$(CONFIG_WIN32) += os-win32.o
@@ -111,18 +111,3 @@ version-lobj-$(CONFIG_WIN32) += $(BUILD_DIR)/version.lo
 # by libqemuutil.a.  These should be moved to a separate .json schema.
 qga-obj-y = qga/ qapi-types.o qapi-visit.o
 qga-vss-dll-obj-y = qga/
-
-vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS)
-
-vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS)
-
-QEMU_CFLAGS+=$(GLIB_CFLAGS)
-
-nested-vars += \
-   stub-obj-y \
-   util-obj-y \
-   qga-obj-y \
-   qga-vss-dll-obj-y \
-   block-obj-y \
-   common-obj-y
-dummy := $(call unnest-vars)
diff --git a/Makefile.target b/Makefile.target
index af6ac7e..9a6e7dd 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -139,13 +139,22 @@ endif # CONFIG_SOFTMMU
 # Workaround for http://gcc.gnu.org/PR55489, see configure.
 %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
 
-nested-vars += obj-y
+dummy := $(call unnest-vars,,obj-y)
 
-# This resolves all nested paths, so it must come last
+# we are making another call to unnest-vars with different vars, protect obj-y,
+# it can be overriden in subdir Makefile.objs
+obj-y-save := $(obj-y)
+
+block-obj-y :=
+common-obj-y :=
 include $(SRC_PATH)/Makefile.objs
+dummy := $(call unnest-vars,..,block-obj-y common-obj-y)
+
+# Now restore obj-y
+obj-y := $(obj-y-save)
 
-all-obj-y = $(obj-y)
-all-obj-y += $(addprefix ../, $(common-obj-y))
+all-obj-y = $(obj-y) $(common-obj-y)
+all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
 
 ifndef CONFIG_HAIKU
 LIBS+=-lm
diff --git a/configure b/configure
index 236764a..afff201 100755
--- a/configure
+++ b/configure
@@ -2346,6 +2346,7 @@ fi
 if $pkg_config --atleast-version=$glib_req_ver gthread-2.0; then
 glib_cflags=`$pkg_config --cflags gthread-2.0`
 glib_libs=`$pkg_config --libs gthread-2.0`
+CFLAGS=$glib_cflags $CFLAGS
 LIBS=$glib_libs $LIBS
 libs_qga=$glib_libs $libs_qga
 else
diff --git a/rules.mak b/rules.mak
index 49edb9b..7d27602 100644
--- a/rules.mak
+++ b/rules.mak
@@ -138,9 +138,6 @@ clean: clean-timestamp
 
 # magic to descend into other directories
 
-obj := .
-old-nested-dirs :=
-
 define push-var
 $(eval save-$2-$1 = $(value $1))
 $(eval $1 :=)
@@ -154,9 +151,11 @@ endef
 
 define unnest-dir
 $(foreach var,$(nested-vars),$(call push-var,$(var),$1/))
-$(eval obj := $(obj)/$1)
+$(eval obj-parent-$1 := $(obj))
+$(eval obj := $(if $(obj),$(obj)/$1,$1))
 $(eval include $(SRC_PATH)/$1/Makefile.objs)
-$(eval obj := $(patsubst %/$1,%,$(obj)))
+$(eval obj := $(obj-parent-$1))
+$(eval obj-parent-$1 := )
 $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/))
 endef
 
@@ -171,7 +170,12 @@ $(if $(nested-dirs),
 endef
 
 define unnest-vars
+$(eval obj := $1)
+$(eval nested-vars := $2)
+$(eval old-nested-dirs := )
 $(call unnest-vars-1)
+$(if $1,$(foreach v,$(nested-vars),$(eval \
+   $v := $(addprefix 

[Qemu-devel] [PATCH v18 00/10] Shared library module support

2014-01-31 Thread Paolo Bonzini
Yet another rebase of the loadable module series, with the
following changes:

1) reworked a bit the build system magic so that make foo.o will pick
the right flags when foo.o is part of a module.

2) redid the split between patches 6/7/9, doing first the makefile rules,
then the C code to load the modules, and only introducing the (initially
empty) *-obj-m variables at the end.

3) finally, tweaked the patches to only require limited changes to
scripts/create_config.

Paolo

Fam Zheng (9):
  util: Split out qemu_exec_dir from os_find_datadir
  rules.mak: fix $(obj) to a real relative path
  rules.mak: allow per object cflags and libs
  block: use per-object cflags and libs
  rules.mak: introduce DSO rules
  module: implement module loading
  Makefile: install modules with make install
  Makefile: introduce common-obj-m and block-obj-m for DSO
  block: convert block drivers linked with libs to modules

Paolo Bonzini (1):
  darwin: do not use -mdynamic-no-pic

 .gitignore|   3 ++
 Makefile  |  29 +-
 Makefile.objs |  19 ++-
 Makefile.target   |  21 ++--
 block/Makefile.objs   |  13 -
 configure |  91 ---
 include/qemu/module.h |  34 +++-
 include/qemu/osdep.h  |   4 ++
 module-common.c   |  10 
 os-posix.c|  40 +++---
 os-win32.c|  19 +--
 rules.mak |  80 +++-
 scripts/create_config |   3 ++
 util/module.c | 145 +-
 util/oslib-posix.c|  45 
 util/oslib-win32.c|  24 +
 16 files changed, 460 insertions(+), 120 deletions(-)
 create mode 100644 module-common.c

-- 
1.8.3.1




[Qemu-devel] [PATCH 1/8] tcg/optimize: fix known-zero bits for right shift ops

2014-01-31 Thread Richard Henderson
From: Aurelien Jarno aurel...@aurel32.net

32-bit versions of sar and shr ops should not propagate known-zero bits
from the unused 32 high bits. For sar it could even lead to wrong code
being generated.

Cc: Paolo Bonzini pbonz...@redhat.com
Cc: qemu-sta...@nongnu.org
Signed-off-by: Aurelien Jarno aurel...@aurel32.net
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 89e2d6a..c5cdde2 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -726,16 +726,25 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 mask = temps[args[1]].mask  mask;
 break;
 
-CASE_OP_32_64(sar):
+case INDEX_op_sar_i32:
+if (temps[args[2]].state == TCG_TEMP_CONST) {
+mask = (int32_t)temps[args[1]].mask  temps[args[2]].val;
+}
+break;
+case INDEX_op_sar_i64:
 if (temps[args[2]].state == TCG_TEMP_CONST) {
-mask = ((tcg_target_long)temps[args[1]].mask
- temps[args[2]].val);
+mask = (int64_t)temps[args[1]].mask  temps[args[2]].val;
 }
 break;
 
-CASE_OP_32_64(shr):
+case INDEX_op_shr_i32:
+if (temps[args[2]].state == TCG_TEMP_CONST) {
+mask = (uint32_t)temps[args[1]].mask  temps[args[2]].val;
+}
+break;
+case INDEX_op_shr_i64:
 if (temps[args[2]].state == TCG_TEMP_CONST) {
-mask = temps[args[1]].mask  temps[args[2]].val;
+mask = (uint64_t)temps[args[1]].mask  temps[args[2]].val;
 }
 break;
 
-- 
1.8.5.3




[Qemu-devel] [PATCH v18 03/10] rules.mak: allow per object cflags and libs

2014-01-31 Thread Paolo Bonzini
From: Fam Zheng f...@redhat.com

Adds extract-libs in LINK to expand any per object libs, the syntax to define
such a libs options is like:

foo.o-libs := $(CURL_LIBS)

in block/Makefile.objs.

Similarly,

foo.o-cflags := $(FOO_CFLAGS)

is also supported.

foo.o must be listed in a nested var (e.g. common-obj-y) to make the
option variables effective.

Signed-off-by: Fam Zheng f...@redhat.com
Signed-off-by: Paolo Bonzini pbonz...@redhat.com
---
 rules.mak | 19 ---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/rules.mak b/rules.mak
index 7d27602..9398268 100644
--- a/rules.mak
+++ b/rules.mak
@@ -21,15 +21,17 @@ QEMU_DGFLAGS += -MMD -MP -MT $@ -MF $(*D)/$(*F).d
 # Same as -I$(SRC_PATH) -I., but for the nested source/object directories
 QEMU_INCLUDES += -I$(D) -I$(@D)
 
+extract-libs = $(strip $(foreach o,$1,$($o-libs)))
+
 %.o: %.c
-   $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $,  CC$(TARGET_DIR)$@)
+   $(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) 
$(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) -c -o $@ $,  CC$(TARGET_DIR)$@)
 %.o: %.rc
$(call quiet-command,$(WINDRES) -I. -o $@ $,  RC$(TARGET_DIR)$@)
 
 ifeq ($(LIBTOOL),)
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
$(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
-   $(LIBS),  LINK  $(TARGET_DIR)$@)
+   $(call extract-libs,$^) $(LIBS),  LINK  $(TARGET_DIR)$@)
 else
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
@@ -45,7 +47,7 @@ LINK = $(call quiet-command,\
$(sort $(filter %.o, $1)) $(filter-out %.o, $1) \
$(if $(filter %.lo %.la,$^),$(version-lobj-y),$(version-obj-y)) \
$(if $(filter %.lo %.la,$^),$(LIBTOOLFLAGS)) \
-   $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK ,   LINK  
)$(TARGET_DIR)$@)
+   $(call extract-libs,$^) $(LIBS),$(if $(filter %.lo %.la,$^),lt LINK , 
  LINK  )$(TARGET_DIR)$@)
 endif
 
 %.asm: %.S
@@ -149,11 +151,22 @@ $(eval $1 = $(value save-$2-$1) $$(subdir-$2-$1))
 $(eval save-$2-$1 :=)
 endef
 
+define fix-obj-vars
+$(foreach v,$($1), \
+   $(if $($v-cflags), \
+   $(eval $2$v-cflags := $($v-cflags)) \
+   $(eval $v-cflags := )) \
+   $(if $($v-libs), \
+   $(eval $2$v-libs := $($v-libs)) \
+   $(eval $v-libs := )))
+endef
+
 define unnest-dir
 $(foreach var,$(nested-vars),$(call push-var,$(var),$1/))
 $(eval obj-parent-$1 := $(obj))
 $(eval obj := $(if $(obj),$(obj)/$1,$1))
 $(eval include $(SRC_PATH)/$1/Makefile.objs)
+$(foreach v,$(nested-vars),$(call fix-obj-vars,$v,$(if $(obj),$(obj)/)))
 $(eval obj := $(obj-parent-$1))
 $(eval obj-parent-$1 := )
 $(foreach var,$(nested-vars),$(call pop-var,$(var),$1/))
-- 
1.8.3.1





[Qemu-devel] [PATCH 6/8] tcg/optimize: Simply some logical ops to NOT

2014-01-31 Thread Richard Henderson
Given, of course, an appropriate constant.  These could be generated
from the canonical operation for inversion on the guest, or via
other optimizations.

Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 57 +
 1 file changed, 57 insertions(+)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index 3291a08..cdfc746 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -655,6 +655,63 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 }
 }
 break;
+CASE_OP_32_64(xor):
+CASE_OP_32_64(nand):
+if (temps[args[1]].state != TCG_TEMP_CONST
+ temps[args[2]].state == TCG_TEMP_CONST
+ temps[args[2]].val == -1) {
+i = 1;
+goto try_not;
+}
+break;
+CASE_OP_32_64(nor):
+if (temps[args[1]].state != TCG_TEMP_CONST
+ temps[args[2]].state == TCG_TEMP_CONST
+ temps[args[2]].val == 0) {
+i = 1;
+goto try_not;
+}
+break;
+CASE_OP_32_64(andc):
+if (temps[args[2]].state != TCG_TEMP_CONST
+ temps[args[1]].state == TCG_TEMP_CONST
+ temps[args[1]].val == -1) {
+i = 2;
+goto try_not;
+}
+break;
+CASE_OP_32_64(orc):
+CASE_OP_32_64(eqv):
+if (temps[args[2]].state != TCG_TEMP_CONST
+ temps[args[1]].state == TCG_TEMP_CONST
+ temps[args[1]].val == 0) {
+i = 2;
+goto try_not;
+}
+break;
+try_not:
+{
+TCGOpcode not_op;
+bool have_not;
+
+if (def-flags  TCG_OPF_64BIT) {
+not_op = INDEX_op_not_i64;
+have_not = TCG_TARGET_HAS_not_i64;
+} else {
+not_op = INDEX_op_not_i32;
+have_not = TCG_TARGET_HAS_not_i32;
+}
+if (!have_not) {
+break;
+}
+s-gen_opc_buf[op_index] = not_op;
+reset_temp(args[0]);
+gen_args[0] = args[0];
+gen_args[1] = args[i];
+args += 3;
+gen_args += 2;
+continue;
+}
 default:
 break;
 }
-- 
1.8.5.3




[Qemu-devel] [PATCH 2/8] tcg/optimize: fix known-zero bits optimization

2014-01-31 Thread Richard Henderson
From: Aurelien Jarno aurel...@aurel32.net

Known-zero bits optimization is a great idea that helps to generate more
optimized code. However the current implementation only works in very few
cases as the computed mask is not saved.

Fix this to make it really working.

Cc: Paolo Bonzini pbonz...@redhat.com
Signed-off-by: Aurelien Jarno aurel...@aurel32.net
Signed-off-by: Richard Henderson r...@twiddle.net
---
 tcg/optimize.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tcg/optimize.c b/tcg/optimize.c
index c5cdde2..7838be2 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -691,7 +691,8 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t 
*tcg_opc_ptr,
 break;
 }
 
-/* Simplify using known-zero bits */
+/* Simplify using known-zero bits. Currently only ops with a single
+   output argument is supported. */
 mask = -1;
 affected = -1;
 switch (op) {
@@ -1149,6 +1150,11 @@ static TCGArg *tcg_constant_folding(TCGContext *s, 
uint16_t *tcg_opc_ptr,
 } else {
 for (i = 0; i  def-nb_oargs; i++) {
 reset_temp(args[i]);
+/* Save the corresponding known-zero bits mask for the
+   first output argument (only one supported so far). */
+if (i == 0) {
+temps[args[i]].mask = mask;
+}
 }
 }
 for (i = 0; i  def-nb_args; i++) {
-- 
1.8.5.3




[Qemu-devel] [PATCH v2 10/35] target-arm: Stop underdecoding ARM946 PRBS registers

2014-01-31 Thread Peter Maydell
The ARM946 has 8 PRBS (protection region base and size) registers.
Currently we implement these with a CP_ANY reginfo; however this
underdecodes (since there are 16 possible values of CRm but only
8 registers) and we catch the invalid values in the read and
write functions. However this causes issues with migration since
we only migrate the first of a wildcard register set, so we only
migrate c6_region[0]. It also makes it awkward to pull reginfo
access checks out into their own function.

Avoid all these problems by just defining separate reginfo structs
for each of the 8 registers; this also lets us avoid having any
read or write functions and will result in more efficient direct
field accesses from generated code.

Signed-off-by: Peter Maydell peter.mayd...@linaro.org
---
 target-arm/helper.c | 47 ---
 1 file changed, 24 insertions(+), 23 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 6f1ec46..bd78350 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -1162,26 +1162,6 @@ static int pmsav5_insn_ap_read(CPUARMState *env, const 
ARMCPRegInfo *ri,
 return 0;
 }
 
-static int arm946_prbs_read(CPUARMState *env, const ARMCPRegInfo *ri,
-uint64_t *value)
-{
-if (ri-crm = 8) {
-return EXCP_UDEF;
-}
-*value = env-cp15.c6_region[ri-crm];
-return 0;
-}
-
-static int arm946_prbs_write(CPUARMState *env, const ARMCPRegInfo *ri,
- uint64_t value)
-{
-if (ri-crm = 8) {
-return EXCP_UDEF;
-}
-env-cp15.c6_region[ri-crm] = value;
-return 0;
-}
-
 static const ARMCPRegInfo pmsav5_cp_reginfo[] = {
 { .name = DATA_AP, .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 0,
   .access = PL1_RW, .type = ARM_CP_NO_MIGRATE,
@@ -1204,9 +1184,30 @@ static const ARMCPRegInfo pmsav5_cp_reginfo[] = {
   .access = PL1_RW,
   .fieldoffset = offsetof(CPUARMState, cp15.c2_insn), .resetvalue = 0, },
 /* Protection region base and size registers */
-{ .name = 946_PRBS, .cp = 15, .crn = 6, .crm = CP_ANY, .opc1 = 0,
-  .opc2 = CP_ANY, .access = PL1_RW,
-  .readfn = arm946_prbs_read, .writefn = arm946_prbs_write, },
+{ .name = 946_PRBS0, .cp = 15, .crn = 6, .crm = 0, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[0]) },
+{ .name = 946_PRBS1, .cp = 15, .crn = 6, .crm = 1, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[1]) },
+{ .name = 946_PRBS2, .cp = 15, .crn = 6, .crm = 2, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[2]) },
+{ .name = 946_PRBS3, .cp = 15, .crn = 6, .crm = 3, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[3]) },
+{ .name = 946_PRBS4, .cp = 15, .crn = 6, .crm = 4, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[4]) },
+{ .name = 946_PRBS5, .cp = 15, .crn = 6, .crm = 5, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[5]) },
+{ .name = 946_PRBS6, .cp = 15, .crn = 6, .crm = 6, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[6]) },
+{ .name = 946_PRBS7, .cp = 15, .crn = 6, .crm = 7, .opc1 = 0,
+  .opc2 = CP_ANY, .access = PL1_RW, .resetvalue = 0,
+  .fieldoffset = offsetof(CPUARMState, cp15.c6_region[7]) },
 REGINFO_SENTINEL
 };
 
-- 
1.8.5




  1   2   3   >