Skip to content

Commit fefa629

Browse files
Jeremy Fitzhardingejsgf
authored andcommitted
xen: machine operations
Make the appropriate hypercalls to halt and reboot the virtual machine. Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com> Acked-by: Chris Wright <chrisw@sous-sol.org>
1 parent 0d16021 commit fefa629

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

‎arch/i386/xen/enlighten.c‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <xen/interface/xen.h>
3131
#include <xen/interface/physdev.h>
3232
#include <xen/interface/vcpu.h>
33+
#include <xen/interface/sched.h>
3334
#include <xen/features.h>
3435
#include <xen/page.h>
3536

@@ -43,6 +44,7 @@
4344
#include <asm/desc.h>
4445
#include <asm/pgtable.h>
4546
#include <asm/tlbflush.h>
47+
#include <asm/reboot.h>
4648

4749
#include "xen-ops.h"
4850
#include "mmu.h"
@@ -900,6 +902,45 @@ static const struct smp_ops xen_smp_ops __initdata = {
900902
};
901903
#endif /* CONFIG_SMP */
902904

905+
static void xen_reboot(int reason)
906+
{
907+
#ifdef CONFIG_SMP
908+
smp_send_stop();
909+
#endif
910+
911+
if (HYPERVISOR_sched_op(SCHEDOP_shutdown, reason))
912+
BUG();
913+
}
914+
915+
static void xen_restart(char *msg)
916+
{
917+
xen_reboot(SHUTDOWN_reboot);
918+
}
919+
920+
static void xen_emergency_restart(void)
921+
{
922+
xen_reboot(SHUTDOWN_reboot);
923+
}
924+
925+
static void xen_machine_halt(void)
926+
{
927+
xen_reboot(SHUTDOWN_poweroff);
928+
}
929+
930+
static void xen_crash_shutdown(struct pt_regs *regs)
931+
{
932+
xen_reboot(SHUTDOWN_crash);
933+
}
934+
935+
static const struct machine_ops __initdata xen_machine_ops = {
936+
.restart = xen_restart,
937+
.halt = xen_machine_halt,
938+
.power_off = xen_machine_halt,
939+
.shutdown = xen_machine_halt,
940+
.crash_shutdown = xen_crash_shutdown,
941+
.emergency_restart = xen_emergency_restart,
942+
};
943+
903944
/* First C function to be called on Xen boot */
904945
asmlinkage void __init xen_start_kernel(void)
905946
{
@@ -912,6 +953,8 @@ asmlinkage void __init xen_start_kernel(void)
912953

913954
/* Install Xen paravirt ops */
914955
paravirt_ops = xen_paravirt_ops;
956+
machine_ops = xen_machine_ops;
957+
915958
#ifdef CONFIG_SMP
916959
smp_ops = xen_smp_ops;
917960
#endif

‎arch/i386/xen/smp.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ static void stop_self(void *v)
311311

312312
void xen_smp_send_stop(void)
313313
{
314-
cpumask_t mask = cpu_online_map;
315-
cpu_clear(smp_processor_id(), mask);
316-
xen_smp_call_function_mask(mask, stop_self, NULL, 0);
314+
smp_call_function(stop_self, NULL, 0, 0);
317315
}
318316

319317
void xen_smp_send_reschedule(int cpu)

0 commit comments

Comments
 (0)