Skip to contentSkip to conversation

xl shutdown --wait "racy"

DISCUSSION Sander Eikelenboom 5 participants 20 messages Apr 16, 2014 – Apr 23, 2014

lore
Share & tools
lore
#0 lore raw

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

--
Sander

#1 lore raw
Quoted 10 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

Quoted 6 lines

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Ian.

#2 lore raw
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

I can see the shutdown state would be the thing to wait for if it's configured with "preserve", but if it's configured with the default "destroy" i would expect it to wait until the guest is actually destroyed. The "restart" is perhaps somewhat more difficult, same goes for the coredump variants.

Quoted 1 line

Ian.

#3 lore raw
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Quoted 4 lines

I can see the shutdown state would be the thing to wait for if it's configured with "preserve", but if it's configured with the default "destroy" i would expect it to wait until the guest is actually destroyed. The "restart" is perhaps somewhat more difficult, same goes for the coredump variants.

#4 lore raw
Quoted 33 lines · you
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

Quoted 8 lines

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Hmm ok, it should be called "--wait_until_halfway" then ;-)

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

b) make it possible for the xl commandline to overrule the on_* from the configfile
c) also introduce a -w/--wait for xl destroy

(with b and c, i could emulate "a" by doing a "xl shutdown -w preserve" followed by a "xl destroy -w".

Quoted 4 lines
Quoted 4 lines

I can see the shutdown state would be the thing to wait for if it's configured with "preserve", but if it's configured with the default "destroy" i would expect it to wait until the guest is actually destroyed. The "restart" is perhaps somewhat more difficult, same goes for the coredump variants.

#5 lore raw
Quoted 41 lines · Sander Eikelenboom
Quoted 38 lines · you
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

Quoted 4 lines
Quoted 2 lines

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Hmm ok, it should be called "--wait_until_halfway" then ;-)

;-)

Quoted 11 lines

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

Quoted 2 lines

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

Might be tricky, since on_* is processed by the daemonised xl which is monitoring the domain, not the xl shutdown process.

Quoted 1 line

b) make it possible for the xl commandline to overrule the on_* from the configfile

I guess you mean the xl shutdown command. This will also be tricky, for the same reasons as a.

Quoted 1 line

c) also introduce a -w/--wait for xl destroy

Yes.

I'll add:

d) Make "xl shutdown --wait" actually wait for the domain to be destroyed.

Probably, assuming that is possible (I'm concerned about races in the implementation of this...). Might also interact weirdly with on_* I suppose.

Ian.

#6 lore raw
Quoted 53 lines · Ian Campbell
Quoted 38 lines · Sander Eikelenboom
Quoted 28 lines · you
Quoted 19 lines · Sander Eikelenboom
Quoted 17 lines · you
Quoted 16 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

Quoted 8 lines
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Quoted 8 lines

Not really, those are somewhat unrelated.
shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.
on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Quoted 1 line

Hmm ok, it should be called "--wait_until_halfway" then ;-)

;-)

Quoted 11 lines

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

Quoted 4 lines
Quoted 2 lines

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

Might be tricky, since on_* is processed by the daemonised xl which is monitoring the domain, not the xl shutdown process.

Store it in xenstore somewhere?

Quoted 5 lines
Quoted 2 lines

b) make it possible for the xl commandline to overrule the on_* from the configfile

I guess you mean the xl shutdown command. This will also be tricky, for the same reasons as a.

Quoted 7 lines
Quoted 1 line

c) also introduce a -w/--wait for xl destroy

Yes.

I'll add:

d) Make "xl shutdown --wait" actually wait for the domain to be destroyed.

This seems like the most reasonable thing to do.

-George

#7 lore raw
In reply to Ian Campbell
Quoted 75 lines · you
Quoted 41 lines · Sander Eikelenboom
Quoted 38 lines · you
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

Quoted 4 lines
Quoted 2 lines

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Hmm ok, it should be called "--wait_until_halfway" then ;-)

;-)

Quoted 11 lines

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

Quoted 2 lines

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

Might be tricky, since on_* is processed by the daemonised xl which is monitoring the domain, not the xl shutdown process.

Quoted 1 line

b) make it possible for the xl commandline to overrule the on_* from the configfile

I guess you mean the xl shutdown command. This will also be tricky, for the same reasons as a.

Quoted 1 line

c) also introduce a -w/--wait for xl destroy

Yes.

Quoted 8 lines

I'll add:

