Commit a65afaae authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging



x86 and machine queue, 2017-06-05

# gpg: Signature made Mon 05 Jun 2017 19:58:01 BST
# gpg:                using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/x86-and-machine-pull-request:
  scripts: Test script to look for -device crashes
  qemu.py: Add QEMUMachine.exitcode() method
  qemu.py: Don't set _popen=None on error/shutdown
  spapr: cleanup spapr_fixup_cpu_numa_dt() usage
  numa: move numa_node from CPUState into target specific classes
  numa: make hmp 'info numa' fetch numa nodes from qmp_query_cpus() result
  numa: make sure that all cpus have has_node_id set if numa is enabled
  numa: move default mapping init to machine
  numa: consolidate cpu_preplug fixups/checks for pc/arm/spapr
  pc: Use "min-[x]level" on compat_props

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents a0d4aac7 23ea4f30
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -496,12 +496,10 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
    srat->reserved1 = cpu_to_le32(1);

    for (i = 0; i < cpu_list->len; ++i) {
        int node_id = cpu_list->cpus[i].props.has_node_id ?
            cpu_list->cpus[i].props.node_id : 0;
        core = acpi_data_push(table_data, sizeof(*core));
        core->type = ACPI_SRAT_PROCESSOR_GICC;
        core->length = sizeof(*core);
        core->proximity = cpu_to_le32(node_id);
        core->proximity = cpu_to_le32(cpu_list->cpus[i].props.node_id);
        core->acpi_processor_uid = cpu_to_le32(i);
        core->flags = cpu_to_le32(1);
    }
+2 −14
Original line number Diff line number Diff line
@@ -1372,7 +1372,6 @@ static void machvirt_init(MachineState *machine)
    for (n = 0; n < possible_cpus->len; n++) {
        Object *cpuobj;
        CPUState *cs;
        int node_id;

        if (n >= smp_cpus) {
            break;
@@ -1385,19 +1384,8 @@ static void machvirt_init(MachineState *machine)
        cs = CPU(cpuobj);
        cs->cpu_index = n;

        node_id = possible_cpus->cpus[cs->cpu_index].props.node_id;
        if (!possible_cpus->cpus[cs->cpu_index].props.has_node_id) {
            /* by default CPUState::numa_node was 0 if it's not set via CLI
             * keep it this way for now but in future we probably should
             * refuse to start up with incomplete numa mapping */
             node_id = 0;
        }
        if (cs->numa_node == CPU_UNSET_NUMA_NODE_ID) {
            cs->numa_node = node_id;
        } else {
            /* CPU isn't device_add compatible yet, this shouldn't happen */
            error_setg(&error_abort, "user set node-id not implemented");
        }
        numa_cpu_pre_plug(&possible_cpus->cpus[cs->cpu_index], DEVICE(cpuobj),
                          &error_fatal);

        if (!vms->secure) {
            object_property_set_bool(cpuobj, false, "has_el3", NULL);
+27 −10
Original line number Diff line number Diff line
@@ -701,26 +701,43 @@ static char *cpu_slot_to_string(const CPUArchId *cpu)
    return g_string_free(s, false);
}

static void machine_numa_validate(MachineState *machine)
static void machine_numa_finish_init(MachineState *machine)
{
    int i;
    bool default_mapping;
    GString *s = g_string_new(NULL);
    MachineClass *mc = MACHINE_GET_CLASS(machine);
    const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(machine);

    assert(nb_numa_nodes);
    for (i = 0; i < possible_cpus->len; i++) {
        if (possible_cpus->cpus[i].props.has_node_id) {
            break;
        }
    }
    default_mapping = (i == possible_cpus->len);

    for (i = 0; i < possible_cpus->len; i++) {
        const CPUArchId *cpu_slot = &possible_cpus->cpus[i];

        /* at this point numa mappings are initilized by CLI options
         * or with default mappings so it's sufficient to list
         * all not yet mapped CPUs here */
        /* TODO: make it hard error in future */
        if (!cpu_slot->props.has_node_id) {
            /* fetch default mapping from board and enable it */
            CpuInstanceProperties props = cpu_slot->props;

            if (!default_mapping) {
                /* record slots with not set mapping,
                 * TODO: make it hard error in future */
                char *cpu_str = cpu_slot_to_string(cpu_slot);
            g_string_append_printf(s, "%sCPU %d [%s]", s->len ? ", " : "", i,
                                   cpu_str);
                g_string_append_printf(s, "%sCPU %d [%s]",
                                       s->len ? ", " : "", i, cpu_str);
                g_free(cpu_str);

                /* non mapped cpus used to fallback to node 0 */
                props.node_id = 0;
            }

            props.has_node_id = true;
            machine_set_cpu_numa_node(machine, &props, &error_fatal);
        }
    }
    if (s->len && !qtest_enabled()) {
@@ -738,7 +755,7 @@ void machine_run_board_init(MachineState *machine)
    MachineClass *machine_class = MACHINE_GET_CLASS(machine);

    if (nb_numa_nodes) {
        machine_numa_validate(machine);
        machine_numa_finish_init(machine);
    }
    machine_class->init(machine);
}
+1 −2
Original line number Diff line number Diff line
@@ -2335,8 +2335,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)
    srat->reserved1 = cpu_to_le32(1);

    for (i = 0; i < apic_ids->len; i++) {
        int node_id = apic_ids->cpus[i].props.has_node_id ?
            apic_ids->cpus[i].props.node_id : 0;
        int node_id = apic_ids->cpus[i].props.node_id;
        uint32_t apic_id = apic_ids->cpus[i].arch_id;

        if (apic_id < 255) {
+2 −19
Original line number Diff line number Diff line
@@ -788,10 +788,8 @@ static FWCfgState *bochs_bios_init(AddressSpace *as, PCMachineState *pcms)
    for (i = 0; i < cpus->len; i++) {
        unsigned int apic_id = cpus->cpus[i].arch_id;
        assert(apic_id < pcms->apic_id_limit);
        if (cpus->cpus[i].props.has_node_id) {
        numa_fw_cfg[apic_id + 1] = cpu_to_le64(cpus->cpus[i].props.node_id);
    }
    }
    for (i = 0; i < nb_numa_nodes; i++) {
        numa_fw_cfg[pcms->apic_id_limit + 1 + i] =
            cpu_to_le64(numa_info[i].node_mem);
@@ -1893,7 +1891,6 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
                            DeviceState *dev, Error **errp)
{
    int idx;
    int node_id;
    CPUState *cs;
    CPUArchId *cpu_slot;
    X86CPUTopoInfo topo;
@@ -1984,21 +1981,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
    cs = CPU(cpu);
    cs->cpu_index = idx;

    node_id = cpu_slot->props.node_id;
    if (!cpu_slot->props.has_node_id) {
        /* by default CPUState::numa_node was 0 if it's not set via CLI
         * keep it this way for now but in future we probably should
         * refuse to start up with incomplete numa mapping */
        node_id = 0;
    }
    if (cs->numa_node == CPU_UNSET_NUMA_NODE_ID) {
        cs->numa_node = node_id;
    } else if (cs->numa_node != node_id) {
            error_setg(errp, "node-id %d must match numa node specified"
                "with -numa option for cpu-index %d",
                cs->numa_node, cs->cpu_index);
            return;
    }
    numa_cpu_pre_plug(cpu_slot, dev, errp);
}

static void pc_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
Loading