Re: [Qemu-devel] [v2][PATCH 4/8] xen, gfx passthrough: reserve 00:02.0 for INTEL IGD

2014-05-21 Thread Chen, Tiejun
> -Original Message-
> From: Gerd Hoffmann [mailto:kra...@redhat.com]
> Sent: Monday, May 19, 2014 9:51 PM
> To: Chen, Tiejun
> Cc: anthony.per...@citrix.com; stefano.stabell...@eu.citrix.com;
> m...@redhat.com; kelly.zyta...@amd.com; peter.mayd...@linaro.org;
> xen-de...@lists.xensource.com; Kay, Allen M; qemu-devel@nongnu.org;
> anth...@codemonkey.ws; Zhang, Yang Z
> Subject: Re: [Qemu-devel] [v2][PATCH 4/8] xen, gfx passthrough: reserve
> 00:02.0 for INTEL IGD
> 
>   Hi,
> 
> > > Yes, -vga, -net nic, -drive if=scsi (maybe more) can internally
> > > create pci devices with auto slot assignment, which will occupy slot 2
> indeed.
> > > Use -device instead to create the devices.
> > >
> >
> > Are you saying we have to create the devices explicitly when we want
> > to work IGD vga with passthrough? But how to make sure all user know
> > this workable way? Maybe you suggest we should document somewhere.
> 
> libvirt does this unconditionally, because it is a good idea anyway for a 
> number
> of reasons.  Example: create a machine with three pci devices, hot-unplug the
> second, then live-migrate to another machine.  The only way to create the
> correct config on the target machine is to explicitly assign slots, otherwise 
> the
> third pci device ends up in the wrong slot.
> 
> Don't know how the libxl (and xl tool) work.  Maybe it does the same anyway.
> Maybe it can handle the address assignment transparently for the user.
> 
> > > Ah, the xen platform device.  /me looks.  Ah, pc_xen_hvm_init
> > > creates this automatically.  Two options here IMHO:
> > >
> > >   (1) Just move it somewhere else explicitly.  For example slot 3, or
> > >   make it a southbridge function (say 00:01.7).
> > >   (2) Don't create it automatically, instead expect management add it
> > >   if needed, using -device xen-plaform,addr=...
> > >
> > > I personally would suggest to go for #2.  As far I know the platform
> > > device is only needed if you want attach xenbus devices to the guest
> > > (correct?), so creating virtual machines without the xen platform
> > > device is a valid use case and you should allow it.
> 
> > Looks you recommend we should change current xen platform design, I'm
> > not sure if something in libxl also need to be modified. Especially,
> > this may not be compatible with those old xen version.
> 
> Going for (1) certainly is easier as (2) indeed will need changes in the 
> libxl, and
> might be tricky to get work with both old+new versions.
> 
> > And especially, how to guarantee no one occupy 00:02.0 in the future
> > with auto assign?
> 
> Creating devices automatically turned out to have a number of problems.
> So it is very unlikely we'll ever do this again.
> 

According to our discussions, I realize we may have some plans or policies 
dedicated to how to assign devfn, but to support GFX passthrough for XEN, I 
think currently it may be a better solution to adopt #1 simply like this:

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index eaf3e61..500b3c2 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -386,7 +386,7 @@ static void pc_xen_hvm_init(QEMUMachineInitArgs *args)
 
 bus = pci_find_primary_bus();
 if (bus != NULL) {
-pci_create_simple(bus, -1, "xen-platform");
+pci_create_simple(bus, PCI_DEVFN(3,0), "xen-platform");
 }
 }
 #endif

Then we can go out to plan how to assign devfn in common, is this fine?

Thanks
Tiejun



Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Fam Zheng
On Wed, 05/21 07:54, Markus Armbruster wrote:
> Fam Zheng  writes:
> 
> > On Tue, 05/20 13:13, Eric Blake wrote:
> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
> >> > Please first take a look at patch 7 to see what is supported by this 
> >> > series.
> >> > 
> >> > Patch 1 ~ 3 allows some useful basic types in schema.
> >> > 
> >> > Patch 4 ~ 6 implements the new syntax.
> >> > 
> >> > Note: The introduced '@arg' sigil, just like the preexisting '*arg', is
> >> > reducing the cleanness of the syntax. We should get rid of both of them 
> >> > in long
> >> > term. Here, this series compromises on this and introduces '@arg' 
> >> > because:
> >> > 
> >> >   - We have to distinguish the argument property dictionary from nested 
> >> > struct:
> >> > 
> >> > I.e.:
> >> > 
> >> > 'data': {
> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
> >> > '@arg2': { 'type': 'int', 'default': 100 }
> >> >  }
> >> > 
> >> > Until we completely drop and forbid the 'arg1' nested struct use 
> >> > case.
> >> > 
> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull in many
> >> > distractive patches to this series.
> >> 
> >> Question - since we WANT to get rid of nested struct, why not reverse
> >> the sense?  Mark all existing nested structs (weren't there just three
> >> that we found?) with the '@' sigil, and let the new syntax be
> >> sigil-free.  Then when we clean up the nesting, we are also getting rid
> >> of the bad syntax, plus the sigil gives us something to search for in
> >> knowing how much to clean up.  But if you stick the sigil on the new
> >> code, instead of the obsolete code, then as more and more places in the
> >> schema use defaults, it gets harder and harder to remove the use of the
> >> sigil even if the nested structs are eventually removed.
> >> 
> >
> > It makes not much difference I can see. The hard part is actaully dropping
> > nested, converting from sigil <-> non-sigil is easy. Of course, nothing is
> > seriously hard, there are only three nested structs plus some more 
> > qapi-schema
> > test code.
> 
> Adding three ugly sigils and making everybody include one when they add
> a nested struct feels much better to me than ugly sigils all over the
> place.

Well, I could use some background here. Why did we introduce nested structure
in the first place?

Fam

> 
> > A question before that is, if we are determined to drop '@' sigil (whether 
> > from
> > nested or property dict), are we as determined to drop '*' sigil as well?
> 
> We decided to wait and see how many optionals pick up defaults.  '*' is
> only for optionals without defaults.



[Qemu-devel] [Bug 1320030] Re: Qemu 2.0.0 with display=gtk hangs

2014-05-21 Thread tadawson
Testing on other systems reveals that this is solid on Slackware14.1,
with it's associated libraries.  Interestingly, the more heavily the
machine is loaded, the further the emulator runs prior to hanging . . .
The 1.7.1 code, compiled on an older Slackware (loosely based on 12, but
has evolved, but generally older libs) appears to work.  I have changed
out most libs that seem apparent - gtk+, vte, and a few others, as well
as compiling with slirp and aio disabled, as well as not using gthreads,
to no avail.  This appears to be a race between the gtk window thread,
and qemu, but the qemu source is so large, that I have not yet been able
to find that area of the code to be able to debug deeper.

Help!

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

Title:
  Qemu 2.0.0 with display=gtk hangs

Status in QEMU:
  New

Bug description:
  When qemu 2.0.0 is started, compiled with gtk, communications between
  the emulator process and the gtk "wrapper" window hang, and the
  emulator hangs typically before the bios finishes initializing, and if
  boot menu=on is selected, even if it gets to this point, keyboard
  input is not accepted to the emulator process.  Switching to the
  session console in the window header yeilds a fully functional console
  with zero input issues, indicating that the overall process is getting
  keyboard data, just not cleanly passing it to the emulator.  A
  "system_reset" in the console will typically result in a bit more
  execution of the emulator, and then a subsequent hang at a later
  point.  When the hang occurs, CPU useage pegs at 100%, and when I
  strace the process, I get typically 20,000 lines in the trace in about
  2 seconds, 90% of which is repetitive:

  read(5, 0x7fff965c4df0, 16) = -1 EAGAIN (Resource temporarily 
unavai
  lable)
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  read(9, "\1\0\0\0\0\0\0\0", 512)= 8
  write(4, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  recvfrom(11, 0x7f562e697c14, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily 
un
  available)
  ppoll([{fd=3, events=POLLIN|POLLERR|POLLHUP}, {fd=5, events=POLLIN}, {fd=11, 
eve
  nts=POLLIN}, {fd=13, events=POLLIN}, {fd=15, events=POLLIN}, {fd=17, 
events=POLL
  IN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}], 8, {0, 0}, NULL, 8) = 2 
([{f
  d=5, revents=POLLIN}, {fd=4, revents=POLLIN}], left {0, 0})
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  read(4, "\1\0\0\0\0\0\0\0", 512)= 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  recvfrom(11, 0x7f562e697c14, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily 
un
  available)
  futex(0x7f562ce32e40, FUTEX_WAKE_PRIVATE, 1) = 1
  ppoll([{fd=3, events=POLLIN|POLLERR|POLLHUP}, {fd=5, events=POLLIN}, {fd=11, 
eve
  nts=POLLIN}, {fd=13, events=POLLIN}, {fd=15, events=POLLIN}, {fd=17, 
events=POLL
  IN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}, {fd=14, events=POLLIN}, 
{fd=1
  6, events=POLLIN}, {fd=12, events=POLLIN}], 11, {0, 20060537}, NULL, 8) = 1 
([{f
  d=5, revents=POLLIN}], left {0, 20056426})
  read(5, "\10\0\0\0\0\0\0\0", 16)= 8
  recvfrom(11, 0x7f562e697c14, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily 
un
  available)
  futex(0x7f562ce32e40, FUTEX_WAKE_PRIVATE, 1) = 1
  ppoll([{fd=3, events=POLLIN|POLLERR|POLLHUP}, {fd=5, events=POLLIN}, {fd=11, 
eve
  nts=POLLIN}, {fd=13, events=POLLIN}, {fd=15, events=POLLIN}, {fd=17, 
events=POLL
  IN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}, {fd=14, events=POLLIN}, 
{fd=1
  6, events=POLLIN}, {fd=12, events=POLLIN}], 11, {0, 19878122}, NULL, 8) = 1 
([{f
  d=9, revents=POLLIN}], left {0, 19672563})
  futex(0x7f562ce32e40, FUTEX_WAIT_PRIVATE, 2, NULL) = -1 EAGAIN (Resource 
tempora
  rily unavailable)
  read(5, 0x7fff965c4df0, 16) = -1 EAGAIN (Resource temporarily 
unavai
  lable)
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  read(9, "\1\0\0\0\0\0\0\0", 512)= 8
  write(4, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  recvfrom(11, 0x7f562e697c14, 4096, 0, 0, 0) = -1 EAGAIN (Resource temporarily 
un
  available)
  ppoll([{fd=3, events=POLLIN|POLLERR|POLLHUP}, {fd=5, events=POLLIN}, {fd=11, 
eve
  nts=POLLIN}, {fd=13, events=POLLIN}, {fd=15, events=POLLIN}, {fd=17, 
events=POLL
  IN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}], 8, {0, 0}, NULL, 8) = 2 
([{f
  d=5, revents=POLLIN}, {fd=4, revents=POLLIN}], left {0, 0})
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  write(5, "\1\0\0\0\0\0\0\0", 8) = 8
  read(4, "\1\0\0\0\0\0\0\0", 512)= 8
  write(5, "\1\0\0\0\0\0\0\0", 8)   

Re: [Qemu-devel] [PATCH 4/9] target-ppc: Implement "compat" CPU option

2014-05-21 Thread Alexander Graf


On 21.05.14 08:57, Alexey Kardashevskiy wrote:

On 05/17/2014 06:47 AM, Alexander Graf wrote:

On 16.05.14 17:17, Alexey Kardashevskiy wrote:

On 05/17/2014 12:05 AM, Alexander Graf wrote:

On 15.05.14 13:28, Alexey Kardashevskiy wrote:

This adds basic support for the "compat" CPU option. By specifying
the compat property, the user can manually switch guest CPU mode from
"raw" to "architected".

Since the actual compatibility mode is not implemented yet, this does
not change the existing behavior.

Signed-off-by: Alexey Kardashevskiy 
---
hw/ppc/spapr.c  | 15 ++-
target-ppc/cpu-models.h |  6 ++
target-ppc/cpu-qom.h|  2 ++
target-ppc/cpu.h|  3 +++
target-ppc/translate_init.c | 35 +++
5 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0f8bd95..61d0675 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -212,7 +212,8 @@ static int spapr_fixup_cpu_dt(void *fdt,
sPAPREnvironment *spapr)
  CPU_FOREACH(cpu) {
DeviceClass *dc = DEVICE_GET_CLASS(cpu);
-int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
+PowerPCCPU *pcpu = POWERPC_CPU(cpu);
+int index = ppc_get_vcpu_dt_id(pcpu);
uint32_t associativity[] = {cpu_to_be32(0x5),
cpu_to_be32(0x0),
cpu_to_be32(0x0),
@@ -249,6 +250,14 @@ static int spapr_fixup_cpu_dt(void *fdt,
sPAPREnvironment *spapr)
return ret;
}
+if (pcpu->cpu_version) {
+ret = fdt_setprop(fdt, offset, "cpu-version",
+  &pcpu->cpu_version,
sizeof(pcpu->cpu_version));
+if (ret < 0) {
+return ret;
+}
+}
+
/* Build interrupt servers and gservers properties */
for (i = 0; i < smp_threads; i++) {
servers_prop[i] = cpu_to_be32(index + i);
@@ -1278,6 +1287,10 @@ static void ppc_spapr_init(QEMUMachineInitArgs
*args)
kvmppc_set_papr(cpu);
}
+if (cpu->max_compat) {
+ppc_set_compat(cpu, cpu->max_compat);
+}
+
xics_cpu_setup(spapr->icp, cpu);
  qemu_register_reset(spapr_cpu_reset, cpu);
diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
index 33d2c51..45c0028 100644
--- a/target-ppc/cpu-models.h
+++ b/target-ppc/cpu-models.h
@@ -753,4 +753,10 @@ enum {
POWERPC_SVR_8641D  = 0x80900121,
};
+/* Processor Compatibility mask (PCR) */
+enum {
+POWERPC_ISA_COMPAT_2_05 = 0x02,
+POWERPC_ISA_COMPAT_2_06 = 0x04,
+};
+
#endif
diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index 2a8515b..dfd1419 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -83,6 +83,7 @@ typedef struct PowerPCCPUClass {
 * @env: #CPUPPCState
 * @cpu_dt_id: CPU index used in the device tree. KVM uses this
index too
 * @max_compat: Maximal supported logical PVR from the command line
+ * @cpu_version: Current logical PVR, zero if in "raw" mode
 *
 * A PowerPC CPU.
 */
@@ -94,6 +95,7 @@ struct PowerPCCPU {
CPUPPCState env;
int cpu_dt_id;
uint32_t max_compat;
+uint32_t cpu_version;
};
  static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index d498340..f61675a 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1123,6 +1123,8 @@ void ppc_store_msr (CPUPPCState *env, target_ulong
value);
  void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
+void ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
+
/* Time-base and decrementer management */
#ifndef NO_CPU_IO_DEFS
uint64_t cpu_ppc_load_tbl (CPUPPCState *env);
@@ -1338,6 +1340,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
#define SPR_LPCR  (0x13E)
#define SPR_BOOKE_DVC2(0x13F)
#define SPR_BOOKE_TSR (0x150)
+#define SPR_PCR   (0x152)
#define SPR_BOOKE_TCR (0x154)
#define SPR_BOOKE_TLB0PS  (0x158)
#define SPR_BOOKE_TLB1PS  (0x159)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 6f61b34..c4bd5de 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7803,6 +7803,15 @@ static void init_proc_POWER7 (CPUPPCState *env)
/* Can't find information on what this should be on reset.  This
 * value is the one used by 74xx processors. */
vscr_init(env, 0x0001);
+
+/*
+ * Register PCR to report POWERPC_EXCP_PRIV_REG instead of
+ * POWERPC_EXCP_INVAL_SPR.
+ */
+spr_register(env, SPR_PCR, "PCR",
+ SPR_NOACCESS, SPR_NOACCESS,
+ SPR_NOACCESS, SPR_NOACCESS,
+ 0x);
}
  POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
@@ 

Re: [Qemu-devel] [PATCH v2 06/31] pc: create custom generic PC machine type

2014-05-21 Thread Igor Mammedov
On Tue, 20 May 2014 18:55:32 +0300
Marcel Apfelbaum  wrote:

> On Tue, 2014-05-20 at 17:15 +0200, Igor Mammedov wrote:
> > it will be used for PC specific options/variables
> > 
> > Signed-off-by: Igor Mammedov 
> > ---
> >  hw/i386/pc.c |   57 
> > ++
> >  hw/i386/pc_piix.c|   36 +++---
> >  hw/i386/pc_q35.c |   12 +-
> >  include/hw/i386/pc.h |   24 +
> >  4 files changed, 105 insertions(+), 24 deletions(-)
> > 
> > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > index e6369d5..f6781d8 100644
> > --- a/hw/i386/pc.c
> > +++ b/hw/i386/pc.c
> > @@ -1459,3 +1459,60 @@ void ioapic_init_gsi(GSIState *gsi_state, const char 
> > *parent_name)
> >  gsi_state->ioapic_irq[i] = qdev_get_gpio_in(dev, i);
> >  }
> >  }
> > +
> > +static void pc_generic_machine_class_init(ObjectClass *oc, void *data)
> > +{
> > +MachineClass *mc = MACHINE_CLASS(oc);
> > +QEMUMachine *qm = data;
> > +
> > +mc->name = qm->name;
> > +mc->alias = qm->alias;
> > +mc->desc = qm->desc;
> > +mc->init = qm->init;
> > +mc->reset = qm->reset;
> > +mc->hot_add_cpu = qm->hot_add_cpu;
> > +mc->kvm_type = qm->kvm_type;
> > +mc->block_default_type = qm->block_default_type;
> > +mc->max_cpus = qm->max_cpus;
> > +mc->no_serial = qm->no_serial;
> > +mc->no_parallel = qm->no_parallel;
> > +mc->use_virtcon = qm->use_virtcon;
> > +mc->use_sclp = qm->use_sclp;
> > +mc->no_floppy = qm->no_floppy;
> > +mc->no_cdrom = qm->no_cdrom;
> > +mc->no_sdcard = qm->no_sdcard;
> > +mc->is_default = qm->is_default;
> > +mc->default_machine_opts = qm->default_machine_opts;
> > +mc->default_boot_order = qm->default_boot_order;
> > +mc->compat_props = qm->compat_props;
> > +mc->hw_version = qm->hw_version;
> > +}
> Hi Igor,
> This conflicts with the latest "machine as QOM object" series in which
> MachineClass does not have a pointer to QEMUMachine and
> pc_generic_machine_class_init is not needed anymore.
I'm not sure with what it conflicts, this patch is rebased on top of
https://github.com/afaerber/qemu-cpu/commit/33ead66c86c96e37d141cfcfda5664b2fa0408fd
from qom-next queue, which drops QEMUMachineInitArgs but QEMUMachine is still 
exists/used.

MachineClass does not have a pointer to QEMUMachine so we have to
initialize MachineClass fields directly /that's what's changed from previous 
version/

If there will be more patches about Machine conversion in qom-next before
next series respin, I'll rebase it on top them.
> 
> If your series will come first we will have a re-base problem on
> Andreas's QOM's queue.
> Andreas, what's the best practice here?
> 
> > +
> > +void qemu_register_pc_machine(QEMUMachine *m)
> > +{
> > +char *name = g_strconcat(m->name, TYPE_MACHINE_SUFFIX, NULL);
> > +TypeInfo ti = {
> > +.name   = name,
> > +.parent = TYPE_PC_MACHINE,
> > +.class_init = pc_generic_machine_class_init,
> > +.class_data = (void *)m,
> > +};
> > +
> > +type_register(&ti);
> > +g_free(name);
> > +}
> > +
> > +static const TypeInfo pc_machine_info = {
> > +.name = TYPE_PC_MACHINE,
> > +.parent = TYPE_MACHINE,
> > +.abstract = true,
> > +.instance_size = sizeof(PCMachineState),
> > +.class_size = sizeof(PCMachineClass),
> > +};
> > +
> > +static void pc_machine_register_types(void)
> > +{
> > +type_register_static(&pc_machine_info);
> > +}
> > +
> > +type_init(pc_machine_register_types)
> > diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> > index a48e263..abb599b 100644
> > --- a/hw/i386/pc_piix.c
> > +++ b/hw/i386/pc_piix.c
> > @@ -843,25 +843,25 @@ static QEMUMachine xenfv_machine = {
> >  
> >  static void pc_machine_init(void)
> >  {
> > -qemu_register_machine(&pc_i440fx_machine_v2_1);
> > -qemu_register_machine(&pc_i440fx_machine_v2_0);
> > -qemu_register_machine(&pc_i440fx_machine_v1_7);
> > -qemu_register_machine(&pc_i440fx_machine_v1_6);
> > -qemu_register_machine(&pc_i440fx_machine_v1_5);
> > -qemu_register_machine(&pc_i440fx_machine_v1_4);
> > -qemu_register_machine(&pc_machine_v1_3);
> > -qemu_register_machine(&pc_machine_v1_2);
> > -qemu_register_machine(&pc_machine_v1_1);
> > -qemu_register_machine(&pc_machine_v1_0);
> > -qemu_register_machine(&pc_machine_v0_15);
> > -qemu_register_machine(&pc_machine_v0_14);
> > -qemu_register_machine(&pc_machine_v0_13);
> > -qemu_register_machine(&pc_machine_v0_12);
> > -qemu_register_machine(&pc_machine_v0_11);
> > -qemu_register_machine(&pc_machine_v0_10);
> > -qemu_register_machine(&isapc_machine);
> > +qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
> > +qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
> > +qemu_register_pc_machine(&pc_i440fx_machine_v1_7);
> > +qemu_register_pc_machine(&pc_i440fx_machine_v1_6);
> > +qemu_register_pc

[Qemu-devel] [RFC] How to deal with the conflict between DE keymap and qemu console ?

2014-05-21 Thread Gonglei (Arei)
Hi, Gerd

The issues has been reported a few months ago.  The previous mail:
https://lists.gnu.org/archive/html/qemu-devel/2014-01/msg01600.html

Any ideas? Thanks!


Best regards,
-Gonglei





Re: [Qemu-devel] [PATCH v4 1/4] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Igor Mammedov
On Tue, 20 May 2014 12:26:25 -0400
Matthew Rosato  wrote:

> From: Igor Mammedov 
> 
> From: Igor Mammedov 
> 
> Add following parameters:
>   "slots" - total number of hotplug memory slots
>   "maxmem" - maximum possible memory
> 
> "slots" and "maxmem" should go in pair and "maxmem" should be greater
> than "mem" for memory hotplug to be enabled.
this patch is out dated,
there is a new one on the list
https://github.com/imammedo/qemu/commit/390379c3a0edce3975e773da48b894958c72170f
which depends on
"machine: Conversion of QEMUMachineInitArgs to MachineState"
https://github.com/afaerber/qemu-cpu/commit/33ead66c86c96e37d141cfcfda5664b2fa0408fd
from qom-next queue

> 
> Signed-off-by: Igor Mammedov 
> Signed-off-by: Matthew Rosato 
> ---
>  include/hw/boards.h |2 ++
>  qemu-options.hx |9 ++---
>  vl.c|   51 
> +++
>  3 files changed, 59 insertions(+), 3 deletions(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index 4345bd0..5b3a903 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -11,6 +11,8 @@
>  typedef struct QEMUMachineInitArgs {
>  const MachineClass *machine;
>  ram_addr_t ram_size;
> +ram_addr_t maxram_size;
> +uint64_t   ram_slots;
>  const char *boot_order;
>  const char *kernel_filename;
>  const char *kernel_cmdline;
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 781af14..c6411c4 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
> versions.
>  ETEXI
>  
>  DEF("m", HAS_ARG, QEMU_OPTION_m,
> -"-m [size=]megs\n"
> +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
>  "configure guest RAM\n"
>  "size: initial amount of guest memory (default: "
> -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
> +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
> +"slots: number of hotplug slots (default: none)\n"
> +"maxmem: maximum amount of guest memory (default: 
> none)\n",
>  QEMU_ARCH_ALL)
>  STEXI
>  @item -m [size=]@var{megs}
>  @findex -m
>  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
> Optionally,
>  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
> -gigabytes respectively.
> +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be used
> +to set amount of hotluggable memory slots and possible maximum amount of 
> memory.
>  ETEXI
>  
>  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> diff --git a/vl.c b/vl.c
> index 709d8cd..f8f2057 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
>  .name = "size",
>  .type = QEMU_OPT_SIZE,
>  },
> +{
> +.name = "slots",
> +.type = QEMU_OPT_NUMBER,
> +},
> +{
> +.name = "maxmem",
> +.type = QEMU_OPT_SIZE,
> +},
>  { /* end of list */ }
>  },
>  };
> @@ -2988,6 +2996,8 @@ int main(int argc, char **argv, char **envp)
>  const char *trace_file = NULL;
>  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
>  1024 * 1024;
> +ram_addr_t maxram_size = default_ram_size;
> +uint64_t ram_slots = 0;
>  
>  atexit(qemu_run_exit_notifiers);
>  error_set_progname(argv[0]);
> @@ -3323,6 +,7 @@ int main(int argc, char **argv, char **envp)
>  case QEMU_OPTION_m: {
>  uint64_t sz;
>  const char *mem_str;
> +const char *maxmem_str, *slots_str;
>  
>  opts = qemu_opts_parse(qemu_find_opts("memory"),
> optarg, 1);
> @@ -3364,6 +3375,44 @@ int main(int argc, char **argv, char **envp)
>  error_report("ram size too large");
>  exit(EXIT_FAILURE);
>  }
> +
> +maxmem_str = qemu_opt_get(opts, "maxmem");
> +slots_str = qemu_opt_get(opts, "slots");
> +if (maxmem_str && slots_str) {
> +uint64_t slots;
> +
> +sz = qemu_opt_get_size(opts, "maxmem", 0);
> +if (sz < ram_size) {
> +fprintf(stderr, "qemu: invalid -m option value: 
> maxmem "
> +"(%" PRIu64 ") <= initial memory (%"
> +PRIu64 ")\n", sz, ram_size);
> +exit(EXIT_FAILURE);
> +}
> +
> +slots = qemu_opt_get_number(opts, "slots", 0);
> +if ((sz > ram_size) && !slots) {
> +fprintf(stderr, "qemu: invalid -m option value: 
> maxmem "
> +"(%" PRIu64 ") more than initial memory (%"
> +PRIu64 ") but no 

Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Markus Armbruster
Fam Zheng  writes:

> On Wed, 05/21 07:54, Markus Armbruster wrote:
>> Fam Zheng  writes:
>> 
>> > On Tue, 05/20 13:13, Eric Blake wrote:
>> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
>> >> > Please first take a look at patch 7 to see what is supported by this 
>> >> > series.
>> >> > 
>> >> > Patch 1 ~ 3 allows some useful basic types in schema.
>> >> > 
>> >> > Patch 4 ~ 6 implements the new syntax.
>> >> > 
>> >> > Note: The introduced '@arg' sigil, just like the preexisting '*arg', is
>> >> > reducing the cleanness of the syntax. We should get rid of both of them 
>> >> > in long
>> >> > term. Here, this series compromises on this and introduces '@arg' 
>> >> > because:
>> >> > 
>> >> >   - We have to distinguish the argument property dictionary from nested 
>> >> > struct:
>> >> > 
>> >> > I.e.:
>> >> > 
>> >> > 'data': {
>> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
>> >> > '@arg2': { 'type': 'int', 'default': 100 }
>> >> >  }
>> >> > 
>> >> > Until we completely drop and forbid the 'arg1' nested struct use 
>> >> > case.
>> >> > 
>> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull in 
>> >> > many
>> >> > distractive patches to this series.
>> >> 
>> >> Question - since we WANT to get rid of nested struct, why not reverse
>> >> the sense?  Mark all existing nested structs (weren't there just three
>> >> that we found?) with the '@' sigil, and let the new syntax be
>> >> sigil-free.  Then when we clean up the nesting, we are also getting rid
>> >> of the bad syntax, plus the sigil gives us something to search for in
>> >> knowing how much to clean up.  But if you stick the sigil on the new
>> >> code, instead of the obsolete code, then as more and more places in the
>> >> schema use defaults, it gets harder and harder to remove the use of the
>> >> sigil even if the nested structs are eventually removed.
>> >> 
>> >
>> > It makes not much difference I can see. The hard part is actaully dropping
>> > nested, converting from sigil <-> non-sigil is easy. Of course, nothing is
>> > seriously hard, there are only three nested structs plus some more
>> > qapi-schema
>> > test code.
>> 
>> Adding three ugly sigils and making everybody include one when they add
>> a nested struct feels much better to me than ugly sigils all over the
>> place.
>
> Well, I could use some background here. Why did we introduce nested structure
> in the first place?

Because we could?

Felt like a good idea at the time?

I quick glance at commit 0f923be and fb3182c suggests they have been
supported since the beginning.  There is no design rationale.

[...]



Re: [Qemu-devel] [PATCH v4 2/4] sclp-s390: Add device to manage s390 memory hotplug

2014-05-21 Thread Igor Mammedov
On Tue, 20 May 2014 12:26:26 -0400
Matthew Rosato  wrote:

> Add sclpMemoryHotplugDev to contain associated data structures, etc.
> 
> Signed-off-by: Matthew Rosato 
> ---
>  hw/s390x/sclp.c |   38 ++
>  include/hw/s390x/sclp.h |   20 
>  2 files changed, 58 insertions(+)
> 
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index d8ddf35..3f32eba 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -183,3 +183,41 @@ void s390_sclp_init(void)
>OBJECT(dev), NULL);
>  qdev_init_nofail(dev);
>  }
> +
> +sclpMemoryHotplugDev *init_sclp_memory_hotplug_dev(void)
> +{
> +ObjectProperty *op;
> +DeviceState *dev;
> +dev = qdev_create(NULL, TYPE_SCLP_MEMORY_HOTPLUG_DEV);
> +object_property_add_child(qdev_get_machine(),
> +  TYPE_SCLP_MEMORY_HOTPLUG_DEV,
> +  OBJECT(dev), NULL);
> +qdev_init_nofail(dev);
> +op = object_property_find(qdev_get_machine(),
> +  TYPE_SCLP_MEMORY_HOTPLUG_DEV,
> +  NULL);
> +return op->opaque;
one is not supposed to touch internals of ObjectProperty
pls use object_resolve_path*() instead of object_property_find()
in this patch.

> +}
> +
> +sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void)
> +{
> +ObjectProperty *op = object_property_find(qdev_get_machine(),
> +  TYPE_SCLP_MEMORY_HOTPLUG_DEV,
> +  NULL);
> +if (!op) {
> +return NULL;
> +}
> +return op->opaque;
> +}
> +
> +static TypeInfo sclp_memory_hotplug_dev_info = {
> +.name = TYPE_SCLP_MEMORY_HOTPLUG_DEV,
> +.parent = TYPE_SYS_BUS_DEVICE,
> +.instance_size = sizeof(sclpMemoryHotplugDev),
> +};
> +
> +static void register_types(void)
> +{
> +type_register_static(&sclp_memory_hotplug_dev_info);
> +}
> +type_init(register_types);
> diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
> index 7ef1622..03bc9c3 100644
> --- a/include/hw/s390x/sclp.h
> +++ b/include/hw/s390x/sclp.h
> @@ -37,6 +37,7 @@
>  #define SCLP_STARTING_SUBINCREMENT_ID   0x10001
>  #define SCLP_INCREMENT_UNIT 0x1
>  #define MAX_AVAIL_SLOTS 32
> +#define MAX_STORAGE_INCREMENTS  1020
>  
>  /* CPU hotplug SCLP codes */
>  #define SCLP_HAS_CPU_INFO   0x0C00ULL
> @@ -156,6 +157,23 @@ typedef struct SCCB {
>  char data[SCCB_DATA_LEN];
>   } QEMU_PACKED SCCB;
>  
> +typedef struct sclpMemoryHotplugDev sclpMemoryHotplugDev;
> +
> +#define TYPE_SCLP_MEMORY_HOTPLUG_DEV "sclp-memory-hotplug-dev"
> +#define SCLP_MEMORY_HOTPLUG_DEV(obj) \
> +  OBJECT_CHECK(sclpMemoryHotplugDev, (obj), TYPE_SCLP_MEMORY_HOTPLUG_DEV)
> +
> +struct sclpMemoryHotplugDev {
> +DeviceState parent;
> +ram_addr_t standby_mem_size;
> +ram_addr_t padded_ram_size;
> +ram_addr_t pad_size;
> +ram_addr_t standby_subregion_size;
> +ram_addr_t rzm;
> +int increment_size;
> +char *standby_state_map;
> +};
> +
>  static inline int sccb_data_len(SCCB *sccb)
>  {
>  return be16_to_cpu(sccb->h.length) - sizeof(sccb->h);
> @@ -163,6 +181,8 @@ static inline int sccb_data_len(SCCB *sccb)
>  
>  
>  void s390_sclp_init(void);
> +sclpMemoryHotplugDev *init_sclp_memory_hotplug_dev(void);
> +sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void);
>  void sclp_service_interrupt(uint32_t sccb);
>  void raise_irq_cpu_hotplug(void);
>  




Re: [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for hot-unplug device

2014-05-21 Thread Jun Li

Hi Andreas,


On 05/19/2014 11:31 PM, Andreas Färber wrote:

Hi,

Am 19.05.2014 17:03, schrieb Jun Li:

Add remove_boot_device_path() function to remove bootindex when hot-unplug
a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic device.

Signed-off-by: Jun Li 
---
This patch also fixed bug1086603, ref:
https://bugzilla.redhat.com/show_bug.cgi?id=1086603

This version of patch delete dev and suffix parameter from function 
remove_boot_device_path().
---
  hw/block/virtio-blk.c   |  1 +
  hw/net/virtio-net.c |  1 +
  hw/scsi/scsi-disk.c |  1 +
  hw/scsi/scsi-generic.c  |  1 +

On v1 I believe I reminded you of spapr_llan. Your patch is adding a new
remove_*() function, but is using it only for roughly half of the
devices that currently call add_boot_device_path(). Why? I can
understand that ISA devices will not be hot-unpluggable, but all PCI and
USB devices are.


Yes, as I am not so family with spapr_llan, so just fixed roughly half 
of the devices. I have checked the following files.



hw/block/fdc.c:add_boot_device_path(isa->bootindexA, dev, "/floppy@0");


No need here, ISA not support hot-unplug.


hw/block/fdc.c:add_boot_device_path(isa->bootindexB, dev, "/floppy@1");


No need here, ISA not support hot-unplug.


hw/block/virtio-blk.c:add_boot_device_path(s->conf->bootindex, dev,
"/disk@0,0");


Has done.


hw/core/loader.c:add_boot_device_path(bootindex, NULL, devpath);


No need here.


hw/i386/kvm/pci-assign.c:add_boot_device_path(dev->bootindex,
&pci_dev->qdev, NULL);


I will add in assigned_exitfn().


hw/ide/qdev.c:add_boot_device_path(dev->conf.bootindex, &dev->qdev,


ide doesn't support hot-unplug. so no need here.


hw/misc/vfio.c:add_boot_device_path(vdev->bootindex, &pdev->qdev, NULL);


I will add in vfio_exitfn().


hw/net/e1000.c:add_boot_device_path(d->conf.bootindex, dev,
"/ethernet-phy@0");


I will add in pci_e1000_uninit().


hw/net/eepro100.c:add_boot_device_path(s->conf.bootindex,
&pci_dev->qdev, "/ethernet-phy@0");


I will add in pci_nic_uninit().


hw/net/ne2000.c:add_boot_device_path(s->c.bootindex, &pci_dev->qdev,
"/ethernet-phy@0");


I will add in ci_ne2000_exit().


hw/net/pcnet.c:add_boot_device_path(s->conf.bootindex, dev,
"/ethernet-phy@0");


No need here.


hw/net/rtl8139.c:add_boot_device_path(s->conf.bootindex, d,
"/ethernet-phy@0");


I will in add pci_rtl8139_uninit().


hw/net/spapr_llan.c:add_boot_device_path(dev->nicconf.bootindex,
DEVICE(dev), "");


No need here.


hw/net/virtio-net.c:add_boot_device_path(n->nic_conf.bootindex, dev,
"/ethernet-phy@0");


I will add in virtio_net_device_unrealize().


hw/net/vmxnet3.c:add_boot_device_path(s->conf.bootindex, dev,
"/ethernet-phy@0");


I will add in vmxnet3_pci_uninit().


hw/scsi/scsi-disk.c:add_boot_device_path(s->qdev.conf.bootindex,
&dev->qdev, NULL);


has done.


hw/scsi/scsi-generic.c:add_boot_device_path(s->conf.bootindex,
&s->qdev, NULL);


it doesn't support hot-unplug, so no need here.


hw/usb/dev-network.c:add_boot_device_path(s->conf.bootindex,
&dev->qdev, "/ethernet@0");


no need here.


hw/usb/host-libusb.c:add_boot_device_path(s->bootindex, &udev->qdev,
NULL);


No need here.


hw/usb/redirect.c:add_boot_device_path(dev->bootindex, &udev->qdev,
NULL);


No need here. Generic pass-through doesn't support hot-unplug.




  include/sysemu/sysemu.h |  1 +
  vl.c| 15 +++
  6 files changed, 20 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 8a568e5..497eb40 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -752,6 +752,7 @@ static void virtio_blk_device_unrealize(DeviceState *dev, 
Error **errp)
  unregister_savevm(dev, "virtio-blk", s);
  blockdev_mark_auto_del(s->bs);
  virtio_cleanup(vdev);
+remove_boot_device_path(s->conf->bootindex);
  }
  
  static Property virtio_blk_properties[] = {

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 940a7cf..6afb1ca 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1645,6 +1645,7 @@ static void virtio_net_device_unrealize(DeviceState *dev, 
Error **errp)
  g_free(n->vqs);
  qemu_del_nic(n->nic);
  virtio_cleanup(vdev);
+remove_boot_device_path(n->nic_conf.bootindex);
  }
  
  static void virtio_net_instance_init(Object *obj)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index 4bcef55..d33df2e 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -2156,6 +2156,7 @@ static void scsi_destroy(SCSIDevice *dev)
  
  scsi_device_purge_requests(&s->qdev, SENSE_CODE(NO_SENSE));

  blockdev_mark_auto_del(s->qdev.conf.bs);
+remove_boot_device_path(s->qdev.conf.bootindex);

Didn't I previously ask that you use dev->config.bootindex here?
Pointers to parent's struct shouldn't be accessed anywhere except
VMStateDescription.


ok.


  }
  
  static void scsi_disk_resize_cb(void *opaque)

diff --g

Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Paolo Bonzini

Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:

Hi!

We recently discovered that not entire QEMU is GPL2-compatible, the fpu
emulation has a different license (copied below) which might create legal
problems because of that "INDEMNIFY" statement.

Does anyone else care (except IBM)?

What would the proper solution be? Ask the creator to relicense it under
GPL? I failed to find a contact as the homepage on berkeley.edu is
restricted. Rewrite the code? This code is used in FPU emulation for TCG,
is that the only use of it? If it should not get called for KVM, that would
be a temporary band-aid for us :)


