return 1;
}
-void qemu_cpu_add_remove(int cpu, int state)
+int qemu_cpu_add_remove(int cpu, int state)
{
if ((cpu <0) || (cpu >= vcpus)) {
fprintf(stderr, "vcpu out of range, should be [0~%d]\n", vcpus - 1);
- return;
+ return -EINVAL;
}
if (state) {
if (!enable_processor(&gpe_state, cpu))
- return;
+ return 0;
} else {
if (!disable_processor(&gpe_state, cpu))
- return;
+ return 0;
}
fprintf(logfile, "%s vcpu %d\n", state ? "Add" : "Remove", cpu);
+ return 1;
+}
+void qemu_cpu_notify(void)
+{
if (gpe_state.gpe0_en[0] & 4) {
qemu_set_irq(sci_irq, 1);
qemu_set_irq(sci_irq, 0);
term_printf("invalid status: %s\n", status);
return;
}
-
- qemu_cpu_add_remove(value, state);
+ if (qemu_cpu_add_remove(value, state))
+ qemu_cpu_notify();
}
/* Please update qemu-doc.texi when adding or changing commands */
extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
/* acpi */
-void qemu_cpu_add_remove(int cpu, int state);
+/* Returns 0 if nothing changed, 1 if added or removed and < 0 for errors. */
+int qemu_cpu_add_remove(int cpu, int state);
void qemu_system_hot_add_init(void);
void qemu_system_device_hot_add(int pcibus, int slot, int state);
+void qemu_cpu_notify(void);
/* device-hotplug */
char *act = NULL;
char *vcpustr, *node = vec[XS_WATCH_PATH];
unsigned int vcpu, len;
+ int changed = -EINVAL;
vcpustr = strstr(node, "cpu/");
if (!vcpustr) {
}
if (!strncmp(act, "online", len))
- qemu_cpu_add_remove(vcpu, 1);
+ changed = qemu_cpu_add_remove(vcpu, 1);
else if (!strncmp(act, "offline", len))
- qemu_cpu_add_remove(vcpu, 0);
+ changed = qemu_cpu_add_remove(vcpu, 0);
else
fprintf(stderr, "vcpu-set: command error.\n");
free(act);
+ if (changed > 0)
+ qemu_cpu_notify();
return;
}