]> git.proxmox.com Git - qemu.git/commitdiff
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
authorAnthony Liguori <aliguori@us.ibm.com>
Thu, 14 Mar 2013 19:50:58 +0000 (14:50 -0500)
committerAnthony Liguori <aliguori@us.ibm.com>
Thu, 14 Mar 2013 19:50:58 +0000 (14:50 -0500)
# By Andreas Färber (16) and Igor Mammedov (1)
# Via Andreas Färber
* afaerber/qom-cpu:
  target-lm32: Update VMStateDescription to LM32CPU
  target-arm: Override do_interrupt for ARMv7-M profile
  cpu: Replace do_interrupt() by CPUClass::do_interrupt method
  cpu: Pass CPUState to cpu_interrupt()
  exec: Pass CPUState to cpu_reset_interrupt()
  cpu: Move halted and interrupt_request fields to CPUState
  target-cris/helper.c: Update Coding Style
  target-i386: Update VMStateDescription to X86CPU
  cpu: Introduce cpu_class_set_vmsd()
  cpu: Register VMStateDescription through CPUState
  stubs: Add a vmstate_dummy struct for CONFIG_USER_ONLY
  vmstate: Make vmstate_register() static inline
  target-sh4: Move PVR/PRR/CVR into SuperHCPUClass
  target-sh4: Introduce SuperHCPU subclasses
  cpus: Replace open-coded CPU loop in qmp_memsave() with qemu_get_cpu()
  monitor: Use qemu_get_cpu() in monitor_set_cpu()
  cpu: Fix qemu_get_cpu() to return NULL if CPU not found

1  2 
exec.c
monitor.c

diff --combined exec.c
index f84e0955dc024e6d8797264b5ad7bdfba6b60660,c5e65a9380a554faf98c4538faf2c420798d7224..8a6aac36e347399ffa448fac4cab1fae2c135110
--- 1/exec.c
--- 2/exec.c
+++ b/exec.c
@@@ -219,16 -219,16 +219,16 @@@ void cpu_exec_init_all(void
  #endif
  }
  
- #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
+ #if !defined(CONFIG_USER_ONLY)
  
  static int cpu_common_post_load(void *opaque, int version_id)
  {
-     CPUArchState *env = opaque;
+     CPUState *cpu = opaque;
  
      /* 0x01 was CPU_INTERRUPT_EXIT. This line can be removed when the
         version_id is increased. */
-     env->interrupt_request &= ~0x01;
-     tlb_flush(env, 1);
+     cpu->interrupt_request &= ~0x01;
+     tlb_flush(cpu->env_ptr, 1);
  
      return 0;
  }
@@@ -240,11 -240,13 +240,13 @@@ static const VMStateDescription vmstate
      .minimum_version_id_old = 1,
      .post_load = cpu_common_post_load,
      .fields      = (VMStateField []) {
-         VMSTATE_UINT32(halted, CPUArchState),
-         VMSTATE_UINT32(interrupt_request, CPUArchState),
+         VMSTATE_UINT32(halted, CPUState),
+         VMSTATE_UINT32(interrupt_request, CPUState),
          VMSTATE_END_OF_LIST()
      }
  };
+ #else
+ #define vmstate_cpu_common vmstate_dummy
  #endif
  
  CPUState *qemu_get_cpu(int index)
          env = env->next_cpu;
      }
  
-     return cpu;
+     return env ? cpu : NULL;
  }
  
  void cpu_exec_init(CPUArchState *env)
  {
      CPUState *cpu = ENV_GET_CPU(env);
+     CPUClass *cc = CPU_GET_CLASS(cpu);
      CPUArchState **penv;
      int cpu_index;
  
  #if defined(CONFIG_USER_ONLY)
      cpu_list_unlock();
  #endif
+     vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu);
  #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
-     vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
      register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
                      cpu_save, cpu_load, env);
+     assert(cc->vmsd == NULL);
  #endif