http://marc.info/?l=qemu-devel&m=136725946312880&w=4

The following people haven't acked the relicensing of their 
contributions from softfloat-2b to softfloat-2a or GPLv2+ yet:


Fabrice Bellard 
1d6bda356153c82e100680d9f2165e32c8fb1330
750afe93fd15fafc20b6c34d30f339547d15c2d1

Jocelyn Mayer
75d62a585629cdc1ae0d530189653cb1d8d9c53c

Thiemo Seufer's parents (Stefan said he'd contact them)
5a6932d51d1b34b68b3f10fc5ac65598bece88c0
924b2c07cdfaba9ac408fc5fa77da75a570f9dc5
b645bb48850fea8db017026897827f0ab42fbdea
fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10

This list only includes people whose contributions has not been reverted 
in the meanwhile.


Paolo



Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Alexander Graf


On 21.05.14 09:51, Paolo Bonzini wrote:

Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:

Hi!

We recently discovered that not entire QEMU is GPL2-compatible, the fpu
emulation has a different license (copied below) which might create 
legal

problems because of that "INDEMNIFY" statement.

Does anyone else care (except IBM)?

What would the proper solution be? Ask the creator to relicense it under
GPL? I failed to find a contact as the homepage on berkeley.edu is
restricted. Rewrite the code? This code is used in FPU emulation for 
TCG,
is that the only use of it? If it should not get called for KVM, that 
would

be a temporary band-aid for us :)


http://marc.info/?l=qemu-devel&m=136725946312880&w=4

The following people haven't acked the relicensing of their 
contributions from softfloat-2b to softfloat-2a or GPLv2+ yet:


Fabrice Bellard 
1d6bda356153c82e100680d9f2165e32c8fb1330
750afe93fd15fafc20b6c34d30f339547d15c2d1

Jocelyn Mayer
75d62a585629cdc1ae0d530189653cb1d8d9c53c

Thiemo Seufer's parents (Stefan said he'd contact them)
5a6932d51d1b34b68b3f10fc5ac65598bece88c0
924b2c07cdfaba9ac408fc5fa77da75a570f9dc5
b645bb48850fea8db017026897827f0ab42fbdea
fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10

This list only includes people whose contributions has not been 
reverted in the meanwhile.


How many % of the overall commits does that make? IIRC you can relicense 
source code if the "majority of authors" agrees and nobody actively 
disagrees - or so. But IANAL :)



Alex




Re: [Qemu-devel] [PATCH v2 30/31] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole

2014-05-21 Thread Igor Mammedov
On Tue, 20 May 2014 18:38:15 +0300
"Michael S. Tsirkin"  wrote:

> On Tue, May 20, 2014 at 05:15:33PM +0200, Igor Mammedov wrote:
> > Needed for Windows to use hotplugged memory device, otherwise
> > it complains that server is not configured for memory hotplug.
> > Tests shows that aftewards it uses dynamically provided
> > proximity value from _PXM() method if available.
> > 
> > Signed-off-by: Igor Mammedov 
> > ---
> >  hw/i386/acpi-build.c |   14 ++
> >  1 files changed, 14 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 58e7306..97e3a82 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1199,6 +1199,8 @@ build_srat(GArray *table_data, GArray *linker,
> >  uint64_t curnode;
> >  int srat_start, numa_start, slots;
> >  uint64_t mem_len, mem_base, next_base;
> > +PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
> > +ram_addr_t hotplug_as_size = memory_region_size(&pcms->hotplug_memory);
> >  
> >  srat_start = table_data->len;
> >  
> > @@ -1263,6 +1265,18 @@ build_srat(GArray *table_data, GArray *linker,
> >  acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
> >  }
> >  
> > +/*
> > + * Fake entry required by Windows to enable memory hotplug in OS.
> > + * Individual DIMM devices override proximity set here via _PXM method,
> > + * which returns associated with it NUMA node id.
> 
> Failed to parse this last sentence. what returns what associated with
> what? Maybe split to 3-4 short sentences.
How about:
"
Entry is required for Windows to enable memory hotplug in OS.
Memory devices may override proximity set by this entry,
providing _PXM method if necessary.
"

> 
> > + */
> > +if (hotplug_as_size) {
> > +numamem = acpi_data_push(table_data, sizeof *numamem);
> > +acpi_build_srat_memory(numamem, pcms->hotplug_memory_base,
> > +   hotplug_as_size, 0, 
> > MEM_AFFINITY_HOTPLUGGABLE |
> > +   MEM_AFFINITY_ENABLED);
> > +}
> > +
> >  build_header(linker, table_data,
> >   (void *)(table_data->data + srat_start),
> >   "SRAT",
> > -- 
> > 1.7.1




Re: [Qemu-devel] [PATCH 4/9] target-ppc: Implement "compat" CPU option

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 05:29 PM, Alexander Graf wrote:
> 
> On 21.05.14 08:57, Alexey Kardashevskiy wrote:
>> On 05/17/2014 06:47 AM, Alexander Graf wrote:
>>> On 16.05.14 17:17, Alexey Kardashevskiy wrote:
 On 05/17/2014 12:05 AM, Alexander Graf wrote:
> On 15.05.14 13:28, Alexey Kardashevskiy wrote:
>> This adds basic support for the "compat" CPU option. By specifying
>> the compat property, the user can manually switch guest CPU mode from
>> "raw" to "architected".
>>
>> Since the actual compatibility mode is not implemented yet, this does
>> not change the existing behavior.
>>
>> Signed-off-by: Alexey Kardashevskiy 
>> ---
>> hw/ppc/spapr.c  | 15 ++-
>> target-ppc/cpu-models.h |  6 ++
>> target-ppc/cpu-qom.h|  2 ++
>> target-ppc/cpu.h|  3 +++
>> target-ppc/translate_init.c | 35 +++
>> 5 files changed, 60 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 0f8bd95..61d0675 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -212,7 +212,8 @@ static int spapr_fixup_cpu_dt(void *fdt,
>> sPAPREnvironment *spapr)
>>   CPU_FOREACH(cpu) {
>> DeviceClass *dc = DEVICE_GET_CLASS(cpu);
>> -int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
>> +PowerPCCPU *pcpu = POWERPC_CPU(cpu);
>> +int index = ppc_get_vcpu_dt_id(pcpu);
>> uint32_t associativity[] = {cpu_to_be32(0x5),
>> cpu_to_be32(0x0),
>> cpu_to_be32(0x0),
>> @@ -249,6 +250,14 @@ static int spapr_fixup_cpu_dt(void *fdt,
>> sPAPREnvironment *spapr)
>> return ret;
>> }
>> +if (pcpu->cpu_version) {
>> +ret = fdt_setprop(fdt, offset, "cpu-version",
>> +  &pcpu->cpu_version,
>> sizeof(pcpu->cpu_version));
>> +if (ret < 0) {
>> +return ret;
>> +}
>> +}
>> +
>> /* Build interrupt servers and gservers properties */
>> for (i = 0; i < smp_threads; i++) {
>> servers_prop[i] = cpu_to_be32(index + i);
>> @@ -1278,6 +1287,10 @@ static void ppc_spapr_init(QEMUMachineInitArgs
>> *args)
>> kvmppc_set_papr(cpu);
>> }
>> +if (cpu->max_compat) {
>> +ppc_set_compat(cpu, cpu->max_compat);
>> +}
>> +
>> xics_cpu_setup(spapr->icp, cpu);
>>   qemu_register_reset(spapr_cpu_reset, cpu);
>> diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
>> index 33d2c51..45c0028 100644
>> --- a/target-ppc/cpu-models.h
>> +++ b/target-ppc/cpu-models.h
>> @@ -753,4 +753,10 @@ enum {
>> POWERPC_SVR_8641D  = 0x80900121,
>> };
>> +/* Processor Compatibility mask (PCR) */
>> +enum {
>> +POWERPC_ISA_COMPAT_2_05 = 0x02,
>> +POWERPC_ISA_COMPAT_2_06 = 0x04,
>> +};
>> +
>> #endif
>> diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
>> index 2a8515b..dfd1419 100644
>> --- a/target-ppc/cpu-qom.h
>> +++ b/target-ppc/cpu-qom.h
>> @@ -83,6 +83,7 @@ typedef struct PowerPCCPUClass {
>>  * @env: #CPUPPCState
>>  * @cpu_dt_id: CPU index used in the device tree. KVM uses this
>> index too
>>  * @max_compat: Maximal supported logical PVR from the command line
>> + * @cpu_version: Current logical PVR, zero if in "raw" mode
>>  *
>>  * A PowerPC CPU.
>>  */
>> @@ -94,6 +95,7 @@ struct PowerPCCPU {
>> CPUPPCState env;
>> int cpu_dt_id;
>> uint32_t max_compat;
>> +uint32_t cpu_version;
>> };
>>   static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
>> diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
>> index d498340..f61675a 100644
>> --- a/target-ppc/cpu.h
>> +++ b/target-ppc/cpu.h
>> @@ -1123,6 +1123,8 @@ void ppc_store_msr (CPUPPCState *env, target_ulong
>> value);
>>   void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
>> +void ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
>> +
>> /* Time-base and decrementer management */
>> #ifndef NO_CPU_IO_DEFS
>> uint64_t cpu_ppc_load_tbl (CPUPPCState *env);
>> @@ -1338,6 +1340,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
>> #define SPR_LPCR  (0x13E)
>> #define SPR_BOOKE_DVC2(0x13F)
>> #define SPR_BOOKE_TSR (0x150)
>> +#define SPR_PCR   (0x152)
>> #define SPR_BOOKE_TCR (0x154)
>> #define

Re: [Qemu-devel] [PATCH 4/9] target-ppc: Implement "compat" CPU option

2014-05-21 Thread Alexander Graf


On 21.05.14 09:59, Alexey Kardashevskiy wrote:

On 05/21/2014 05:29 PM, Alexander Graf wrote:

On 21.05.14 08:57, Alexey Kardashevskiy wrote:

On 05/17/2014 06:47 AM, Alexander Graf wrote:

On 16.05.14 17:17, Alexey Kardashevskiy wrote:

On 05/17/2014 12:05 AM, Alexander Graf wrote:

On 15.05.14 13:28, Alexey Kardashevskiy wrote:

This adds basic support for the "compat" CPU option. By specifying
the compat property, the user can manually switch guest CPU mode from
"raw" to "architected".

Since the actual compatibility mode is not implemented yet, this does
not change the existing behavior.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c  | 15 ++-
 target-ppc/cpu-models.h |  6 ++
 target-ppc/cpu-qom.h|  2 ++
 target-ppc/cpu.h|  3 +++
 target-ppc/translate_init.c | 35 +++
 5 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0f8bd95..61d0675 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -212,7 +212,8 @@ static int spapr_fixup_cpu_dt(void *fdt,
sPAPREnvironment *spapr)
   CPU_FOREACH(cpu) {
 DeviceClass *dc = DEVICE_GET_CLASS(cpu);
-int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
+PowerPCCPU *pcpu = POWERPC_CPU(cpu);
+int index = ppc_get_vcpu_dt_id(pcpu);
 uint32_t associativity[] = {cpu_to_be32(0x5),
 cpu_to_be32(0x0),
 cpu_to_be32(0x0),
@@ -249,6 +250,14 @@ static int spapr_fixup_cpu_dt(void *fdt,
sPAPREnvironment *spapr)
 return ret;
 }
 +if (pcpu->cpu_version) {
+ret = fdt_setprop(fdt, offset, "cpu-version",
+  &pcpu->cpu_version,
sizeof(pcpu->cpu_version));
+if (ret < 0) {
+return ret;
+}
+}
+
 /* Build interrupt servers and gservers properties */
 for (i = 0; i < smp_threads; i++) {
 servers_prop[i] = cpu_to_be32(index + i);
@@ -1278,6 +1287,10 @@ static void ppc_spapr_init(QEMUMachineInitArgs
*args)
 kvmppc_set_papr(cpu);
 }
 +if (cpu->max_compat) {
+ppc_set_compat(cpu, cpu->max_compat);
+}
+
 xics_cpu_setup(spapr->icp, cpu);
   qemu_register_reset(spapr_cpu_reset, cpu);
diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
index 33d2c51..45c0028 100644
--- a/target-ppc/cpu-models.h
+++ b/target-ppc/cpu-models.h
@@ -753,4 +753,10 @@ enum {
 POWERPC_SVR_8641D  = 0x80900121,
 };
 +/* Processor Compatibility mask (PCR) */
+enum {
+POWERPC_ISA_COMPAT_2_05 = 0x02,
+POWERPC_ISA_COMPAT_2_06 = 0x04,
+};
+
 #endif
diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index 2a8515b..dfd1419 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -83,6 +83,7 @@ typedef struct PowerPCCPUClass {
  * @env: #CPUPPCState
  * @cpu_dt_id: CPU index used in the device tree. KVM uses this
index too
  * @max_compat: Maximal supported logical PVR from the command line
+ * @cpu_version: Current logical PVR, zero if in "raw" mode
  *
  * A PowerPC CPU.
  */
@@ -94,6 +95,7 @@ struct PowerPCCPU {
 CPUPPCState env;
 int cpu_dt_id;
 uint32_t max_compat;
+uint32_t cpu_version;
 };
   static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index d498340..f61675a 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1123,6 +1123,8 @@ void ppc_store_msr (CPUPPCState *env, target_ulong
value);
   void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 +void ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
+
 /* Time-base and decrementer management */
 #ifndef NO_CPU_IO_DEFS
 uint64_t cpu_ppc_load_tbl (CPUPPCState *env);
@@ -1338,6 +1340,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_LPCR  (0x13E)
 #define SPR_BOOKE_DVC2(0x13F)
 #define SPR_BOOKE_TSR (0x150)
+#define SPR_PCR   (0x152)
 #define SPR_BOOKE_TCR (0x154)
 #define SPR_BOOKE_TLB0PS  (0x158)
 #define SPR_BOOKE_TLB1PS  (0x159)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 6f61b34..c4bd5de 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7803,6 +7803,15 @@ static void init_proc_POWER7 (CPUPPCState *env)
 /* Can't find information on what this should be on reset.  This
  * value is the one used by 74xx processors. */
 vscr_init(env, 0x0001);
+
+/*
+ * Register PCR to report POWERPC_EXCP_PRIV_REG instead of
+ * POWERPC_EXCP_INVAL_SPR.
+ */
+spr_register(env, SPR_PCR, "PCR",
+ SPR_NOACCESS, SPR_NOACCESS

Re: [Qemu-devel] [PATCH v2 30/31] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole

2014-05-21 Thread Michael S. Tsirkin
On Wed, May 21, 2014 at 09:56:13AM +0200, Igor Mammedov wrote:
> On Tue, 20 May 2014 18:38:15 +0300
> "Michael S. Tsirkin"  wrote:
> 
> > On Tue, May 20, 2014 at 05:15:33PM +0200, Igor Mammedov wrote:
> > > Needed for Windows to use hotplugged memory device, otherwise
> > > it complains that server is not configured for memory hotplug.
> > > Tests shows that aftewards it uses dynamically provided
> > > proximity value from _PXM() method if available.
> > > 
> > > Signed-off-by: Igor Mammedov 
> > > ---
> > >  hw/i386/acpi-build.c |   14 ++
> > >  1 files changed, 14 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index 58e7306..97e3a82 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -1199,6 +1199,8 @@ build_srat(GArray *table_data, GArray *linker,
> > >  uint64_t curnode;
> > >  int srat_start, numa_start, slots;
> > >  uint64_t mem_len, mem_base, next_base;
> > > +PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
> > > +ram_addr_t hotplug_as_size = 
> > > memory_region_size(&pcms->hotplug_memory);
> > >  
> > >  srat_start = table_data->len;
> > >  
> > > @@ -1263,6 +1265,18 @@ build_srat(GArray *table_data, GArray *linker,
> > >  acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
> > >  }
> > >  
> > > +/*
> > > + * Fake entry required by Windows to enable memory hotplug in OS.
> > > + * Individual DIMM devices override proximity set here via _PXM 
> > > method,
> > > + * which returns associated with it NUMA node id.
> > 
> > Failed to parse this last sentence. what returns what associated with
> > what? Maybe split to 3-4 short sentences.
> How about:
> "
> Entry is required for Windows to enable memory hotplug in OS.
> Memory devices may override proximity set by this entry,
> providing _PXM method if necessary.
> "

Sounds good, thanks.

> > 
> > > + */
> > > +if (hotplug_as_size) {
> > > +numamem = acpi_data_push(table_data, sizeof *numamem);
> > > +acpi_build_srat_memory(numamem, pcms->hotplug_memory_base,
> > > +   hotplug_as_size, 0, 
> > > MEM_AFFINITY_HOTPLUGGABLE |
> > > +   MEM_AFFINITY_ENABLED);
> > > +}
> > > +
> > >  build_header(linker, table_data,
> > >   (void *)(table_data->data + srat_start),
> > >   "SRAT",
> > > -- 
> > > 1.7.1



Re: [Qemu-devel] [PATCH 1/2] arch_init: replace fprintf(stderr, ...) with error_report()

2014-05-21 Thread Andreas Färber
Am 21.05.2014 02:10, schrieb Le Tan:
> Replace fprintf(stderr,...) with error_report() in the file
> arch_init.c. The trailing "\n"s of the @fmt argument have been removed
> because @fmt of error_report() should not contain newline.
> 
> Signed-off-by: Le Tan 
> ---
>  arch_init.c |   32 +++-
>  1 file changed, 15 insertions(+), 17 deletions(-)

Reviewed-by: Andreas Färber 

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] [PATCH v2 30/31] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole

2014-05-21 Thread Michael S. Tsirkin
On Tue, May 20, 2014 at 05:15:33PM +0200, Igor Mammedov wrote:
> Needed for Windows to use hotplugged memory device, otherwise
> it complains that server is not configured for memory hotplug.
> Tests shows that aftewards it uses dynamically provided
> proximity value from _PXM() method if available.
> 
> Signed-off-by: Igor Mammedov 
> ---
>  hw/i386/acpi-build.c |   14 ++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 58e7306..97e3a82 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1199,6 +1199,8 @@ build_srat(GArray *table_data, GArray *linker,
>  uint64_t curnode;
>  int srat_start, numa_start, slots;
>  uint64_t mem_len, mem_base, next_base;
> +PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
> +ram_addr_t hotplug_as_size = memory_region_size(&pcms->hotplug_memory);
>  
>  srat_start = table_data->len;
>

Please don't abbreviate address space as "as". If you abbreviate as as
as it can be misunderstood for the English as which stands for as.
You see how confusing this can be :)
How about hotplug_memory_max_size?

Also, it would be a bit more elegant to make this a read-only property
of the machine.
  
> @@ -1263,6 +1265,18 @@ build_srat(GArray *table_data, GArray *linker,
>  acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS);
>  }
>  
> +/*
> + * Fake entry required by Windows to enable memory hotplug in OS.
> + * Individual DIMM devices override proximity set here via _PXM method,
> + * which returns associated with it NUMA node id.
> + */
> +if (hotplug_as_size) {
> +numamem = acpi_data_push(table_data, sizeof *numamem);
> +acpi_build_srat_memory(numamem, pcms->hotplug_memory_base,
> +   hotplug_as_size, 0, MEM_AFFINITY_HOTPLUGGABLE 
> |
> +   MEM_AFFINITY_ENABLED);
> +}
> +
>  build_header(linker, table_data,
>   (void *)(table_data->data + srat_start),
>   "SRAT",
> -- 
> 1.7.1



Re: [Qemu-devel] [PATCH 4/9] target-ppc: Implement "compat" CPU option

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 06:00 PM, Alexander Graf wrote:
> 
> On 21.05.14 09:59, Alexey Kardashevskiy wrote:
>> On 05/21/2014 05:29 PM, Alexander Graf wrote:
>>> On 21.05.14 08:57, Alexey Kardashevskiy wrote:
 On 05/17/2014 06:47 AM, Alexander Graf wrote:
> On 16.05.14 17:17, Alexey Kardashevskiy wrote:
>> On 05/17/2014 12:05 AM, Alexander Graf wrote:
>>> On 15.05.14 13:28, Alexey Kardashevskiy wrote:
 This adds basic support for the "compat" CPU option. By specifying
 the compat property, the user can manually switch guest CPU mode from
 "raw" to "architected".

 Since the actual compatibility mode is not implemented yet, this does
 not change the existing behavior.

 Signed-off-by: Alexey Kardashevskiy 
 ---
  hw/ppc/spapr.c  | 15 ++-
  target-ppc/cpu-models.h |  6 ++
  target-ppc/cpu-qom.h|  2 ++
  target-ppc/cpu.h|  3 +++
  target-ppc/translate_init.c | 35
 +++
  5 files changed, 60 insertions(+), 1 deletion(-)

 diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
 index 0f8bd95..61d0675 100644
 --- a/hw/ppc/spapr.c
 +++ b/hw/ppc/spapr.c
 @@ -212,7 +212,8 @@ static int spapr_fixup_cpu_dt(void *fdt,
 sPAPREnvironment *spapr)
CPU_FOREACH(cpu) {
  DeviceClass *dc = DEVICE_GET_CLASS(cpu);
 -int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
 +PowerPCCPU *pcpu = POWERPC_CPU(cpu);
 +int index = ppc_get_vcpu_dt_id(pcpu);
  uint32_t associativity[] = {cpu_to_be32(0x5),
  cpu_to_be32(0x0),
  cpu_to_be32(0x0),
 @@ -249,6 +250,14 @@ static int spapr_fixup_cpu_dt(void *fdt,
 sPAPREnvironment *spapr)
  return ret;
  }
  +if (pcpu->cpu_version) {
 +ret = fdt_setprop(fdt, offset, "cpu-version",
 +  &pcpu->cpu_version,
 sizeof(pcpu->cpu_version));
 +if (ret < 0) {
 +return ret;
 +}
 +}
 +
  /* Build interrupt servers and gservers properties */
  for (i = 0; i < smp_threads; i++) {
  servers_prop[i] = cpu_to_be32(index + i);
 @@ -1278,6 +1287,10 @@ static void ppc_spapr_init(QEMUMachineInitArgs
 *args)
  kvmppc_set_papr(cpu);
  }
  +if (cpu->max_compat) {
 +ppc_set_compat(cpu, cpu->max_compat);
 +}
 +
  xics_cpu_setup(spapr->icp, cpu);
qemu_register_reset(spapr_cpu_reset, cpu);
 diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
 index 33d2c51..45c0028 100644
 --- a/target-ppc/cpu-models.h
 +++ b/target-ppc/cpu-models.h
 @@ -753,4 +753,10 @@ enum {
  POWERPC_SVR_8641D  = 0x80900121,
  };
  +/* Processor Compatibility mask (PCR) */
 +enum {
 +POWERPC_ISA_COMPAT_2_05 = 0x02,
 +POWERPC_ISA_COMPAT_2_06 = 0x04,
 +};
 +
  #endif
 diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
 index 2a8515b..dfd1419 100644
 --- a/target-ppc/cpu-qom.h
 +++ b/target-ppc/cpu-qom.h
 @@ -83,6 +83,7 @@ typedef struct PowerPCCPUClass {
   * @env: #CPUPPCState
   * @cpu_dt_id: CPU index used in the device tree. KVM uses this
 index too
   * @max_compat: Maximal supported logical PVR from the command
 line
 + * @cpu_version: Current logical PVR, zero if in "raw" mode
   *
   * A PowerPC CPU.
   */
 @@ -94,6 +95,7 @@ struct PowerPCCPU {
  CPUPPCState env;
  int cpu_dt_id;
  uint32_t max_compat;
 +uint32_t cpu_version;
  };
static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
 diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
 index d498340..f61675a 100644
 --- a/target-ppc/cpu.h
 +++ b/target-ppc/cpu.h
 @@ -1123,6 +1123,8 @@ void ppc_store_msr (CPUPPCState *env,
 target_ulong
 value);
void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
  +void ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
 +
  /* Time-base and decrementer management */
  #ifndef NO_CPU_IO_DEFS
  uint6

Re: [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Michael S. Tsirkin
On Tue, May 20, 2014 at 05:15:08PM +0200, Igor Mammedov wrote:
> Add following parameters:
>   "slots" - total number of hotplug memory slots
>   "maxmem" - maximum possible memory
> 
> "slots" and "maxmem" should go in pair and "maxmem" should be greater
> than "mem" for memory hotplug to be enabled.
> 
> Signed-off-by: Igor Mammedov 

Also, it's a bug to mix this with a compat machine type, right?
Maybe best to fail initialization if users try this.

> ---
> v4:
>  - store maxmem & slots values in MachineState
> v3:
>  - store maxmem & slots values in QEMUMachineInitArgs
> v2:
>  - rebased on top of the latest "vl: convert -m to QemuOpts"
> ---
>  include/hw/boards.h |3 ++-
>  qemu-options.hx |9 ++---
>  vl.c|   51 
> +++
>  3 files changed, 59 insertions(+), 4 deletions(-)
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index b62de4a..f6fbbe1 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -8,7 +8,6 @@
>  #include "hw/qdev.h"
>  #include "qom/object.h"
>  
> -
>  typedef struct MachineState MachineState;
>  
>  typedef void QEMUMachineInitFunc(MachineState *ms);
> @@ -113,6 +112,8 @@ struct MachineState {
>  char *firmware;
>  
>  ram_addr_t ram_size;
> +ram_addr_t maxram_size;
> +uint64_t   ram_slots;
>  const char *boot_order;
>  const char *kernel_filename;
>  const char *kernel_cmdline;
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 781af14..c6411c4 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
> versions.
>  ETEXI
>  
>  DEF("m", HAS_ARG, QEMU_OPTION_m,
> -"-m [size=]megs\n"
> +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
>  "configure guest RAM\n"
>  "size: initial amount of guest memory (default: "
> -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
> +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
> +"slots: number of hotplug slots (default: none)\n"
> +"maxmem: maximum amount of guest memory (default: 
> none)\n",
>  QEMU_ARCH_ALL)
>  STEXI
>  @item -m [size=]@var{megs}
>  @findex -m
>  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
> Optionally,
>  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
> -gigabytes respectively.
> +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be used
> +to set amount of hotluggable memory slots and possible maximum amount of 
> memory.
>  ETEXI
>  
>  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> diff --git a/vl.c b/vl.c
> index 8fd4ed9..9fb6fa4 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
>  .name = "size",
>  .type = QEMU_OPT_SIZE,
>  },
> +{
> +.name = "slots",
> +.type = QEMU_OPT_NUMBER,
> +},
> +{
> +.name = "maxmem",
> +.type = QEMU_OPT_SIZE,
> +},
>  { /* end of list */ }
>  },
>  };
> @@ -2989,6 +2997,8 @@ int main(int argc, char **argv, char **envp)
>  const char *trace_file = NULL;
>  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
>  1024 * 1024;
> +ram_addr_t maxram_size = default_ram_size;
> +uint64_t ram_slots = 0;
>  
>  atexit(qemu_run_exit_notifiers);
>  error_set_progname(argv[0]);
> @@ -3324,6 +3334,7 @@ int main(int argc, char **argv, char **envp)
>  case QEMU_OPTION_m: {
>  uint64_t sz;
>  const char *mem_str;
> +const char *maxmem_str, *slots_str;
>  
>  opts = qemu_opts_parse(qemu_find_opts("memory"),
> optarg, 1);
> @@ -3365,6 +3376,44 @@ int main(int argc, char **argv, char **envp)
>  error_report("ram size too large");
>  exit(EXIT_FAILURE);
>  }
> +
> +maxmem_str = qemu_opt_get(opts, "maxmem");
> +slots_str = qemu_opt_get(opts, "slots");
> +if (maxmem_str && slots_str) {
> +uint64_t slots;
> +
> +sz = qemu_opt_get_size(opts, "maxmem", 0);
> +if (sz < ram_size) {
> +fprintf(stderr, "qemu: invalid -m option value: 
> maxmem "
> +"(%" PRIu64 ") <= initial memory (%"
> +PRIu64 ")\n", sz, ram_size);
> +exit(EXIT_FAILURE);
> +}
> +
> +slots = qemu_opt_get_number(opts, "slots", 0);
> +if ((sz > ram_size) && !slots) {
> +fprintf(stderr, "qemu: invalid -m option value: 
> maxmem "
> +"(%" PRIu64 ") more than initi

Re: [Qemu-devel] [PATCH v3] Add remove_boot_device_path() function for hot-unplug device

2014-05-21 Thread Andreas Färber
Am 19.05.2014 17:57, schrieb Michael S. Tsirkin:
> On Mon, May 19, 2014 at 05:31:43PM +0200, Andreas Färber wrote:
>> Hi,
>>
>> Am 19.05.2014 17:03, schrieb Jun Li:
>>> Add remove_boot_device_path() function to remove bootindex when hot-unplug
>>> a device. This patch fixed virtio-blk/virtio-net/scsi-disk/scsi-generic 
>>> device.
>>>
>>> Signed-off-by: Jun Li 
>>> ---
>>> This patch also fixed bug1086603, ref:
>>> https://bugzilla.redhat.com/show_bug.cgi?id=1086603
>>>
>>> This version of patch delete dev and suffix parameter from function 
>>> remove_boot_device_path().
>>> ---
>>>  hw/block/virtio-blk.c   |  1 +
>>>  hw/net/virtio-net.c |  1 +
>>>  hw/scsi/scsi-disk.c |  1 +
>>>  hw/scsi/scsi-generic.c  |  1 +
>>
>> On v1 I believe I reminded you of spapr_llan. Your patch is adding a new
>> remove_*() function, but is using it only for roughly half of the
>> devices that currently call add_boot_device_path(). Why? I can
>> understand that ISA devices will not be hot-unpluggable, but all PCI and
>> USB devices are.
> 
> Can we remove the device from boot path automatically
> when it's going away?

I'm not familiar with that code myself; assuming that only one path gets
registered per device, I guess we could add a field to DeviceState and
if non-NULL call the unregistration from device_set_unrealize().

Jun, if that works it would save you some work.

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



[Qemu-devel] [RFC PATCH] trace: Replace error with warning if event is not defined

2014-05-21 Thread Alexey Kardashevskiy
At the moment QEMU exits if trace point is not defined which makes
a developer life harder if he has to switch between branches with
different traces implemented.

This replaces error+exit wit WARNING if the tracepoint does not exist or
not traceable.

Signed-off-by: Alexey Kardashevskiy 
---


That would make my life easier indeed. Thanks :)


---
 trace/control.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/trace/control.c b/trace/control.c
index 49f61e1..4aa02cf 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -112,15 +112,15 @@ void trace_backend_init_events(const char *fname)
 TraceEvent *ev = trace_event_name(line_ptr);
 if (ev == NULL) {
 fprintf(stderr,
-"error: trace event '%s' does not exist\n", 
line_ptr);
-exit(1);
-}
-if (!trace_event_get_state_static(ev)) {
+"WARNING: trace event '%s' does not exist\n",
+line_ptr);
+} else if (!trace_event_get_state_static(ev)) {
 fprintf(stderr,
-"error: trace event '%s' is not traceable\n", 
line_ptr);
-exit(1);
+"WARNING: trace event '%s' is not traceable\n",
+line_ptr);
+} else {
+trace_event_set_state_dynamic(ev, enable);
 }
-trace_event_set_state_dynamic(ev, enable);
 }
 }
 }
-- 
1.9.rc0




Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Kevin Wolf
Am 21.05.2014 um 09:46 hat Markus Armbruster geschrieben:
> Fam Zheng  writes:
> 
> > On Wed, 05/21 07:54, Markus Armbruster wrote:
> >> Fam Zheng  writes:
> >> 
> >> > On Tue, 05/20 13:13, Eric Blake wrote:
> >> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
> >> >> > Please first take a look at patch 7 to see what is supported by this 
> >> >> > series.
> >> >> > 
> >> >> > Patch 1 ~ 3 allows some useful basic types in schema.
> >> >> > 
> >> >> > Patch 4 ~ 6 implements the new syntax.
> >> >> > 
> >> >> > Note: The introduced '@arg' sigil, just like the preexisting '*arg', 
> >> >> > is
> >> >> > reducing the cleanness of the syntax. We should get rid of both of 
> >> >> > them in long
> >> >> > term. Here, this series compromises on this and introduces '@arg' 
> >> >> > because:
> >> >> > 
> >> >> >   - We have to distinguish the argument property dictionary from 
> >> >> > nested struct:
> >> >> > 
> >> >> > I.e.:
> >> >> > 
> >> >> > 'data': {
> >> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
> >> >> > '@arg2': { 'type': 'int', 'default': 100 }
> >> >> >  }
> >> >> > 
> >> >> > Until we completely drop and forbid the 'arg1' nested struct use 
> >> >> > case.
> >> >> > 
> >> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull in 
> >> >> > many
> >> >> > distractive patches to this series.
> >> >> 
> >> >> Question - since we WANT to get rid of nested struct, why not reverse
> >> >> the sense?  Mark all existing nested structs (weren't there just three
> >> >> that we found?) with the '@' sigil, and let the new syntax be
> >> >> sigil-free.  Then when we clean up the nesting, we are also getting rid
> >> >> of the bad syntax, plus the sigil gives us something to search for in
> >> >> knowing how much to clean up.  But if you stick the sigil on the new
> >> >> code, instead of the obsolete code, then as more and more places in the
> >> >> schema use defaults, it gets harder and harder to remove the use of the
> >> >> sigil even if the nested structs are eventually removed.
> >> >> 
> >> >
> >> > It makes not much difference I can see. The hard part is actaully 
> >> > dropping
> >> > nested, converting from sigil <-> non-sigil is easy. Of course, nothing 
> >> > is
> >> > seriously hard, there are only three nested structs plus some more
> >> > qapi-schema
> >> > test code.
> >> 
> >> Adding three ugly sigils and making everybody include one when they add
> >> a nested struct feels much better to me than ugly sigils all over the
> >> place.
> >
> > Well, I could use some background here. Why did we introduce nested 
> > structure
> > in the first place?
> 
> Because we could?
> 
> Felt like a good idea at the time?
> 
> I quick glance at commit 0f923be and fb3182c suggests they have been
> supported since the beginning.  There is no design rationale.

Let me extend Fam's question: Why don't we simply remove them right
now? If it's really only three instances, converting them to full
types should be a matter of five minutes.

Kevin



Re: [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Andrey Korolyov
On Wed, May 21, 2014 at 12:10 PM, Michael S. Tsirkin  wrote:
> On Tue, May 20, 2014 at 05:15:08PM +0200, Igor Mammedov wrote:
>> Add following parameters:
>>   "slots" - total number of hotplug memory slots
>>   "maxmem" - maximum possible memory
>>
>> "slots" and "maxmem" should go in pair and "maxmem" should be greater
>> than "mem" for memory hotplug to be enabled.
>>
>> Signed-off-by: Igor Mammedov 
>
> Also, it's a bug to mix this with a compat machine type, right?
> Maybe best to fail initialization if users try this.
>
>> ---
>> v4:
>>  - store maxmem & slots values in MachineState
>> v3:
>>  - store maxmem & slots values in QEMUMachineInitArgs
>> v2:
>>  - rebased on top of the latest "vl: convert -m to QemuOpts"
>> ---
>>  include/hw/boards.h |3 ++-
>>  qemu-options.hx |9 ++---
>>  vl.c|   51 
>> +++
>>  3 files changed, 59 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/hw/boards.h b/include/hw/boards.h
>> index b62de4a..f6fbbe1 100644
>> --- a/include/hw/boards.h
>> +++ b/include/hw/boards.h
>> @@ -8,7 +8,6 @@
>>  #include "hw/qdev.h"
>>  #include "qom/object.h"
>>
>> -
>>  typedef struct MachineState MachineState;
>>
>>  typedef void QEMUMachineInitFunc(MachineState *ms);
>> @@ -113,6 +112,8 @@ struct MachineState {
>>  char *firmware;
>>
>>  ram_addr_t ram_size;
>> +ram_addr_t maxram_size;
>> +uint64_t   ram_slots;
>>  const char *boot_order;
>>  const char *kernel_filename;
>>  const char *kernel_cmdline;
>> diff --git a/qemu-options.hx b/qemu-options.hx
>> index 781af14..c6411c4 100644
>> --- a/qemu-options.hx
>> +++ b/qemu-options.hx
>> @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
>> versions.
>>  ETEXI
>>
>>  DEF("m", HAS_ARG, QEMU_OPTION_m,
>> -"-m [size=]megs\n"
>> +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
>>  "configure guest RAM\n"
>>  "size: initial amount of guest memory (default: "
>> -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
>> +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
>> +"slots: number of hotplug slots (default: none)\n"
>> +"maxmem: maximum amount of guest memory (default: 
>> none)\n",
>>  QEMU_ARCH_ALL)
>>  STEXI
>>  @item -m [size=]@var{megs}
>>  @findex -m
>>  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
>> Optionally,
>>  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
>> -gigabytes respectively.
>> +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be 
>> used
>> +to set amount of hotluggable memory slots and possible maximum amount of 
>> memory.
>>  ETEXI
>>
>>  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
>> diff --git a/vl.c b/vl.c
>> index 8fd4ed9..9fb6fa4 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
>>  .name = "size",
>>  .type = QEMU_OPT_SIZE,
>>  },
>> +{
>> +.name = "slots",
>> +.type = QEMU_OPT_NUMBER,
>> +},
>> +{
>> +.name = "maxmem",
>> +.type = QEMU_OPT_SIZE,
>> +},
>>  { /* end of list */ }
>>  },
>>  };
>> @@ -2989,6 +2997,8 @@ int main(int argc, char **argv, char **envp)
>>  const char *trace_file = NULL;
>>  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
>>  1024 * 1024;
>> +ram_addr_t maxram_size = default_ram_size;
>> +uint64_t ram_slots = 0;
>>
>>  atexit(qemu_run_exit_notifiers);
>>  error_set_progname(argv[0]);
>> @@ -3324,6 +3334,7 @@ int main(int argc, char **argv, char **envp)
>>  case QEMU_OPTION_m: {
>>  uint64_t sz;
>>  const char *mem_str;
>> +const char *maxmem_str, *slots_str;
>>
>>  opts = qemu_opts_parse(qemu_find_opts("memory"),
>> optarg, 1);
>> @@ -3365,6 +3376,44 @@ int main(int argc, char **argv, char **envp)
>>  error_report("ram size too large");
>>  exit(EXIT_FAILURE);
>>  }
>> +
>> +maxmem_str = qemu_opt_get(opts, "maxmem");
>> +slots_str = qemu_opt_get(opts, "slots");
>> +if (maxmem_str && slots_str) {
>> +uint64_t slots;
>> +
>> +sz = qemu_opt_get_size(opts, "maxmem", 0);
>> +if (sz < ram_size) {
>> +fprintf(stderr, "qemu: invalid -m option value: 
>> maxmem "
>> +"(%" PRIu64 ") <= initial memory (%"
>> +PRIu64 ")\n", sz, ram_size);
>> +exit(EXIT_FAILURE);
>> +}
>> +
>> +slots = qemu_opt_get_number(opts, "slots", 0);
>> + 

Re: [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Igor Mammedov
On Wed, 21 May 2014 11:10:28 +0300
"Michael S. Tsirkin"  wrote:

> On Tue, May 20, 2014 at 05:15:08PM +0200, Igor Mammedov wrote:
> > Add following parameters:
> >   "slots" - total number of hotplug memory slots
> >   "maxmem" - maximum possible memory
> > 
> > "slots" and "maxmem" should go in pair and "maxmem" should be greater
> > than "mem" for memory hotplug to be enabled.
> > 
> > Signed-off-by: Igor Mammedov 
> 
> Also, it's a bug to mix this with a compat machine type, right?
> Maybe best to fail initialization if users try this.
I'll add PC specific patch for this.

> 
> > ---
> > v4:
> >  - store maxmem & slots values in MachineState
> > v3:
> >  - store maxmem & slots values in QEMUMachineInitArgs
> > v2:
> >  - rebased on top of the latest "vl: convert -m to QemuOpts"
> > ---
> >  include/hw/boards.h |3 ++-
> >  qemu-options.hx |9 ++---
> >  vl.c|   51 
> > +++
> >  3 files changed, 59 insertions(+), 4 deletions(-)
> > 
> > diff --git a/include/hw/boards.h b/include/hw/boards.h
> > index b62de4a..f6fbbe1 100644
> > --- a/include/hw/boards.h
> > +++ b/include/hw/boards.h
> > @@ -8,7 +8,6 @@
> >  #include "hw/qdev.h"
> >  #include "qom/object.h"
> >  
> > -
> >  typedef struct MachineState MachineState;
> >  
> >  typedef void QEMUMachineInitFunc(MachineState *ms);
> > @@ -113,6 +112,8 @@ struct MachineState {
> >  char *firmware;
> >  
> >  ram_addr_t ram_size;
> > +ram_addr_t maxram_size;
> > +uint64_t   ram_slots;
> >  const char *boot_order;
> >  const char *kernel_filename;
> >  const char *kernel_cmdline;
> > diff --git a/qemu-options.hx b/qemu-options.hx
> > index 781af14..c6411c4 100644
> > --- a/qemu-options.hx
> > +++ b/qemu-options.hx
> > @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
> > versions.
> >  ETEXI
> >  
> >  DEF("m", HAS_ARG, QEMU_OPTION_m,
> > -"-m [size=]megs\n"
> > +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
> >  "configure guest RAM\n"
> >  "size: initial amount of guest memory (default: "
> > -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
> > +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
> > +"slots: number of hotplug slots (default: none)\n"
> > +"maxmem: maximum amount of guest memory (default: 
> > none)\n",
> >  QEMU_ARCH_ALL)
> >  STEXI
> >  @item -m [size=]@var{megs}
> >  @findex -m
> >  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
> > Optionally,
> >  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
> > -gigabytes respectively.
> > +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be 
> > used
> > +to set amount of hotluggable memory slots and possible maximum amount of 
> > memory.
> >  ETEXI
> >  
> >  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> > diff --git a/vl.c b/vl.c
> > index 8fd4ed9..9fb6fa4 100644
> > --- a/vl.c
> > +++ b/vl.c
> > @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
> >  .name = "size",
> >  .type = QEMU_OPT_SIZE,
> >  },
> > +{
> > +.name = "slots",
> > +.type = QEMU_OPT_NUMBER,
> > +},
> > +{
> > +.name = "maxmem",
> > +.type = QEMU_OPT_SIZE,
> > +},
> >  { /* end of list */ }
> >  },
> >  };
> > @@ -2989,6 +2997,8 @@ int main(int argc, char **argv, char **envp)
> >  const char *trace_file = NULL;
> >  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
> >  1024 * 1024;
> > +ram_addr_t maxram_size = default_ram_size;
> > +uint64_t ram_slots = 0;
> >  
> >  atexit(qemu_run_exit_notifiers);
> >  error_set_progname(argv[0]);
> > @@ -3324,6 +3334,7 @@ int main(int argc, char **argv, char **envp)
> >  case QEMU_OPTION_m: {
> >  uint64_t sz;
> >  const char *mem_str;
> > +const char *maxmem_str, *slots_str;
> >  
> >  opts = qemu_opts_parse(qemu_find_opts("memory"),
> > optarg, 1);
> > @@ -3365,6 +3376,44 @@ int main(int argc, char **argv, char **envp)
> >  error_report("ram size too large");
> >  exit(EXIT_FAILURE);
> >  }
> > +
> > +maxmem_str = qemu_opt_get(opts, "maxmem");
> > +slots_str = qemu_opt_get(opts, "slots");
> > +if (maxmem_str && slots_str) {
> > +uint64_t slots;
> > +
> > +sz = qemu_opt_get_size(opts, "maxmem", 0);
> > +if (sz < ram_size) {
> > +fprintf(stderr, "qemu: invalid -m option value: 
> > maxmem "
> > +"(%" PRIu64 ") <= initial memory (%"
> > +PRIu64 ")\n

[Qemu-devel] [PATCH v2 6/9] spapr: Rework spapr_fixup_cpu_dt()

2014-05-21 Thread Alexey Kardashevskiy
In PPC code we usually use the "cs" name for a CPUState* variables
and "cpu" for PowerPCCPU. So let's change spapr_fixup_cpu_dt() to
use same rules as spapr_create_fdt_skel() does.

This adds missing nodes creation if they do not already exist in
the current device tree, this is going to be used from
the client-architecture-support handler.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c | 33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 400d0c7..7082237 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -239,32 +239,43 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, 
PowerPCCPU *cpu,
 
 static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
 {
-int ret = 0, offset;
-CPUState *cpu;
+int ret = 0, offset, cpus_offset;
+CPUState *cs;
 char cpu_model[32];
 int smt = kvmppc_smt_threads();
 uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
 
-CPU_FOREACH(cpu) {
-DeviceClass *dc = DEVICE_GET_CLASS(cpu);
-int index = ppc_get_vcpu_dt_id(POWERPC_CPU(cpu));
+CPU_FOREACH(cs) {
+PowerPCCPU *cpu = POWERPC_CPU(cs);
+DeviceClass *dc = DEVICE_GET_CLASS(cs);
+int index = ppc_get_vcpu_dt_id(cpu);
 uint32_t associativity[] = {cpu_to_be32(0x5),
 cpu_to_be32(0x0),
 cpu_to_be32(0x0),
 cpu_to_be32(0x0),
-cpu_to_be32(cpu->numa_node),
+cpu_to_be32(cs->numa_node),
 cpu_to_be32(index)};
 
 if ((index % smt) != 0) {
 continue;
 }
 
-snprintf(cpu_model, 32, "/cpus/%s@%x", dc->fw_name,
- index);
+snprintf(cpu_model, 32, "%s@%x", dc->fw_name, index);
 
-offset = fdt_path_offset(fdt, cpu_model);
+cpus_offset = fdt_path_offset(fdt, "/cpus");
+if (cpus_offset < 0) {
+cpus_offset = fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"),
+  "cpus");
+if (cpus_offset < 0) {
+return cpus_offset;
+}
+}
+offset = fdt_subnode_offset(fdt, cpus_offset, cpu_model);
 if (offset < 0) {
-return offset;
+offset = fdt_add_subnode(fdt, cpus_offset, cpu_model);
+if (offset < 0) {
+return offset;
+}
 }
 
 if (nb_numa_nodes > 1) {
@@ -281,7 +292,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment 
*spapr)
 return ret;
 }
 
-ret = spapr_fixup_cpu_smt_dt(fdt, offset, POWERPC_CPU(cpu),
+ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
  smp_threads);
 if (ret < 0) {
 return ret;
-- 
1.9.rc0




[Qemu-devel] [PATCH v2 4/9] target-ppc: Define Processor Compatibility Masks

2014-05-21 Thread Alexey Kardashevskiy
This introduces PCR mask for supported compatibility modes.
This will be used later by the ibm,client-architecture-support call.

Signed-off-by: Alexey Kardashevskiy 
---
 target-ppc/cpu-qom.h| 1 +
 target-ppc/translate_init.c | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index e88e1da..13c7031 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -57,6 +57,7 @@ typedef struct PowerPCCPUClass {
 
 uint32_t pvr;
 uint32_t pvr_mask;
+uint64_t pcr_mask;
 uint32_t svr;
 uint64_t insns_flags;
 uint64_t insns_flags2;
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 41afc5e..faac74a 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7850,6 +7850,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 dc->props = powerpc_servercpu_properties;
 pcc->pvr = CPU_POWERPC_POWER7_BASE;
 pcc->pvr_mask = CPU_POWERPC_POWER7_MASK;
+pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
 pcc->init_proc = init_proc_POWER7;
 pcc->check_pow = check_pow_nocheck;
 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
@@ -7910,6 +7911,7 @@ POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data)
 dc->props = powerpc_servercpu_properties;
 pcc->pvr = CPU_POWERPC_POWER7P_BASE;
 pcc->pvr_mask = CPU_POWERPC_POWER7P_MASK;
+pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
 pcc->init_proc = init_proc_POWER7;
 pcc->check_pow = check_pow_nocheck;
 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
@@ -7982,6 +7984,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
 dc->props = powerpc_servercpu_properties;
 pcc->pvr = CPU_POWERPC_POWER8_BASE;
 pcc->pvr_mask = CPU_POWERPC_POWER8_MASK;
+pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06;
 pcc->init_proc = init_proc_POWER8;
 pcc->check_pow = check_pow_nocheck;
 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB |
-- 
1.9.rc0




[Qemu-devel] [PATCH v2 0/9] spapr: Enable ibm, client-architecture-support

2014-05-21 Thread Alexey Kardashevskiy
This enables a ibm,client-architecture-support RTAS call.

This allows older distros (such as SLES11 or RHEL6) to work on modern
POWERPC hardware (such as POWER8) in "architected" mode.

There is no change log as the changes are mostly about readbility, code
design style and commit logs.

Please comment. Thank you.

Alexey Kardashevskiy (9):
  target-ppc: Add "compat" CPU option
  spapr: Move SMT-related properties out of skeleton fdt
  target-ppc: Implement "compat" CPU option
  target-ppc: Define Processor Compatibility Masks
  spapr: Add ibm,client-architecture-support call
  spapr: Rework spapr_fixup_cpu_dt()
  spapr: Limit threads per core according to current compatibility mode
  spapr: Implement processor compatibility in
ibm,client-architecture-support
  KVM: PPC: Enable compatibility mode

 hw/ppc/spapr.c  | 131 
 hw/ppc/spapr_hcall.c| 106 
 include/hw/ppc/spapr.h  |   9 ++-
 target-ppc/cpu-models.h |  10 +++
 target-ppc/cpu-qom.h|   5 ++
 target-ppc/cpu.h|  12 
 target-ppc/kvm.c|   5 ++
 target-ppc/kvm_ppc.h|   6 ++
 target-ppc/translate_init.c | 144 
 trace-events|   8 +++
 10 files changed, 410 insertions(+), 26 deletions(-)

-- 
1.9.rc0




[Qemu-devel] [PATCH v2 2/9] spapr: Move SMT-related properties out of skeleton fdt

2014-05-21 Thread Alexey Kardashevskiy
The upcoming support of the "ibm,client-architecture-support"
reconfiguration call will be able to change dynamically the number
of threads per core (SMT mode). From the device tree prospective
this does not change the number of CPU nodes (as it is one node per
a CPU core) but affects content and size of the ibm,ppc-interrupt-server#s
and ibm,ppc-interrupt-gserver#s properties.

This moves ibm,ppc-interrupt-server#s and ibm,ppc-interrupt-gserver#s
out of the device tree skeleton.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c | 48 +---
 1 file changed, 33 insertions(+), 15 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0a61246..aa17cae 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -202,6 +202,32 @@ static XICSState *xics_system_init(int nr_servers, int 
nr_irqs)
 return icp;
 }
 
+static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
+  int smt_threads)
+{
+int i, ret = 0;
+uint32_t servers_prop[smt_threads];
+uint32_t gservers_prop[smt_threads * 2];
+int index = ppc_get_vcpu_dt_id(cpu);
+
+/* Build interrupt servers and gservers properties */
+for (i = 0; i < smt_threads; i++) {
+servers_prop[i] = cpu_to_be32(index + i);
+/* Hack, direct the group queues back to cpu 0 */
+gservers_prop[i*2] = cpu_to_be32(index + i);
+gservers_prop[i*2 + 1] = 0;
+}
+ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
+  servers_prop, sizeof(servers_prop));
+if (ret < 0) {
+return ret;
+}
+ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s",
+  gservers_prop, sizeof(gservers_prop));
+
+return ret;
+}
+
 static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment *spapr)
 {
 int ret = 0, offset;
@@ -245,6 +271,12 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment 
*spapr)
 if (ret < 0) {
 return ret;
 }
+
+ret = spapr_fixup_cpu_smt_dt(fdt, offset, POWERPC_CPU(cpu),
+ smp_threads);
+if (ret < 0) {
+return ret;
+}
 }
 return ret;
 }