d) Make "xl shutdown --wait" actually wait for the domain to be destroyed.

Probably, assuming that is possible (I'm concerned about races in the implementation of this...). Might also interact weirdly with on_* I suppose.

Well if we could pass down the events that "wait_for_domain_deaths" is allowed to return on ... now it seems to return on *any* event .. and only print something different on both shutdown and complete death ...

Is there a special event that's triggered on timeout (as defined in /etc/defaults/xendomains: XENDOMAINS_STOP_MAXWAIT=300 ?

The the solution seems to be to let the caller of "wait_for_domain_deaths" be able the specify the events it should return on. (always return on timeout ... return on any unless specified ... only return on specified when specific events are specified)

Could you elaborate on how you think this would get "racy" ?

static void wait_for_domain_deaths(libxl_evgen_domain_death **deathws, int nr)

{
    int rc, count = 0;
    LOG("Waiting for %d domains", nr);
    while(1 && count < nr) {
        libxl_event *event;
        rc = libxl_event_wait(ctx, &event, LIBXL_EVENTMASK_ALL, 0,0);
        if (rc) {
            LOG("Failed to get event, quitting (rc=%d)", rc);
            exit(-1);
        }

        switch (event->type) {
        case LIBXL_EVENT_TYPE_DOMAIN_DEATH:
            LOG("Domain %d has been destroyed", event->domid);
            libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
            count++;
            break;
        case LIBXL_EVENT_TYPE_DOMAIN_SHUTDOWN:
            LOG("Domain %d has been shut down, reason code %d",
                event->domid, event->u.domain_shutdown.shutdown_reason);
            libxl_evdisable_domain_death(ctx, deathws[event->for_user]);
            count++;
            break;
        default:
            LOG("Unexpected event type %d", event->type);
            break;
        }
        libxl_event_free(ctx, event);
    }
}
Quoted 1 line

Ian.

#8 lore raw
Quoted 82 lines · Sander Eikelenboom
Quoted 79 lines · you
Quoted 41 lines · Sander Eikelenboom
Quoted 38 lines · you
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

Quoted 4 lines
Quoted 2 lines

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Hmm ok, it should be called "--wait_until_halfway" then ;-)

;-)

Quoted 11 lines

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

Quoted 2 lines

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

Might be tricky, since on_* is processed by the daemonised xl which is monitoring the domain, not the xl shutdown process.

Quoted 1 line

b) make it possible for the xl commandline to overrule the on_* from the configfile

I guess you mean the xl shutdown command. This will also be tricky, for the same reasons as a.

Quoted 1 line

c) also introduce a -w/--wait for xl destroy

Yes.

I'll add:

d) Make "xl shutdown --wait" actually wait for the domain to be destroyed.

Quoted 7 lines
Quoted 3 lines

Probably, assuming that is possible (I'm concerned about races in the implementation of this...). Might also interact weirdly with on_* I suppose.

Well if we could pass down the events that "wait_for_domain_deaths" is allowed to return on ... now it seems to return on *any* event .. and only print something different on both shutdown and complete death ...

Any other even would be unexpected I think, since the corresponding libxl_evenable_* would never have been called in the xl shutdown path.

Quoted 2 lines

Is there a special event that's triggered on timeout (as defined in /etc/defaults/xendomains: XENDOMAINS_STOP_MAXWAIT=300 ?

I don't see a timeout in the libxl_event_wait prototype so I suppose not.

Quoted 2 lines

The the solution seems to be to let the caller of "wait_for_domain_deaths" be able the specify the events it should return on.

They already can -- by only enabling those events.

Quoted 5 lines

(always return on timeout ...
return on any unless specified ... only return on specified when specific events are specified)

Could you elaborate on how you think this would get "racy" ?

Oh, it looks like libxl already solved it and has an event, never mind. (I was concerned that a new domain with the same domid might appear right after the domain was gone)

Ian.

#9 lore raw
Quoted 109 lines · you
Quoted 82 lines · Sander Eikelenboom
Quoted 79 lines · you
Quoted 41 lines · Sander Eikelenboom
Quoted 38 lines · you
Quoted 25 lines · Sander Eikelenboom
Quoted 16 lines · you
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 4 lines

It's at least not entirely what i expected ;-)

Is it because there can be different "follow-up actions" due to the "on_poweroff=" config option ?

Not really, those are somewhat unrelated.

shutdown and destroy are two distinct events. Once a domain has shutdown (called the shutdown hypercall etc) it goes into state "shutdown" and an event is generated from the hypervisor to the toolstack. The toolstack's response to this is to actually destroy the domain, that is to tear down the resources it is using etc.

Quoted 4 lines
Quoted 2 lines

on_* only matter for the destroy phase since they tell the toolstack what it should do (restart, preserve, really destroy etc).

Hmm ok, it should be called "--wait_until_halfway" then ;-)