+     if (cc->vmsd != NULL) {
+         vmstate_register(NULL, cpu_index, cc->vmsd, cpu);
+     }
  }
  
  #if defined(TARGET_HAS_ICE)
@@@ -485,11 -492,6 +492,6 @@@ void cpu_single_step(CPUArchState *env
  #endif
  }
  
- void cpu_reset_interrupt(CPUArchState *env, int mask)
- {
-     env->interrupt_request &= ~mask;
- }
  void cpu_exit(CPUArchState *env)
  {
      CPUState *cpu = ENV_GET_CPU(env);
@@@ -844,8 -846,6 +846,8 @@@ static void *file_ram_alloc(RAMBlock *b
                              const char *path)
  {
      char *filename;
 +    char *sanitized_name;
 +    char *c;
      void *area;
      int fd;
  #ifdef MAP_POPULATE
          return NULL;
      }
  
 -    filename = g_strdup_printf("%s/qemu_back_mem.XXXXXX", path);
 +    /* Make name safe to use with mkstemp by replacing '/' with '_'. */
 +    sanitized_name = g_strdup(block->mr->name);
 +    for (c = sanitized_name; *c != '\0'; c++) {
 +        if (*c == '/')
 +            *c = '_';
 +    }
 +
 +    filename = g_strdup_printf("%s/qemu_back_mem.%s.XXXXXX", path,
 +                               sanitized_name);
 +    g_free(sanitized_name);
  
      fd = mkstemp(filename);
      if (fd < 0) {
@@@ -1476,7 -1467,7 +1478,7 @@@ static void check_watchpoint(int offset
          /* We re-entered the check after replacing the TB. Now raise
           * the debug interrupt so that is will trigger after the
           * current instruction. */
-         cpu_interrupt(env, CPU_INTERRUPT_DEBUG);
+         cpu_interrupt(ENV_GET_CPU(env), CPU_INTERRUPT_DEBUG);
          return;
      }
      vaddr = (env->mem_io_vaddr & TARGET_PAGE_MASK) + offset;
diff --combined monitor.c
index 1b5acf876dc7709cd1e87a144675cabcb522da85,ab05c49abbb795d65c96158e1ab1326340c4eaa2..112e92064d4cc957805127c67f114100adbfade0
+++ b/monitor.c
@@@ -47,7 -47,6 +47,7 @@@
  #include "migration/migration.h"
  #include "sysemu/kvm.h"
  #include "qemu/acl.h"
 +#include "tpm/tpm.h"
  #include "qapi/qmp/qint.h"
  #include "qapi/qmp/qfloat.h"
  #include "qapi/qmp/qlist.h"
@@@ -856,17 -855,14 +856,14 @@@ EventInfoList *qmp_query_events(Error *
  /* set the current CPU defined by the user */
  int monitor_set_cpu(int cpu_index)
  {
-     CPUArchState *env;
      CPUState *cpu;
  
-     for (env = first_cpu; env != NULL; env = env->next_cpu) {
-         cpu = ENV_GET_CPU(env);
-         if (cpu->cpu_index == cpu_index) {
-             cur_mon->mon_cpu = env;
-             return 0;
-         }
+     cpu = qemu_get_cpu(cpu_index);
+     if (cpu == NULL) {
+         return -1;
      }
-     return -1;
+     cur_mon->mon_cpu = cpu->env_ptr;
+     return 0;
  }
  
  static CPUArchState *mon_get_cpu(void)
@@@ -2722,13 -2718,6 +2719,13 @@@ static mon_cmd_t info_cmds[] = 
          .help       = "show available trace-events & their state",
          .mhandler.cmd = do_trace_print_events,
      },
 +    {
 +        .name       = "tpm",
 +        .args_type  = "",
 +        .params     = "",
 +        .help       = "show the TPM device",
 +        .mhandler.cmd = hmp_info_tpm,
 +    },
      {
          .name       = NULL,
      },