@@ -311,7 +343,7 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
 char qemu_hypertas_prop[] = "hcall-memop1";
 uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
 uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
-int i, smt = kvmppc_smt_threads();
+int smt = kvmppc_smt_threads();
 unsigned char vec5[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x80};
 QemuOpts *opts = qemu_opts_find(qemu_find_opts("smp-opts"), NULL);
 unsigned sockets = opts ? qemu_opt_get_number(opts, "sockets", 0) : 0;
@@ -378,8 +410,6 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
 DeviceClass *dc = DEVICE_GET_CLASS(cs);
 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
 int index = ppc_get_vcpu_dt_id(cpu);
-uint32_t servers_prop[smp_threads];
-uint32_t gservers_prop[smp_threads * 2];
 char *nodename;
 uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
0x, 0x};
@@ -428,18 +458,6 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
 _FDT((fdt_property_string(fdt, "status", "okay")));
 _FDT((fdt_property(fdt, "64-bit", NULL, 0)));
 
-/* Build interrupt servers and gservers properties */
-for (i = 0; i < smp_threads; i++) {
-servers_prop[i] = cpu_to_be32(index + i);
-/* Hack, direct the group queues back to cpu 0 */
-gservers_prop[i*2] = cpu_to_be32(index + i);
-gservers_prop[i*2 + 1] = 0;
-}
-_FDT((fdt_property(fdt, "ibm,ppc-interrupt-server#s",
-   servers_prop, sizeof(servers_prop;
-_FDT((fdt_property(fdt, "ibm,ppc-interrupt-gserver#s",
-   gservers_prop, sizeof(gservers_prop;
-
 if (env->spr_cb[SPR_PURR].oea_read) {
 _FDT((fdt_property(fdt, "ibm,purr", NULL, 0)));
 }
-- 
1.9.rc0




[Qemu-devel] [PATCH v2 5/9] spapr: Add ibm, client-architecture-support call

2014-05-21 Thread Alexey Kardashevskiy
The PAPR+ specification defines a ibm,client-architecture-support (CAS)
RTAS call which purpose is to provide a negotiation mechanism for
the guest and the hypervisor to work out the best compatibility parameters.
During the negotiation process, the guest provides an array of various
options and capabilities which it supports, the hypervisor adjusts
the device tree and (optionally) reboots the guest.

At the moment the Linux guest calls CAS method at early boot so SLOF
gets called. SLOF allocates a memory buffer for the device tree changes
and calls a custom KVMPPC_H_CAS hypercall. QEMU parses the options,
composes a diff for the device tree, copies it to the buffer provided
by SLOF and returns to SLOF. SLOF updates the device tree and returns
control to the guest kernel. Only then the Linux guest parses the device
tree so it is possible to avoid unnecessary reboot in most cases.

The device tree diff is a header with an update format version
(defined as 1 in this patch) followed by a device tree with the properties
which require update.

If QEMU detects that it has to reboot the guest, it silently does so
as the guest expects reboot to happen because this is usual pHyp firmware
behavior.

This defines custom KVMPPC_H_CAS hypercall. The current SLOF already
has support for it.

This implements stub which returns very basic tree (root node,
no properties) to the guest.

As the return buffer does not contain any change, no change in behavior is
expected.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c | 36 
 hw/ppc/spapr_hcall.c   | 21 +
 include/hw/ppc/spapr.h |  9 -
 trace-events   |  4 
 4 files changed, 69 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 5ea9640..400d0c7 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -53,6 +53,7 @@
 #include "hw/usb.h"
 #include "qemu/config-file.h"
 #include "qemu/error-report.h"
+#include "trace.h"
 
 #include 
 
@@ -572,6 +573,41 @@ static void *spapr_create_fdt_skel(hwaddr initrd_base,
 return fdt;
 }
 
+int spapr_h_cas_compose_response(target_ulong addr, target_ulong size)
+{
+void *fdt, *fdt_skel;
+sPAPRDeviceTreeUpdateHeader hdr = { .version_id = 1 };
+
+size -= sizeof(hdr);
+
+/* Create sceleton */
+fdt_skel = g_malloc0(size);
+_FDT((fdt_create(fdt_skel, size)));
+_FDT((fdt_begin_node(fdt_skel, "")));
+_FDT((fdt_end_node(fdt_skel)));
+_FDT((fdt_finish(fdt_skel)));
+fdt = g_malloc0(size);
+_FDT((fdt_open_into(fdt_skel, fdt, size)));
+g_free(fdt_skel);
+
+/* Place to make changes to the tree */
+
+/* Pack resulting tree */
+_FDT((fdt_pack(fdt)));
+
+if (fdt_totalsize(fdt) + sizeof(hdr) > size) {
+trace_spapr_cas_failed(size);
+return -1;
+}
+
+cpu_physical_memory_write(addr, &hdr, sizeof(hdr));
+cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt));
+trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr));
+g_free(fdt);
+
+return 0;
+}
+
 static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt)
 {
 uint32_t associativity[] = {cpu_to_be32(0x4), cpu_to_be32(0x0),
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 0bae053..2f6aa5c 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -752,6 +752,24 @@ out:
 return ret;
 }
 
+static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
+  sPAPREnvironment *spapr,
+  target_ulong opcode,
+  target_ulong *args)
+{
+target_ulong list = args[0];
+
+if (!list) {
+return H_SUCCESS;
+}
+
+if (spapr_h_cas_compose_response(args[1], args[2])) {
+qemu_system_reset_request();
+}
+
+return H_SUCCESS;
+}
+
 static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1];
 static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - 
KVMPPC_HCALL_BASE + 1];
 
@@ -831,6 +849,9 @@ static void hypercall_register_types(void)
 spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas);
 
 spapr_register_hypercall(H_SET_MODE, h_set_mode);
+
+/* ibm,client-architecture-support support */
+spapr_register_hypercall(KVMPPC_H_CAS, h_client_architecture_support);
 }
 
 type_init(hypercall_register_types)
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 9f8bb89..b8c2ba4 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -303,10 +303,16 @@ typedef struct sPAPREnvironment {
 #define KVMPPC_HCALL_BASE   0xf000
 #define KVMPPC_H_RTAS   (KVMPPC_HCALL_BASE + 0x0)
 #define KVMPPC_H_LOGICAL_MEMOP  (KVMPPC_HCALL_BASE + 0x1)
-#define KVMPPC_HCALL_MAXKVMPPC_H_LOGICAL_MEMOP
+/* Client Architecture support */
+#define KVMPPC_H_CAS(KVMPPC_HCALL_BASE + 0x2)
+#define KVMPPC_HCALL_MAXKVMPPC_H

[Qemu-devel] [PATCH v2 3/9] target-ppc: Implement "compat" CPU option

2014-05-21 Thread Alexey Kardashevskiy
This adds basic support for the "compat" CPU option. By specifying
the compat property, the user can manually switch guest CPU mode from
"raw" to "architected".

This defines feature disable bits which are not used yet as, for example,
PowerISA 2.07 says if 2.06 mode is selected, the TM bit does not matter -
transactional memory (TM) will be disabled because 2.06 does not define
it at all. The same is true for VSX and 2.05 mode. So just setting a mode
must be ok.

This does not change the existing behavior as the actual compatibility
mode support is coming in next patches.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c  | 14 ++
 target-ppc/cpu-qom.h|  2 ++
 target-ppc/cpu.h| 11 +++
 target-ppc/translate_init.c | 34 ++
 4 files changed, 61 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index aa17cae..5ea9640 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -210,6 +210,14 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, 
PowerPCCPU *cpu,
 uint32_t gservers_prop[smt_threads * 2];
 int index = ppc_get_vcpu_dt_id(cpu);
 
+if (cpu->cpu_version) {
+ret = fdt_setprop(fdt, offset, "cpu-version",
+  &cpu->cpu_version, sizeof(cpu->cpu_version));
+if (ret < 0) {
+return ret;
+}
+}
+
 /* Build interrupt servers and gservers properties */
 for (i = 0; i < smt_threads; i++) {
 servers_prop[i] = cpu_to_be32(index + i);
@@ -1289,6 +1297,12 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
 kvmppc_set_papr(cpu);
 }
 
+if (cpu->max_compat) {
+if (ppc_set_compat(cpu, cpu->max_compat) < 0) {
+exit(1);
+}
+}
+
 xics_cpu_setup(spapr->icp, cpu);
 
 qemu_register_reset(spapr_cpu_reset, cpu);
diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index 533de8f..e88e1da 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -84,6 +84,7 @@ typedef struct PowerPCCPUClass {
  * @env: #CPUPPCState
  * @cpu_dt_id: CPU index used in the device tree. KVM uses this index too
  * @max_compat: Maximal supported logical PVR from the command line
+ * @cpu_version: Current logical PVR, zero if in "raw" mode
  *
  * A PowerPC CPU.
  */
@@ -95,6 +96,7 @@ struct PowerPCCPU {
 CPUPPCState env;
 int cpu_dt_id;
 uint32_t max_compat;
+uint32_t cpu_version;
 };
 
 static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index b035e91..d3b8236 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1122,6 +1122,7 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulong 
value);
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
+int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
 
 /* Time-base and decrementer management */
 #ifndef NO_CPU_IO_DEFS
@@ -1338,6 +1339,7 @@ static inline int cpu_mmu_index (CPUPPCState *env)
 #define SPR_LPCR  (0x13E)
 #define SPR_BOOKE_DVC2(0x13F)
 #define SPR_BOOKE_TSR (0x150)
+#define SPR_PCR   (0x152)
 #define SPR_BOOKE_TCR (0x154)
 #define SPR_BOOKE_TLB0PS  (0x158)
 #define SPR_BOOKE_TLB1PS  (0x159)
@@ -2061,6 +2063,15 @@ enum {
 PPC_INTERRUPT_PERFM,  /* Performance monitor interrupt*/
 };
 
+/* Processor Compatibility mask (PCR) */
+enum {
+PCR_COMPAT_2_05 = 1ul << (63-62),
+PCR_COMPAT_2_06 = 1ul << (63-61),
+PCR_VEC_DIS = 1ul << (63-0), /* Vec. disable (bit NA since POWER8) 
*/
+PCR_VSX_DIS = 1ul << (63-1), /* VSX disable (bit NA since POWER8) 
*/
+PCR_TM_DIS  = 1ul << (63-2), /* Trans. memory disable (POWER8) */
+};
+
 /*/
 
 static inline target_ulong cpu_read_xer(CPUPPCState *env)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 2e273dc..41afc5e 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7829,6 +7829,15 @@ static void init_proc_POWER7 (CPUPPCState *env)
 /* Can't find information on what this should be on reset.  This
  * value is the one used by 74xx processors. */
 vscr_init(env, 0x0001);
+
+/*
+ * Register PCR to report POWERPC_EXCP_PRIV_REG instead of
+ * POWERPC_EXCP_INVAL_SPR.
+ */
+spr_register(env, SPR_PCR, "PCR",
+ SPR_NOACCESS, SPR_NOACCESS,
+ SPR_NOACCESS, SPR_NOACCESS,
+ 0x);
 }
 
 POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
@@ -8909,6 +8918,31 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error 
**errp)
 }
 }
 
+int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
+{
+int ret = 0;
+CPUPPCState *env = &cpu->env;
+
+cpu->cpu_version = cpu_version;
+
+sw

[Qemu-devel] [PATCH v2 9/9] KVM: PPC: Enable compatibility mode

2014-05-21 Thread Alexey Kardashevskiy
The host kernel implements a KVM_REG_PPC_ARCH_COMPAT register which
this uses to enable a compatibility mode if any chosen.

This sets the KVM_REG_PPC_ARCH_COMPAT register in KVM. ppc_set_compat()
signals the caller if the mode cannot be enabled by the host kernel.

Signed-off-by: Alexey Kardashevskiy 
---
 target-ppc/kvm.c| 5 +
 target-ppc/kvm_ppc.h| 6 ++
 target-ppc/translate_init.c | 5 +
 3 files changed, 16 insertions(+)

diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index ca31027..05952d0 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1514,6 +1514,11 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
 cap_papr = 1;
 }
 
+int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
+{
+return kvm_set_one_reg(CPU(cpu), KVM_REG_PPC_ARCH_COMPAT, &cpu_version);
+}
+
 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
 {
 CPUState *cs = CPU(cpu);
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index ff077ec..716c33d 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -23,6 +23,7 @@ int kvmppc_get_hasidle(CPUPPCState *env);
 int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len);
 int kvmppc_set_interrupt(PowerPCCPU *cpu, int irq, int level);
 void kvmppc_set_papr(PowerPCCPU *cpu);
+int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
 void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy);
 int kvmppc_smt_threads(void);
 int kvmppc_clear_tsr_bits(PowerPCCPU *cpu, uint32_t tsr_bits);
@@ -95,6 +96,11 @@ static inline void kvmppc_set_papr(PowerPCCPU *cpu)
 {
 }
 
+static inline int kvmppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
+{
+return 0;
+}
+
 static inline void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
 {
 }
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 56d3b97..ad5c27d 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8970,6 +8970,11 @@ int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
 break;
 }
 
+if (kvmppc_set_compat(cpu, cpu->max_compat) < 0) {
+error_report("Unable to set compatibility mode in KVM");
+ret = -1;
+}
+
 return ret;
 }
 
-- 
1.9.rc0




[Qemu-devel] [PATCH v2 8/9] spapr: Implement processor compatibility in ibm, client-architecture-support

2014-05-21 Thread Alexey Kardashevskiy
Modern Linux kernels support last POWERPC CPUs so when a kernel boots,
in most cases it can find a matching cpu_spec in the kernel's cpu_specs
list. However if the kernel is quite old, it may be missing a definition
of the actual CPU. To provide an ability for old kernels to work on modern
hardware, a Processor Compatibility Mode has been introduced
by the PowerISA specification.

>From the hardware prospective, it is supported by the Processor
Compatibility Register (PCR) which is defined in PowerISA. The register
enables one of the compatibility modes (2.05/2.06/2.07).
Since PCR is a hypervisor privileged register and cannot be
directly accessed from the guest, the mode selection is done via
ibm,client-architecture-support (CAS) RTAS call using which the guest
specifies what "raw" and "architected" CPU versions it supports.
QEMU works out the best match, changes a "cpu-version" property of
every CPU and notifies the guest about the change by setting these
properties in the buffer passed as a response on a custom H_CAS hypercall.

This implements ibm,client-architecture-support parameters parsing
(now only for PVRs) and cooks the device tree diff with new values for
"cpu-version", "ibm,ppc-interrupt-server#s" and
"ibm,ppc-interrupt-server#s" properties.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c   |  4 ++-
 hw/ppc/spapr_hcall.c | 85 
 trace-events |  4 +++
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 14c72d9..020426a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -34,6 +34,7 @@
 #include "sysemu/kvm.h"
 #include "kvm_ppc.h"
 #include "mmu-hash64.h"
+#include "qom/cpu.h"
 
 #include "hw/boards.h"
 #include "hw/ppc/ppc.h"
@@ -601,7 +602,8 @@ int spapr_h_cas_compose_response(target_ulong addr, 
target_ulong size)
 _FDT((fdt_open_into(fdt_skel, fdt, size)));
 g_free(fdt_skel);
 
-/* Place to make changes to the tree */
+/* Fix skeleton up */
+_FDT((spapr_fixup_cpu_dt(fdt, spapr)));
 
 /* Pack resulting tree */
 _FDT((fdt_pack(fdt)));
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 2f6aa5c..2e0a49c 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -3,6 +3,9 @@
 #include "helper_regs.h"
 #include "hw/ppc/spapr.h"
 #include "mmu-hash64.h"
+#include "cpu-models.h"
+#include "trace.h"
+#include "kvm_ppc.h"
 
 struct SPRSyncState {
 CPUState *cs;
@@ -752,12 +755,94 @@ out:
 return ret;
 }
 