;-)

Quoted 11 lines

On the more serious side .. would patches be accepted that:

a) differentiate when it returns from waiting based on the on_*

preserve: this could probably stay as is .. after the shutdown event destroy:
restart:
rename-restart:
coredump-destroy:
coredump-restart:

Quoted 2 lines

for the other ones .. i don't know if there actually are events in libxl that could be 'easily' coupled ?

Might be tricky, since on_* is processed by the daemonised xl which is monitoring the domain, not the xl shutdown process.

Quoted 1 line

b) make it possible for the xl commandline to overrule the on_* from the configfile

I guess you mean the xl shutdown command. This will also be tricky, for the same reasons as a.

Quoted 1 line

c) also introduce a -w/--wait for xl destroy

Yes.

I'll add:

d) Make "xl shutdown --wait" actually wait for the domain to be destroyed.

Quoted 7 lines
Quoted 3 lines

Probably, assuming that is possible (I'm concerned about races in the implementation of this...). Might also interact weirdly with on_* I suppose.

Well if we could pass down the events that "wait_for_domain_deaths" is allowed to return on ... now it seems to return on *any* event .. and only print something different on both shutdown and complete death ...

Any other even would be unexpected I think, since the corresponding libxl_evenable_* would never have been called in the xl shutdown path.

Quoted 2 lines

Is there a special event that's triggered on timeout (as defined in /etc/defaults/xendomains: XENDOMAINS_STOP_MAXWAIT=300 ?

I don't see a timeout in the libxl_event_wait prototype so I suppose not.

Quoted 2 lines

The the solution seems to be to let the caller of "wait_for_domain_deaths" be able the specify the events it should return on.

They already can -- by only enabling those events.

Quoted 4 lines

(always return on timeout ...
return on any unless specified ... only return on specified when specific events are specified)

Quoted 5 lines
Quoted 1 line

Could you elaborate on how you think this would get "racy" ?

Oh, it looks like libxl already solved it and has an event, never mind. (I was concerned that a new domain with the same domid might appear right after the domain was gone)

Hrmm yes well .. i only see a way to enable both from libxl_event.h:

typedef struct libxl__evgen_domain_death libxl_evgen_domain_death; int libxl_evenable_domain_death(libxl_ctx *ctx, uint32_t domid,

                         libxl_ev_user, libxl_evgen_domain_death **evgen_out);

void libxl_evdisable_domain_death(libxl_ctx *ctx, libxl_evgen_domain_death*);
/* Arranges for the generation of DOMAIN_SHUTDOWN and DOMAIN_DESTROY
* events. A domain which is destroyed before it shuts down
* may generate only a DESTROY event.
*/

Although from libxl_internal.h it looks like there once has been a thought about differentiating:

struct libxl__evgen_domain_death {
    uint32_t domid;
    unsigned shutdown_reported:1, death_reported:1;
    LIBXL_TAILQ_ENTRY(libxl_evgen_domain_death) entry;
        /* on list .death_reported ? CTX->death_list : CTX->death_reported */
    libxl_ev_user user;
};

_hidden void
libxl__evdisable_domain_death(libxl__gc*, libxl_evgen_domain_death*);

Quoted 1 line

Ian.

#10 lore raw
Quoted 1 line · Sander Eikelenboom

i only see a way to enable both from libxl_event.h:

You could always ignore the one you don't want...

#11 lore raw
In reply to Ian Campbell
Quoted 16 lines · Ian Campbell
Quoted 15 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 6 lines
Quoted 1 line

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

-George

#12 lore raw

George Dunlap writes ("Re: [Xen-devel] xl shutdown --wait "racy""):

Quoted 11 lines · Ian Campbell
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

Quite. I think this is simply a bug and it should wait for the domain to be destroyed.

It's IMO a tolerable side-effect if this means that when the domain shuts down in a way that causes it to be preserved (ie the daemonic xl doesn't reap it) xl shutdown -w gets stuck. (There should be an option to restore the former behaviour but it should not be the default.)

Ideally xl would record something somewhere so that it would know what's going on and could make "xl shutdown -w" fail in the default case if it's going to wait "forever".

