At present, after hotplug a discontinuous cpu id on source side, then done migration, hotplug again will fail on destination side. for example: on source side: 1) boot with -smp 1,maxcpus=4 2) cpu-add id=2 3) live-migration on destination side: 1) boot with -smp 2,maxcpus=4 1) cpu-add id=1
the root cause is the generated apicid is sequential from 0 to smp_cpus when initialize cpus at booting time on destination side, there apicid will be 0 and 1, but on source side the existed apicid after hotplug are 0 and 2. so if add cpu with id=1, this will show error with this cpu alreay exists. this patches added -smp X,apics=0x option to specify apic map. follow above example: on destination side: 1) boot with -smp 2,maxcpus=4,apics=0xA this apics value is a hex number as existed apicid bitmap, 0xA is 1010B for apicid are 0 and 2. this patches will be helpful for arbitrary CPU hot-remove as well. Chen Fan (3): target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn() target-i386: add -smp X,apics=0x option target-i386: add qmp command 'query-cpus' to display apic_id cpus.c | 1 + exec.c | 5 ++++ hw/i386/pc.c | 9 +++++-- include/sysemu/sysemu.h | 4 ++++ qapi-schema.json | 4 +++- qemu-options.hx | 15 +++++++++--- target-i386/cpu.c | 9 +++++++ vl.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++- 8 files changed, 102 insertions(+), 7 deletions(-) -- 1.8.1.4