+#define get_compat_level(cpuver) ( \
+((cpuver) == CPU_POWERPC_LOGICAL_2_05) ? 2050 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_06) ? 2060 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0)
+
 static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
   sPAPREnvironment *spapr,
   target_ulong opcode,
   target_ulong *args)
 {
 target_ulong list = args[0];
+PowerPCCPUClass *pcc_ = POWERPC_CPU_GET_CLASS(cpu_);
+CPUState *cs;
+bool cpu_match = false;
+unsigned old_cpu_version = cpu_->cpu_version;
+unsigned compat_lvl = 0, cpu_version = 0;
+unsigned max_lvl = get_compat_level(cpu_->max_compat);
+
+/* Parse PVR list */
+for ( ; ; ) {
+uint32_t pvr, pvr_mask;
+
+pvr_mask = rtas_ld(list, 0);
+list += 4;
+pvr = rtas_ld(list, 0);
+list += 4;
+
+trace_spapr_cas_pvr_try(pvr);
+if (!max_lvl &&
+((cpu_->env.spr[SPR_PVR] & pvr_mask) == (pvr & pvr_mask))) {
+cpu_match = true;
+cpu_version = 0;
+} else if (pvr == cpu_->cpu_version) {
+cpu_match = true;
+cpu_version = cpu_->cpu_version;
+} else if (!cpu_match) {
+/* If it is a logical PVR, try to determine the highest level */
+unsigned lvl = get_compat_level(pvr);
+if (lvl) {
+bool is205 = (pcc_->pcr_mask & PCR_COMPAT_2_05) &&
+ (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
+bool is206 = (pcc_->pcr_mask & PCR_COMPAT_2_06) &&
+((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
+(lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS)));
+
+if (is205 || is206) {
+if (!max_lvl) {
+/* User did not set the level, choose the highest */
+if (compat_lvl <= lvl) {
+compat_lvl = lvl;
+cpu_version = pvr;
+}
+} else if (max_lvl >= lvl) {
+/* User chose the level, don't set higher than this */
+compat_lvl = lvl;
+cpu_version = p

[Qemu-devel] [PATCH v2 7/9] spapr: Limit threads per core according to current compatibility mode

2014-05-21 Thread Alexey Kardashevskiy
This puts a limit to the number of threads per core based on the current
compatibility mode. Although PowerISA specs do not specify the maximum
threads per core number, the linux guest still expects that
PowerISA2.05-compatible CPU supports only 2 threads per core as this
is what POWER6 (2.05 compliant CPU) implements, the same is for
POWER7 (2.06, 4 threads) and POWER8 (2.07, 8 threads).

This calls spapr_fixup_cpu_smt_dt() with the maximum allowed number of
threads which affects ibm,ppc-interrupt-server#s and
ibm,ppc-interrupt-gserver#s properties.

The number of CPU nodesremains unchanged.

Signed-off-by: Alexey Kardashevskiy 
---
 hw/ppc/spapr.c  |  2 +-
 target-ppc/cpu.h|  1 +
 target-ppc/translate_init.c | 27 +++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 7082237..14c72d9 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -293,7 +293,7 @@ static int spapr_fixup_cpu_dt(void *fdt, sPAPREnvironment 
*spapr)
 }
 
 ret = spapr_fixup_cpu_smt_dt(fdt, offset, cpu,
- smp_threads);
+ ppc_get_compat_smt_threads(cpu));
 if (ret < 0) {
 return ret;
 }
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index d3b8236..7b465b8 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1122,6 +1122,7 @@ void ppc_store_sdr1 (CPUPPCState *env, target_ulong 
value);
 void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
+int ppc_get_compat_smt_threads(PowerPCCPU *cpu);
 int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version);
 
 /* Time-base and decrementer management */
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index faac74a..56d3b97 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8921,6 +8921,33 @@ static void ppc_cpu_unrealizefn(DeviceState *dev, Error 
**errp)
 }
 }
 
+int ppc_get_compat_smt_threads(PowerPCCPU *cpu)
+{
+int ret = smp_threads;
+PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+switch (cpu->cpu_version) {
+case CPU_POWERPC_LOGICAL_2_05:
+ret = 2;
+break;
+case CPU_POWERPC_LOGICAL_2_06:
+ret = 4;
+break;
+case CPU_POWERPC_LOGICAL_2_07:
+ret = 8;
+break;
+default:
+if (pcc->pcr_mask & PCR_COMPAT_2_06) {
+ret = 4;
+} else if (pcc->pcr_mask & PCR_COMPAT_2_05) {
+ret = 2;
+}
+break;
+}
+
+return MIN(ret, smp_threads);
+}
+
 int ppc_set_compat(PowerPCCPU *cpu, uint32_t cpu_version)
 {
 int ret = 0;
-- 
1.9.rc0




Re: [Qemu-devel] [PATCH v2 4/8] spapr: Move interrupt allocator to xics

2014-05-21 Thread Alexander Graf


On 15.05.14 11:59, Alexey Kardashevskiy wrote:

The current allocator returns IRQ numbers from a pool and does not
support IRQs reuse in any form as it did not keep track of what it
previously returned, it only keeps the last returned IRQ. Some use
cases such as PCI hot(un)plug may require IRQ release and reallocation.

This moves an allocator from SPAPR to XICS.

This switches IRQ users to use new API.

This uses LSI/MSI flags to know if interrupt is allocated.

The interrupt release function will be posted as a separate patch.

Signed-off-by: Alexey Kardashevskiy 
---
  hw/intc/xics.c | 88 ++
  hw/ppc/spapr.c | 67 --
  hw/ppc/spapr_events.c  |  2 +-
  hw/ppc/spapr_pci.c |  6 ++--
  hw/ppc/spapr_vio.c |  2 +-
  include/hw/ppc/spapr.h | 10 --
  include/hw/ppc/xics.h  |  2 ++
  trace-events   |  4 +++
  8 files changed, 99 insertions(+), 82 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 83a809e..fdcbb3a 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -689,6 +689,94 @@ void xics_set_irq_type(XICSState *icp, int irq, bool lsi)
  ics_set_irq_type(ics, irq - ics->offset, lsi);
  }
  
+#define ICS_IRQ_FREE(ics, srcno)   \

+(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
+
+static int ics_find_free_block(ICSState *ics, int num, int alignnum)
+{
+int first, i;
+
+for (first = 0; first < ics->nr_irqs; first += alignnum) {
+if (num > (ics->nr_irqs - first)) {
+return -1;
+}
+for (i = first; i < first + num; ++i) {
+if (!ICS_IRQ_FREE(ics, i)) {
+break;
+}
+}
+if (i == (first + num)) {
+return first;
+}
+}
+
+return -1;
+}
+
+int xics_alloc(XICSState *icp, int src, int irq_hint, bool lsi)
+{
+ICSState *ics = &icp->ics[src];
+int irq;
+
+if (irq_hint) {
+assert(src == xics_find_source(icp, irq_hint));


Could this ever get triggered by a guest? Why don't we just fail as if 
the IRQ wasn't available?



Alex




Re: [Qemu-devel] [PATCH 6/6] docs: add multiseat.txt

2014-05-21 Thread Gerd Hoffmann
On Di, 2014-05-20 at 20:08 +0200, Paolo Bonzini wrote:
> Il 20/05/2014 16:00, Gerd Hoffmann ha scritto:
> > +   -device pci-bridge,addr=12.0,chassis_nr=2,id=head.2 \
> > +   -device secondary-vga,bus=head.2,addr=02.0,id=video.2 \
> > +   -device nec-usb-xhci,bus=head.2,addr=0f.0,id=usb.2 \
> > +   -device usb-kbd,bus=usb.2.0,port=1,display=video.2 \
> > +   -device usb-tablet,bus=usb.2.0,port=2,display=video.2
> > +
> > +This places a pci bridge in slot 12, connects a display adapter and
> > +xhci (usb) controller to the bridge.  Then it adds a usb keyboard and
> > +usb mouse, both connected to the xhci and linked to the display.
> > +
> > +The "display=video2" sets up the input routing.  Any input coming from
> > +the window which belongs to the video.2 display adapter will be routed
> > +to these input devices.
> > +
> 
> Is there anything about the window that we would like to configure?  If 
> so, should this be something like
> 
>   -object window,id=window.2 \
>   -device pci-bridge,addr=12.0,chassis_nr=2,id=head.2 \
>   -device secondary-vga,bus=head.2,addr=02.0,window=window.2 \
>   -device nec-usb-xhci,bus=head.2,addr=0f.0,id=usb.2 \
>   -device usb-kbd,bus=usb.2.0,port=1,window=window.2 \
>   -device usb-tablet,bus=usb.2.0,port=2,window=window.2
> 
> ?

The "window" is a QemuConsole.  Which is a object already, visible
in /backend/console[nr].  Has a device link pointing to the display
device it is bound to.

QemuConsoles are automatically created by display devices and don't have
ids, so we lookup them using the display device id.  See
qemu_input_handler_bind in patch #3.

If there is anything to configure then it most likely will be ui
specific, i.e. we could possibly allow something like this ...

   -display gtk,display=video.1 \
   -vnc :0,display=video.2

... to have one head show up on gtk and the other on vnc (needs '-vga
none -device VGA,id=video.1' instead of '-vga std').

cheers,
  Gerd





Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Alexander Graf


On 15.05.14 11:59, Alexey Kardashevskiy wrote:

Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
XICS used to be unable to reuse interrupts which becomes a problem for
dynamic MSI reconfiguration which is happening on guest driver reload or
PCI hot (un)plug. Another problem is that PHB has a limit of devices
supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
for that.

This makes use of new XICS ability to reuse interrupts.

This removes cached MSI configuration from SPAPR PHB so the first IRQ number
of a device is stored in MSI/MSIX config space so there is no need to store
this anywhere else. From now on, SPAPR PHB only keeps flags telling what type
of interrupt for which device it has configured in order to return error if
(for example) MSIX was enabled and the guest is trying to disable MSI which
it has not enabled.

This removes a limit for the maximum number of MSIX-enabled devices per PHB,
now XICS and PCI bus capacity are the only limitation.

This changes migration stream as it fixes vmstate_spapr_pci_msi::name which was
wrong since the beginning.

This fixed traces to be more informative.

Signed-off-by: Alexey Kardashevskiy 
---

In reality either MSIX or MSI is enabled, never both. So I could remove msi/msix
bitmaps from this patch, would it make sense?


Is this a hard requirement? Does a device have to choose between MSIX 
and MSI or could it theoretically have both enabled? Is this a PCI 
limitation, a PAPR/XICS limitation or just a limitation of your 
implementation?



Alex




Re: [Qemu-devel] [PATCH] e1000: allow command-line selection of card model

2014-05-21 Thread Andreas Färber
Hi,

Am 20.05.2014 17:05, schrieb Gabriel L. Somlo:
> Allow selection of different card models from the qemu
> command line, to better accomodate a wider range of guests.
> 
> Based-on-patch-by: Romain Dolbeau 

If that patch carried a Signed-off-by line, you should retain it. Your
From: line already indicates that it has been rewritten since.

> Signed-off-by: Gabriel Somlo 
> ---
> 
> Based on the conversation in [2,3,4], and given that I would still like
> OS X to work as close to "out of the box" as possible, I took a stab
> at isolating just the bits that allow command-line selection of the
> specific e1000 device model from Romain's patch set [1]. Hope that's
> OK with everyone :)
> 
> Beyond a few small style improvements, I'm still not 100% familiar with
> QOM, so I wonder if there isn't a cleaner way to offer "e1000" as some
> sort of "alias" to the default 82540EM, instead of listing two different
> devices (e1000 and 82540EM) with otherwise 100% identical properties.
> However, if the patch is acceptable as-is, I'm happy to leave it be... :)
> 
> I tested this on Windows 7 (where the default e1000 continues to work
> as before), Linux (F20, which is fine with either model), and OS X
> (10.9 requires E1000_DEV_ID_82545EM_COPPER, which also works with prior
> versions starting at 10.6; and the default e1000 works on versions <= 10.8).
> 
> Comments, suggestions, (or even a straight-forward upstream acceptance
> of the patch) much appreciated ! :)
> 
> Thanks,
>Gabriel
> 
> [1] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01397.html
> [2] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01831.html
> [3] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01841.html
> [4] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg03669.html
> 
>  hw/net/e1000.c | 97 
> --
>  1 file changed, 80 insertions(+), 17 deletions(-)
> 
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index 8387443..92323a3 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -69,23 +69,29 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
>  
>  /*
>   * HW models:
> - *  E1000_DEV_ID_82540EM works with Windows and Linux
> + *  E1000_DEV_ID_82540EM works with Windows, Linux, and OS X <= 10.8
>   *  E1000_DEV_ID_82573L OK with windoze and Linux 2.6.22,
>   *   appears to perform better than 82540EM, but breaks with Linux 2.6.18
>   *  E1000_DEV_ID_82544GC_COPPER appears to work; not well tested
> + *  E1000_DEV_ID_82545EM_COPPER works with Linux and OS X >= 10.6
>   *  Others never tested
>   */
> -enum { E1000_DEVID = E1000_DEV_ID_82540EM };
>  
>  /*
>   * May need to specify additional MAC-to-PHY entries --
>   * Intel's Windows driver refuses to initialize unless they match
>   */
> -enum {
> -PHY_ID2_INIT = E1000_DEVID == E1000_DEV_ID_82573L ?  0xcc2 :
> -   E1000_DEVID == E1000_DEV_ID_82544GC_COPPER ?  0xc30 :
> -   /* default to E1000_DEV_ID_82540EM */ 0xc20
> -};
> +static uint16_t

   static inline uint16_t maybe?

> +e1000_phy_id2_init(uint16_t dev_id) {
> +switch(dev_id) {

   switch (dev_id) {

> +case E1000_DEV_ID_82573L:
> +return 0xcc2;
> +case E1000_DEV_ID_82544GC_COPPER:
> +return 0xc30;
> +default:
> +return 0xc20; /* default for 82540EM and others */
> +}
> +}
>  
>  typedef struct E1000State_st {
>  /*< private >*/
> @@ -151,7 +157,7 @@ typedef struct E1000State_st {
>  uint32_t compat_flags;
>  } E1000State;
>  
> -#define TYPE_E1000 "e1000"
> +#define TYPE_E1000 "e1000-base"
>  
>  #define E1000(obj) \
>  OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
> @@ -235,7 +241,7 @@ static const char phy_regcap[0x20] = {
>  static const uint16_t phy_reg_init[] = {
>  [PHY_CTRL] = 0x1140,
>  [PHY_STATUS] = 0x794d, /* link initially up with not completed autoneg */
> -[PHY_ID1] = 0x141,   [PHY_ID2] = 
> PHY_ID2_INIT,
> +[PHY_ID1] = 0x141, /* [PHY_ID2] configured per DevId, from e1000_reset() 
> */
>  [PHY_1000T_CTRL] = 0x0e00,   
> [M88E1000_PHY_SPEC_CTRL] = 0x360,
>  [M88E1000_EXT_PHY_SPEC_CTRL] = 0x0d60,   [PHY_AUTONEG_ADV] = 0xde1,
>  [PHY_LP_ABILITY] = 0x1e0,[PHY_1000T_STATUS] = 
> 0x3c00,
> @@ -271,8 +277,9 @@ set_interrupt_cause(E1000State *s, int index, uint32_t 
> val)
>  PCIDevice *d = PCI_DEVICE(s);

   PCIDeviceClass *pdc = PCI_DEVICE_GET_CLASS(s); // note: not d

>  uint32_t pending_ints;
>  uint32_t mit_delay;
> +uint16_t dev_id = PCI_DEVICE_GET_CLASS(d)->device_id;

   uint16_t dev_id = pdc->device_id;

By convention, don't use these macros inline in FOO(bar)->baz style
expressions, use a variable. Applies elsewhere as well.

>  
> -if (val && (E1000_DEVID >= E1000_DEV_ID_82547EI_MOBILE)) {
> +if (val && (dev_id >= E1000_DEV_ID_82547EI

Re: [Qemu-devel] [PATCH v2 1/8] xics: Add flags for interrupts

2014-05-21 Thread Alexander Graf


On 21.05.14 08:30, Alexey Kardashevskiy wrote:

On 05/15/2014 07:59 PM, Alexey Kardashevskiy wrote:

The existing interrupt allocation scheme in SPAPR assumes that
interrupts are allocated at the start time, continously and the config
will not change. However, there are cases when this is not going to work
such as:

1. migration - we will have to have an ability to choose interrupt
numbers for devices in the command line and this will create gaps in
interrupt space.

2. PCI hotplug - interrupts from unplugged device need to be returned
back to interrupt pool, otherwise we will quickly run out of interrupts.

This replaces a separate lslsi[] array with a byte in the ICSIRQState
struct and defines "LSI" and "MSI" flags. Neither of these flags set
signals that the descriptor is not allocated and not in use.

Signed-off-by: Alexey Kardashevskiy 
---
  hw/intc/xics.c| 23 ---
  hw/intc/xics_kvm.c|  5 ++---
  include/hw/ppc/xics.h |  6 +-
  3 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 64aabe7..220ca0e 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -438,7 +438,7 @@ static void ics_set_irq(void *opaque, int srcno, int val)
  {
  ICSState *ics = (ICSState *)opaque;
  
-if (ics->islsi[srcno]) {

+if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
  set_irq_lsi(ics, srcno, val);
  } else {
  set_irq_msi(ics, srcno, val);
@@ -475,7 +475,7 @@ static void ics_write_xive(ICSState *ics, int nr, int 
server,
  
  trace_xics_ics_write_xive(nr, srcno, server, priority);
  
-if (ics->islsi[srcno]) {

+if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
  write_xive_lsi(ics, srcno);
  } else {
  write_xive_msi(ics, srcno);
@@ -497,7 +497,7 @@ static void ics_resend(ICSState *ics)
  
  for (i = 0; i < ics->nr_irqs; i++) {

  /* FIXME: filter by server#? */
-if (ics->islsi[i]) {
+if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) {
  resend_lsi(ics, i);
  } else {
  resend_msi(ics, i);
@@ -512,7 +512,7 @@ static void ics_eoi(ICSState *ics, int nr)
  
  trace_xics_ics_eoi(nr);
  
-if (ics->islsi[srcno]) {

+if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_LSI) {
  irq->status &= ~XICS_STATUS_SENT;
  }
  }
@@ -609,7 +609,6 @@ static void ics_realize(DeviceState *dev, Error **errp)
  return;
  }
  ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
-ics->islsi = g_malloc0(ics->nr_irqs * sizeof(bool));
  ics->qirqs = qemu_allocate_irqs(ics_set_irq, ics, ics->nr_irqs);
  }
  
@@ -646,11 +645,21 @@ qemu_irq xics_get_qirq(XICSState *icp, int irq)

  return icp->ics->qirqs[irq - icp->ics->offset];
  }
  
+static void ics_set_irq_type(ICSState *ics, int srcno, bool lsi)

+{
+assert(!(ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MASK));
+
+ics->irqs[srcno].flags |=
+lsi ? XICS_FLAGS_IRQ_LSI : XICS_FLAGS_IRQ_MSI;
+}
+
  void xics_set_irq_type(XICSState *icp, int irq, bool lsi)
  {
-assert(ics_valid_irq(icp->ics, irq));
+ICSState *ics = icp->ics;
  
-icp->ics->islsi[irq - icp->ics->offset] = lsi;

+assert(ics_valid_irq(ics, irq));
+
+ics_set_irq_type(ics, irq - ics->offset, lsi);
  }
  
  /*

diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index 09476ae..8719a88 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -224,7 +224,7 @@ static int ics_set_kvm_state(ICSState *ics, int version_id)
  state |= KVM_XICS_MASKED;
  }
  
-if (ics->islsi[i]) {

+if (ics->irqs[i].flags & XICS_FLAGS_IRQ_LSI) {
  state |= KVM_XICS_LEVEL_SENSITIVE;
  if (irq->status & XICS_STATUS_ASSERTED) {
  state |= KVM_XICS_PENDING;
@@ -253,7 +253,7 @@ static void ics_kvm_set_irq(void *opaque, int srcno, int 
val)
  int rc;
  
  args.irq = srcno + ics->offset;

-if (!ics->islsi[srcno]) {
+if (ics->irqs[srcno].flags & XICS_FLAGS_IRQ_MSI) {
  if (!val) {
  return;
  }
@@ -290,7 +290,6 @@ static void ics_kvm_realize(DeviceState *dev, Error **errp)
  return;
  }
  ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
-ics->islsi = g_malloc0(ics->nr_irqs * sizeof(bool));
  ics->qirqs = qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs);
  }
  
diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h

index 0d7673d..fa8e9c2 100644
--- a/include/hw/ppc/xics.h
+++ b/include/hw/ppc/xics.h
@@ -136,7 +136,6 @@ struct ICSState {
  uint32_t nr_irqs;
  uint32_t offset;
  qemu_irq *qirqs;
-bool *islsi;
  ICSIRQState *irqs;
  XICSState *icp;
  };
@@ -150,6 +149,11 @@ struct ICSIRQState {
  #define XICS_STATUS_REJECTED   0x4
  #define XICS_STATUS_MASKED_PENDING 0x8
  uint8_t status;
+/* (flags & XICS_FLAGS_IRQ_MASK) == 0 means the interrupt is not allocated */
+#define XICS_FLAGS_IRQ_LSI  

Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Fam Zheng
On Wed, 05/21 10:23, Kevin Wolf wrote:
> Am 21.05.2014 um 09:46 hat Markus Armbruster geschrieben:
> > Fam Zheng  writes:
> > 
> > > On Wed, 05/21 07:54, Markus Armbruster wrote:
> > >> Fam Zheng  writes:
> > >> 
> > >> > On Tue, 05/20 13:13, Eric Blake wrote:
> > >> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
> > >> >> > Please first take a look at patch 7 to see what is supported by 
> > >> >> > this series.
> > >> >> > 
> > >> >> > Patch 1 ~ 3 allows some useful basic types in schema.
> > >> >> > 
> > >> >> > Patch 4 ~ 6 implements the new syntax.
> > >> >> > 
> > >> >> > Note: The introduced '@arg' sigil, just like the preexisting 
> > >> >> > '*arg', is
> > >> >> > reducing the cleanness of the syntax. We should get rid of both of 
> > >> >> > them in long
> > >> >> > term. Here, this series compromises on this and introduces '@arg' 
> > >> >> > because:
> > >> >> > 
> > >> >> >   - We have to distinguish the argument property dictionary from 
> > >> >> > nested struct:
> > >> >> > 
> > >> >> > I.e.:
> > >> >> > 
> > >> >> > 'data': {
> > >> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
> > >> >> > '@arg2': { 'type': 'int', 'default': 100 }
> > >> >> >  }
> > >> >> > 
> > >> >> > Until we completely drop and forbid the 'arg1' nested struct 
> > >> >> > use case.
> > >> >> > 
> > >> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull 
> > >> >> > in many
> > >> >> > distractive patches to this series.
> > >> >> 
> > >> >> Question - since we WANT to get rid of nested struct, why not reverse
> > >> >> the sense?  Mark all existing nested structs (weren't there just three
> > >> >> that we found?) with the '@' sigil, and let the new syntax be
> > >> >> sigil-free.  Then when we clean up the nesting, we are also getting 
> > >> >> rid
> > >> >> of the bad syntax, plus the sigil gives us something to search for in
> > >> >> knowing how much to clean up.  But if you stick the sigil on the new
> > >> >> code, instead of the obsolete code, then as more and more places in 
> > >> >> the
> > >> >> schema use defaults, it gets harder and harder to remove the use of 
> > >> >> the
> > >> >> sigil even if the nested structs are eventually removed.
> > >> >> 
> > >> >
> > >> > It makes not much difference I can see. The hard part is actaully 
> > >> > dropping
> > >> > nested, converting from sigil <-> non-sigil is easy. Of course, 
> > >> > nothing is
> > >> > seriously hard, there are only three nested structs plus some more
> > >> > qapi-schema
> > >> > test code.
> > >> 
> > >> Adding three ugly sigils and making everybody include one when they add
> > >> a nested struct feels much better to me than ugly sigils all over the
> > >> place.
> > >
> > > Well, I could use some background here. Why did we introduce nested 
> > > structure
> > > in the first place?
> > 
> > Because we could?
> > 
> > Felt like a good idea at the time?
> > 
> > I quick glance at commit 0f923be and fb3182c suggests they have been
> > supported since the beginning.  There is no design rationale.
> 
> Let me extend Fam's question: Why don't we simply remove them right
> now? If it's really only three instances, converting them to full
> types should be a matter of five minutes.
> 

Actually, my question is: do we want it independently, or do we want to include
the removal of nested as the first part of this series?

I would prefer the former because I feel uncomfortable with making more changes
in this series, since there are already many things to do: adding qapi types,
adding argument property dict, adding all test cases for all of them, updating
documentation, and apply the new syntax in qapi-schema.json. A non-RFC revision
could be long and hard to review.

Fam



Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 05:51 PM, Paolo Bonzini wrote:
> Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:
>> Hi!
>>
>> We recently discovered that not entire QEMU is GPL2-compatible, the fpu
>> emulation has a different license (copied below) which might create legal
>> problems because of that "INDEMNIFY" statement.
>>
>> Does anyone else care (except IBM)?
>>
>> What would the proper solution be? Ask the creator to relicense it under
>> GPL? I failed to find a contact as the homepage on berkeley.edu is
>> restricted. Rewrite the code? This code is used in FPU emulation for TCG,
>> is that the only use of it? If it should not get called for KVM, that would
>> be a temporary band-aid for us :)
> 
> http://marc.info/?l=qemu-devel&m=136725946312880&w=4
> 
> The following people haven't acked the relicensing of their contributions
> from softfloat-2b to softfloat-2a or GPLv2+ yet:
> 
> Fabrice Bellard 
> 1d6bda356153c82e100680d9f2165e32c8fb1330
> 750afe93fd15fafc20b6c34d30f339547d15c2d1
> 
> Jocelyn Mayer
> 75d62a585629cdc1ae0d530189653cb1d8d9c53c
> 
> Thiemo Seufer's parents (Stefan said he'd contact them)
> 5a6932d51d1b34b68b3f10fc5ac65598bece88c0
> 924b2c07cdfaba9ac408fc5fa77da75a570f9dc5
> b645bb48850fea8db017026897827f0ab42fbdea
> fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10
> 
> This list only includes people whose contributions has not been reverted in
> the meanwhile.

Wow. People definitely care, a lot :) Thanks for the link and info!


-- 
Alexey



[Qemu-devel] [PATCH 09/25] gtk: use device type as label

2014-05-21 Thread Gerd Hoffmann
IMO useful than showing VGA for any graphic device
even in case it is something completely different.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 0756432..a8393dd 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -67,6 +67,7 @@
 #include "x_keymap.h"
 #include "keymaps.h"
 #include "sysemu/char.h"
+#include "qom/object.h"
 
 #define MAX_VCS 10
 
@@ -1457,6 +1458,15 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, 
VirtualConsole *vc,
   QemuConsole *con, int idx,
   GSList *group, GtkWidget *view_menu)
 {
+const char *label = "VGA";
+Error *local_err = NULL;
+Object *obj;
+
+obj = object_property_get_link(OBJECT(con), "device", &local_err);
+if (obj) {
+label = object_get_typename(obj);
+}
+
 vc->s = s;
 vc->gfx.scale_x = 1.0;
 vc->gfx.scale_y = 1.0;
@@ -1477,10 +1487,10 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, 
VirtualConsole *vc,
 vc->type = GD_VC_GFX;
 vc->tab_item = vc->gfx.drawing_area;
 gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook),
- vc->tab_item, gtk_label_new("VGA"));
+ vc->tab_item, gtk_label_new(label));
 gd_connect_vc_gfx_signals(vc);
 
-group = gd_vc_menu_init(s, vc, "VGA", idx, group, view_menu);
+group = gd_vc_menu_init(s, vc, label, idx, group, view_menu);
 
 vc->gfx.dcl.ops = &dcl_ops;
 vc->gfx.dcl.con = con;
-- 
1.8.3.1




[Qemu-devel] [PATCH 15/25] gtk: skip keyboard grab when hover autograb is active

2014-05-21 Thread Gerd Hoffmann
It's pointless.  With grab on hover enabled the keyboard grab
is already active when you press Ctrl-Alt-G ;)

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index d87bd1b..f804813 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1183,7 +1183,9 @@ static void gd_menu_grab_input(GtkMenuItem *item, void 
*opaque)
 VirtualConsole *vc = gd_vc_find_current(s);
 
 if (gd_is_grab_active(s)) {
-gd_grab_keyboard(vc);
+if (!gd_grab_on_hover(s)) {
+gd_grab_keyboard(vc);
+}
 gd_grab_pointer(vc);
 } else {
 gd_ungrab_keyboard(s);
-- 
1.8.3.1




[Qemu-devel] [PATCH 08/25] gtk: support multiple gfx displays

2014-05-21 Thread Gerd Hoffmann
Each display gets its own tab.  Tab switching continues to work like it
did, just the hotkeys of the vte consoles changes in case a secondary
display is present as it will get ctrl-alt-2 assigned and the vtes are
shifted by one.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 80 ++--
 1 file changed, 43 insertions(+), 37 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index bc42f68..0756432 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1206,6 +1206,26 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
 
 /** Virtual Console Callbacks **/
 
+static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
+   const char *label, int idx,
+   GSList *group, GtkWidget *view_menu)
+{
+char path[32];
+
+snprintf(path, sizeof(path), "/View/VC%d", idx);
+
+vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
+group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
+gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
+gtk_accel_map_add_entry(path, GDK_KEY_1 + idx, HOTKEY_MODIFIERS);
+
+g_signal_connect(vc->menu_item, "activate",
+ G_CALLBACK(gd_menu_switch_vc), s);
+gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
+
+return group;
+}
+
 #if defined(CONFIG_VTE)
 static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
 {
@@ -1253,32 +1273,22 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar 
*text, guint size,
 return TRUE;
 }
 
-static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, int 
index,
+static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
+  CharDriverState *chr, int idx,
   GSList *group, GtkWidget *view_menu)
 {
 const char *label;
 char buffer[32];
-char path[32];
 GtkWidget *box;
 GtkWidget *scrollbar;
 GtkAdjustment *vadjustment;
 
-snprintf(buffer, sizeof(buffer), "vc%d", index);
-snprintf(path, sizeof(path), "/View/VC%d", index);
-
 vc->s = s;
-vc->vte.chr = vcs[index];
-
-if (vc->vte.chr->label) {
-label = vc->vte.chr->label;
-} else {
-label = buffer;
-}
+vc->vte.chr = chr;
 
-vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
-group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
-gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
-gtk_accel_map_add_entry(path, GDK_KEY_2 + index, HOTKEY_MODIFIERS);
+snprintf(buffer, sizeof(buffer), "vc%d", idx);
+label = vc->vte.chr->label ? vc->vte.chr->label : buffer;
+group = gd_vc_menu_init(s, vc, vc->vte.chr->label, idx, group, view_menu);
 
 vc->vte.terminal = vte_terminal_new();
 g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc);
@@ -1315,10 +1325,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, 
VirtualConsole *vc, int index,
 vc->tab_item = box;
 gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
  gtk_label_new(label));
-g_signal_connect(vc->menu_item, "activate",
- G_CALLBACK(gd_menu_switch_vc), s);
-
-gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item);
 
 qemu_chr_be_generic_open(vc->vte.chr);
 if (vc->vte.chr->init) {
@@ -1328,15 +1334,14 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, 
VirtualConsole *vc, int index,
 return group;
 }
 
-static void gd_vcs_init(GtkDisplayState *s, int offset, GSList *group,
+static void gd_vcs_init(GtkDisplayState *s, GSList *group,
 GtkWidget *view_menu)
 {
 int i;
 
 for (i = 0; i < nb_vcs; i++) {
-VirtualConsole *vc = &s->vc[offset+i];
-
-group = gd_vc_vte_init(s, vc, i, group, view_menu);
+VirtualConsole *vc = &s->vc[s->nb_vcs];
+group = gd_vc_vte_init(s, vc, vcs[i], s->nb_vcs, group, view_menu);
 s->nb_vcs++;
 }
 }
@@ -1449,7 +1454,7 @@ static const DisplayChangeListenerOps dcl_ops = {
 };
 
 static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
-  QemuConsole *con, int index,
+  QemuConsole *con, int idx,
   GSList *group, GtkWidget *view_menu)
 {
 vc->s = s;
@@ -1475,15 +1480,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, 
VirtualConsole *vc,
  vc->tab_item, gtk_label_new("VGA"));
 gd_connect_vc_gfx_signals(vc);
 
-vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, "_VGA");
-group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
-gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item),
- "/View/VGA");
-gtk_accel_map_add_entry("/View/VGA", GDK_KEY_1, HOTKEY_MODIFIERS);

[Qemu-devel] [PATCH 18/25] gtk: update all windows on mouse mode changes

2014-05-21 Thread Gerd Hoffmann
We might have multiple graphic displays now which all need a cursor update.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 91b6824..8215841 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -553,6 +553,7 @@ static void gd_change_runstate(void *opaque, int running, 
RunState state)
 static void gd_mouse_mode_change(Notifier *notify, void *data)
 {
 GtkDisplayState *s;
+int i;
 
 s = container_of(notify, GtkDisplayState, mouse_mode_notifier);
 /* release the grab at switching to absolute mode */
@@ -560,7 +561,10 @@ static void gd_mouse_mode_change(Notifier *notify, void 
*data)
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
 }
-gd_update_cursor(gd_vc_find_current(s));
+for (i = 0; i < s->nb_vcs; i++) {
+VirtualConsole *vc = &s->vc[i];
+gd_update_cursor(vc);
+}
 }
 
 /** GTK Events **/
-- 
1.8.3.1




[Qemu-devel] [PATCH 14/25] gtk: keep track of grab owner

2014-05-21 Thread Gerd Hoffmann
Simplifies grab state tracking and makes ungrab more reliable.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 0e35abf..d87bd1b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -185,6 +185,8 @@ struct GtkDisplayState {
 int last_y;
 int grab_x_root;
 int grab_y_root;
+VirtualConsole *kbd_owner;
+VirtualConsole *ptr_owner;
 
 gboolean full_screen;
 
@@ -1058,11 +1060,19 @@ static void gd_grab_keyboard(VirtualConsole *vc)
   FALSE,
   GDK_CURRENT_TIME);
 #endif
+vc->s->kbd_owner = vc;
 trace_gd_grab(vc->label, "kbd", true);
 }
 
-static void gd_ungrab_keyboard(VirtualConsole *vc)
+static void gd_ungrab_keyboard(GtkDisplayState *s)
 {
+VirtualConsole *vc = s->kbd_owner;
+
+if (vc == NULL) {
+return;
+}
+s->kbd_owner = NULL;
+
 #if GTK_CHECK_VERSION(3, 0, 0)
 GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
 GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
@@ -1127,11 +1137,19 @@ static void gd_grab_pointer(VirtualConsole *vc)
 gdk_display_get_pointer(display, NULL,
 &vc->s->grab_x_root, &vc->s->grab_y_root, NULL);
 #endif
+vc->s->ptr_owner = vc;
 trace_gd_grab(vc->label, "ptr", true);
 }
 
-static void gd_ungrab_pointer(VirtualConsole *vc)
+static void gd_ungrab_pointer(GtkDisplayState *s)
 {
+VirtualConsole *vc = s->ptr_owner;
+
+if (vc == NULL) {
+return;
+}
+s->ptr_owner = NULL;
+
 GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
 #if GTK_CHECK_VERSION(3, 0, 0)
 GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
@@ -1168,8 +1186,8 @@ static void gd_menu_grab_input(GtkMenuItem *item, void 
*opaque)
 gd_grab_keyboard(vc);
 gd_grab_pointer(vc);
 } else {
-gd_ungrab_keyboard(vc);
-gd_ungrab_pointer(vc);
+gd_ungrab_keyboard(s);
+gd_ungrab_pointer(s);
 }
 
 gd_update_caption(s);
@@ -1227,7 +1245,7 @@ static gboolean gd_leave_event(GtkWidget *widget, 
GdkEventCrossing *crossing,
 GtkDisplayState *s = vc->s;
 
 if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
-gd_ungrab_keyboard(vc);
+gd_ungrab_keyboard(s);
 }
 
 return TRUE;
-- 
1.8.3.1




[Qemu-devel] [PATCH 01/25] gtk: zap scrolled_window

2014-05-21 Thread Gerd Hoffmann
The vte widget implements the scrollable interface, placing it into
a scrolled window is pointless and creates a bunch of strange effects.
Zap it.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 19 ++-
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 9f5061a..f6f3677 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -110,7 +110,6 @@ typedef struct VirtualConsole
 GtkWidget *menu_item;
 GtkWidget *terminal;
 #if defined(CONFIG_VTE)
-GtkWidget *scrolled_window;
 CharDriverState *chr;
 #endif
 } VirtualConsole;
@@ -1189,8 +1188,6 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 const char *label;
 char buffer[32];
 char path[32];
-GtkWidget *scrolled_window;
-GtkAdjustment *vadjustment;
 
 snprintf(buffer, sizeof(buffer), "vc%d", index);
 snprintf(path, sizeof(path), "/View/VC%d", index);
@@ -1213,24 +1210,12 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 
 vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->terminal), -1);
 
-#if VTE_CHECK_VERSION(0, 28, 0) && GTK_CHECK_VERSION(3, 0, 0)
-vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vc->terminal));
-#else
-vadjustment = vte_terminal_get_adjustment(VTE_TERMINAL(vc->terminal));
-#endif
-
-scrolled_window = gtk_scrolled_window_new(NULL, vadjustment);
-gtk_container_add(GTK_CONTAINER(scrolled_window), vc->terminal);
-
 vte_terminal_set_size(VTE_TERMINAL(vc->terminal), 80, 25);
 
 vc->chr->opaque = vc;
-vc->scrolled_window = scrolled_window;
-
-gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(vc->scrolled_window),
-   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
 
-gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), scrolled_window, 
gtk_label_new(label));
+gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->terminal,
+ gtk_label_new(label));
 g_signal_connect(vc->menu_item, "activate",
  G_CALLBACK(gd_menu_switch_vc), s);
 
-- 
1.8.3.1




[Qemu-devel] [PATCH 05/25] gtk: remove page numbering assumtions from the code

2014-05-21 Thread Gerd Hoffmann
Lookup page numbers using gtk_notebook_page_num() instead.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 6a3fe00..49753ef 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -190,7 +190,11 @@ static bool gd_grab_on_hover(GtkDisplayState *s)
 
 static bool gd_on_vga(GtkDisplayState *s)
 {
-return gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook)) == 0;
+gint p1, p2;
+
+p1 = gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook));
+p2 = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), s->drawing_area);
+return p1 == p2;
 }
 
 static void gd_update_cursor(GtkDisplayState *s, gboolean override)
@@ -805,19 +809,25 @@ static void gd_menu_quit(GtkMenuItem *item, void *opaque)
 static void gd_menu_switch_vc(GtkMenuItem *item, void *opaque)
 {
 GtkDisplayState *s = opaque;
+gint page;
 
 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vga_item))) {
-gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), 0);
+page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
+ s->drawing_area);
+gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
 } else {
-int i;
-
 gtk_release_modifiers(s);
+#if defined(CONFIG_VTE)
+gint i;
 for (i = 0; i < s->nb_vcs; i++) {
 if 
(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vc[i].menu_item))) {
-gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), i + 
1);
-break;
+page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
+ s->vc[i].box);
+gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
+return;
 }
 }
+#endif
 }
 }
 
@@ -1061,12 +1071,14 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
 {
 GtkDisplayState *s = data;
 gboolean on_vga;
+gint page;
 
 if (!gtk_widget_get_realized(s->notebook)) {
 return;
 }
 
-on_vga = arg2 == 0;
+page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), s->drawing_area);
+on_vga = arg2 == page;
 
 if (!on_vga) {
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
@@ -1076,12 +1088,20 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
TRUE);
 }
 
-if (arg2 == 0) {
+if (on_vga) {
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->vga_item), TRUE);
 } else {
 #if defined(CONFIG_VTE)
-VirtualConsole *vc = &s->vc[arg2 - 1];
-gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), 
TRUE);
+VirtualConsole *vc;
+gint page, i;
+for (i = 0; i < s->nb_vcs; i++) {
+vc = &s->vc[i];
+page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->box);
+if (page == arg2) {
+gtk_check_menu_item_set_active
+(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
+}
+}
 #else
 g_assert_not_reached();
 #endif
-- 
1.8.3.1




[Qemu-devel] [PATCH 17/25] gtk: fix grab checks

2014-05-21 Thread Gerd Hoffmann
Make it handle multiple windows case correctly.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 35 +++
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 7d6a20d..91b6824 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -201,6 +201,9 @@ struct GtkDisplayState {
 
 static GtkDisplayState *global_state;
 
+static void gd_grab_pointer(VirtualConsole *vc);
+static void gd_ungrab_pointer(GtkDisplayState *s);
+
 /** Utility Functions **/
 
 static VirtualConsole *gd_vc_find_by_menu(GtkDisplayState *s)
@@ -261,7 +264,7 @@ static void gd_update_cursor(VirtualConsole *vc)
 }
 
 window = gtk_widget_get_window(GTK_WIDGET(vc->gfx.drawing_area));