Ian.

#13 lore raw
Quoted 7 lines · you

George Dunlap writes ("Re: [Xen-devel] xl shutdown --wait "racy""):

Quoted 6 lines · Ian Campbell
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 8 lines
Quoted 5 lines

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

Quite. I think this is simply a bug and it should wait for the domain to be destroyed.

It seems the shutdown is racy in another aspect as well, the code in "wait_for_domain_deaths" on receiving a event doesn't actually check if it's a event related to the domain it should wait for. It only checks a count (1 if you shutdown only one domain, nb_domains -1 if you shutdown all).

To be less error prone it should ideally pass an array of domids it needs to wait for through to wait_for_domain_deaths and check on it.

Quoted 9 lines

It's IMO a tolerable side-effect if this means that when the domain shuts down in a way that causes it to be preserved (ie the daemonic xl doesn't reap it) xl shutdown -w gets stuck. (There should be an option to restore the former behaviour but it should not be the default.)

Ideally xl would record something somewhere so that it would know what's going on and could make "xl shutdown -w" fail in the default case if it's going to wait "forever".

There isn't a generic timeout function that could raise an timeout event when it is taking too long ?

But i'm running into my all too limited C skills here ..
(passive reading is fairly ok, actively building something somewhat more complex in a sane way is not :-) )

Quoted 1 line

Ian.

#14 lore raw
Quoted 15 lines · Sander Eikelenboom
Quoted 12 lines · you

George Dunlap writes ("Re: [Xen-devel] xl shutdown --wait "racy""):

Quoted 11 lines · Ian Campbell
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

Quoted 7 lines
Quoted 2 lines

Quite. I think this is simply a bug and it should wait for the domain to be destroyed.

It seems the shutdown is racy in another aspect as well, the code in "wait_for_domain_deaths" on receiving a event doesn't actually check if it's a event related to the domain it should wait for. It only checks a count (1 if you shutdown only one domain, nb_domains -1 if you shutdown all).

It only calls libxl_evenable_domain_death for domains which it should wait for, and by construction the number of deaths passed to wait_for_domain_deaths is equal to the number of domains for which libxl_evenable_domain_death was called.

Quoted 9 lines

To be less error prone it should ideally pass an array of domids it needs to wait for through to wait_for_domain_deaths and check on it.

Quoted 5 lines

It's IMO a tolerable side-effect if this means that when the domain shuts down in a way that causes it to be preserved (ie the daemonic xl doesn't reap it) xl shutdown -w gets stuck. (There should be an option to restore the former behaviour but it should not be the default.)

Quoted 6 lines
Quoted 3 lines

Ideally xl would record something somewhere so that it would know what's going on and could make "xl shutdown -w" fail in the default case if it's going to wait "forever".

There isn't a generic timeout function that could raise an timeout event when it is taking too long ?

Nope. I suppose you could use alarm(2) or something but that would be getting pretty hairy.

Ian.

#15 lore raw
Quoted 24 lines · you
Quoted 15 lines · Sander Eikelenboom
Quoted 12 lines · you

George Dunlap writes ("Re: [Xen-devel] xl shutdown --wait "racy""):

Quoted 11 lines · Ian Campbell
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

Quoted 7 lines
Quoted 2 lines

Quite. I think this is simply a bug and it should wait for the domain to be destroyed.

It seems the shutdown is racy in another aspect as well, the code in "wait_for_domain_deaths" on receiving a event doesn't actually check if it's a event related to the domain it should wait for. It only checks a count (1 if you shutdown only one domain, nb_domains -1 if you shutdown all).

Quoted 4 lines

It only calls libxl_evenable_domain_death for domains which it should wait for, and by construction the number of deaths passed to wait_for_domain_deaths is equal to the number of domains for which libxl_evenable_domain_death was called.

Also if i do two times "xl shutdown --wait" with a script in parallel ?

That would give a event for the guest that shuts down the fastest .. but wouldn't the "wait_for_domain_deaths" for the other guest also respond to that (and return too early) ?

Quoted 20 lines
Quoted 9 lines

To be less error prone it should ideally pass an array of domids it needs to wait for through to wait_for_domain_deaths and check on it.

Quoted 5 lines

It's IMO a tolerable side-effect if this means that when the domain shuts down in a way that causes it to be preserved (ie the daemonic xl doesn't reap it) xl shutdown -w gets stuck. (There should be an option to restore the former behaviour but it should not be the default.)

