Skip to contentSkip to conversation

From which place in source code Xen start to deal with the GuestOS shutdown operation?

DISCUSSION Bruce Granger 2 participants 2 messages Sep 21, 2012

lore
Share & tools
lore
#0 lore raw

Hello everyone!
I feel I'm still a new baby though I have been study xen source code for some days!
When I shutdown GuestOS, I want to get to know how Xen deal with the operation? I find the code in xen\arch\x86\hvm\vlapic.c, see:
static int vlapic_accept_irq(struct vcpu *v, uint32_t icr_low) {
……
switch ( icr_low & APIC_MODE_MASK )
{
……

    case APIC_DM_INIT:
        /* No work on INIT de-assert for P4-type APIC. */
        if ( (icr_low & (APIC_INT_LEVELTRIG | APIC_INT_ASSERT)) ==
             APIC_INT_LEVELTRIG )
            break;
        /* Nothing to do if the VCPU is already reset. */
        if ( !v->is_initialised )
            break;
        hvm_vcpu_down(v);
        rc = vlapic_schedule_init_sipi_tasklet(v, icr_low);
        break;

……
}
……
I think that when we input the shutdown command in GuestOS, xen will first catch the APIC_DM_INIT and then call the ‘hvm_vcpu_down(v)’、’domain_shutdown()’ and so on , is that right? If not, where is the code entrance when shutdown operation occurs?

--
View this message in context: http://xen.1045712.n5.nabble.com/From-which-place-in-source-code-Xen-start-to-deal-with-the-GuestOS-shutdown-operation-tp5711422.html
Sent from the Xen - Dev mailing list archive at Nabble.com.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#1 lore raw
Quoted 1 line · Bruce Granger

Hello everyone!

I feel I'm still a new baby though I have been study xen

Quoted 1 line

source code for

some days!
When I shutdown GuestOS, I want to get to know how

Quoted 1 line

Xen deal with the

operation? I find the code in xen\arch\x86\hvm\vlapic.c,

Quoted 1 line

see:

static int vlapic_accept_irq(struct vcpu *v, uint32_t

Quoted 1 line

icr_low)

{
……
switch ( icr_low & APIC_MODE_MASK )
{
……
case APIC_DM_INIT:

Quoted 1 line

/* No work on INIT de-assert for P4-type APIC. */

        if ( (icr_low &
Quoted 1 line

(APIC_INT_LEVELTRIG | APIC_INT_ASSERT)) ==

APIC_INT_LEVELTRIG )

Quoted 1 line

break;

        /* Nothing to do if the VCPU is already reset. */
        if (
Quoted 1 line

!v->is_initialised )

            break;
        hvm_vcpu_down(v);
        rc =
Quoted 1 line

vlapic_schedule_init_sipi_tasklet(v, icr_low);

        break;

……
}
……
I think

Quoted 1 line

that when we input the shutdown command in GuestOS, xen will first

catch the

Quoted 1 line

APIC_DM_INIT and then call the

‘hvm_vcpu_down(v)’、’domain_shutdown()’ and so

Quoted 1 line

on , is that right? If not,

where is the code entrance when shutdown operation

Quoted 1 line

occurs?

--
View this message in context:

Yes that's about right. Some guests will not re-INIT the VCPUs but will simply leave them HLTed with interrupts disabled. We also pick up that case in hvm_hlt().

Once all VCPUs are down, hvm_vcpu_down() dows the domain_shutdown() call, which then triggers machinery in dom0 to kill off the domain fully. I described that path in my previous email.

-- Keir

Quoted 2 lines

http://xen.1045712.n5.nabble.com/From-which-place-in-source-code-Xen-start-to-
deal-with-the-GuestOS-shutdown-operation-tp5711422.html

Sent from the Xen -

Quoted 2 lines

Dev mailing list archive at
Nabble.com.

_______________________________________________
Xen-devel mailing

Quoted 1 line

list

[email protected]
http://lists.xen.org/xen-devel