-if (s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s)) {
+if (s->full_screen || qemu_input_is_absolute() || s->ptr_owner == vc) {
 gdk_window_set_cursor(window, s->null_cursor);
 } else {
 gdk_window_set_cursor(window, NULL);
@@ -702,7 +705,7 @@ static gboolean gd_motion_event(GtkWidget *widget, 
GdkEventMotion *motion,
 qemu_input_queue_abs(vc->gfx.dcl.con, INPUT_AXIS_Y, y,
  surface_height(vc->gfx.ds));
 qemu_input_event_sync();
-} else if (s->last_set && gd_is_grab_active(s)) {
+} else if (s->last_set && s->ptr_owner == vc) {
 qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_X, x - s->last_x);
 qemu_input_queue_rel(vc->gfx.dcl.con, INPUT_AXIS_Y, y - s->last_y);
 qemu_input_event_sync();
@@ -711,7 +714,7 @@ static gboolean gd_motion_event(GtkWidget *widget, 
GdkEventMotion *motion,
 s->last_y = y;
 s->last_set = TRUE;
 
-if (!qemu_input_is_absolute() && gd_is_grab_active(s)) {
+if (!qemu_input_is_absolute() && s->ptr_owner == vc) {
 GdkScreen *screen = gtk_widget_get_screen(vc->gfx.drawing_area);
 int x = (int)motion->x_root;
 int y = (int)motion->y_root;
@@ -760,9 +763,18 @@ static gboolean gd_button_event(GtkWidget *widget, 
GdkEventButton *button,
 
 /* implicitly grab the input at the first click in the relative mode */
 if (button->button == 1 && button->type == GDK_BUTTON_PRESS &&
-!qemu_input_is_absolute() && !gd_is_grab_active(s)) {
-gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
-   TRUE);
+!qemu_input_is_absolute() && s->ptr_owner != vc) {
+gd_ungrab_pointer(s);
+if (!vc->window) {
+gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
+   TRUE);
+} else {
+#if 0
+/* FIXME: no way (yet) to ungrab */
+gd_grab_pointer(vc);
+#endif
+gd_update_caption(s);
+}
 return TRUE;
 }
 
@@ -1224,7 +1236,6 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
 }
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
-
 on_vga = (vc->type == GD_VC_GFX);
 if (!on_vga) {
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
@@ -1244,10 +1255,11 @@ static gboolean gd_enter_event(GtkWidget *widget, 
GdkEventCrossing *crossing,
 VirtualConsole *vc = opaque;
 GtkDisplayState *s = vc->s;
 
-if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
+if (gd_grab_on_hover(s)) {
+gd_ungrab_keyboard(s);
 gd_grab_keyboard(vc);
+gd_update_caption(s);
 }
-
 return TRUE;
 }
 
@@ -1257,10 +1269,10 @@ static gboolean gd_leave_event(GtkWidget *widget, 
GdkEventCrossing *crossing,
 VirtualConsole *vc = opaque;
 GtkDisplayState *s = vc->s;
 
-if (!gd_is_grab_active(s) && gd_grab_on_hover(s)) {
+if (gd_grab_on_hover(s)) {
 gd_ungrab_keyboard(s);
+gd_update_caption(s);
 }
-
 return TRUE;
 }
 
@@ -1271,7 +1283,6 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
 GtkDisplayState *s = vc->s;
 
 gtk_release_modifiers(s);
-
 return TRUE;
 }
 
-- 
1.8.3.1




[Qemu-devel] [PATCH 25/25] gtk: factor out gtk3 grab into the new gd_grab_devices function

2014-05-21 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 100 +++
 1 file changed, 36 insertions(+), 64 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index b908936..bc33a2f 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1141,28 +1141,39 @@ static void gd_menu_zoom_fit(GtkMenuItem *item, void 
*opaque)
 gd_update_full_redraw(vc);
 }
 
-static void gd_grab_keyboard(VirtualConsole *vc)
-{
 #if GTK_CHECK_VERSION(3, 0, 0)
+static void gd_grab_devices(VirtualConsole *vc, bool grab,
+GdkInputSource source, GdkEventMask mask,
+GdkCursor *cursor)
+{
 GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
 GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
-GList *devices = gdk_device_manager_list_devices(mgr,
- GDK_DEVICE_TYPE_MASTER);
-GList *tmp = devices;
-while (tmp) {
+GList *devs = gdk_device_manager_list_devices(mgr, GDK_DEVICE_TYPE_MASTER);
+GList *tmp = devs;
+
+for (tmp = devs; tmp; tmp = tmp->next) {
 GdkDevice *dev = tmp->data;
-if (gdk_device_get_source(dev) == GDK_SOURCE_KEYBOARD) {
-gdk_device_grab(dev,
-gtk_widget_get_window(vc->gfx.drawing_area),
-GDK_OWNERSHIP_NONE,
-FALSE,
-GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
-NULL,
-GDK_CURRENT_TIME);
+if (gdk_device_get_source(dev) != source) {
+continue;
+}
+if (grab) {
+GdkWindow *win = gtk_widget_get_window(vc->gfx.drawing_area);
+gdk_device_grab(dev, win, GDK_OWNERSHIP_NONE, FALSE,
+mask, cursor, GDK_CURRENT_TIME);
+} else {
+gdk_device_ungrab(dev, GDK_CURRENT_TIME);
 }
-tmp = tmp->next;
 }
-g_list_free(devices);
+g_list_free(devs);
+}
+#endif
+
+static void gd_grab_keyboard(VirtualConsole *vc)
+{
+#if GTK_CHECK_VERSION(3, 0, 0)
+gd_grab_devices(vc, true, GDK_SOURCE_KEYBOARD,
+   GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
+   NULL);
 #else
 gdk_keyboard_grab(gtk_widget_get_window(vc->gfx.drawing_area),
   FALSE,
@@ -1182,20 +1193,7 @@ static void gd_ungrab_keyboard(GtkDisplayState *s)
 s->kbd_owner = NULL;
 
 #if GTK_CHECK_VERSION(3, 0, 0)
-GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
-GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
-GList *devices = gdk_device_manager_list_devices(mgr,
- GDK_DEVICE_TYPE_MASTER);
-GList *tmp = devices;
-while (tmp) {
-GdkDevice *dev = tmp->data;
-if (gdk_device_get_source(dev) == GDK_SOURCE_KEYBOARD) {
-gdk_device_ungrab(dev,
-  GDK_CURRENT_TIME);
-}
-tmp = tmp->next;
-}
-g_list_free(devices);
+gd_grab_devices(vc, false, GDK_SOURCE_KEYBOARD, 0, NULL);
 #else
 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
 #endif
@@ -1207,28 +1205,13 @@ static void gd_grab_pointer(VirtualConsole *vc)
 GdkDisplay *display = gtk_widget_get_display(vc->gfx.drawing_area);
 #if GTK_CHECK_VERSION(3, 0, 0)
 GdkDeviceManager *mgr = gdk_display_get_device_manager(display);
-GList *devices = gdk_device_manager_list_devices(mgr,
- GDK_DEVICE_TYPE_MASTER);
-GList *tmp = devices;
-while (tmp) {
-GdkDevice *dev = tmp->data;
-if (gdk_device_get_source(dev) == GDK_SOURCE_MOUSE) {
-gdk_device_grab(dev,
-gtk_widget_get_window(vc->gfx.drawing_area),
-GDK_OWNERSHIP_NONE,
-FALSE, /* All events to come to our
-  window directly */
-GDK_POINTER_MOTION_MASK |
-GDK_BUTTON_PRESS_MASK |
-GDK_BUTTON_RELEASE_MASK |
-GDK_BUTTON_MOTION_MASK |
-GDK_SCROLL_MASK,
-vc->s->null_cursor,
-GDK_CURRENT_TIME);
-}
-tmp = tmp->next;
-}
-g_list_free(devices);
+gd_grab_devices(vc, true, GDK_SOURCE_MOUSE,
+GDK_POINTER_MOTION_MASK |
+GDK_BUTTON_PRESS_MASK |
+GDK_BUTTON_RELEASE_MASK |
+GDK_BUTTON_MOTION_MASK |
+GDK_SCROLL_MASK,
+vc->s->null_cursor);
 gdk_device_get_position(gdk_device_manager_get_client_pointer(mgr),
 NULL, &vc->s->grab_x_root, &vc->s->grab_y_root);
 #else
@@ -1261,18 +1244,7 @@ static void gd

[Qemu-devel] [PATCH 06/25] gtk: VirtualConsole restruction

2014-05-21 Thread Gerd Hoffmann
Move all vte-related items into VirtualVteConsole substruct.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 119 +++
 1 file changed, 73 insertions(+), 46 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 49753ef..78f6ccc 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -105,15 +105,23 @@ static const int modifier_keycode[] = {
 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd,
 };
 
-typedef struct VirtualConsole
-{
-GtkWidget *menu_item;
 #if defined(CONFIG_VTE)
+typedef struct VirtualVteConsole {
 GtkWidget *box;
 GtkWidget *scrollbar;
 GtkWidget *terminal;
 CharDriverState *chr;
+} VirtualVteConsole;
+#endif
+
+typedef struct VirtualConsole {
+GtkWidget *menu_item;
+GtkWidget *tab_item;
+union {
+#if defined(CONFIG_VTE)
+VirtualVteConsole vte;
 #endif
+};
 } VirtualConsole;
 
 typedef struct GtkDisplayState
@@ -178,6 +186,36 @@ static GtkDisplayState *global_state;
 
 /** Utility Functions **/
 
+static VirtualConsole *gd_vc_find_by_menu(GtkDisplayState *s)
+{
+VirtualConsole *vc;
+gint i;
+
+for (i = 0; i < s->nb_vcs; i++) {
+vc = &s->vc[i];
+if (gtk_check_menu_item_get_active
+(GTK_CHECK_MENU_ITEM(vc->menu_item))) {
+return vc;
+}
+}
+return NULL;
+}
+
+static VirtualConsole *gd_vc_find_by_page(GtkDisplayState *s, gint page)
+{
+VirtualConsole *vc;
+gint i, p;
+
+for (i = 0; i < s->nb_vcs; i++) {
+vc = &s->vc[i];
+p = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->tab_item);
+if (p == page) {
+return vc;
+}
+}
+return NULL;
+}
+
 static bool gd_is_grab_active(GtkDisplayState *s)
 {
 return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_item));
@@ -817,17 +855,12 @@ static void gd_menu_switch_vc(GtkMenuItem *item, void 
*opaque)
 gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
 } else {
 gtk_release_modifiers(s);
-#if defined(CONFIG_VTE)
-gint i;
-for (i = 0; i < s->nb_vcs; i++) {
-if 
(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->vc[i].menu_item))) {
-page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
- s->vc[i].box);
-gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
-return;
-}
+VirtualConsole *vc = gd_vc_find_by_menu(s);
+if (vc) {
+page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook),
+ vc->tab_item);
+gtk_notebook_set_current_page(GTK_NOTEBOOK(s->notebook), page);
 }
-#endif
 }
 }
 
@@ -1091,20 +1124,12 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
 if (on_vga) {
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->vga_item), TRUE);
 } else {
-#if defined(CONFIG_VTE)
 VirtualConsole *vc;
-gint page, i;
-for (i = 0; i < s->nb_vcs; i++) {
-vc = &s->vc[i];
-page = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->box);
-if (page == arg2) {
-gtk_check_menu_item_set_active
-(GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE);
-}
+vc = gd_vc_find_by_page(s, arg2);
+if (vc) {
+gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
+   TRUE);
 }
-#else
-g_assert_not_reached();
-#endif
 }
 
 gtk_widget_set_sensitive(s->grab_item, on_vga);
@@ -1153,9 +1178,9 @@ static void gd_vc_adjustment_changed(GtkAdjustment 
*adjustment, void *opaque)
 
 if (gtk_adjustment_get_upper(adjustment) >
 gtk_adjustment_get_page_size(adjustment)) {
-gtk_widget_show(vc->scrollbar);
+gtk_widget_show(vc->vte.scrollbar);
 } else {
-gtk_widget_hide(vc->scrollbar);
+gtk_widget_hide(vc->vte.scrollbar);
 }
 }
 
@@ -1163,7 +1188,7 @@ static int gd_vc_chr_write(CharDriverState *chr, const 
uint8_t *buf, int len)
 {
 VirtualConsole *vc = chr->opaque;
 
-vte_terminal_feed(VTE_TERMINAL(vc->terminal), (const char *)buf, len);
+vte_terminal_feed(VTE_TERMINAL(vc->vte.terminal), (const char *)buf, len);
 return len;
 }
 
@@ -1189,7 +1214,7 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar 
*text, guint size,
 {
 VirtualConsole *vc = user_data;
 
-qemu_chr_be_write(vc->chr, (uint8_t  *)text, (unsigned int)size);
+qemu_chr_be_write(vc->vte.chr, (uint8_t  *)text, (unsigned int)size);
 return TRUE;
 }
 
@@ -1206,10 +1231,10 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 snprintf(buffer, sizeof(buffer), "vc%d", index);
 snprintf(path, sizeof(path), "/View/VC%d", index);
 
-vc->chr = vcs[index];
+vc->vte.chr = vcs[index];
 

[Qemu-devel] [PATCH 22/25] gtk: zap unused global_state

2014-05-21 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index a55ceb4..0d86025 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -204,8 +204,6 @@ struct GtkDisplayState {
 bool has_evdev;
 };
 
-static GtkDisplayState *global_state;
-
 static void gd_grab_pointer(VirtualConsole *vc);
 static void gd_ungrab_pointer(GtkDisplayState *s);
 
@@ -1815,8 +1813,6 @@ void gtk_display_init(DisplayState *ds, bool full_screen, 
bool grab_on_hover)
 }
 
 gd_set_keycode_type(s);
-
-global_state = s;
 }
 
 void early_gtk_display_init(void)
-- 
1.8.3.1




[Qemu-devel] [PATCH 20/25] gtk: enable untabify for gfx

2014-05-21 Thread Gerd Hoffmann
Now we have all grab fixes in place, so we can allow detaching
graphic display tabs too.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 298419b..79dc8db 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -338,7 +338,11 @@ static void gd_update_windowsize(VirtualConsole *vc)
 gtk_widget_set_size_request(vc->gfx.drawing_area,
 surface_width(vc->gfx.ds) * sx,
 surface_height(vc->gfx.ds) * sy);
-gtk_window_resize(GTK_WINDOW(s->window), 320, 240);
+if (vc->window) {
+gtk_window_resize(GTK_WINDOW(vc->window), 320, 240);
+} else {
+gtk_window_resize(GTK_WINDOW(s->window), 320, 240);
+}
 }
 
 static void gd_update_full_redraw(VirtualConsole *vc)
@@ -962,8 +966,8 @@ static void gd_menu_untabify(GtkMenuItem *item, void 
*opaque)
 VirtualConsole *vc = gd_vc_find_current(s);
 
 if (vc->type == GD_VC_GFX) {
-/* temporary: needs more work to get grabs etc correct */
-return;
+gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
+   FALSE);
 }
 if (!vc->window) {
 gtk_widget_set_sensitive(vc->menu_item, false);
-- 
1.8.3.1




[Qemu-devel] [PATCH 16/25] gtk: update gd_update_caption

2014-05-21 Thread Gerd Hoffmann
Adapt to recent changes, handle multiple windows.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 45 -
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index f804813..7d6a20d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -271,11 +271,20 @@ static void gd_update_cursor(VirtualConsole *vc)
 static void gd_update_caption(GtkDisplayState *s)
 {
 const char *status = "";
+gchar *prefix;
 gchar *title;
 const char *grab = "";
 bool is_paused = !runstate_is_running();
+int i;
 
-if (gd_is_grab_active(s)) {
+if (qemu_name) {
+prefix = g_strdup_printf("QEMU (%s)", qemu_name);
+} else {
+prefix = g_strdup_printf("QEMU");
+}
+
+if (s->ptr_owner != NULL &&
+s->ptr_owner->window == NULL) {
 grab = _(" - Press Ctrl+Alt+G to release grab");
 }
 
@@ -287,15 +296,24 @@ static void gd_update_caption(GtkDisplayState *s)
is_paused);
 s->external_pause_update = false;
 
-if (qemu_name) {
-title = g_strdup_printf("QEMU (%s)%s%s", qemu_name, status, grab);
-} else {
-title = g_strdup_printf("QEMU%s%s", status, grab);
-}
-
+title = g_strdup_printf("%s%s%s", prefix, status, grab);
 gtk_window_set_title(GTK_WINDOW(s->window), title);
-
 g_free(title);
+
+for (i = 0; i < s->nb_vcs; i++) {
+VirtualConsole *vc = &s->vc[i];
+
+if (!vc->window) {
+continue;
+}
+title = g_strdup_printf("%s: %s%s%s", prefix, vc->label,
+vc == s->kbd_owner ? " +kbd" : "",
+vc == s->ptr_owner ? " +ptr" : "");
+gtk_window_set_title(GTK_WINDOW(vc->window), title);
+g_free(title);
+}
+
+g_free(prefix);
 }
 
 static void gd_update_windowsize(VirtualConsole *vc)
@@ -915,7 +933,6 @@ static void gd_menu_untabify(GtkMenuItem *item, void 
*opaque)
 {
 GtkDisplayState *s = opaque;
 VirtualConsole *vc = gd_vc_find_current(s);
-char *title;
 
 if (vc->type == GD_VC_GFX) {
 /* temporary: needs more work to get grabs etc correct */
@@ -926,17 +943,11 @@ static void gd_menu_untabify(GtkMenuItem *item, void 
*opaque)
 vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 gtk_widget_reparent(vc->tab_item, vc->window);
 
-if (qemu_name) {
-title = g_strdup_printf("QEMU (%s): %s", qemu_name, vc->label);
-} else {
-title = g_strdup_printf("QEMU: %s", vc->label);
-}
-gtk_window_set_title(GTK_WINDOW(vc->window), title);
-g_free(title);
-
 g_signal_connect(vc->window, "delete-event",
  G_CALLBACK(gd_tab_window_close), vc);
 gtk_widget_show_all(vc->window);
+
+gd_update_caption(s);
 }
 }
 
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 0/9] spapr: Enable ibm, client-architecture-support

2014-05-21 Thread Alexander Graf


On 21.05.14 10:27, Alexey Kardashevskiy wrote:

This enables a ibm,client-architecture-support RTAS call.

This allows older distros (such as SLES11 or RHEL6) to work on modern
POWERPC hardware (such as POWER8) in "architected" mode.

There is no change log as the changes are mostly about readbility, code
design style and commit logs.


And these changes are not changes? Please *always* provide a full change 
log of things that changed from version to version.



Alex




[Qemu-devel] [PATCH 19/25] gtk: detached window pointer grabs

2014-05-21 Thread Gerd Hoffmann
Make ungrab hotkey work with detached windows.
Enable pointer grabs for detached windows.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 8215841..298419b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -773,10 +773,7 @@ static gboolean gd_button_event(GtkWidget *widget, 
GdkEventButton *button,
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
TRUE);
 } else {
-#if 0
-/* FIXME: no way (yet) to ungrab */
 gd_grab_pointer(vc);
-#endif
 gd_update_caption(s);
 }
 return TRUE;
@@ -945,6 +942,20 @@ static gboolean gd_tab_window_close(GtkWidget *widget, 
GdkEvent *event,
 return TRUE;
 }
 
+static gboolean gd_win_grab(void *opaque)
+{
+VirtualConsole *vc = opaque;
+
+fprintf(stderr, "%s: %s\n", __func__, vc->label);
+if (vc->s->ptr_owner) {
+gd_ungrab_pointer(vc->s);
+} else {
+gd_grab_pointer(vc);
+}
+gd_update_caption(vc->s);
+return TRUE;
+}
+
 static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
 {
 GtkDisplayState *s = opaque;
@@ -963,6 +974,13 @@ static void gd_menu_untabify(GtkMenuItem *item, void 
*opaque)
  G_CALLBACK(gd_tab_window_close), vc);
 gtk_widget_show_all(vc->window);
 
+GtkAccelGroup *ag = gtk_accel_group_new();
+gtk_window_add_accel_group(GTK_WINDOW(vc->window), ag);
+
+GClosure *cb = g_cclosure_new_swap(G_CALLBACK(gd_win_grab), vc, NULL);
+gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb);
+
+fprintf(stderr, "%s: %p\n", __func__, vc);
 gd_update_caption(s);
 }
 }
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 4/8] spapr: Move interrupt allocator to xics

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 06:34 PM, Alexander Graf wrote:
> 
> On 15.05.14 11:59, Alexey Kardashevskiy wrote:
>> The current allocator returns IRQ numbers from a pool and does not
>> support IRQs reuse in any form as it did not keep track of what it
>> previously returned, it only keeps the last returned IRQ. Some use
>> cases such as PCI hot(un)plug may require IRQ release and reallocation.
>>
>> This moves an allocator from SPAPR to XICS.
>>
>> This switches IRQ users to use new API.
>>
>> This uses LSI/MSI flags to know if interrupt is allocated.
>>
>> The interrupt release function will be posted as a separate patch.
>>
>> Signed-off-by: Alexey Kardashevskiy 
>> ---
>>   hw/intc/xics.c | 88
>> ++
>>   hw/ppc/spapr.c | 67 --
>>   hw/ppc/spapr_events.c  |  2 +-
>>   hw/ppc/spapr_pci.c |  6 ++--
>>   hw/ppc/spapr_vio.c |  2 +-
>>   include/hw/ppc/spapr.h | 10 --
>>   include/hw/ppc/xics.h  |  2 ++
>>   trace-events   |  4 +++
>>   8 files changed, 99 insertions(+), 82 deletions(-)
>>
>> diff --git a/hw/intc/xics.c b/hw/intc/xics.c
>> index 83a809e..fdcbb3a 100644
>> --- a/hw/intc/xics.c
>> +++ b/hw/intc/xics.c
>> @@ -689,6 +689,94 @@ void xics_set_irq_type(XICSState *icp, int irq, bool
>> lsi)
>>   ics_set_irq_type(ics, irq - ics->offset, lsi);
>>   }
>>   +#define ICS_IRQ_FREE(ics, srcno)   \
>> +(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
>> +
>> +static int ics_find_free_block(ICSState *ics, int num, int alignnum)
>> +{
>> +int first, i;
>> +
>> +for (first = 0; first < ics->nr_irqs; first += alignnum) {
>> +if (num > (ics->nr_irqs - first)) {
>> +return -1;
>> +}
>> +for (i = first; i < first + num; ++i) {
>> +if (!ICS_IRQ_FREE(ics, i)) {
>> +break;
>> +}
>> +}
>> +if (i == (first + num)) {
>> +return first;
>> +}
>> +}
>> +
>> +return -1;
>> +}
>> +
>> +int xics_alloc(XICSState *icp, int src, int irq_hint, bool lsi)
>> +{
>> +ICSState *ics = &icp->ics[src];
>> +int irq;
>> +
>> +if (irq_hint) {
>> +assert(src == xics_find_source(icp, irq_hint));
> 
> Could this ever get triggered by a guest? Why don't we just fail as if the
> IRQ wasn't available?

The @irq_hist is only used when the user specified IRQ in the command line,
this is why it is assert. And the guest never gets to choose IRQ number, it
receives numbers either via device tree (and QEMU puts those numbers there,
not SLOF) or ibm,change-msi (QEMU returns numbers).



-- 
Alexey



[Qemu-devel] [PATCH 24/25] gtk: workaround gtk2 vte resize issue

2014-05-21 Thread Gerd Hoffmann
Hack isn't pretty, but gets the job done.
See source code comment for details.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/ui/gtk.c b/ui/gtk.c
index ac5dbe0..b908936 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -85,6 +85,20 @@
 # define VTE_CHECK_VERSION(a, b, c) 0
 #endif
 
+#if defined(CONFIG_VTE) && !GTK_CHECK_VERSION(3, 0, 0)
+/*
+ * The gtk2 vte terminal widget seriously messes up the window resize
+ * for some reason.  You basically can't make the qemu window smaller
+ * any more because the toplevel window geoemtry hints are overridden.
+ *
+ * Workaround that by hiding all vte widgets, except the one in the
+ * current tab.
+ *
+ * Luckily everything works smooth in gtk3.
+ */
+# define VTE_RESIZE_HACK 1
+#endif
+
 /* Compatibility define to let us build on both Gtk2 and Gtk3 */
 #if GTK_CHECK_VERSION(3, 0, 0)
 static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
@@ -1301,10 +1315,21 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
 return;
 }
 
+#ifdef VTE_RESIZE_HACK
+vc = gd_vc_find_current(s);
+if (vc && vc->type == GD_VC_VTE) {
+gtk_widget_hide(vc->vte.terminal);
+}
+#endif
 vc = gd_vc_find_by_page(s, arg2);
 if (!vc) {
 return;
 }
+#ifdef VTE_RESIZE_HACK
+if (vc->type == GD_VC_VTE) {
+gtk_widget_show(vc->vte.terminal);
+}
+#endif
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item),
TRUE);
 on_vga = (vc->type == GD_VC_GFX);
@@ -1845,6 +1870,21 @@ void gtk_display_init(DisplayState *ds, bool 
full_screen, bool grab_on_hover)
 
 gtk_widget_show_all(s->window);
 
+#ifdef VTE_RESIZE_HACK
+{
+VirtualConsole *cur = gd_vc_find_current(s);
+int i;
+
+for (i = 0; i < s->nb_vcs; i++) {
+VirtualConsole *vc = &s->vc[i];
+if (vc && vc->type == GD_VC_VTE && vc != cur) {
+gtk_widget_hide(vc->vte.terminal);
+}
+}
+gd_update_windowsize(cur);
+}
+#endif
+
 if (full_screen) {
 gtk_menu_item_activate(GTK_MENU_ITEM(s->full_screen_item));
 }
-- 
1.8.3.1




[Qemu-devel] [PATCH 07/25] gtk: move vga state into VirtualGfxConsole

2014-05-21 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 615 ++-
 1 file changed, 337 insertions(+), 278 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 78f6ccc..bc42f68 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -105,6 +105,18 @@ static const int modifier_keycode[] = {
 0x2a, 0x36, 0x1d, 0x9d, 0x38, 0xb8, 0xdb, 0xdd,
 };
 
+typedef struct GtkDisplayState GtkDisplayState;
+
+typedef struct VirtualGfxConsole {
+GtkWidget *drawing_area;
+DisplayChangeListener dcl;
+DisplaySurface *ds;
+pixman_image_t *convert;
+cairo_surface_t *surface;
+double scale_x;
+double scale_y;
+} VirtualGfxConsole;
+
 #if defined(CONFIG_VTE)
 typedef struct VirtualVteConsole {
 GtkWidget *box;
@@ -114,18 +126,25 @@ typedef struct VirtualVteConsole {
 } VirtualVteConsole;
 #endif
 
+typedef enum VirtualConsoleType {
+GD_VC_GFX,
+GD_VC_VTE,
+} VirtualConsoleType;
+
 typedef struct VirtualConsole {
+GtkDisplayState *s;
 GtkWidget *menu_item;
 GtkWidget *tab_item;
+VirtualConsoleType type;
 union {
+VirtualGfxConsole gfx;
 #if defined(CONFIG_VTE)
 VirtualVteConsole vte;
 #endif
 };
 } VirtualConsole;
 
-typedef struct GtkDisplayState
-{
+struct GtkDisplayState {
 GtkWidget *window;
 
 GtkWidget *menu_bar;
@@ -148,7 +167,6 @@ typedef struct GtkDisplayState
 GtkWidget *zoom_fit_item;
 GtkWidget *grab_item;
 GtkWidget *grab_on_hover_item;
-GtkWidget *vga_item;
 
 int nb_vcs;
 VirtualConsole vc[MAX_VCS];
@@ -157,11 +175,6 @@ typedef struct GtkDisplayState
 
 GtkWidget *vbox;
 GtkWidget *notebook;
-GtkWidget *drawing_area;
-cairo_surface_t *surface;
-pixman_image_t *convert;
-DisplayChangeListener dcl;
-DisplaySurface *ds;
 int button_mask;
 gboolean last_set;
 int last_x;
@@ -169,8 +182,6 @@ typedef struct GtkDisplayState
 int grab_x_root;
 int grab_y_root;
 
-double scale_x;
-double scale_y;
 gboolean full_screen;
 
 GdkCursor *null_cursor;
@@ -180,7 +191,7 @@ typedef struct GtkDisplayState
 bool external_pause_update;
 
 bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
-} GtkDisplayState;
+};
 
 static GtkDisplayState *global_state;
 
@@ -216,6 +227,14 @@ static VirtualConsole *gd_vc_find_by_page(GtkDisplayState 
*s, gint page)
 return NULL;
 }
 
+static VirtualConsole *gd_vc_find_current(GtkDisplayState *s)
+{
+gint page;
+
+page = gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook));
+return gd_vc_find_by_page(s, page);
+}
+
 static bool gd_is_grab_active(GtkDisplayState *s)
 {
 return gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_item));
@@ -226,26 +245,17 @@ static bool gd_grab_on_hover(GtkDisplayState *s)
 return 
gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(s->grab_on_hover_item));
 }
 