Quoted 6 lines
Quoted 3 lines

Ideally xl would record something somewhere so that it would know what's going on and could make "xl shutdown -w" fail in the default case if it's going to wait "forever".

There isn't a generic timeout function that could raise an timeout event when it is taking too long ?

Nope. I suppose you could use alarm(2) or something but that would be getting pretty hairy.

Ian.

#16 lore raw
Quoted 26 lines · Sander Eikelenboom
Quoted 23 lines · you
Quoted 22 lines · Sander Eikelenboom
Quoted 7 lines · you

George Dunlap writes ("Re: [Xen-devel] xl shutdown --wait "racy""):

Quoted 6 lines · Ian Campbell
Quoted 4 lines

It is waiting for the domain to be shutdown (state 's') not for the domain to be destroyed. So it's doing what it said it would (I appreciate you might not find this distinction helpful under the circumstances...)

Quoted 8 lines
Quoted 5 lines

For any reasonable person's definition of "shutdown", it does *not* wait until it's shutdown. "In the shutdown state" is not something anyone outside of Xen cares about: what they care about is being able to, for example, start the domain again (or start a domain that depends on resources currently held by the shutting down domain).

Quite. I think this is simply a bug and it should wait for the domain to be destroyed.

It seems the shutdown is racy in another aspect as well, the code in "wait_for_domain_deaths" on receiving a event doesn't actually check if it's a event related to the domain it should wait for. It only checks a count (1 if you shutdown only one domain, nb_domains -1 if you shutdown all).

Quoted 8 lines
Quoted 4 lines

It only calls libxl_evenable_domain_death for domains which it should wait for, and by construction the number of deaths passed to wait_for_domain_deaths is equal to the number of domains for which libxl_evenable_domain_death was called.

Also if i do two times "xl shutdown --wait" with a script in parallel ?

That would give a event for the guest that shuts down the fastest ..

Both instance of xl are independent and will see the events for the domain they are interested in, irrespecitve of whether some other xl is also waiting for hte same domain to die.

Quoted 3 lines

but wouldn't
the "wait_for_domain_deaths" for the other guest also respond to that (and return too early) ?

I don't think libxl will fire events for domains which the particular xl instance didn't express an interest in.

Ian.

#17 lore raw
In reply to Sander Eikelenboom
Quoted 10 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

Quoted 4 lines

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Which reminds me - when you do this - are you (or any processes) in the /sysfs directory? I've been having a hard-time reproducing the issue. Sometimes I see it, but then if I try again the problem does not show up again.

Quoted 6 lines

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

--
Sander

#18 lore raw
Quoted 11 lines · you
Quoted 10 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

Quoted 8 lines
Quoted 4 lines

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Which reminds me - when you do this - are you (or any processes) in the /sysfs directory? I've been having a hard-time reproducing the issue. Sometimes I see it, but then if I try again the problem does not show up again.

When i do *what* ? (it's not exactly clear if you are referring to the problem i'm trying to workaround .. or the problems i'm finding when trying to workaround :-) )

Quoted 6 lines
Quoted 6 lines

So it seems the wait loop is exiting somewhat prematurely, is this expected ?

--
Sander

#19 lore raw
Quoted 19 lines · Sander Eikelenboom
Quoted 15 lines · you
Quoted 14 lines · Sander Eikelenboom

Hi Ian (C|J) Konrad,

I'm currently trying to workaround the pci-(detach|assignable-remove) issues i reported earlier.

The workaround i thought of was:
- shutting down the guest
- starting it without 1 of the original devices passed through
- use xl pci-assignable-remove and bind the device to the dom0 driver.

But during this i noticed that a "xl shutdown --wait" does wait .. but returns:
- Before the domain is removed from for instance "xl list", it still listed there in "--ps--" state.
- before pciback has done it's restore config space magic.

Quoted 7 lines
Quoted 3 lines

Which reminds me - when you do this - are you (or any processes) in the /sysfs directory? I've been having a hard-time reproducing the issue. Sometimes I see it, but then if I try again the problem does not show up again.

When i do *what* ? (it's not exactly clear if you are referring to the problem i'm trying to workaround .. or the problems i'm finding when trying to workaround :-) )

Whoa. Looking back at my response it is pretty vague. I was refering to the
http://lists.xen.org/archives/html/xen-devel/2014-04/msg02237.html issue.

But that is unrelated to this problem you are reporting so lets just skip my question.