[snip]
> @@ -1382,8 +1384,40 @@ static void virt_cpu_pre_plug(HotplugHandler
> *hotplug_dev,
> }
>
> if (cpu->phy_id == UNSET_PHY_ID) {
> - error_setg(&local_err, "CPU hotplug not supported");
> - goto out;
> + if ((cpu->thread_id < 0) || (cpu->thread_id >= ms->smp.threads)) {
> + error_setg(&local_err,
> + "Invalid thread-id %u specified, must be in range
> 1:%u",
> + cpu->thread_id, ms->smp.threads - 1);
> + goto out;
> + }
> +
> + if ((cpu->core_id < 0) || (cpu->core_id >= ms->smp.cores)) {
> + error_setg(&local_err,
> + "Invalid core-id %u specified, must be in range 1:%u",
> + cpu->core_id, ms->smp.cores - 1);
> + goto out;
> + }
> +
> + if ((cpu->socket_id < 0) || (cpu->socket_id >= ms->smp.sockets)) {
> + error_setg(&local_err,
> + "Invalid socket-id %u specified, must be in range
> 1:%u",
> + cpu->socket_id, ms->smp.sockets - 1);
> + goto out;
> + }
> +
> + topo.socket_id = cpu->socket_id;
> + topo.core_id = cpu->core_id;
> + topo.thread_id = cpu->thread_id;
> + arch_id = virt_get_arch_id_from_topo(ms, &topo);
> + cpu_slot = virt_find_cpu_slot(ms, arch_id, &index);
> + if (CPU(cpu_slot->cpu)) {
> + error_setg(&local_err,
> + "cpu(id%d=%d:%d:%d) with arch-id %" PRIu64 " exists",
> + cs->cpu_index, cpu->socket_id, cpu->core_id,
> + cpu->thread_id, cpu_slot->arch_id);
> + goto out;
> + }
> + cpu->phy_id = arch_id;
> } else {
Here you allow user to specify topology IDs, but "else" still indicates
user could use "phy_id" instead of topology IDs, right?
Is it necessary to expose "phy_id" to user?
Thanks,
Zhao