-static bool gd_on_vga(GtkDisplayState *s)
-{
-gint p1, p2;
-
-p1 = gtk_notebook_get_current_page(GTK_NOTEBOOK(s->notebook));
-p2 = gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), s->drawing_area);
-return p1 == p2;
-}
-
-static void gd_update_cursor(GtkDisplayState *s, gboolean override)
+static void gd_update_cursor(VirtualConsole *vc)
 {
+GtkDisplayState *s = vc->s;
 GdkWindow *window;
-bool on_vga;
-
-window = gtk_widget_get_window(GTK_WIDGET(s->drawing_area));
 
-on_vga = gd_on_vga(s);
+if (vc->type != GD_VC_GFX) {
+return;
+}
 
-if ((override || on_vga) &&
-(s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s))) {
+window = gtk_widget_get_window(GTK_WIDGET(vc->gfx.drawing_area));
+if (s->full_screen || qemu_input_is_absolute() || gd_is_grab_active(s)) {
 gdk_window_set_cursor(window, s->null_cursor);
 } else {
 gdk_window_set_cursor(window, NULL);
@@ -282,26 +292,29 @@ static void gd_update_caption(GtkDisplayState *s)
 g_free(title);
 }
 
-static void gd_update_windowsize(GtkDisplayState *s)
+static void gd_update_windowsize(VirtualConsole *vc)
 {
+GtkDisplayState *s = vc->s;
+
 if (!s->full_screen) {
 GtkRequisition req;
 double sx, sy;
 
 if (s->free_scale) {
-sx = s->scale_x;
-sy = s->scale_y;
+sx = vc->gfx.scale_x;
+sy = vc->gfx.scale_y;
 
-s->scale_y = 1.0;
-s->scale_x = 1.0;
+vc->gfx.scale_y = 1.0;
+vc->gfx.scale_x = 1.0;
 } else {
 sx = 1.0;
 sy = 1.0;
 }
 
-gtk_widget_set_size_request(s->drawing_area,
-surface_width(s->ds) * s->scale_x,
-surface_height(s->ds) * s->scale_y);
+gtk_widget_set_size_request
+(vc->gfx.drawing_area,
+ surface_width(vc->gfx.ds) * vc->gfx.scale_x,
+ surface_height(vc->gfx.ds) * vc->gfx.scale_y);
 #if GTK_CHECK_VERSION(3, 0, 0)

Re: [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Igor Mammedov
On Wed, 21 May 2014 12:27:05 +0400
Andrey Korolyov  wrote:

> On Wed, May 21, 2014 at 12:10 PM, Michael S. Tsirkin  wrote:
> > On Tue, May 20, 2014 at 05:15:08PM +0200, Igor Mammedov wrote:
> >> Add following parameters:
> >>   "slots" - total number of hotplug memory slots
> >>   "maxmem" - maximum possible memory
> >>
> >> "slots" and "maxmem" should go in pair and "maxmem" should be greater
> >> than "mem" for memory hotplug to be enabled.
> >>
> >> Signed-off-by: Igor Mammedov 
> >
> > Also, it's a bug to mix this with a compat machine type, right?
> > Maybe best to fail initialization if users try this.
> >
> >> ---
> >> v4:
> >>  - store maxmem & slots values in MachineState
> >> v3:
> >>  - store maxmem & slots values in QEMUMachineInitArgs
> >> v2:
> >>  - rebased on top of the latest "vl: convert -m to QemuOpts"
> >> ---
> >>  include/hw/boards.h |3 ++-
> >>  qemu-options.hx |9 ++---
> >>  vl.c|   51 
> >> +++
> >>  3 files changed, 59 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/include/hw/boards.h b/include/hw/boards.h
> >> index b62de4a..f6fbbe1 100644
> >> --- a/include/hw/boards.h
> >> +++ b/include/hw/boards.h
> >> @@ -8,7 +8,6 @@
> >>  #include "hw/qdev.h"
> >>  #include "qom/object.h"
> >>
> >> -
> >>  typedef struct MachineState MachineState;
> >>
> >>  typedef void QEMUMachineInitFunc(MachineState *ms);
> >> @@ -113,6 +112,8 @@ struct MachineState {
> >>  char *firmware;
> >>
> >>  ram_addr_t ram_size;
> >> +ram_addr_t maxram_size;
> >> +uint64_t   ram_slots;
> >>  const char *boot_order;
> >>  const char *kernel_filename;
> >>  const char *kernel_cmdline;
> >> diff --git a/qemu-options.hx b/qemu-options.hx
> >> index 781af14..c6411c4 100644
> >> --- a/qemu-options.hx
> >> +++ b/qemu-options.hx
> >> @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
> >> versions.
> >>  ETEXI
> >>
> >>  DEF("m", HAS_ARG, QEMU_OPTION_m,
> >> -"-m [size=]megs\n"
> >> +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
> >>  "configure guest RAM\n"
> >>  "size: initial amount of guest memory (default: "
> >> -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
> >> +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
> >> +"slots: number of hotplug slots (default: none)\n"
> >> +"maxmem: maximum amount of guest memory (default: 
> >> none)\n",
> >>  QEMU_ARCH_ALL)
> >>  STEXI
> >>  @item -m [size=]@var{megs}
> >>  @findex -m
> >>  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
> >> Optionally,
> >>  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
> >> -gigabytes respectively.
> >> +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be 
> >> used
> >> +to set amount of hotluggable memory slots and possible maximum amount of 
> >> memory.
> >>  ETEXI
> >>
> >>  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
> >> diff --git a/vl.c b/vl.c
> >> index 8fd4ed9..9fb6fa4 100644
> >> --- a/vl.c
> >> +++ b/vl.c
> >> @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
> >>  .name = "size",
> >>  .type = QEMU_OPT_SIZE,
> >>  },
> >> +{
> >> +.name = "slots",
> >> +.type = QEMU_OPT_NUMBER,
> >> +},
> >> +{
> >> +.name = "maxmem",
> >> +.type = QEMU_OPT_SIZE,
> >> +},
> >>  { /* end of list */ }
> >>  },
> >>  };
> >> @@ -2989,6 +2997,8 @@ int main(int argc, char **argv, char **envp)
> >>  const char *trace_file = NULL;
> >>  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
> >>  1024 * 1024;
> >> +ram_addr_t maxram_size = default_ram_size;
> >> +uint64_t ram_slots = 0;
> >>
> >>  atexit(qemu_run_exit_notifiers);
> >>  error_set_progname(argv[0]);
> >> @@ -3324,6 +3334,7 @@ int main(int argc, char **argv, char **envp)
> >>  case QEMU_OPTION_m: {
> >>  uint64_t sz;
> >>  const char *mem_str;
> >> +const char *maxmem_str, *slots_str;
> >>
> >>  opts = qemu_opts_parse(qemu_find_opts("memory"),
> >> optarg, 1);
> >> @@ -3365,6 +3376,44 @@ int main(int argc, char **argv, char **envp)
> >>  error_report("ram size too large");
> >>  exit(EXIT_FAILURE);
> >>  }
> >> +
> >> +maxmem_str = qemu_opt_get(opts, "maxmem");
> >> +slots_str = qemu_opt_get(opts, "slots");
> >> +if (maxmem_str && slots_str) {
> >> +uint64_t slots;
> >> +
> >> +sz = qemu_opt_get_size(opts, "maxmem", 0);
> >> +if (sz < ram_size) {
> >> +fprintf(stderr, "qemu: invalid -m option value: 

[Qemu-devel] [PULL 2/2] hw/audio/intel-hda: Avoid shift into sign bit

2014-05-21 Thread Gerd Hoffmann
From: Peter Maydell 

Add a U suffix to avoid shifting into the sign bit (which is
undefined behaviour in C).

Signed-off-by: Peter Maydell 
Signed-off-by: Gerd Hoffmann 
---
 hw/audio/intel-hda.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 9e075c0..3cfb66c 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -245,7 +245,7 @@ static void intel_hda_update_int_sts(IntelHDAState *d)
 
 /* update global status */
 if (sts & d->int_ctl) {
-sts |= (1 << 31);
+sts |= (1U << 31);
 }
 
 d->int_sts = sts;
@@ -257,7 +257,7 @@ static void intel_hda_update_irq(IntelHDAState *d)
 int level;
 
 intel_hda_update_int_sts(d);
-if (d->int_sts & (1 << 31) && d->int_ctl & (1 << 31)) {
+if (d->int_sts & (1U << 31) && d->int_ctl & (1U << 31)) {
 level = 1;
 } else {
 level = 0;
-- 
1.8.3.1




[Qemu-devel] [PATCH 23/25] gtk: window sizing overhaul

2014-05-21 Thread Gerd Hoffmann
Major overhaul for window size handling.  This basically switches qemu
over to use geometry hints for the window manager instead of trying to
get the job done with widget resize requests.  This allows to specify
better what we need and also avoids window resizes.

FIXME: on gtk2 someone overwrites the geometry hints :(

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 100 ---
 1 file changed, 70 insertions(+), 30 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 0d86025..ac5dbe0 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -74,6 +74,12 @@
 #endif
 
 #define MAX_VCS 10
+#define VC_WINDOW_X_MIN  320
+#define VC_WINDOW_Y_MIN  240
+#define VC_TERM_X_MIN 80
+#define VC_TERM_Y_MIN 25
+#define VC_SCALE_MIN0.25
+#define VC_SCALE_STEP   0.25
 
 #if !defined(CONFIG_VTE)
 # define VTE_CHECK_VERSION(a, b, c) 0
@@ -322,29 +328,63 @@ static void gd_update_caption(GtkDisplayState *s)
 g_free(prefix);
 }
 
-static void gd_update_windowsize(VirtualConsole *vc)
+static void gd_update_geometry_hints(VirtualConsole *vc)
 {
 GtkDisplayState *s = vc->s;
-double sx, sy;
+GdkWindowHints mask = 0;
+GdkGeometry geo = {};
+GtkWidget *geo_widget = NULL;
+GtkWindow *geo_window;
 
-if (vc->type != GD_VC_GFX || s->full_screen) {
-return;
+if (vc->type == GD_VC_GFX) {
+if (s->free_scale) {
+geo.min_width  = surface_width(vc->gfx.ds) * VC_SCALE_MIN;
+geo.min_height = surface_height(vc->gfx.ds) * VC_SCALE_MIN;
+mask |= GDK_HINT_MIN_SIZE;
+} else {
+geo.min_width  = surface_width(vc->gfx.ds) * vc->gfx.scale_x;
+geo.min_height = surface_height(vc->gfx.ds) * vc->gfx.scale_y;
+mask |= GDK_HINT_MIN_SIZE;
+}
+geo_widget = vc->gfx.drawing_area;
+gtk_widget_set_size_request(geo_widget, geo.min_width, geo.min_height);
+
+#if defined(CONFIG_VTE)
+} else if (vc->type == GD_VC_VTE) {
+VteTerminal *term = VTE_TERMINAL(vc->vte.terminal);
+GtkBorder *ib;
+
+geo.width_inc  = vte_terminal_get_char_width(term);
+geo.height_inc = vte_terminal_get_char_height(term);
+mask |= GDK_HINT_RESIZE_INC;
+geo.base_width  = geo.width_inc;
+geo.base_height = geo.height_inc;
+mask |= GDK_HINT_BASE_SIZE;
+geo.min_width  = geo.width_inc * VC_TERM_X_MIN;
+geo.min_height = geo.height_inc * VC_TERM_Y_MIN;
+mask |= GDK_HINT_MIN_SIZE;
+gtk_widget_style_get(vc->vte.terminal, "inner-border", &ib, NULL);
+geo.base_width  += ib->left + ib->right;
+geo.base_height += ib->top + ib->bottom;
+geo.min_width   += ib->left + ib->right;
+geo.min_height  += ib->top + ib->bottom;
+geo_widget = vc->vte.terminal;
+#endif
 }
 
-if (s->free_scale) {
-sx = 1.0;
-sy = 1.0;
-} else {
-sx = vc->gfx.scale_x;
-sy = vc->gfx.scale_y;
-}
-gtk_widget_set_size_request(vc->gfx.drawing_area,
-surface_width(vc->gfx.ds) * sx,
-surface_height(vc->gfx.ds) * sy);
-if (vc->window) {
-gtk_window_resize(GTK_WINDOW(vc->window), 320, 240);
-} else {
-gtk_window_resize(GTK_WINDOW(s->window), 320, 240);
+geo_window = GTK_WINDOW(vc->window ? vc->window : s->window);
+gtk_window_set_geometry_hints(geo_window, geo_widget, &geo, mask);
+}
+
+static void gd_update_windowsize(VirtualConsole *vc)
+{
+GtkDisplayState *s = vc->s;
+
+gd_update_geometry_hints(vc);
+
+if (vc->type == GD_VC_GFX && !s->full_screen && !s->free_scale) {
+gtk_window_resize(GTK_WINDOW(vc->window ? vc->window : s->window),
+  VC_WINDOW_X_MIN, VC_WINDOW_Y_MIN);
 }
 }
 
@@ -991,7 +1031,7 @@ static void gd_menu_untabify(GtkMenuItem *item, void 
*opaque)
 GClosure *cb = g_cclosure_new_swap(G_CALLBACK(gd_win_grab), vc, NULL);
 gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb);
 
-fprintf(stderr, "%s: %p\n", __func__, vc);
+gd_update_geometry_hints(vc);
 gd_update_caption(s);
 }
 }
@@ -1019,9 +1059,7 @@ static void gd_menu_full_screen(GtkMenuItem *item, void 
*opaque)
 if (vc->type == GD_VC_GFX) {
 vc->gfx.scale_x = 1.0;
 vc->gfx.scale_y = 1.0;
-gtk_widget_set_size_request(vc->gfx.drawing_area,
-surface_width(vc->gfx.ds),
-surface_height(vc->gfx.ds));
+gd_update_windowsize(vc);
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->grab_item),
FALSE);
 }
@@ -1038,8 +1076,8 @@ static void gd_menu_zoom_in(GtkMenuItem *item, void 
*opaque)
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(s->zoom_fit_item),
FALSE);
 
-   

Re: [Qemu-devel] [PATCH v2 4/8] spapr: Move interrupt allocator to xics

2014-05-21 Thread Alexander Graf


On 21.05.14 10:46, Alexey Kardashevskiy wrote:

On 05/21/2014 06:34 PM, Alexander Graf wrote:

On 15.05.14 11:59, Alexey Kardashevskiy wrote:

The current allocator returns IRQ numbers from a pool and does not
support IRQs reuse in any form as it did not keep track of what it
previously returned, it only keeps the last returned IRQ. Some use
cases such as PCI hot(un)plug may require IRQ release and reallocation.

This moves an allocator from SPAPR to XICS.

This switches IRQ users to use new API.

This uses LSI/MSI flags to know if interrupt is allocated.

The interrupt release function will be posted as a separate patch.

Signed-off-by: Alexey Kardashevskiy 
---
   hw/intc/xics.c | 88
++
   hw/ppc/spapr.c | 67 --
   hw/ppc/spapr_events.c  |  2 +-
   hw/ppc/spapr_pci.c |  6 ++--
   hw/ppc/spapr_vio.c |  2 +-
   include/hw/ppc/spapr.h | 10 --
   include/hw/ppc/xics.h  |  2 ++
   trace-events   |  4 +++
   8 files changed, 99 insertions(+), 82 deletions(-)

diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 83a809e..fdcbb3a 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -689,6 +689,94 @@ void xics_set_irq_type(XICSState *icp, int irq, bool
lsi)
   ics_set_irq_type(ics, irq - ics->offset, lsi);
   }
   +#define ICS_IRQ_FREE(ics, srcno)   \
+(!((ics)->irqs[(srcno)].flags & (XICS_FLAGS_IRQ_MASK)))
+
+static int ics_find_free_block(ICSState *ics, int num, int alignnum)
+{
+int first, i;
+
+for (first = 0; first < ics->nr_irqs; first += alignnum) {
+if (num > (ics->nr_irqs - first)) {
+return -1;
+}
+for (i = first; i < first + num; ++i) {
+if (!ICS_IRQ_FREE(ics, i)) {
+break;
+}
+}
+if (i == (first + num)) {
+return first;
+}
+}
+
+return -1;
+}
+
+int xics_alloc(XICSState *icp, int src, int irq_hint, bool lsi)
+{
+ICSState *ics = &icp->ics[src];
+int irq;
+
+if (irq_hint) {
+assert(src == xics_find_source(icp, irq_hint));

Could this ever get triggered by a guest? Why don't we just fail as if the
IRQ wasn't available?

The @irq_hist is only used when the user specified IRQ in the command line,
this is why it is assert. And the guest never gets to choose IRQ number, it
receives numbers either via device tree (and QEMU puts those numbers there,
not SLOF) or ibm,change-msi (QEMU returns numbers).


Ok, it's safe then :).


Alex





[Qemu-devel] [PULL 1/2] audio/intel-hda: support FIFORDY

2014-05-21 Thread Gerd Hoffmann
From: Stanislav Vorobiov 

linux kernel 3.12 has changed intel-hda
driver to always check for FIFORDY, this
causes long hangs in guest since QEMU
always has this bit set to 0. We now simply set
it to 1 always, since we're synchronous anyway
and always ready to receive the stream

Signed-off-by: Stanislav Vorobiov 
Signed-off-by: Gerd Hoffmann 
---
 hw/audio/intel-hda.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index d41f82c..9e075c0 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -574,7 +574,7 @@ static void intel_hda_set_st_ctl(IntelHDAState *d, const 
IntelHDAReg *reg, uint3
 if (st->ctl & 0x01) {
 /* reset */
 dprint(d, 1, "st #%d: reset\n", reg->stream);
-st->ctl = 0;
+st->ctl = SD_STS_FIFO_READY << 24;
 }
 if ((st->ctl & 0x02) != (old & 0x02)) {
 uint32_t stnr = (st->ctl >> 20) & 0x0f;
@@ -829,6 +829,7 @@ static const struct IntelHDAReg regtab[] = {
 .wclear   = 0x1c00,   \
 .offset   = offsetof(IntelHDAState, st[_i].ctl),  \
 .whandler = intel_hda_set_st_ctl, \
+.reset= SD_STS_FIFO_READY << 24   \
 },\
 [ ST_REG(_i, ICH6_REG_SD_LPIB) ] = {  \
 .stream   = _i,   \
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 06:40 PM, Alexander Graf wrote:
> 
> On 15.05.14 11:59, Alexey Kardashevskiy wrote:
>> Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
>> XICS used to be unable to reuse interrupts which becomes a problem for
>> dynamic MSI reconfiguration which is happening on guest driver reload or
>> PCI hot (un)plug. Another problem is that PHB has a limit of devices
>> supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
>> for that.
>>
>> This makes use of new XICS ability to reuse interrupts.
>>
>> This removes cached MSI configuration from SPAPR PHB so the first IRQ number
>> of a device is stored in MSI/MSIX config space so there is no need to store
>> this anywhere else. From now on, SPAPR PHB only keeps flags telling what
>> type
>> of interrupt for which device it has configured in order to return error if
>> (for example) MSIX was enabled and the guest is trying to disable MSI which
>> it has not enabled.
>>
>> This removes a limit for the maximum number of MSIX-enabled devices per PHB,
>> now XICS and PCI bus capacity are the only limitation.
>>
>> This changes migration stream as it fixes vmstate_spapr_pci_msi::name
>> which was
>> wrong since the beginning.
>>
>> This fixed traces to be more informative.
>>
>> Signed-off-by: Alexey Kardashevskiy 
>> ---
>>
>> In reality either MSIX or MSI is enabled, never both. So I could remove
>> msi/msix
>> bitmaps from this patch, would it make sense?
> 
> Is this a hard requirement? Does a device have to choose between MSIX and
> MSI or could it theoretically have both enabled? Is this a PCI limitation,
> a PAPR/XICS limitation or just a limitation of your implementation?


My implementation does not have this limitation, I asked if I can simplify
code by introducing one :)

I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
it does not seem to be used by anyone => cannot debug and confirm.

PAPR spec assumes that if the guest tries enabling MSIX when MSI is already
enabled, this is a "change", not enabling both types. But it also says MSI
and MSIX vector numbers are not shared. Hm.


-- 
Alexey



[Qemu-devel] [PATCH v2] virtio-balloon: return empty data when no stats are available

2014-05-21 Thread Ján Tomko
If the guest hasn't updated the stats yet, instead of returning
an error, return '-1' for the stats and '0' as 'last-update'.

This lets applications ignore this without parsing the error message.

Related libvirt patch and discussion:
https://www.redhat.com/archives/libvir-list/2014-May/msg00460.html

Tested against current upstream libvirt - stat reporting works and
it no longer logs errors when the stats are queried on domain startup.
(Note: libvirt doesn't use the last-update field for anything yet)

Signed-off-by: Ján Tomko 
---
v1: https://lists.gnu.org/archive/html/qemu-devel/2014-05/msg03643.html
  Reviewed-by: Eric Blake 
v2:
  rebased
  added documentation changes
  mentioned testing in the commit message

 docs/virtio-balloon-stats.txt | 5 +++--
 hw/virtio/virtio-balloon.c| 7 ++-
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/docs/virtio-balloon-stats.txt b/docs/virtio-balloon-stats.txt
index f74612f..edff5f2 100644
--- a/docs/virtio-balloon-stats.txt
+++ b/docs/virtio-balloon-stats.txt
@@ -35,7 +35,8 @@ which will return a dictionary containing:
 
   o A key named last-update, which contains the last stats update
 timestamp in seconds. Since this timestamp is generated by the host,
-a buggy guest can't influence its value
+a buggy guest can't influence its value. The value is 0 if the guest
+has not updated the stats (yet).
 
 It's also important to note the following:
 
@@ -49,7 +50,7 @@ It's also important to note the following:
 
  - Polling can be enabled even if the guest doesn't have stats support
or the balloon driver wasn't loaded in the guest. If this is the case
-   and stats are queried, an error will be returned
+   and stats are queried, last-update will be 0.
 
  - The polling timer is only re-armed when the guest responds to the
statistics request. This means that if a (buggy) guest doesn't ever
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index bf2b588..22cd52e 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -112,11 +112,6 @@ static void balloon_stats_get_all(Object *obj, struct 
Visitor *v,
 VirtIOBalloon *s = opaque;
 int i;
 
-if (!s->stats_last_update) {
-error_setg(errp, "guest hasn't updated any stats yet");
-return;
-}
-
 visit_start_struct(v, NULL, "guest-stats", name, 0, &err);
 if (err) {
 goto out;
@@ -378,6 +373,8 @@ static void virtio_balloon_device_realize(DeviceState *dev, 
Error **errp)
 s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
 s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
 
+reset_stats(s);
+
 register_savevm(dev, "virtio-balloon", -1, 1,
 virtio_balloon_save, virtio_balloon_load, s);
 
-- 
1.8.3.2




[Qemu-devel] [PATCH 04/25] gtk: Add a scrollbar for text consoles

2014-05-21 Thread Gerd Hoffmann
From: Cole Robinson 

Only show the scrollbar if the content doesn't fit on the visible space.

[ kraxel: fix box packing ]

Signed-off-by: Cole Robinson 
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 42 --
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 068a39b..6a3fe00 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -109,6 +109,8 @@ typedef struct VirtualConsole
 {
 GtkWidget *menu_item;
 #if defined(CONFIG_VTE)
+GtkWidget *box;
+GtkWidget *scrollbar;
 GtkWidget *terminal;
 CharDriverState *chr;
 #endif
@@ -1125,6 +1127,18 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
 /** Virtual Console Callbacks **/
 
 #if defined(CONFIG_VTE)
+static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
+{
+VirtualConsole *vc = opaque;
+
+if (gtk_adjustment_get_upper(adjustment) >
+gtk_adjustment_get_page_size(adjustment)) {
+gtk_widget_show(vc->scrollbar);
+} else {
+gtk_widget_hide(vc->scrollbar);
+}
+}
+
 static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
 VirtualConsole *vc = chr->opaque;
@@ -1165,6 +1179,9 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 const char *label;
 char buffer[32];
 char path[32];
+GtkWidget *box;
+GtkWidget *scrollbar;
+GtkAdjustment *vadjustment;
 
 snprintf(buffer, sizeof(buffer), "vc%d", index);
 snprintf(path, sizeof(path), "/View/VC%d", index);
@@ -1186,12 +1203,33 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 g_signal_connect(vc->terminal, "commit", G_CALLBACK(gd_vc_in), vc);
 
 vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->terminal), -1);
-
 vte_terminal_set_size(VTE_TERMINAL(vc->terminal), 80, 25);
 
+#if VTE_CHECK_VERSION(0, 28, 0) && GTK_CHECK_VERSION(3, 0, 0)
+vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(vc->terminal));
+#else
+vadjustment = vte_terminal_get_adjustment(VTE_TERMINAL(vc->terminal));
+#endif
+
+#if GTK_CHECK_VERSION(3, 0, 0)
+box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
+scrollbar = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, vadjustment);
+#else
+box = gtk_hbox_new(false, 2);
+scrollbar = gtk_vscrollbar_new(vadjustment);
+#endif
+
+gtk_box_pack_start(GTK_BOX(box), vc->terminal, TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(box), scrollbar, FALSE, FALSE, 0);
+
 vc->chr->opaque = vc;
+vc->box = box;
+vc->scrollbar = scrollbar;
+
+g_signal_connect(vadjustment, "changed",
+ G_CALLBACK(gd_vc_adjustment_changed), vc);
 
-gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->terminal,
+gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), box,
  gtk_label_new(label));
 g_signal_connect(vc->menu_item, "activate",
  G_CALLBACK(gd_menu_switch_vc), s);
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH] e1000: allow command-line selection of card model

2014-05-21 Thread Michael S. Tsirkin
On Wed, May 21, 2014 at 10:40:54AM +0200, Andreas Färber wrote:
> Hi,
> 
> Am 20.05.2014 17:05, schrieb Gabriel L. Somlo:
> > Allow selection of different card models from the qemu
> > command line, to better accomodate a wider range of guests.
> > 
> > Based-on-patch-by: Romain Dolbeau 
> 
> If that patch carried a Signed-off-by line, you should retain it.

Actually I think that would be confusing. Romain didn't sign off
on *this* patch, he signed off on a previous one.
A signature by Gabriel indicates Developer's Certificate of Origin 1.1
which has an option to incorporate other's work - it
does not seem to require signatures by these others.


> Your
> From: line already indicates that it has been rewritten since.
> 
> > Signed-off-by: Gabriel Somlo 
> > ---
> > 
> > Based on the conversation in [2,3,4], and given that I would still like
> > OS X to work as close to "out of the box" as possible, I took a stab
> > at isolating just the bits that allow command-line selection of the
> > specific e1000 device model from Romain's patch set [1]. Hope that's
> > OK with everyone :)
> > 
> > Beyond a few small style improvements, I'm still not 100% familiar with
> > QOM, so I wonder if there isn't a cleaner way to offer "e1000" as some
> > sort of "alias" to the default 82540EM, instead of listing two different
> > devices (e1000 and 82540EM) with otherwise 100% identical properties.
> > However, if the patch is acceptable as-is, I'm happy to leave it be... :)
> > 
> > I tested this on Windows 7 (where the default e1000 continues to work
> > as before), Linux (F20, which is fine with either model), and OS X
> > (10.9 requires E1000_DEV_ID_82545EM_COPPER, which also works with prior
> > versions starting at 10.6; and the default e1000 works on versions <= 10.8).
> > 
> > Comments, suggestions, (or even a straight-forward upstream acceptance
> > of the patch) much appreciated ! :)
> > 
> > Thanks,
> >Gabriel
> > 
> > [1] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01397.html
> > [2] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01831.html
> > [3] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg01841.html
> > [4] http://lists.nongnu.org/archive/html/qemu-devel/2014-03/msg03669.html
> > 
> >  hw/net/e1000.c | 97 
> > --
> >  1 file changed, 80 insertions(+), 17 deletions(-)
> > 
> > diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> > index 8387443..92323a3 100644
> > --- a/hw/net/e1000.c
> > +++ b/hw/net/e1000.c
> > @@ -69,23 +69,29 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL);
> >  
> >  /*
> >   * HW models:
> > - *  E1000_DEV_ID_82540EM works with Windows and Linux
> > + *  E1000_DEV_ID_82540EM works with Windows, Linux, and OS X <= 10.8
> >   *  E1000_DEV_ID_82573L OK with windoze and Linux 2.6.22,
> >   * appears to perform better than 82540EM, but breaks with Linux 2.6.18
> >   *  E1000_DEV_ID_82544GC_COPPER appears to work; not well tested
> > + *  E1000_DEV_ID_82545EM_COPPER works with Linux and OS X >= 10.6
> >   *  Others never tested
> >   */
> > -enum { E1000_DEVID = E1000_DEV_ID_82540EM };
> >  
> >  /*
> >   * May need to specify additional MAC-to-PHY entries --
> >   * Intel's Windows driver refuses to initialize unless they match
> >   */
> > -enum {
> > -PHY_ID2_INIT = E1000_DEVID == E1000_DEV_ID_82573L ?0xcc2 :
> > -   E1000_DEVID == E1000_DEV_ID_82544GC_COPPER ?0xc30 :
> > -   /* default to E1000_DEV_ID_82540EM */   0xc20
> > -};
> > +static uint16_t
> 
>static inline uint16_t maybe?

inline in c file is an optimization hint for a compiler, so
really useless without a benchmark.
It's useful in headers since some compilers warn about unused
non-inline static functions.

> > +e1000_phy_id2_init(uint16_t dev_id) {
> > +switch(dev_id) {
> 
>switch (dev_id) {
> 
> > +case E1000_DEV_ID_82573L:
> > +return 0xcc2;
> > +case E1000_DEV_ID_82544GC_COPPER:
> > +return 0xc30;
> > +default:
> > +return 0xc20; /* default for 82540EM and others */
> > +}
> > +}
> >  
> >  typedef struct E1000State_st {
> >  /*< private >*/
> > @@ -151,7 +157,7 @@ typedef struct E1000State_st {
> >  uint32_t compat_flags;
> >  } E1000State;
> >  
> > -#define TYPE_E1000 "e1000"
> > +#define TYPE_E1000 "e1000-base"
> >  
> >  #define E1000(obj) \
> >  OBJECT_CHECK(E1000State, (obj), TYPE_E1000)
> > @@ -235,7 +241,7 @@ static const char phy_regcap[0x20] = {
> >  static const uint16_t phy_reg_init[] = {
> >  [PHY_CTRL] = 0x1140,
> >  [PHY_STATUS] = 0x794d, /* link initially up with not completed autoneg 
> > */
> > -[PHY_ID1] = 0x141, [PHY_ID2] = 
> > PHY_ID2_INIT,
> > +[PHY_ID1] = 0x141, /* [PHY_ID2] configured per DevId, from 
> > e1000_reset() */
> >  [PHY_1000T_CTRL] = 0x0e00, 
> > [M88E1000_PHY_SPEC_CTRL] = 0x36

Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Alexander Graf


On 21.05.14 10:52, Alexey Kardashevskiy wrote:

On 05/21/2014 06:40 PM, Alexander Graf wrote:

On 15.05.14 11:59, Alexey Kardashevskiy wrote:

Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
XICS used to be unable to reuse interrupts which becomes a problem for
dynamic MSI reconfiguration which is happening on guest driver reload or
PCI hot (un)plug. Another problem is that PHB has a limit of devices
supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
for that.

This makes use of new XICS ability to reuse interrupts.

This removes cached MSI configuration from SPAPR PHB so the first IRQ number
of a device is stored in MSI/MSIX config space so there is no need to store
this anywhere else. From now on, SPAPR PHB only keeps flags telling what
type
of interrupt for which device it has configured in order to return error if
(for example) MSIX was enabled and the guest is trying to disable MSI which
it has not enabled.

This removes a limit for the maximum number of MSIX-enabled devices per PHB,
now XICS and PCI bus capacity are the only limitation.

This changes migration stream as it fixes vmstate_spapr_pci_msi::name
which was
wrong since the beginning.

This fixed traces to be more informative.

Signed-off-by: Alexey Kardashevskiy 
---

In reality either MSIX or MSI is enabled, never both. So I could remove
msi/msix
bitmaps from this patch, would it make sense?

Is this a hard requirement? Does a device have to choose between MSIX and
MSI or could it theoretically have both enabled? Is this a PCI limitation,
a PAPR/XICS limitation or just a limitation of your implementation?


My implementation does not have this limitation, I asked if I can simplify
code by introducing one :)

I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
it does not seem to be used by anyone => cannot debug and confirm.

PAPR spec assumes that if the guest tries enabling MSIX when MSI is already
enabled, this is a "change", not enabling both types. But it also says MSI
and MSIX vector numbers are not shared. Hm.


Yeah, I'm not aware of any limitation on hardware here and I'd rather 
not impose one.


Michael, do you know of any hardware that uses MSI *and* MSI-X at the 
same time?



Alex




[Qemu-devel] [PATCH 02/25] gtk: zap vte size requests

2014-05-21 Thread Gerd Hoffmann
The vte tabs simply get the size of the vga tab then, with whatever
cols and lines are fitting in.  I find this bahavior more useful than
resizing the qemu window all day long.

YMMV.  Comments are welcome.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index f6f3677..776e72d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1058,19 +1058,12 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
gpointer data)
 {
 GtkDisplayState *s = data;
-guint last_page;
 gboolean on_vga;
 
 if (!gtk_widget_get_realized(s->notebook)) {
 return;
 }
 
-last_page = gtk_notebook_get_current_page(nb);
-
-if (last_page) {
-gtk_widget_set_size_request(s->vc[last_page - 1].terminal, -1, -1);
-}
-
 on_vga = arg2 == 0;
 
 if (!on_vga) {
@@ -1086,14 +1079,7 @@ static void gd_change_page(GtkNotebook *nb, gpointer 
arg1, guint arg2,
 } else {
 #if defined(CONFIG_VTE)
 VirtualConsole *vc = &s->vc[arg2 - 1];
-VteTerminal *term = VTE_TERMINAL(vc->terminal);
-int width, height;
-
-width = 80 * vte_terminal_get_char_width(term);
-height = 25 * vte_terminal_get_char_height(term);
-
 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(vc->menu_item), 
TRUE);
-gtk_widget_set_size_request(vc->terminal, width, height);
 #else
 g_assert_not_reached();
 #endif
-- 
1.8.3.1




[Qemu-devel] [PULL 0/2] audio: two intel-hda fixes.

2014-05-21 Thread Gerd Hoffmann
  Hi,

$sibject says all.

please pull,
  Gerd

The following changes since commit c5fa6c86d0765f837515d1c10654c621724a77e0:

  Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging 
(2014-05-19 14:10:01 +0100)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-audio-5

for you to fetch changes up to b1fe60cd3525871a4c593ad8c2b39b89c19c00d0:

  hw/audio/intel-hda: Avoid shift into sign bit (2014-05-20 08:49:21 +0200)


audio: two intel-hda fixes.


Peter Maydell (1):
  hw/audio/intel-hda: Avoid shift into sign bit

Stanislav Vorobiov (1):
  audio/intel-hda: support FIFORDY

 hw/audio/intel-hda.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)



Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Michael S. Tsirkin
On Wed, May 21, 2014 at 11:06:09AM +0200, Alexander Graf wrote:
> 
> On 21.05.14 10:52, Alexey Kardashevskiy wrote:
> >On 05/21/2014 06:40 PM, Alexander Graf wrote:
> >>On 15.05.14 11:59, Alexey Kardashevskiy wrote:
> >>>Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
> >>>XICS used to be unable to reuse interrupts which becomes a problem for
> >>>dynamic MSI reconfiguration which is happening on guest driver reload or
> >>>PCI hot (un)plug. Another problem is that PHB has a limit of devices
> >>>supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
> >>>for that.
> >>>
> >>>This makes use of new XICS ability to reuse interrupts.
> >>>
> >>>This removes cached MSI configuration from SPAPR PHB so the first IRQ 
> >>>number
> >>>of a device is stored in MSI/MSIX config space so there is no need to store
> >>>this anywhere else. From now on, SPAPR PHB only keeps flags telling what
> >>>type
> >>>of interrupt for which device it has configured in order to return error if
> >>>(for example) MSIX was enabled and the guest is trying to disable MSI which
> >>>it has not enabled.
> >>>
> >>>This removes a limit for the maximum number of MSIX-enabled devices per 
> >>>PHB,
> >>>now XICS and PCI bus capacity are the only limitation.
> >>>
> >>>This changes migration stream as it fixes vmstate_spapr_pci_msi::name
> >>>which was
> >>>wrong since the beginning.
> >>>
> >>>This fixed traces to be more informative.
> >>>
> >>>Signed-off-by: Alexey Kardashevskiy 
> >>>---
> >>>
> >>>In reality either MSIX or MSI is enabled, never both. So I could remove
> >>>msi/msix
> >>>bitmaps from this patch, would it make sense?
> >>Is this a hard requirement? Does a device have to choose between MSIX and
> >>MSI or could it theoretically have both enabled? Is this a PCI limitation,
> >>a PAPR/XICS limitation or just a limitation of your implementation?
> >
> >My implementation does not have this limitation, I asked if I can simplify
> >code by introducing one :)
> >
> >I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
> >it does not seem to be used by anyone => cannot debug and confirm.
> >
> >PAPR spec assumes that if the guest tries enabling MSIX when MSI is already
> >enabled, this is a "change", not enabling both types. But it also says MSI
> >and MSIX vector numbers are not shared. Hm.
> 
> Yeah, I'm not aware of any limitation on hardware here and I'd
> rather not impose one.
> 
> Michael, do you know of any hardware that uses MSI *and* MSI-X at
> the same time?
> 
> 
> Alex

No, and the PCI spec says:
A function is permitted to implement both MSI and MSI-X, but system
software is
prohibited from enabling both at the same time. If system software
enables both at the same time, the result is undefined.





Re: [Qemu-devel] [PATCH v2 05/31] vl.c: extend -m option to support options for memory hotplug

2014-05-21 Thread Andrey Korolyov
On Wed, May 21, 2014 at 12:55 PM, Igor Mammedov  wrote:
> On Wed, 21 May 2014 12:27:05 +0400
> Andrey Korolyov  wrote:
>
>> On Wed, May 21, 2014 at 12:10 PM, Michael S. Tsirkin  wrote:
>> > On Tue, May 20, 2014 at 05:15:08PM +0200, Igor Mammedov wrote:
>> >> Add following parameters:
>> >>   "slots" - total number of hotplug memory slots
>> >>   "maxmem" - maximum possible memory
>> >>
>> >> "slots" and "maxmem" should go in pair and "maxmem" should be greater
>> >> than "mem" for memory hotplug to be enabled.
>> >>
>> >> Signed-off-by: Igor Mammedov 
>> >
>> > Also, it's a bug to mix this with a compat machine type, right?
>> > Maybe best to fail initialization if users try this.
>> >
>> >> ---
>> >> v4:
>> >>  - store maxmem & slots values in MachineState
>> >> v3:
>> >>  - store maxmem & slots values in QEMUMachineInitArgs
>> >> v2:
>> >>  - rebased on top of the latest "vl: convert -m to QemuOpts"
>> >> ---
>> >>  include/hw/boards.h |3 ++-
>> >>  qemu-options.hx |9 ++---
>> >>  vl.c|   51 
>> >> +++
>> >>  3 files changed, 59 insertions(+), 4 deletions(-)
>> >>
>> >> diff --git a/include/hw/boards.h b/include/hw/boards.h
>> >> index b62de4a..f6fbbe1 100644
>> >> --- a/include/hw/boards.h
>> >> +++ b/include/hw/boards.h
>> >> @@ -8,7 +8,6 @@
>> >>  #include "hw/qdev.h"
>> >>  #include "qom/object.h"
>> >>
>> >> -
>> >>  typedef struct MachineState MachineState;
>> >>
>> >>  typedef void QEMUMachineInitFunc(MachineState *ms);
>> >> @@ -113,6 +112,8 @@ struct MachineState {
>> >>  char *firmware;
>> >>
>> >>  ram_addr_t ram_size;
>> >> +ram_addr_t maxram_size;
>> >> +uint64_t   ram_slots;
>> >>  const char *boot_order;
>> >>  const char *kernel_filename;
>> >>  const char *kernel_cmdline;
>> >> diff --git a/qemu-options.hx b/qemu-options.hx
>> >> index 781af14..c6411c4 100644
>> >> --- a/qemu-options.hx
>> >> +++ b/qemu-options.hx
>> >> @@ -210,17 +210,20 @@ use is discouraged as it may be removed from future 
>> >> versions.
>> >>  ETEXI
>> >>
>> >>  DEF("m", HAS_ARG, QEMU_OPTION_m,
>> >> -"-m [size=]megs\n"
>> >> +"-m[emory] [size=]megs[,slots=n,maxmem=size]\n"
>> >>  "configure guest RAM\n"
>> >>  "size: initial amount of guest memory (default: "
>> >> -stringify(DEFAULT_RAM_SIZE) "MiB)\n",
>> >> +stringify(DEFAULT_RAM_SIZE) "MiB)\n"
>> >> +"slots: number of hotplug slots (default: none)\n"
>> >> +"maxmem: maximum amount of guest memory (default: 
>> >> none)\n",
>> >>  QEMU_ARCH_ALL)
>> >>  STEXI
>> >>  @item -m [size=]@var{megs}
>> >>  @findex -m
>> >>  Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  
>> >> Optionally,
>> >>  a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
>> >> -gigabytes respectively.
>> >> +gigabytes respectively. Optional pair @var{slots}, @var{maxmem} could be 
>> >> used
>> >> +to set amount of hotluggable memory slots and possible maximum amount of 
>> >> memory.
>> >>  ETEXI
>> >>
>> >>  DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
>> >> diff --git a/vl.c b/vl.c
>> >> index 8fd4ed9..9fb6fa4 100644
>> >> --- a/vl.c
>> >> +++ b/vl.c
>> >> @@ -520,6 +520,14 @@ static QemuOptsList qemu_mem_opts = {
>> >>  .name = "size",
>> >>  .type = QEMU_OPT_SIZE,
>> >>  },
>> >> +{
>> >> +.name = "slots",
>> >> +.type = QEMU_OPT_NUMBER,
>> >> +},
>> >> +{
>> >> +.name = "maxmem",
>> >> +.type = QEMU_OPT_SIZE,
>> >> +},
>> >>  { /* end of list */ }
>> >>  },
>> >>  };
>> >> @@ -2989,6 +2997,8 @@ int main(int argc, char **argv, char **envp)
>> >>  const char *trace_file = NULL;
>> >>  const ram_addr_t default_ram_size = (ram_addr_t)DEFAULT_RAM_SIZE *
>> >>  1024 * 1024;
>> >> +ram_addr_t maxram_size = default_ram_size;
>> >> +uint64_t ram_slots = 0;
>> >>
>> >>  atexit(qemu_run_exit_notifiers);
>> >>  error_set_progname(argv[0]);
>> >> @@ -3324,6 +3334,7 @@ int main(int argc, char **argv, char **envp)
>> >>  case QEMU_OPTION_m: {
>> >>  uint64_t sz;
>> >>  const char *mem_str;
>> >> +const char *maxmem_str, *slots_str;
>> >>
>> >>  opts = qemu_opts_parse(qemu_find_opts("memory"),
>> >> optarg, 1);
>> >> @@ -3365,6 +3376,44 @@ int main(int argc, char **argv, char **envp)
>> >>  error_report("ram size too large");
>> >>  exit(EXIT_FAILURE);
>> >>  }
>> >> +
>> >> +maxmem_str = qemu_opt_get(opts, "maxmem");
>> >> +slots_str = qemu_opt_get(opts, "slots");
>> >> +if (maxmem_str && slots_str) {
>> >> +uint64_t slots;
>> >> +
>> >>

Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Alexander Graf


On 21.05.14 11:11, Michael S. Tsirkin wrote:

On Wed, May 21, 2014 at 11:06:09AM +0200, Alexander Graf wrote:

On 21.05.14 10:52, Alexey Kardashevskiy wrote:

On 05/21/2014 06:40 PM, Alexander Graf wrote:

On 15.05.14 11:59, Alexey Kardashevskiy wrote:

Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
XICS used to be unable to reuse interrupts which becomes a problem for
dynamic MSI reconfiguration which is happening on guest driver reload or
PCI hot (un)plug. Another problem is that PHB has a limit of devices
supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
for that.

This makes use of new XICS ability to reuse interrupts.

This removes cached MSI configuration from SPAPR PHB so the first IRQ number
of a device is stored in MSI/MSIX config space so there is no need to store
this anywhere else. From now on, SPAPR PHB only keeps flags telling what
type
of interrupt for which device it has configured in order to return error if
(for example) MSIX was enabled and the guest is trying to disable MSI which
it has not enabled.

This removes a limit for the maximum number of MSIX-enabled devices per PHB,
now XICS and PCI bus capacity are the only limitation.

This changes migration stream as it fixes vmstate_spapr_pci_msi::name
which was
wrong since the beginning.

This fixed traces to be more informative.

Signed-off-by: Alexey Kardashevskiy 
---

In reality either MSIX or MSI is enabled, never both. So I could remove
msi/msix
bitmaps from this patch, would it make sense?

Is this a hard requirement? Does a device have to choose between MSIX and
MSI or could it theoretically have both enabled? Is this a PCI limitation,
a PAPR/XICS limitation or just a limitation of your implementation?

My implementation does not have this limitation, I asked if I can simplify
code by introducing one :)

I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
it does not seem to be used by anyone => cannot debug and confirm.

PAPR spec assumes that if the guest tries enabling MSIX when MSI is already
enabled, this is a "change", not enabling both types. But it also says MSI
and MSIX vector numbers are not shared. Hm.

Yeah, I'm not aware of any limitation on hardware here and I'd
rather not impose one.

Michael, do you know of any hardware that uses MSI *and* MSI-X at
the same time?


Alex

No, and the PCI spec says:
A function is permitted to implement both MSI and MSI-X, but system
software is
prohibited from enabling both at the same time. If system software
enables both at the same time, the result is undefined.


Ah, cool. So yes Alexey, feel free to impose it :).


Alex




[Qemu-devel] [PATCH 11/25] gtk: allow moving tabs to windows and back.

2014-05-21 Thread Gerd Hoffmann
"View->Detach tab" will move to tab to a new window.
Simply closing the window will move it back into a notebook tab.
The label will be permamently stored in VirtualConsole->label,
so it can easily be reused to (re-)label tabs and windows.

Works for vte tabs only for now. pointer/kbd grab code needs
adaptions before we can enable it for gfx tabs too.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 74 ++--
 1 file changed, 63 insertions(+), 11 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 6790cf8..07883a1 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -134,6 +134,8 @@ typedef enum VirtualConsoleType {
 
 typedef struct VirtualConsole {
 GtkDisplayState *s;
+char *label;
+GtkWidget *window;
 GtkWidget *menu_item;
 GtkWidget *tab_item;
 VirtualConsoleType type;
@@ -173,6 +175,7 @@ struct GtkDisplayState {
 VirtualConsole vc[MAX_VCS];
 
 GtkWidget *show_tabs_item;
+GtkWidget *untabify_item;
 
 GtkWidget *vbox;
 GtkWidget *notebook;
@@ -891,6 +894,50 @@ static void gd_menu_show_tabs(GtkMenuItem *item, void 
*opaque)
 }
 }
 
+static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event,
+void *opaque)
+{
+VirtualConsole *vc = opaque;
+GtkDisplayState *s = vc->s;
+
+gtk_widget_set_sensitive(vc->menu_item, true);
+gtk_widget_reparent(vc->tab_item, s->notebook);
+gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(s->notebook),
+vc->tab_item, vc->label);
+gtk_widget_destroy(vc->window);
+vc->window = NULL;
+return TRUE;
+}
+
+static void gd_menu_untabify(GtkMenuItem *item, void *opaque)
+{
+GtkDisplayState *s = opaque;
+VirtualConsole *vc = gd_vc_find_current(s);
+char *title;
+
+if (vc->type == GD_VC_GFX) {
+/* temporary: needs more work to get grabs etc correct */
+return;
+}
+if (!vc->window) {
+gtk_widget_set_sensitive(vc->menu_item, false);
+vc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+gtk_widget_reparent(vc->tab_item, vc->window);
+
+if (qemu_name) {
+title = g_strdup_printf("QEMU (%s): %s", qemu_name, vc->label);
+} else {
+title = g_strdup_printf("QEMU: %s", vc->label);
+}
+gtk_window_set_title(GTK_WINDOW(vc->window), title);
+g_free(title);
+
+g_signal_connect(vc->window, "delete-event",
+ G_CALLBACK(gd_tab_window_close), vc);
+gtk_widget_show_all(vc->window);
+}
+}
+
 static void gd_menu_full_screen(GtkMenuItem *item, void *opaque)
 {
 GtkDisplayState *s = opaque;
@@ -1196,14 +1243,13 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
 /** Virtual Console Callbacks **/
 
 static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc,
-   const char *label, int idx,
-   GSList *group, GtkWidget *view_menu)
+   int idx, GSList *group, GtkWidget *view_menu)
 {
 char path[32];
 
 snprintf(path, sizeof(path), "/View/VC%d", idx);
 
-vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, label);
+vc->menu_item = gtk_radio_menu_item_new_with_mnemonic(group, vc->label);
 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item));
 gtk_menu_item_set_accel_path(GTK_MENU_ITEM(vc->menu_item), path);
 gtk_accel_map_add_entry(path, GDK_KEY_1 + idx, HOTKEY_MODIFIERS);
