On Tue, Aug 13, 2019 at 03:34:02PM +0300, Ilias Stamatis wrote: > On Tue, Aug 13, 2019 at 3:28 PM Ilias Stamatis > <stamatis.iliass@xxxxxxxxx> wrote: > > > > Signed-off-by: Ilias Stamatis <stamatis.iliass@xxxxxxxxx> > > --- > > src/test/test_driver.c | 77 ++++++++++++++++++++++++------------------ > > 1 file changed, 45 insertions(+), 32 deletions(-) > > > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > > index 5f5c512571..5a3ed45008 100755 > > --- a/src/test/test_driver.c > > +++ b/src/test/test_driver.c > > @@ -1902,6 +1902,40 @@ static int testDomainSuspend(virDomainPtr domain) > > return ret; > > } > > > > + > > +static void > > +testDomainActionSetState(virDomainObjPtr dom, > > + int lifecycle_type) > > +{ > > + switch (lifecycle_type) { > > + case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: > > + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, > > + VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > + break; > > + > > + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: > > + virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, > > + VIR_DOMAIN_RUNNING_BOOTED); > > + break; > > + > > + case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: > > + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, > > + VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > + break; > > + > > + case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: > > + virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, > > + VIR_DOMAIN_RUNNING_BOOTED); > > + break; > > + > > + default: > > + virDomainObjSetState(dom, VIR_DOMAIN_SHUTOFF, > > + VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > + break; > > + } > > +} > > + > > + > > static int testDomainShutdownFlags(virDomainPtr domain, > > unsigned int flags) > > { > > @@ -1922,13 +1956,17 @@ static int testDomainShutdownFlags(virDomainPtr domain, > > goto cleanup; > > } > > > > - testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > - event = virDomainEventLifecycleNewFromObj(privdom, > > - VIR_DOMAIN_EVENT_STOPPED, > > - VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); > > + testDomainActionSetState(privdom, privdom->def->onPoweroff); > > > > - if (!privdom->persistent) > > - virDomainObjListRemove(privconn->domains, privdom); > > + if (virDomainObjGetState(privdom, NULL) == VIR_DOMAIN_SHUTOFF) { > > + testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > + event = virDomainEventLifecycleNewFromObj(privdom, > > + VIR_DOMAIN_EVENT_STOPPED, > > + VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); indentation... The thing with the events like proposed is that onPoweroff "restart" would not generate any, but I think that events are a problem for another day. > > + > > + if (!privdom->persistent) > > + virDomainObjListRemove(privconn->domains, privdom); > > + } > > > > ret = 0; > > cleanup: > > @@ -1967,32 +2005,7 @@ static int testDomainReboot(virDomainPtr domain, > > virDomainObjSetState(privdom, VIR_DOMAIN_SHUTDOWN, > > VIR_DOMAIN_SHUTDOWN_USER); > > ^ Actually probably this is not needed since it's going to get > overridden anyways. Yes, I'll drop that. > > > > > - switch (privdom->def->onReboot) { > > - case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: > > - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, > > - VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > - break; > > - > > - case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: > > - virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, > > - VIR_DOMAIN_RUNNING_BOOTED); > > - break; > > - > > - case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: > > - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, > > - VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > - break; > > - > > - case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: > > - virDomainObjSetState(privdom, VIR_DOMAIN_RUNNING, > > - VIR_DOMAIN_RUNNING_BOOTED); > > - break; > > - > > - default: > > - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, > > - VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > - break; > > - } > > + testDomainActionSetState(privdom, privdom->def->onReboot); > > > > if (virDomainObjGetState(privdom, NULL) == VIR_DOMAIN_SHUTOFF) { > > testDomainShutdownState(domain, privdom, VIR_DOMAIN_SHUTOFF_SHUTDOWN); > > -- > > 2.22.0 > > > > -- > libvir-list mailing list > libvir-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list