@@ -1266,7 +1312,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, 
VirtualConsole *vc,
   CharDriverState *chr, int idx,
   GSList *group, GtkWidget *view_menu)
 {
-const char *label;
 char buffer[32];
 GtkWidget *box;
 GtkWidget *scrollbar;
@@ -1276,8 +1321,9 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, 
VirtualConsole *vc,
 vc->vte.chr = chr;
 
 snprintf(buffer, sizeof(buffer), "vc%d", idx);
-label = vc->vte.chr->label ? vc->vte.chr->label : buffer;
-group = gd_vc_menu_init(s, vc, vc->vte.chr->label, idx, group, view_menu);
+vc->label = g_strdup_printf("%s", vc->vte.chr->label
+? vc->vte.chr->label : buffer);
+group = gd_vc_menu_init(s, vc, idx, group, view_menu);
 
 vc->vte.terminal = vte_terminal_new();
 g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc);
@@ -1313,7 +1359,7 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, 
VirtualConsole *vc,
 vc->type = GD_VC_VTE;
 vc->tab_item = box;
 gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), vc->tab_item,
- gtk_label_new(label));
+ gtk_label_new(vc->label));
 
 qemu_chr_be_generic_open(vc->vte.chr);
 if (vc->vte.chr->init) {
@@ -1372,6 +1418,8 @@ static void gd_connect_signals(GtkDisplayState *s)
 {
 g_signal_connect(s->show

Re: [Qemu-devel] [PATCH] e1000: allow command-line selection of card model

2014-05-21 Thread Andreas Färber
Am 21.05.2014 11:04, schrieb Michael S. Tsirkin:
> On Wed, May 21, 2014 at 10:40:54AM +0200, Andreas Färber wrote:
>> Hi,
>>
>> Am 20.05.2014 17:05, schrieb Gabriel L. Somlo:
>>> Allow selection of different card models from the qemu
>>> command line, to better accomodate a wider range of guests.
>>>
>>> Based-on-patch-by: Romain Dolbeau 
>>
>> If that patch carried a Signed-off-by line, you should retain it.
> 
> Actually I think that would be confusing. Romain didn't sign off
> on *this* patch, he signed off on a previous one.
> A signature by Gabriel indicates Developer's Certificate of Origin 1.1
> which has an option to incorporate other's work - it
> does not seem to require signatures by these others.

With the same argument you could drop anyone's Sob you get as a
maintainer. But the purpose of Sob is to track through whose hands a
patch went, not just who last touched it.
My point here was that Based-on-patch-by is very unusual.

The alternative would be to leave the original From: Romain Dolbeau, his
Sob, then a [gsomlo: Dropped this, added that] followed by Sob.

Cheers,
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] fpu/softfloat.c licensing

2014-05-21 Thread Peter Maydell
On 21 May 2014 08:51, Paolo Bonzini  wrote:
> Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:
>
>> Hi!
>>
>> We recently discovered that not entire QEMU is GPL2-compatible, the fpu
>> emulation has a different license (copied below) which might create legal
>> problems because of that "INDEMNIFY" statement.
>>
>> Does anyone else care (except IBM)?
>>
>> What would the proper solution be? Ask the creator to relicense it under
>> GPL? I failed to find a contact as the homepage on berkeley.edu is
>> restricted. Rewrite the code? This code is used in FPU emulation for TCG,
>> is that the only use of it? If it should not get called for KVM, that
>> would
>> be a temporary band-aid for us :)
>
>
> http://marc.info/?l=qemu-devel&m=136725946312880&w=4
>
> The following people haven't acked the relicensing of their contributions
> from softfloat-2b to softfloat-2a or GPLv2+ yet:
>
> Fabrice Bellard 
> 1d6bda356153c82e100680d9f2165e32c8fb1330

Some float-to-int conversions, comparisons, chs, abs.

> 750afe93fd15fafc20b6c34d30f339547d15c2d1

Trivial bulk change of 'flag' and 'char' return types to 'int'.

> Jocelyn Mayer
> 75d62a585629cdc1ae0d530189653cb1d8d9c53c

uint64_to_float32() and uint64_to_float64() would need
redoing -- the rest have been completely rewritten or deleted.

> Thiemo Seufer's parents (Stefan said he'd contact them)
> 5a6932d51d1b34b68b3f10fc5ac65598bece88c0

SNAN_BIT_IS_ONE support.

> 924b2c07cdfaba9ac408fc5fa77da75a570f9dc5

Trivial fixes to a few busted prototypes.

> b645bb48850fea8db017026897827f0ab42fbdea

Also SNAN_BIT_IS_ONE support.

> fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10

fc81ba5 is changes to code which has been deleted since.


I think we could, if we had to, rewrite those pieces. It would
be nice if we could at least get an ack from Fabrice though.

thanks
-- PMM



[Qemu-devel] [PATCH 13/25] gtk: add gd_grab trace event

2014-05-21 Thread Gerd Hoffmann
Input grab code is tricky, add some debug & trouble shooting aid.

Signed-off-by: Gerd Hoffmann 
---
 trace-events | 1 +
 ui/gtk.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/trace-events b/trace-events
index 3a41abf..e42 100644
--- a/trace-events
+++ b/trace-events
@@ -1048,6 +1048,7 @@ ppm_save(const char *filename, void *display_surface) "%s 
surface=%p"
 gd_switch(const char *tab, int width, int height) "tab=%s, width=%d, height=%d"
 gd_update(const char *tab, int x, int y, int w, int h) "tab=%s, x=%d, y=%d, 
w=%d, h=%d"
 gd_key_event(const char *tab, int gdk_keycode, int qemu_keycode, const char 
*action) "tab=%s, translated GDK keycode %d to QEMU keycode %d (%s)"
+gd_grab(const char *tab, const char *device, bool on) "tab=%s, %s %d"
 
 # ui/input.c
 input_event_key_number(int conidx, int number, bool down) "con %d, key number 
0x%x, down %d"
diff --git a/ui/gtk.c b/ui/gtk.c
index 3ee9465..0e35abf 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1058,6 +1058,7 @@ static void gd_grab_keyboard(VirtualConsole *vc)
   FALSE,
   GDK_CURRENT_TIME);
 #endif
+trace_gd_grab(vc->label, "kbd", true);
 }
 
 static void gd_ungrab_keyboard(VirtualConsole *vc)
@@ -1080,6 +1081,7 @@ static void gd_ungrab_keyboard(VirtualConsole *vc)
 #else
 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
 #endif
+trace_gd_grab(vc->label, "kbd", false);
 }
 
 static void gd_grab_pointer(VirtualConsole *vc)
@@ -1125,6 +1127,7 @@ static void gd_grab_pointer(VirtualConsole *vc)
 gdk_display_get_pointer(display, NULL,
 &vc->s->grab_x_root, &vc->s->grab_y_root, NULL);
 #endif
+trace_gd_grab(vc->label, "ptr", true);
 }
 
 static void gd_ungrab_pointer(VirtualConsole *vc)
@@ -1153,6 +1156,7 @@ static void gd_ungrab_pointer(VirtualConsole *vc)
  gtk_widget_get_screen(vc->gfx.drawing_area),
  vc->s->grab_x_root, vc->s->grab_y_root);
 #endif
+trace_gd_grab(vc->label, "ptr", false);
 }
 
 static void gd_menu_grab_input(GtkMenuItem *item, void *opaque)
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 6/6] docs: add multiseat.txt

2014-05-21 Thread Paolo Bonzini

Il 21/05/2014 10:38, Gerd Hoffmann ha scritto:

On Di, 2014-05-20 at 20:08 +0200, Paolo Bonzini wrote:

Is there anything about the window that we would like to configure?  If
so, should this be something like

-object window,id=window.2 \
-device pci-bridge,addr=12.0,chassis_nr=2,id=head.2 \
-device secondary-vga,bus=head.2,addr=02.0,window=window.2 \
-device nec-usb-xhci,bus=head.2,addr=0f.0,id=usb.2 \
-device usb-kbd,bus=usb.2.0,port=1,window=window.2 \
-device usb-tablet,bus=usb.2.0,port=2,window=window.2

?


The "window" is a QemuConsole.  Which is a object already, visible
in /backend/console[nr].  Has a device link pointing to the display
device it is bound to.

QemuConsoles are automatically created by display devices and don't have
ids, so we lookup them using the display device id.  See
qemu_input_handler_bind in patch #3.

If there is anything to configure then it most likely will be ui
specific, i.e. we could possibly allow something like this ...

   -display gtk,display=video.1 \
   -vnc :0,display=video.2

... to have one head show up on gtk and the other on vnc (needs '-vga
none -device VGA,id=video.1' instead of '-vga std').


How would you configure the case where one input goes to multiple heads 
(e.g. 2 seats, 4 monitors)?


Paolo



Re: [Qemu-devel] [PATCH] pcie_host: Turn pcie_host_init() into an instance_init

2014-05-21 Thread Andreas Färber
Am 24.04.2014 17:26, schrieb Andreas Färber:
> This assures the trivial field initialization is applied for any derived
> type - currently only Q35PCIHost.
> 
> Signed-off-by: Andreas Färber 
> ---
>  Michael, I've had this preparation lying around for a while but didn't 
>  get further yet. Can you take this through the PCI queue already?

Ping!

> 
>  hw/pci-host/q35.c  | 4 
>  hw/pci/pcie_host.c | 7 ---
>  include/hw/pci/pcie_host.h | 1 -
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 8b8cc4e..aa48b1c 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -47,10 +47,6 @@ static void q35_host_realize(DeviceState *dev, Error 
> **errp)
>  sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
>  sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
>  
> -if (pcie_host_init(PCIE_HOST_BRIDGE(s)) < 0) {
> -error_setg(errp, "failed to initialize pcie host");
> -return;
> -}
>  pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
> s->mch.pci_address_space, s->mch.address_space_io,
> 0, TYPE_PCIE_BUS);
> diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
> index c6e1b57..7c88a1d 100644
> --- a/hw/pci/pcie_host.c
> +++ b/hw/pci/pcie_host.c
> @@ -83,11 +83,11 @@ static const MemoryRegionOps pcie_mmcfg_ops = {
>  .endianness = DEVICE_NATIVE_ENDIAN,
>  };
>  
> -int pcie_host_init(PCIExpressHost *e)
> +static void pcie_host_init(Object *obj)
>  {
> -e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
> +PCIExpressHost *e = PCIE_HOST_BRIDGE(obj);
>  
> -return 0;
> +e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
>  }
>  
>  void pcie_host_mmcfg_unmap(PCIExpressHost *e)
> @@ -128,6 +128,7 @@ static const TypeInfo pcie_host_type_info = {
>  .parent = TYPE_PCI_HOST_BRIDGE,
>  .abstract = true,
>  .instance_size = sizeof(PCIExpressHost),
> +.instance_init = pcie_host_init,
>  };
>  
>  static void pcie_host_register_types(void)
> diff --git a/include/hw/pci/pcie_host.h b/include/hw/pci/pcie_host.h
> index acca45e..ff44ef6 100644
> --- a/include/hw/pci/pcie_host.h
> +++ b/include/hw/pci/pcie_host.h
> @@ -49,7 +49,6 @@ struct PCIExpressHost {
>  MemoryRegion mmio;
>  };
>  
> -int pcie_host_init(PCIExpressHost *e);
>  void pcie_host_mmcfg_unmap(PCIExpressHost *e);
>  void pcie_host_mmcfg_map(PCIExpressHost *e, hwaddr addr, uint32_t size);
>  void pcie_host_mmcfg_update(PCIExpressHost *e,
> 


-- 
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 v2 8/9] spapr: Implement processor compatibility in ibm, client-architecture-support

2014-05-21 Thread Alexander Graf


On 21.05.14 10:27, Alexey Kardashevskiy wrote:

Modern Linux kernels support last POWERPC CPUs so when a kernel boots,
in most cases it can find a matching cpu_spec in the kernel's cpu_specs
list. However if the kernel is quite old, it may be missing a definition
of the actual CPU. To provide an ability for old kernels to work on modern
hardware, a Processor Compatibility Mode has been introduced
by the PowerISA specification.

 From the hardware prospective, it is supported by the Processor
Compatibility Register (PCR) which is defined in PowerISA. The register
enables one of the compatibility modes (2.05/2.06/2.07).
Since PCR is a hypervisor privileged register and cannot be
directly accessed from the guest, the mode selection is done via
ibm,client-architecture-support (CAS) RTAS call using which the guest
specifies what "raw" and "architected" CPU versions it supports.
QEMU works out the best match, changes a "cpu-version" property of
every CPU and notifies the guest about the change by setting these
properties in the buffer passed as a response on a custom H_CAS hypercall.

This implements ibm,client-architecture-support parameters parsing
(now only for PVRs) and cooks the device tree diff with new values for
"cpu-version", "ibm,ppc-interrupt-server#s" and
"ibm,ppc-interrupt-server#s" properties.

Signed-off-by: Alexey Kardashevskiy 
---
  hw/ppc/spapr.c   |  4 ++-
  hw/ppc/spapr_hcall.c | 85 
  trace-events |  4 +++
  3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 14c72d9..020426a 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -34,6 +34,7 @@
  #include "sysemu/kvm.h"
  #include "kvm_ppc.h"
  #include "mmu-hash64.h"
+#include "qom/cpu.h"
  
  #include "hw/boards.h"

  #include "hw/ppc/ppc.h"
@@ -601,7 +602,8 @@ int spapr_h_cas_compose_response(target_ulong addr, 
target_ulong size)
  _FDT((fdt_open_into(fdt_skel, fdt, size)));
  g_free(fdt_skel);
  
-/* Place to make changes to the tree */

+/* Fix skeleton up */
+_FDT((spapr_fixup_cpu_dt(fdt, spapr)));
  
  /* Pack resulting tree */

  _FDT((fdt_pack(fdt)));
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 2f6aa5c..2e0a49c 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -3,6 +3,9 @@
  #include "helper_regs.h"
  #include "hw/ppc/spapr.h"
  #include "mmu-hash64.h"
+#include "cpu-models.h"
+#include "trace.h"
+#include "kvm_ppc.h"
  
  struct SPRSyncState {

  CPUState *cs;
@@ -752,12 +755,94 @@ out:
  return ret;
  }
  
+#define get_compat_level(cpuver) ( \

+((cpuver) == CPU_POWERPC_LOGICAL_2_05) ? 2050 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_06) ? 2060 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \
+((cpuver) == CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0)
+
  static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
  {
  target_ulong list = args[0];
+PowerPCCPUClass *pcc_ = POWERPC_CPU_GET_CLASS(cpu_);
+CPUState *cs;
+bool cpu_match = false;
+unsigned old_cpu_version = cpu_->cpu_version;
+unsigned compat_lvl = 0, cpu_version = 0;
+unsigned max_lvl = get_compat_level(cpu_->max_compat);
+
+/* Parse PVR list */
+for ( ; ; ) {
+uint32_t pvr, pvr_mask;
+
+pvr_mask = rtas_ld(list, 0);
+list += 4;
+pvr = rtas_ld(list, 0);
+list += 4;
+
+trace_spapr_cas_pvr_try(pvr);
+if (!max_lvl &&
+((cpu_->env.spr[SPR_PVR] & pvr_mask) == (pvr & pvr_mask))) {
+cpu_match = true;
+cpu_version = 0;
+} else if (pvr == cpu_->cpu_version) {
+cpu_match = true;
+cpu_version = cpu_->cpu_version;
+} else if (!cpu_match) {
+/* If it is a logical PVR, try to determine the highest level */
+unsigned lvl = get_compat_level(pvr);
+if (lvl) {
+bool is205 = (pcc_->pcr_mask & PCR_COMPAT_2_05) &&
+ (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
+bool is206 = (pcc_->pcr_mask & PCR_COMPAT_2_06) &&
+((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
+(lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS)));
+
+if (is205 || is206) {
+if (!max_lvl) {
+/* User did not set the level, choose the highest */
+if (compat_lvl <= lvl) {
+compat_lvl = lvl;
+cpu_version = pvr;
+}
+} else if (max_lvl >= lvl) {
+/* User chose the level, don't set higher than this 

Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Kevin Wolf
Am 21.05.2014 um 10:42 hat Fam Zheng geschrieben:
> On Wed, 05/21 10:23, Kevin Wolf wrote:
> > Am 21.05.2014 um 09:46 hat Markus Armbruster geschrieben:
> > > Fam Zheng  writes:
> > > 
> > > > On Wed, 05/21 07:54, Markus Armbruster wrote:
> > > >> Fam Zheng  writes:
> > > >> 
> > > >> > On Tue, 05/20 13:13, Eric Blake wrote:
> > > >> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
> > > >> >> > Please first take a look at patch 7 to see what is supported by 
> > > >> >> > this series.
> > > >> >> > 
> > > >> >> > Patch 1 ~ 3 allows some useful basic types in schema.
> > > >> >> > 
> > > >> >> > Patch 4 ~ 6 implements the new syntax.
> > > >> >> > 
> > > >> >> > Note: The introduced '@arg' sigil, just like the preexisting 
> > > >> >> > '*arg', is
> > > >> >> > reducing the cleanness of the syntax. We should get rid of both 
> > > >> >> > of them in long
> > > >> >> > term. Here, this series compromises on this and introduces '@arg' 
> > > >> >> > because:
> > > >> >> > 
> > > >> >> >   - We have to distinguish the argument property dictionary from 
> > > >> >> > nested struct:
> > > >> >> > 
> > > >> >> > I.e.:
> > > >> >> > 
> > > >> >> > 'data': {
> > > >> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
> > > >> >> > '@arg2': { 'type': 'int', 'default': 100 }
> > > >> >> >  }
> > > >> >> > 
> > > >> >> > Until we completely drop and forbid the 'arg1' nested struct 
> > > >> >> > use case.
> > > >> >> > 
> > > >> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull 
> > > >> >> > in many
> > > >> >> > distractive patches to this series.
> > > >> >> 
> > > >> >> Question - since we WANT to get rid of nested struct, why not 
> > > >> >> reverse
> > > >> >> the sense?  Mark all existing nested structs (weren't there just 
> > > >> >> three
> > > >> >> that we found?) with the '@' sigil, and let the new syntax be
> > > >> >> sigil-free.  Then when we clean up the nesting, we are also getting 
> > > >> >> rid
> > > >> >> of the bad syntax, plus the sigil gives us something to search for 
> > > >> >> in
> > > >> >> knowing how much to clean up.  But if you stick the sigil on the new
> > > >> >> code, instead of the obsolete code, then as more and more places in 
> > > >> >> the
> > > >> >> schema use defaults, it gets harder and harder to remove the use of 
> > > >> >> the
> > > >> >> sigil even if the nested structs are eventually removed.
> > > >> >> 
> > > >> >
> > > >> > It makes not much difference I can see. The hard part is actaully 
> > > >> > dropping
> > > >> > nested, converting from sigil <-> non-sigil is easy. Of course, 
> > > >> > nothing is
> > > >> > seriously hard, there are only three nested structs plus some more
> > > >> > qapi-schema
> > > >> > test code.
> > > >> 
> > > >> Adding three ugly sigils and making everybody include one when they add
> > > >> a nested struct feels much better to me than ugly sigils all over the
> > > >> place.
> > > >
> > > > Well, I could use some background here. Why did we introduce nested 
> > > > structure
> > > > in the first place?
> > > 
> > > Because we could?
> > > 
> > > Felt like a good idea at the time?
> > > 
> > > I quick glance at commit 0f923be and fb3182c suggests they have been
> > > supported since the beginning.  There is no design rationale.
> > 
> > Let me extend Fam's question: Why don't we simply remove them right
> > now? If it's really only three instances, converting them to full
> > types should be a matter of five minutes.
> > 
> 
> Actually, my question is: do we want it independently, or do we want to 
> include
> the removal of nested as the first part of this series?
> 
> I would prefer the former because I feel uncomfortable with making more 
> changes
> in this series, since there are already many things to do: adding qapi types,
> adding argument property dict, adding all test cases for all of them, updating
> documentation, and apply the new syntax in qapi-schema.json. A non-RFC 
> revision
> could be long and hard to review.

The removal of nested structs must come first. Whether it's done as part
of this series or as a separate series that this one will depend on
doesn't really matter that much. I think I would do it as one big series
(and 8 patches with a diffstat like this is not that big, after all),
but if you prefer to split it up, I think that should be okay, too.

Kevin



Re: [Qemu-devel] [PATCH] qga: Fix handle fd leak in acquire_privilege()

2014-05-21 Thread Yan Vugenfirer

On May 20, 2014, at 10:46 PM, Michael Roth  wrote:

> Quoting Luiz Capitulino (2014-05-20 14:17:42)
>> On Mon, 19 May 2014 15:26:03 +0800
>>  wrote:
>> 
>>> From: Gonglei 
>>> 
>>> token should be closed in all conditions.
>>> So move CloseHandle(token) to "out" branch.
>> 
>> Looks good to me. Michael, are you going to pick this one?
> 
> Sure I'll queue it. Though i'm a bit surprised OpenProcessToken() will still
> return an open handle on failure. Is there any confirmation a handle is
> actually getting leaked here, as opposed to just returning a handle that's
> already been closed?

It won’t return a handle if it failed (I actually was going to reject the patch 
because of it) - but if you look closely at the code you will see error cases 
after OpenProcessToken was successful where we jump out of the if scope and 
then CloseHandle won’t be called.

Best regards,
Yan.

> 
> If it's the latter case we might end up closing it twice after the change,
> so just want to confirm.
> 
>> 
>>> 
>>> Signed-off-by: Wang Rui 
>>> Signed-off-by: Gonglei 
>>> ---
>>> qga/commands-win32.c | 6 --
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
>>> index d793dd0..e769396 100644
>>> --- a/qga/commands-win32.c
>>> +++ b/qga/commands-win32.c
>>> @@ -31,7 +31,7 @@
>>> 
>>> static void acquire_privilege(const char *name, Error **errp)
>>> {
>>> -HANDLE token;
>>> +HANDLE token = NULL;
>>> TOKEN_PRIVILEGES priv;
>>> Error *local_err = NULL;
>>> 
>>> @@ -53,13 +53,15 @@ static void acquire_privilege(const char *name, Error 
>>> **errp)
>>> goto out;
>>> }
>>> 
>>> -CloseHandle(token);
>>> } else {
>>> error_set(&local_err, QERR_QGA_COMMAND_FAILED,
>>>   "failed to open privilege token");
>>> }
>>> 
>>> out:
>>> +if (token) {
>>> +CloseHandle(token);
>>> +}
>>> if (local_err) {
>>> error_propagate(errp, local_err);
>>> }
> 
> 




[Qemu-devel] [PATCH 00/25] qemu gtk ui overhaul

2014-05-21 Thread Gerd Hoffmann
  Hi,

I'm trying to put the qemu gtk ui into shape.  Fixing a bunch of
issues we have, and also make it ready for multihead support.

Git tree is here:
  git://git.kraxel.org/qemu rebase/ui-gtk-next  

please review,
  Gerd

Bruce Rogers (1):
  gtk: Add handling for the xfree86 keycodes

Cole Robinson (1):
  gtk: Add a scrollbar for text consoles

Gerd Hoffmann (23):
  gtk: zap scrolled_window
  gtk: zap vte size requests
  gtk: cleanup CONFIG_VTE ifdef a bit.
  gtk: remove page numbering assumtions from the code
  gtk: VirtualConsole restruction
  gtk: move vga state into VirtualGfxConsole
  gtk: support multiple gfx displays
  gtk: use device type as label
  gtk: simplify resize
  gtk: allow moving tabs to windows and back.
  gtk: add tab to trace events
  gtk: add gd_grab trace event
  gtk: keep track of grab owner
  gtk: skip keyboard grab when hover autograb is active
  gtk: update gd_update_caption
  gtk: fix grab checks
  gtk: update all windows on mouse mode changes
  gtk: detached window pointer grabs
  gtk: enable untabify for gfx
  gtk: zap unused global_state
  gtk: window sizing overhaul
  gtk: workaround gtk2 vte resize issue
  gtk: factor out gtk3 grab into the new gd_grab_devices function

 trace-events |7 +-
 ui/gtk.c | 1198 +-
 2 files changed, 769 insertions(+), 436 deletions(-)

-- 
1.8.3.1




Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Alexander Graf


On 21.05.14 11:17, Peter Maydell wrote:

On 21 May 2014 08:51, Paolo Bonzini  wrote:

Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:


Hi!

We recently discovered that not entire QEMU is GPL2-compatible, the fpu
emulation has a different license (copied below) which might create legal
problems because of that "INDEMNIFY" statement.

Does anyone else care (except IBM)?

What would the proper solution be? Ask the creator to relicense it under
GPL? I failed to find a contact as the homepage on berkeley.edu is
restricted. Rewrite the code? This code is used in FPU emulation for TCG,
is that the only use of it? If it should not get called for KVM, that
would
be a temporary band-aid for us :)


http://marc.info/?l=qemu-devel&m=136725946312880&w=4

The following people haven't acked the relicensing of their contributions
from softfloat-2b to softfloat-2a or GPLv2+ yet:

Fabrice Bellard 
 1d6bda356153c82e100680d9f2165e32c8fb1330

Some float-to-int conversions, comparisons, chs, abs.


 750afe93fd15fafc20b6c34d30f339547d15c2d1

Trivial bulk change of 'flag' and 'char' return types to 'int'.


Jocelyn Mayer
 75d62a585629cdc1ae0d530189653cb1d8d9c53c

uint64_to_float32() and uint64_to_float64() would need
redoing -- the rest have been completely rewritten or deleted.


Thiemo Seufer's parents (Stefan said he'd contact them)
 5a6932d51d1b34b68b3f10fc5ac65598bece88c0

SNAN_BIT_IS_ONE support.


 924b2c07cdfaba9ac408fc5fa77da75a570f9dc5

Trivial fixes to a few busted prototypes.


 b645bb48850fea8db017026897827f0ab42fbdea

Also SNAN_BIT_IS_ONE support.


 fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10

fc81ba5 is changes to code which has been deleted since.


I think we could, if we had to, rewrite those pieces. It would
be nice if we could at least get an ack from Fabrice though.


Yeah - Fabrice, could you please take a quick minute and take a look at 
this and possibly ack the original patch?


  http://marc.info/?l=qemu-devel&m=136725946312880&w=4

Thanks a lot!


Alex





Re: [Qemu-devel] [PATCH] e1000: allow command-line selection of card model

2014-05-21 Thread Michael S. Tsirkin
On Wed, May 21, 2014 at 11:12:42AM +0200, Andreas Färber wrote:
> Am 21.05.2014 11:04, schrieb Michael S. Tsirkin:
> > On Wed, May 21, 2014 at 10:40:54AM +0200, Andreas Färber wrote:
> >> Hi,
> >>
> >> Am 20.05.2014 17:05, schrieb Gabriel L. Somlo:
> >>> Allow selection of different card models from the qemu
> >>> command line, to better accomodate a wider range of guests.
> >>>
> >>> Based-on-patch-by: Romain Dolbeau 
> >>
> >> If that patch carried a Signed-off-by line, you should retain it.
> > 
> > Actually I think that would be confusing. Romain didn't sign off
> > on *this* patch, he signed off on a previous one.
> > A signature by Gabriel indicates Developer's Certificate of Origin 1.1
> > which has an option to incorporate other's work - it
> > does not seem to require signatures by these others.
> 
> With the same argument you could drop anyone's Sob you get as a
> maintainer.

I could but it would not be nice to submitters, and it drops useful info
(author's Sob).  So if someone thinks there's problematic code here and
comes complaining, we want to be able to say "this code came from XYZ".


> But the purpose of Sob is to track through whose hands a
> patch went, not just who last touched it.

Went untouched or mostly untouched.
Did you bother checking?
I looked and Romain's patch isn't very similar to this one.

> My point here was that Based-on-patch-by is very unusual.

What's the harm?
Gabriel's just being nice and crediting other's work.

> The alternative would be to leave the original From: Romain Dolbeau, his
> Sob, then a [gsomlo: Dropped this, added that] followed by Sob.
> 
> Cheers,
> Andreas

That's just asking submitter to do a lot of extra work,
I don't see why would we place roadblocks in submitter's paths
like this. Linux certainly does not and we didn't ask for this
in the past.

Further, the patch author in git will also be the original author then
which is only fair if the patch is changed in very minor ways.
In which case keeping the original Sob around *would* be right.

> -- 
> 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] pcie_host: Turn pcie_host_init() into an instance_init

2014-05-21 Thread Michael S. Tsirkin
On Thu, Apr 24, 2014 at 05:26:51PM +0200, Andreas Färber wrote:
> This assures the trivial field initialization is applied for any derived
> type - currently only Q35PCIHost.
> 
> Signed-off-by: Andreas Färber 
> ---
>  Michael, I've had this preparation lying around for a while but didn't 
>  get further yet. Can you take this through the PCI queue already?


Applied, sorry about the delay.

> 
>  hw/pci-host/q35.c  | 4 
>  hw/pci/pcie_host.c | 7 ---
>  include/hw/pci/pcie_host.h | 1 -
>  3 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 8b8cc4e..aa48b1c 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -47,10 +47,6 @@ static void q35_host_realize(DeviceState *dev, Error 
> **errp)
>  sysbus_add_io(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, &pci->data_mem);
>  sysbus_init_ioports(sbd, MCH_HOST_BRIDGE_CONFIG_DATA, 4);
>  
> -if (pcie_host_init(PCIE_HOST_BRIDGE(s)) < 0) {
> -error_setg(errp, "failed to initialize pcie host");
> -return;
> -}
>  pci->bus = pci_bus_new(DEVICE(s), "pcie.0",
> s->mch.pci_address_space, s->mch.address_space_io,
> 0, TYPE_PCIE_BUS);
> diff --git a/hw/pci/pcie_host.c b/hw/pci/pcie_host.c
> index c6e1b57..7c88a1d 100644
> --- a/hw/pci/pcie_host.c
> +++ b/hw/pci/pcie_host.c
> @@ -83,11 +83,11 @@ static const MemoryRegionOps pcie_mmcfg_ops = {
>  .endianness = DEVICE_NATIVE_ENDIAN,
>  };
>  
> -int pcie_host_init(PCIExpressHost *e)
> +static void pcie_host_init(Object *obj)
>  {
> -e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
> +PCIExpressHost *e = PCIE_HOST_BRIDGE(obj);
>  
> -return 0;
> +e->base_addr = PCIE_BASE_ADDR_UNMAPPED;
>  }
>  
>  void pcie_host_mmcfg_unmap(PCIExpressHost *e)
> @@ -128,6 +128,7 @@ static const TypeInfo pcie_host_type_info = {
>  .parent = TYPE_PCI_HOST_BRIDGE,
>  .abstract = true,
>  .instance_size = sizeof(PCIExpressHost),
> +.instance_init = pcie_host_init,
>  };
>  
>  static void pcie_host_register_types(void)
> diff --git a/include/hw/pci/pcie_host.h b/include/hw/pci/pcie_host.h
> index acca45e..ff44ef6 100644
> --- a/include/hw/pci/pcie_host.h
> +++ b/include/hw/pci/pcie_host.h
> @@ -49,7 +49,6 @@ struct PCIExpressHost {
>  MemoryRegion mmio;
>  };
>  
> -int pcie_host_init(PCIExpressHost *e);
>  void pcie_host_mmcfg_unmap(PCIExpressHost *e);
>  void pcie_host_mmcfg_map(PCIExpressHost *e, hwaddr addr, uint32_t size);
>  void pcie_host_mmcfg_update(PCIExpressHost *e,
> -- 
> 1.8.4.5



[Qemu-devel] [PATCH 03/25] gtk: cleanup CONFIG_VTE ifdef a bit.

2014-05-21 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 45 ++---
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 776e72d..068a39b 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -108,8 +108,8 @@ static const int modifier_keycode[] = {
 typedef struct VirtualConsole
 {
 GtkWidget *menu_item;
-GtkWidget *terminal;
 #if defined(CONFIG_VTE)
+GtkWidget *terminal;
 CharDriverState *chr;
 #endif
 } VirtualConsole;
@@ -1124,13 +1124,12 @@ static gboolean gd_focus_out_event(GtkWidget *widget,
 
 /** Virtual Console Callbacks **/
 
+#if defined(CONFIG_VTE)
 static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
 {
-#if defined(CONFIG_VTE)
 VirtualConsole *vc = chr->opaque;
 
 vte_terminal_feed(VTE_TERMINAL(vc->terminal), (const char *)buf, len);
-#endif
 return len;
 }
 
@@ -1151,12 +1150,6 @@ static CharDriverState *gd_vc_handler(ChardevVC *unused)
 return chr;
 }
 
-void early_gtk_display_init(void)
-{
-register_vc_handler(gd_vc_handler);
-}
-
-#if defined(CONFIG_VTE)
 static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
  gpointer user_data)
 {
@@ -1165,12 +1158,10 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar 
*text, guint size,
 qemu_chr_be_write(vc->chr, (uint8_t  *)text, (unsigned int)size);
 return TRUE;
 }
-#endif
 
 static GSList *gd_vc_init(GtkDisplayState *s, VirtualConsole *vc, int index, 
GSList *group,
   GtkWidget *view_menu)
 {
-#if defined(CONFIG_VTE)
 const char *label;
 char buffer[32];
 char path[32];
@@ -1212,10 +1203,23 @@ static GSList *gd_vc_init(GtkDisplayState *s, 
VirtualConsole *vc, int index, GSL
 vc->chr->init(vc->chr);
 }
 
-#endif /* CONFIG_VTE */
 return group;
 }
 
+static void gd_vcs_init(GtkDisplayState *s, GSList *group,
+GtkWidget *view_menu)
+{
+int i;
+
+for (i = 0; i < nb_vcs; i++) {
+VirtualConsole *vc = &s->vc[i];
+
+group = gd_vc_init(s, vc, i, group, view_menu);
+s->nb_vcs++;
+}
+}
+#endif /* CONFIG_VTE */
+
 /** Window Creation **/
 
 static void gd_connect_signals(GtkDisplayState *s)
@@ -1316,7 +1320,6 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState *s, 
GtkAccelGroup *accel_g
 GSList *group = NULL;
 GtkWidget *view_menu;
 GtkWidget *separator;
-int i;
 
 view_menu = gtk_menu_new();
 gtk_menu_set_accel_group(GTK_MENU(view_menu), accel_group);
@@ -1378,12 +1381,9 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState 
*s, GtkAccelGroup *accel_g
 gtk_accel_map_add_entry("/View/VGA", GDK_KEY_1, HOTKEY_MODIFIERS);
 gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->vga_item);
 
-for (i = 0; i < nb_vcs; i++) {
-VirtualConsole *vc = &s->vc[i];
-
-group = gd_vc_init(s, vc, i, group, view_menu);
-s->nb_vcs++;
-}
+#if defined(CONFIG_VTE)
+gd_vcs_init(s, group, view_menu);
+#endif
 
 separator = gtk_separator_menu_item_new();
 gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator);
@@ -1512,3 +1512,10 @@ void gtk_display_init(DisplayState *ds, bool 
full_screen, bool grab_on_hover)
 
 global_state = s;
 }
+
+void early_gtk_display_init(void)
+{
+#if defined(CONFIG_VTE)
+register_vc_handler(gd_vc_handler);
+#endif
+}
-- 
1.8.3.1




[Qemu-devel] [PATCH 21/25] gtk: Add handling for the xfree86 keycodes

2014-05-21 Thread Gerd Hoffmann
From: Bruce Rogers 

Currently only evdev keycodes are handled by the gtk-ui. SDL has
code to handle both. This patch adds similar processing so that
both keycode types will be handled via the gtk-ui.

Signed-off-by: Bruce Rogers 
Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 36 +++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index 79dc8db..a55ceb4 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -68,6 +68,10 @@
 #include "keymaps.h"
 #include "sysemu/char.h"
 #include "qom/object.h"
+#ifndef _WIN32
+#include 
+#include 
+#endif
 
 #define MAX_VCS 10
 
@@ -197,6 +201,7 @@ struct GtkDisplayState {
 bool external_pause_update;
 
 bool modifier_pressed[ARRAY_SIZE(modifier_keycode)];
+bool has_evdev;
 };
 
 static GtkDisplayState *global_state;
@@ -842,7 +847,11 @@ static gboolean gd_key_event(GtkWidget *widget, 
GdkEventKey *key, void *opaque)
 } else if (gdk_keycode < 97) {
 qemu_keycode = gdk_keycode - 8;
 } else if (gdk_keycode < 158) {
-qemu_keycode = translate_evdev_keycode(gdk_keycode - 97);
+if (s->has_evdev) {
+qemu_keycode = translate_evdev_keycode(gdk_keycode - 97);
+} else {
+qemu_keycode = translate_xfree86_keycode(gdk_keycode - 97);
+}
 } else if (gdk_keycode == 208) { /* Hiragana_Katakana */
 qemu_keycode = 0x70;
 } else if (gdk_keycode == 211) { /* backslash */
@@ -1719,6 +1728,29 @@ static void gd_create_menus(GtkDisplayState *s)
 s->accel_group = accel_group;
 }
 
+static void gd_set_keycode_type(GtkDisplayState *s)
+{
+#ifndef _WIN32
+char *keycodes = NULL;
+GdkDisplay *display = gtk_widget_get_display(s->window);
+Display *x11_display = gdk_x11_display_get_xdisplay(display);
+XkbDescPtr desc = XkbGetKeyboard(x11_display, XkbGBN_AllComponentsMask,
+ XkbUseCoreKbd);
+
+if (desc && desc->names) {
+keycodes = XGetAtomName(x11_display, desc->names->keycodes);
+}
+if (keycodes == NULL) {
+fprintf(stderr, "could not lookup keycode name\n");
+} else if (strstart(keycodes, "evdev", NULL)) {
+s->has_evdev = true;
+} else if (!strstart(keycodes, "xfree86", NULL)) {
+fprintf(stderr, "unknown keycodes `%s', please report to "
+"qemu-devel@nongnu.org\n", keycodes);
+}
+#endif
+}
+
 void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
 {
 GtkDisplayState *s = g_malloc0(sizeof(*s));
@@ -1782,6 +1814,8 @@ void gtk_display_init(DisplayState *ds, bool full_screen, 
bool grab_on_hover)
 gtk_menu_item_activate(GTK_MENU_ITEM(s->grab_on_hover_item));
 }
 
+gd_set_keycode_type(s);
+
 global_state = s;
 }
 
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 07:13 PM, Alexander Graf wrote:
> 
> On 21.05.14 11:11, Michael S. Tsirkin wrote:
>> On Wed, May 21, 2014 at 11:06:09AM +0200, Alexander Graf wrote:
>>> On 21.05.14 10:52, Alexey Kardashevskiy wrote:
 On 05/21/2014 06:40 PM, Alexander Graf wrote:
> On 15.05.14 11:59, Alexey Kardashevskiy wrote:
>> Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
>> XICS used to be unable to reuse interrupts which becomes a problem for
>> dynamic MSI reconfiguration which is happening on guest driver reload or
>> PCI hot (un)plug. Another problem is that PHB has a limit of devices
>> supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good reason
>> for that.
>>
>> This makes use of new XICS ability to reuse interrupts.
>>
>> This removes cached MSI configuration from SPAPR PHB so the first IRQ
>> number
>> of a device is stored in MSI/MSIX config space so there is no need to
>> store
>> this anywhere else. From now on, SPAPR PHB only keeps flags telling what
>> type
>> of interrupt for which device it has configured in order to return
>> error if
>> (for example) MSIX was enabled and the guest is trying to disable MSI
>> which
>> it has not enabled.
>>
>> This removes a limit for the maximum number of MSIX-enabled devices
>> per PHB,
>> now XICS and PCI bus capacity are the only limitation.
>>
>> This changes migration stream as it fixes vmstate_spapr_pci_msi::name
>> which was
>> wrong since the beginning.
>>
>> This fixed traces to be more informative.
>>
>> Signed-off-by: Alexey Kardashevskiy 
>> ---
>>
>> In reality either MSIX or MSI is enabled, never both. So I could remove
>> msi/msix
>> bitmaps from this patch, would it make sense?
> Is this a hard requirement? Does a device have to choose between MSIX and
> MSI or could it theoretically have both enabled? Is this a PCI
> limitation,
> a PAPR/XICS limitation or just a limitation of your implementation?
 My implementation does not have this limitation, I asked if I can simplify
 code by introducing one :)

 I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
 it does not seem to be used by anyone => cannot debug and confirm.

 PAPR spec assumes that if the guest tries enabling MSIX when MSI is
 already
 enabled, this is a "change", not enabling both types. But it also says MSI
 and MSIX vector numbers are not shared. Hm.
>>> Yeah, I'm not aware of any limitation on hardware here and I'd
>>> rather not impose one.
>>>
>>> Michael, do you know of any hardware that uses MSI *and* MSI-X at
>>> the same time?
>>>
>>>
>>> Alex
>> No, and the PCI spec says:
>> A function is permitted to implement both MSI and MSI-X, but system
>> software is
>> prohibited from enabling both at the same time. If system software
>> enables both at the same time, the result is undefined.
> 
> Ah, cool. So yes Alexey, feel free to impose it :).

Heh. This solves just half of the problem - I still have to keep track of
what device got MSI/MSIX configured via that ibm,change-msi interface. I
was hoping I can store such flag somewhere in a device PCI config space but
MSI/MSIX enable bit is not good as it is not set when those calls are made.
And I cannot rely on address/data fields much as the guest can change them
(I already use them to store IRQ numbers and btw it is missing checks when
I read them back for disposal, I'll fix in next round).

Or on "enable" event I could put IRQ numbers to .data of MSI config space
and on "disable" check if it is not zero, then configuration took place,
then I can remove my msi[]/msix[] flag arrays. If the guest did any change
to MSI/MSIX config space (it does not on SPAPR except weird selftest
cases), I compare .data with what ICS can possibly have and either reject
"disable" or handle it and if it breaks XICS - that's too bad for the
stupid guest. Would that be acceptable?


-- 
Alexey



Re: [Qemu-devel] [RFC PATCH v2 0/7] qapi: Specify default value for optional argument in schema json

2014-05-21 Thread Markus Armbruster
Kevin Wolf  writes:

> Am 21.05.2014 um 09:46 hat Markus Armbruster geschrieben:
>> Fam Zheng  writes:
>> 
>> > On Wed, 05/21 07:54, Markus Armbruster wrote:
>> >> Fam Zheng  writes:
>> >> 
>> >> > On Tue, 05/20 13:13, Eric Blake wrote:
>> >> >> On 05/20/2014 03:07 AM, Fam Zheng wrote:
>> >> >> > Please first take a look at patch 7 to see what is supported by this 
>> >> >> > series.
>> >> >> > 
>> >> >> > Patch 1 ~ 3 allows some useful basic types in schema.
>> >> >> > 
>> >> >> > Patch 4 ~ 6 implements the new syntax.
>> >> >> > 
>> >> >> > Note: The introduced '@arg' sigil, just like the preexisting '*arg', 
>> >> >> > is
>> >> >> > reducing the cleanness of the syntax. We should get rid of both of 
>> >> >> > them in long
>> >> >> > term. Here, this series compromises on this and introduces '@arg' 
>> >> >> > because:
>> >> >> > 
>> >> >> >   - We have to distinguish the argument property dictionary from 
>> >> >> > nested struct:
>> >> >> > 
>> >> >> > I.e.:
>> >> >> > 
>> >> >> > 'data': {
>> >> >> > 'arg1': { 'member1': 'int', 'member2': 'str' }
>> >> >> > '@arg2': { 'type': 'int', 'default': 100 }
>> >> >> >  }
>> >> >> > 
>> >> >> > Until we completely drop and forbid the 'arg1' nested struct use 
>> >> >> > case.
>> >> >> > 
>> >> >> >   - Forbidding 'arg1' it's doable, but doing it now means we pull in 
>> >> >> > many
>> >> >> > distractive patches to this series.
>> >> >> 
>> >> >> Question - since we WANT to get rid of nested struct, why not reverse
>> >> >> the sense?  Mark all existing nested structs (weren't there just three
>> >> >> that we found?) with the '@' sigil, and let the new syntax be
>> >> >> sigil-free.  Then when we clean up the nesting, we are also getting rid
>> >> >> of the bad syntax, plus the sigil gives us something to search for in
>> >> >> knowing how much to clean up.  But if you stick the sigil on the new
>> >> >> code, instead of the obsolete code, then as more and more places in the
>> >> >> schema use defaults, it gets harder and harder to remove the use of the
>> >> >> sigil even if the nested structs are eventually removed.
>> >> >> 
>> >> >
>> >> > It makes not much difference I can see. The hard part is
>> >> > actaully dropping
>> >> > nested, converting from sigil <-> non-sigil is easy. Of course,
>> >> > nothing is
>> >> > seriously hard, there are only three nested structs plus some more
>> >> > qapi-schema
>> >> > test code.
>> >> 
>> >> Adding three ugly sigils and making everybody include one when they add
>> >> a nested struct feels much better to me than ugly sigils all over the
>> >> place.
>> >
>> > Well, I could use some background here. Why did we introduce
>> > nested structure
>> > in the first place?
>> 
>> Because we could?
>> 
>> Felt like a good idea at the time?
>> 
>> I quick glance at commit 0f923be and fb3182c suggests they have been
>> supported since the beginning.  There is no design rationale.
>
> Let me extend Fam's question: Why don't we simply remove them right
> now? If it's really only three instances, converting them to full
> types should be a matter of five minutes.

Trades some convenience of expresssion we haven't found useful all that
often for simplicity.

I take the simplicity.



Re: [Qemu-devel] [PATCH v2 8/9] spapr: Implement processor compatibility in ibm, client-architecture-support

2014-05-21 Thread Alexey Kardashevskiy
On 05/21/2014 07:21 PM, Alexander Graf wrote:
> 
> On 21.05.14 10:27, Alexey Kardashevskiy wrote:
>> Modern Linux kernels support last POWERPC CPUs so when a kernel boots,
>> in most cases it can find a matching cpu_spec in the kernel's cpu_specs
>> list. However if the kernel is quite old, it may be missing a definition
>> of the actual CPU. To provide an ability for old kernels to work on modern
>> hardware, a Processor Compatibility Mode has been introduced
>> by the PowerISA specification.
>>
>>  From the hardware prospective, it is supported by the Processor
>> Compatibility Register (PCR) which is defined in PowerISA. The register
>> enables one of the compatibility modes (2.05/2.06/2.07).
>> Since PCR is a hypervisor privileged register and cannot be
>> directly accessed from the guest, the mode selection is done via
>> ibm,client-architecture-support (CAS) RTAS call using which the guest
>> specifies what "raw" and "architected" CPU versions it supports.
>> QEMU works out the best match, changes a "cpu-version" property of
>> every CPU and notifies the guest about the change by setting these
>> properties in the buffer passed as a response on a custom H_CAS hypercall.
>>
>> This implements ibm,client-architecture-support parameters parsing
>> (now only for PVRs) and cooks the device tree diff with new values for
>> "cpu-version", "ibm,ppc-interrupt-server#s" and
>> "ibm,ppc-interrupt-server#s" properties.
>>
>> Signed-off-by: Alexey Kardashevskiy 
>> ---
>>   hw/ppc/spapr.c   |  4 ++-
>>   hw/ppc/spapr_hcall.c | 85
>> 
>>   trace-events |  4 +++
>>   3 files changed, 92 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
>> index 14c72d9..020426a 100644
>> --- a/hw/ppc/spapr.c
>> +++ b/hw/ppc/spapr.c
>> @@ -34,6 +34,7 @@
>>   #include "sysemu/kvm.h"
>>   #include "kvm_ppc.h"
>>   #include "mmu-hash64.h"
>> +#include "qom/cpu.h"
>> #include "hw/boards.h"
>>   #include "hw/ppc/ppc.h"
>> @@ -601,7 +602,8 @@ int spapr_h_cas_compose_response(target_ulong addr,
>> target_ulong size)
>>   _FDT((fdt_open_into(fdt_skel, fdt, size)));
>>   g_free(fdt_skel);
>>   -/* Place to make changes to the tree */
>> +/* Fix skeleton up */
>> +_FDT((spapr_fixup_cpu_dt(fdt, spapr)));
>> /* Pack resulting tree */
>>   _FDT((fdt_pack(fdt)));
>> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
>> index 2f6aa5c..2e0a49c 100644
>> --- a/hw/ppc/spapr_hcall.c
>> +++ b/hw/ppc/spapr_hcall.c
>> @@ -3,6 +3,9 @@
>>   #include "helper_regs.h"
>>   #include "hw/ppc/spapr.h"
>>   #include "mmu-hash64.h"
>> +#include "cpu-models.h"
>> +#include "trace.h"
>> +#include "kvm_ppc.h"
>> struct SPRSyncState {
>>   CPUState *cs;
>> @@ -752,12 +755,94 @@ out:
>>   return ret;
>>   }
>>   +#define get_compat_level(cpuver) ( \
>> +((cpuver) == CPU_POWERPC_LOGICAL_2_05) ? 2050 : \
>> +((cpuver) == CPU_POWERPC_LOGICAL_2_06) ? 2060 : \
>> +((cpuver) == CPU_POWERPC_LOGICAL_2_06_PLUS) ? 2061 : \
>> +((cpuver) == CPU_POWERPC_LOGICAL_2_07) ? 2070 : 0)
>> +
>>   static target_ulong h_client_architecture_support(PowerPCCPU *cpu_,
>> sPAPREnvironment *spapr,
>> target_ulong opcode,
>> target_ulong *args)
>>   {
>>   target_ulong list = args[0];
>> +PowerPCCPUClass *pcc_ = POWERPC_CPU_GET_CLASS(cpu_);
>> +CPUState *cs;
>> +bool cpu_match = false;
>> +unsigned old_cpu_version = cpu_->cpu_version;
>> +unsigned compat_lvl = 0, cpu_version = 0;
>> +unsigned max_lvl = get_compat_level(cpu_->max_compat);
>> +
>> +/* Parse PVR list */
>> +for ( ; ; ) {
>> +uint32_t pvr, pvr_mask;
>> +
>> +pvr_mask = rtas_ld(list, 0);
>> +list += 4;
>> +pvr = rtas_ld(list, 0);
>> +list += 4;
>> +
>> +trace_spapr_cas_pvr_try(pvr);
>> +if (!max_lvl &&
>> +((cpu_->env.spr[SPR_PVR] & pvr_mask) == (pvr & pvr_mask))) {
>> +cpu_match = true;
>> +cpu_version = 0;
>> +} else if (pvr == cpu_->cpu_version) {
>> +cpu_match = true;
>> +cpu_version = cpu_->cpu_version;
>> +} else if (!cpu_match) {
>> +/* If it is a logical PVR, try to determine the highest
>> level */
>> +unsigned lvl = get_compat_level(pvr);
>> +if (lvl) {
>> +bool is205 = (pcc_->pcr_mask & PCR_COMPAT_2_05) &&
>> + (lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_05));
>> +bool is206 = (pcc_->pcr_mask & PCR_COMPAT_2_06) &&
>> +((lvl == get_compat_level(CPU_POWERPC_LOGICAL_2_06)) ||
>> +(lvl ==
>> get_compat_level(CPU_POWERPC_LOGICAL_2_06_PLUS)));
>> +
>> +if (is205 || is206) {
>> +if (!max_

[Qemu-devel] [PATCH 10/25] gtk: simplify resize

2014-05-21 Thread Gerd Hoffmann
Simply ask for a small window size.  When the widgets don't fit in gtk
will automatically make the window large enougth to make things fit, no
need to try (and fail) duplicate that logic in qemu.

Signed-off-by: Gerd Hoffmann 
---
 ui/gtk.c | 40 ++--
 1 file changed, 14 insertions(+), 26 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index a8393dd..6790cf8 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -296,35 +296,23 @@ static void gd_update_caption(GtkDisplayState *s)
 static void gd_update_windowsize(VirtualConsole *vc)
 {
 GtkDisplayState *s = vc->s;
+double sx, sy;
 
-if (!s->full_screen) {
-GtkRequisition req;
-double sx, sy;
-
-if (s->free_scale) {
-sx = vc->gfx.scale_x;
-sy = vc->gfx.scale_y;
-
-vc->gfx.scale_y = 1.0;
-vc->gfx.scale_x = 1.0;
-} else {
-sx = 1.0;
-sy = 1.0;
-}
-
-gtk_widget_set_size_request
-(vc->gfx.drawing_area,
- surface_width(vc->gfx.ds) * vc->gfx.scale_x,
- surface_height(vc->gfx.ds) * vc->gfx.scale_y);
-#if GTK_CHECK_VERSION(3, 0, 0)
-gtk_widget_get_preferred_size(s->vbox, NULL, &req);
-#else
-gtk_widget_size_request(s->vbox, &req);
-#endif
+if (vc->type != GD_VC_GFX || s->full_screen) {
+return;
+}
 
-gtk_window_resize(GTK_WINDOW(s->window),
-  req.width * sx, req.height * sy);
+if (s->free_scale) {
+sx = 1.0;
+sy = 1.0;
+} else {
+sx = vc->gfx.scale_x;
+sy = vc->gfx.scale_y;
 }
+gtk_widget_set_size_request(vc->gfx.drawing_area,
+surface_width(vc->gfx.ds) * sx,
+surface_height(vc->gfx.ds) * sy);
+gtk_window_resize(GTK_WINDOW(s->window), 320, 240);
 }
 
 static void gd_update_full_redraw(VirtualConsole *vc)
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH v2 8/8] spapr_pci: Use XICS interrupt allocator and do not cache interrupts in PHB

2014-05-21 Thread Michael S. Tsirkin
On Wed, May 21, 2014 at 07:33:36PM +1000, Alexey Kardashevskiy wrote:
> On 05/21/2014 07:13 PM, Alexander Graf wrote:
> > 
> > On 21.05.14 11:11, Michael S. Tsirkin wrote:
> >> On Wed, May 21, 2014 at 11:06:09AM +0200, Alexander Graf wrote:
> >>> On 21.05.14 10:52, Alexey Kardashevskiy wrote:
>  On 05/21/2014 06:40 PM, Alexander Graf wrote:
> > On 15.05.14 11:59, Alexey Kardashevskiy wrote:
> >> Currently SPAPR PHB keeps track of all allocated MSI/MISX interrupt as
> >> XICS used to be unable to reuse interrupts which becomes a problem for
> >> dynamic MSI reconfiguration which is happening on guest driver reload 
> >> or
> >> PCI hot (un)plug. Another problem is that PHB has a limit of devices
> >> supporting MSI/MSIX (SPAPR_MSIX_MAX_DEVS=32) and there is no good 
> >> reason
> >> for that.
> >>
> >> This makes use of new XICS ability to reuse interrupts.
> >>
> >> This removes cached MSI configuration from SPAPR PHB so the first IRQ
> >> number
> >> of a device is stored in MSI/MSIX config space so there is no need to
> >> store
> >> this anywhere else. From now on, SPAPR PHB only keeps flags telling 
> >> what
> >> type
> >> of interrupt for which device it has configured in order to return
> >> error if
> >> (for example) MSIX was enabled and the guest is trying to disable MSI
> >> which
> >> it has not enabled.
> >>
> >> This removes a limit for the maximum number of MSIX-enabled devices
> >> per PHB,
> >> now XICS and PCI bus capacity are the only limitation.
> >>
> >> This changes migration stream as it fixes vmstate_spapr_pci_msi::name
> >> which was
> >> wrong since the beginning.
> >>
> >> This fixed traces to be more informative.
> >>
> >> Signed-off-by: Alexey Kardashevskiy 
> >> ---
> >>
> >> In reality either MSIX or MSI is enabled, never both. So I could remove
> >> msi/msix
> >> bitmaps from this patch, would it make sense?
> > Is this a hard requirement? Does a device have to choose between MSIX 
> > and
> > MSI or could it theoretically have both enabled? Is this a PCI
> > limitation,
> > a PAPR/XICS limitation or just a limitation of your implementation?
>  My implementation does not have this limitation, I asked if I can 
>  simplify
>  code by introducing one :)
> 
>  I cannot see any reason why PCI cannot have both MSI and MSIX enabled but
>  it does not seem to be used by anyone => cannot debug and confirm.
> 
>  PAPR spec assumes that if the guest tries enabling MSIX when MSI is
>  already
>  enabled, this is a "change", not enabling both types. But it also says 
>  MSI
>  and MSIX vector numbers are not shared. Hm.
> >>> Yeah, I'm not aware of any limitation on hardware here and I'd
> >>> rather not impose one.
> >>>
> >>> Michael, do you know of any hardware that uses MSI *and* MSI-X at
> >>> the same time?
> >>>
> >>>
> >>> Alex
> >> No, and the PCI spec says:
> >> A function is permitted to implement both MSI and MSI-X, but system
> >> software is
> >> prohibited from enabling both at the same time. If system software
> >> enables both at the same time, the result is undefined.
> > 
> > Ah, cool. So yes Alexey, feel free to impose it :).
> 
> Heh. This solves just half of the problem - I still have to keep track of
> what device got MSI/MSIX configured via that ibm,change-msi interface. I
> was hoping I can store such flag somewhere in a device PCI config space but
> MSI/MSIX enable bit is not good as it is not set when those calls are made.

Hmm could you pls remind me why is it desirable to store this
in device? Device is not yet sending MSI interrupts after all
otherwise enable would be set.

> And I cannot rely on address/data fields much as the guest can change them
> (I already use them to store IRQ numbers and btw it is missing checks when
> I read them back for disposal, I'll fix in next round).
> 
> Or on "enable" event I could put IRQ numbers to .data of MSI config space
> and on "disable" check if it is not zero, then configuration took place,
> then I can remove my msi[]/msix[] flag arrays. If the guest did any change
> to MSI/MSIX config space (it does not on SPAPR except weird selftest
> cases), I compare .data with what ICS can possibly have and either reject
> "disable" or handle it and if it breaks XICS - that's too bad for the
> stupid guest. Would that be acceptable?


> 
> -- 
> Alexey



Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Markus Armbruster
Alexander Graf  writes:

> On 21.05.14 09:51, Paolo Bonzini wrote:
>> Il 21/05/2014 05:54, Alexey Kardashevskiy ha scritto:
>>> Hi!
>>>
>>> We recently discovered that not entire QEMU is GPL2-compatible, the fpu
>>> emulation has a different license (copied below) which might create
>>> legal
>>> problems because of that "INDEMNIFY" statement.
>>>
>>> Does anyone else care (except IBM)?
>>>
>>> What would the proper solution be? Ask the creator to relicense it under
>>> GPL? I failed to find a contact as the homepage on berkeley.edu is
>>> restricted. Rewrite the code? This code is used in FPU emulation
>>> for TCG,
>>> is that the only use of it? If it should not get called for KVM,
>>> that would
>>> be a temporary band-aid for us :)
>>
>> http://marc.info/?l=qemu-devel&m=136725946312880&w=4
>>
>> The following people haven't acked the relicensing of their
>> contributions from softfloat-2b to softfloat-2a or GPLv2+ yet:
>>
>> Fabrice Bellard 
>> 1d6bda356153c82e100680d9f2165e32c8fb1330
>> 750afe93fd15fafc20b6c34d30f339547d15c2d1
>>
>> Jocelyn Mayer
>> 75d62a585629cdc1ae0d530189653cb1d8d9c53c
>>
>> Thiemo Seufer's parents (Stefan said he'd contact them)
>> 5a6932d51d1b34b68b3f10fc5ac65598bece88c0
>> 924b2c07cdfaba9ac408fc5fa77da75a570f9dc5
>> b645bb48850fea8db017026897827f0ab42fbdea
>> fc81ba536bc3d8cdbcf9e92369e9bc5ede69da10
>>
>> This list only includes people whose contributions has not been
>> reverted in the meanwhile.
>
> How many % of the overall commits does that make? IIRC you can
> relicense source code if the "majority of authors" agrees and nobody
> actively disagrees - or so. But IANAL :)

You can get away with infringing copyright if nobody actively sues you.

Sorry, not an option.  We have to rip out contributions we can't get
relicensed.  Except for contributions that don't qualify for copyright
protection, but that's shaky ground; let's not go there.



Re: [Qemu-devel] [PATCH 01/18] migration: dump vmstate info as a json file for static analysis

2014-05-21 Thread Dr. David Alan Gilbert
* Amit Shah (amit.s...@redhat.com) wrote:
> This commit adds a new command, '-dump-vmstate', that takes a filename
> as a parameter.  When executed, QEMU will dump the vmstate information
> for the machine type it's invoked with to the file, and quit.
> 
> The JSON-format output can then be used to compare the vmstate info for
> different QEMU versions, specifically to test whether live migration
> would break due to changes in the vmstate data.
> 
> This is based on a version from Andreas Färber posted here:
> https://lists.gnu.org/archive/html/qemu-devel/2013-10/msg03095.html
> 
> A Python script that compares the output of such JSON dumps is included
> in the following commit.
> 
> Signed-off-by: Amit Shah 
> ---
>  include/migration/vmstate.h |   2 +
>  qemu-options.hx |   9 +++
>  savevm.c| 134 
> 
>  vl.c|  14 +
>  4 files changed, 159 insertions(+)
> 
> diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
> index 7e45048..9829c0e 100644
> --- a/include/migration/vmstate.h
> +++ b/include/migration/vmstate.h
> @@ -778,4 +778,6 @@ void vmstate_register_ram(struct MemoryRegion *memory, 
> DeviceState *dev);
>  void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev);
>  void vmstate_register_ram_global(struct MemoryRegion *memory);
>  
> +void dump_vmstate_json_to_file(FILE *out_fp);
> +
>  #endif
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 781af14..d376227 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -3146,6 +3146,15 @@ STEXI
>  prepend a timestamp to each log message.(default:on)
>  ETEXI
>  
> +DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
> +"-dump-vmstate \n" "", QEMU_ARCH_ALL)
> +STEXI
> +@item -dump-vmstate @var{file}
> +@findex -dump-vmstate
> +Dump json-encoded vmstate information for current machine type to file
> +in @var{file}
> +ETEXI
> +
>  HXCOMM This is the last statement. Insert new options before this line!
>  STEXI
>  @end table
> diff --git a/savevm.c b/savevm.c
> index da8aa24..a4ce279 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -24,6 +24,7 @@
>  
>  #include "config-host.h"
>  #include "qemu-common.h"
> +#include "hw/boards.h"
>  #include "hw/hw.h"
>  #include "hw/qdev.h"
>  #include "net/net.h"
> @@ -241,6 +242,139 @@ static QTAILQ_HEAD(savevm_handlers, SaveStateEntry) 
> savevm_handlers =
>  QTAILQ_HEAD_INITIALIZER(savevm_handlers);
>  static int global_section_id;
>  
> +static void dump_vmstate_vmsd(FILE *out_file,
> +  const VMStateDescription *vmsd, int indent,
> +  bool is_subsection);
> +
> +static void dump_vmstate_vmsf(FILE *out_file, const VMStateField *field,
> +   int indent)

checkpatch points out that some tabs managed to get into that indent line.


Generally I think this patch is OK and quite useful; two thoughts:
   1) I was surprised it dumped every object type, rather than just those
  that are instantiated; I think the latter would be more use in some
  circumstances, since there's a load of weird and wonderful objects
  that exist and are very rarely used.

   2) 'fields_exists' is a weird naming to put in the json file - it's
  a function pointer for determining if the field is going to be present;
  maybe renaming as 'conditional' would make sense.

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



[Qemu-devel] [PATCH 12/25] gtk: add tab to trace events

2014-05-21 Thread Gerd Hoffmann
So you can see which of multiple displays (if present) was resized ;)

Signed-off-by: Gerd Hoffmann 
---
 trace-events | 6 +++---
 ui/gtk.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/trace-events b/trace-events
index b6d289d..3a41abf 100644
--- a/trace-events
+++ b/trace-events
@@ -1045,9 +1045,9 @@ displaychangelistener_unregister(void *dcl, const char 
*name) "%p [ %s ]"
 ppm_save(const char *filename, void *display_surface) "%s surface=%p"
 
 # ui/gtk.c
-gd_switch(int width, int height) "width=%d, height=%d"
-gd_update(int x, int y, int w, int h) "x=%d, y=%d, w=%d, h=%d"
-gd_key_event(int gdk_keycode, int qemu_keycode, const char *action) 
"translated GDK keycode %d to QEMU keycode %d (%s)"
+gd_switch(const char *tab, int width, int height) "tab=%s, width=%d, height=%d"
+gd_update(const char *tab, int x, int y, int w, int h) "tab=%s, x=%d, y=%d, 
w=%d, h=%d"
+gd_key_event(const char *tab, int gdk_keycode, int qemu_keycode, const char 
*action) "tab=%s, translated GDK keycode %d to QEMU keycode %d (%s)"
 
 # ui/input.c
 input_event_key_number(int conidx, int number, bool down) "con %d, key number 
0x%x, down %d"
diff --git a/ui/gtk.c b/ui/gtk.c
index 07883a1..3ee9465 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -355,7 +355,7 @@ static void gd_update(DisplayChangeListener *dcl,
 int fbw, fbh;
 int ww, wh;
 
-trace_gd_update(x, y, w, h);
+trace_gd_update(vc->label, x, y, w, h);
 
 if (vc->gfx.convert) {
 pixman_image_composite(PIXMAN_OP_SRC, vc->gfx.ds->image,
@@ -461,7 +461,7 @@ static void gd_switch(DisplayChangeListener *dcl,
 VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
 bool resized = true;
 
-trace_gd_switch(surface_width(surface), surface_height(surface));
+trace_gd_switch(vc->label, surface_width(surface), 
surface_height(surface));
 
 if (vc->gfx.surface) {
 cairo_surface_destroy(vc->gfx.surface);
@@ -815,7 +815,7 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey 
*key, void *opaque)
 }
 #endif
 
-trace_gd_key_event(gdk_keycode, qemu_keycode,
+trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
 
 for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
-- 
1.8.3.1




Re: [Qemu-devel] fpu/softfloat.c licensing

2014-05-21 Thread Peter Maydell
On 21 May 2014 10:43, Markus Armbruster  wrote:
> Alexander Graf  writes:
>> How many % of the overall commits does that make? IIRC you can
>> relicense source code if the "majority of authors" agrees and nobody
>> actively disagrees - or so. But IANAL :)
>
> You can get away with infringing copyright if nobody actively sues you.
>
> Sorry, not an option.  We have to rip out contributions we can't get
> relicensed.  Except for contributions that don't qualify for copyright
> protection, but that's shaky ground; let's not go there.

Presumably if IBM has an active interest in helping us to fix this
they can provide an actual lawyer's legal opinion, so we don't
need to make amateur guesses about what we need to do...

thanks
-- PMM



Re: [Qemu-devel] [PATCH] e1000: allow command-line selection of card model

2014-05-21 Thread Andreas Färber
Am 21.05.2014 11:25, schrieb Michael S. Tsirkin:
> On Wed, May 21, 2014 at 11:12:42AM +0200, Andreas Färber wrote:
>> Am 21.05.2014 11:04, schrieb Michael S. Tsirkin:
>>> On Wed, May 21, 2014 at 10:40:54AM +0200, Andreas Färber wrote:
 Hi,

 Am 20.05.2014 17:05, schrieb Gabriel L. Somlo:
> Allow selection of different card models from the qemu
> command line, to better accomodate a wider range of guests.
>
> Based-on-patch-by: Romain Dolbeau 

 If that patch carried a Signed-off-by line, you should retain it.
>>>
>>> Actually I think that would be confusing. Romain didn't sign off
>>> on *this* patch, he signed off on a previous one.
>>> A signature by Gabriel indicates Developer's Certificate of Origin 1.1
>>> which has an option to incorporate other's work - it
>>> does not seem to require signatures by these others.
>>
>> With the same argument you could drop anyone's Sob you get as a
>> maintainer.
> 
> I could but it would not be nice to submitters, and it drops useful info
> (author's Sob).  So if someone thinks there's problematic code here and
> comes complaining, we want to be able to say "this code came from XYZ".
> 
> 
>> But the purpose of Sob is to track through whose hands a
>> patch went, not just who last touched it.
> 
> Went untouched or mostly untouched.
> Did you bother checking?
> I looked and Romain's patch isn't very similar to this one.
> 
>> My point here was that Based-on-patch-by is very unusual.
> 
> What's the harm?
> Gabriel's just being nice and crediting other's work.
> 
>> The alternative would be to leave the original From: Romain Dolbeau, his
>> Sob, then a [gsomlo: Dropped this, added that] followed by Sob.
>>
>> Cheers,
>> Andreas
> 
> That's just asking submitter to do a lot of extra work,
> I don't see why would we place roadblocks in submitter's paths
> like this. Linux certainly does not and we didn't ask for this
> in the past.
> 
> Further, the patch author in git will also be the original author then
> which is only fair if the patch is changed in very minor ways.
> In which case keeping the original Sob around *would* be right.

Either the patch is based on the patch the submitter claims it is based
on, or it is not based on that patch.

If it is, then the Sob should be retained because not doing so is
dropping useful information as you put it. You will find both ways, From
new and old+new Sob or From original and [], in git history, depending
on how much changed (which I have not checked here).

If it is not based on Romain's patch, then Suggested-by would be much
more to the point - and something the maintainer (Stefan) could easily
edit when signing off, if there were nothing else to change.

Andreas

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



[Qemu-devel] [PATCH v2 1/9] target-ppc: Add "compat" CPU option

2014-05-21 Thread Alexey Kardashevskiy
PowerISA defines a compatibility mode for server POWERPC CPUs which
is supported by the PCR special register which is hypervisor privileged.
To support this mode for guests, SPAPR defines a set of virtual PVRs,
one per PowerISA spec version. When a hypervisor needs a guest to work in
a compatibility mode, it puts a virtual PVR value into @cpu-version
property of a CPU node.

This introduces a "compat" CPU option which defines maximal compatibility
mode enabled. The supported modes are power6/power7/power8.

This does not change the existing behaviour, new property will be used
by next patches.

Signed-off-by: Alexey Kardashevskiy 
---
 target-ppc/cpu-models.h | 10 ++
 target-ppc/cpu-qom.h|  2 ++
 target-ppc/translate_init.c | 75 +
 3 files changed, 87 insertions(+)

diff --git a/target-ppc/cpu-models.h b/target-ppc/cpu-models.h
index 9a003b4..db75896 100644
--- a/target-ppc/cpu-models.h
+++ b/target-ppc/cpu-models.h
@@ -595,6 +595,16 @@ enum {
 CPU_POWERPC_PA6T   = 0x0090,
 };
 
+/* Logical PVR definitions for sPAPR */
+enum {
+CPU_POWERPC_LOGICAL_2_04   = 0x0F01,
+CPU_POWERPC_LOGICAL_2_05   = 0x0F02,
+CPU_POWERPC_LOGICAL_2_06   = 0x0F03,
+CPU_POWERPC_LOGICAL_2_06_PLUS  = 0x0F13,
+CPU_POWERPC_LOGICAL_2_07   = 0x0F04,
+CPU_POWERPC_LOGICAL_2_08   = 0x0F05,
+};
+
 /* System version register (used on MPC 8xxx)*/
 enum {
 POWERPC_SVR_NONE   = 0x,
diff --git a/target-ppc/cpu-qom.h b/target-ppc/cpu-qom.h
index 046ea0e..533de8f 100644
--- a/target-ppc/cpu-qom.h
+++ b/target-ppc/cpu-qom.h
@@ -83,6 +83,7 @@ typedef struct PowerPCCPUClass {
  * PowerPCCPU:
  * @env: #CPUPPCState
  * @cpu_dt_id: CPU index used in the device tree. KVM uses this index too
+ * @max_compat: Maximal supported logical PVR from the command line
  *
  * A PowerPC CPU.
  */
@@ -93,6 +94,7 @@ struct PowerPCCPU {
 
 CPUPPCState env;
 int cpu_dt_id;
+uint32_t max_compat;
 };
 
 static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 16ecada..2e273dc 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -28,6 +28,8 @@
 #include "mmu-hash32.h"
 #include "mmu-hash64.h"
 #include "qemu/error-report.h"
+#include "qapi/visitor.h"
+#include "hw/qdev-properties.h"
 
 //#define PPC_DUMP_CPU
 //#define PPC_DEBUG_SPR
@@ -7680,6 +7682,76 @@ POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data)
 pcc->l1_icache_size = 0x1;
 }
 
+static void powerpc_get_compat(Object *obj, Visitor *v,
+   void *opaque, const char *name, Error **errp)
+{
+char *value = (char *)"";
+Property *prop = opaque;
+uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);
+
+switch (*max_compat) {
+case CPU_POWERPC_LOGICAL_2_05:
+value = (char *)"power6";
+break;
+case CPU_POWERPC_LOGICAL_2_06:
+value = (char *)"power7";
+break;
+case CPU_POWERPC_LOGICAL_2_07:
+value = (char *)"power8";
+break;
+case 0:
+break;
+default:
+error_setg(errp, "Internal error: compat is set to %x",
+   max_compat ? *max_compat : -1);
+break;
+}
+
+visit_type_str(v, &value, name, errp);
+}
+
+static void powerpc_set_compat(Object *obj, Visitor *v,
+   void *opaque, const char *name, Error **errp)
+{
+Error *error = NULL;
+char *value = NULL;
+Property *prop = opaque;
+uint32_t *max_compat = qdev_get_prop_ptr(DEVICE(obj), prop);
+
+visit_type_str(v, &value, name, &error);
+if (error) {
+error_propagate(errp, error);
+return;
+}
+
+if (strcmp(value, "power6") == 0) {
+*max_compat = CPU_POWERPC_LOGICAL_2_05;
+} else if (strcmp(value, "power7") == 0) {
+*max_compat = CPU_POWERPC_LOGICAL_2_06;
+} else if (strcmp(value, "power8") == 0) {
+*max_compat = CPU_POWERPC_LOGICAL_2_07;
+} else {
+error_setg(errp, "Invalid compatibility mode \"%s\"", value);
+}
+
+g_free(value);
+}
+
+static PropertyInfo powerpc_compat_propinfo = {
+.name = "str",
+.legacy_name = "powerpc-server-compat",
+.get = powerpc_get_compat,
+.set = powerpc_set_compat,
+};
+
+#define DEFINE_PROP_POWERPC_COMPAT(_n, _s, _f) \
+DEFINE_PROP(_n, _s, _f, powerpc_compat_propinfo, uint32_t)
+
+static Property powerpc_servercpu_properties[] = {
+DEFINE_PROP_POWERPC_COMPAT("compat", PowerPCCPU, max_compat),
+DEFINE_PROP_END_OF_LIST(),
+};
+
 static void init_proc_POWER7 (CPUPPCState *env)
 {
 gen_spr_ne_601(env);
@@ -7766,6 +7838,7 @@ POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data)
 
 dc->fw_name = "PowerPC,POWER7";
 dc->desc = "POWER7";
+dc->props = powerpc_servercpu_properties;
 pcc->pvr = CPU_POWERP

  1   2   3   4   >