Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:FrontRunner
libvirt.11329
82452a5d-libxl-rm-goto-libxlDomainShutdownThrea...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 82452a5d-libxl-rm-goto-libxlDomainShutdownThread.patch of Package libvirt.11329
commit 82452a5d7f55c7698459728a3ee071402f43bb4d Author: Jim Fehlig <jfehlig@suse.com> Date: Wed Oct 31 10:54:14 2018 -0600 libxl: Remove some goto labels in libxlDomainShutdownThread There are too many goto labels in libxlDomainShutdownThread. Convert the 'destroy' and 'restart' labels to helper functions, leaving only the commonly used pattern of 'endjob' and 'cleanup' labels. Signed-off-by: Jim Fehlig <jfehlig@suse.com> ACKed-by: Michal Privoznik <mprivozn@redhat.com> Index: libvirt-4.0.0/src/libxl/libxl_domain.c =================================================================== --- libvirt-4.0.0.orig/src/libxl/libxl_domain.c +++ libvirt-4.0.0/src/libxl/libxl_domain.c @@ -424,6 +424,30 @@ virDomainDefParserConfig libxlDomainDefP }; +static void +libxlDomainShutdownHandleDestroy(libxlDriverPrivatePtr driver, + virDomainObjPtr vm) +{ + libxlDomainDestroyInternal(driver, vm); + libxlDomainCleanup(driver, vm); + if (!vm->persistent) + virDomainObjListRemove(driver->domains, vm); +} + + +static void +libxlDomainShutdownHandleRestart(libxlDriverPrivatePtr driver, + virDomainObjPtr vm) +{ + libxlDomainDestroyInternal(driver, vm); + libxlDomainCleanup(driver, vm); + if (libxlDomainStartNew(driver, vm, false) < 0) { + VIR_ERROR(_("Failed to restart VM '%s': %s"), + vm->def->name, virGetLastErrorMessage()); + } +} + + struct libxlShutdownThreadInfo { libxlDriverPrivatePtr driver; @@ -462,10 +486,12 @@ libxlDomainShutdownThread(void *opaque) VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); switch ((virDomainLifecycleAction) vm->def->onPoweroff) { case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: - goto destroy; + libxlDomainShutdownHandleDestroy(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: - goto restart; + libxlDomainShutdownHandleRestart(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: @@ -481,19 +507,23 @@ libxlDomainShutdownThread(void *opaque) VIR_DOMAIN_EVENT_STOPPED_CRASHED); switch ((virDomainLifecycleAction) vm->def->onCrash) { case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: - goto destroy; + libxlDomainShutdownHandleDestroy(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: - goto restart; + libxlDomainShutdownHandleRestart(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: case VIR_DOMAIN_LIFECYCLE_ACTION_LAST: goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: libxlDomainAutoCoreDump(driver, vm); - goto destroy; + libxlDomainShutdownHandleDestroy(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: libxlDomainAutoCoreDump(driver, vm); - goto restart; + libxlDomainShutdownHandleRestart(driver, vm); + goto endjob; } } else if (xl_reason == LIBXL_SHUTDOWN_REASON_REBOOT) { virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, @@ -504,10 +534,12 @@ libxlDomainShutdownThread(void *opaque) VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN); switch ((virDomainLifecycleAction) vm->def->onReboot) { case VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY: - goto destroy; + libxlDomainShutdownHandleDestroy(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART: case VIR_DOMAIN_LIFECYCLE_ACTION_RESTART_RENAME: - goto restart; + libxlDomainShutdownHandleRestart(driver, vm); + goto endjob; case VIR_DOMAIN_LIFECYCLE_ACTION_PRESERVE: case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY: case VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_RESTART: @@ -516,23 +548,6 @@ libxlDomainShutdownThread(void *opaque) } } else { VIR_INFO("Unhandled shutdown_reason %d", xl_reason); - goto endjob; - } - - destroy: - libxlDomainDestroyInternal(driver, vm); - libxlDomainCleanup(driver, vm); - if (!vm->persistent) - virDomainObjListRemove(driver->domains, vm); - - goto endjob; - - restart: - libxlDomainDestroyInternal(driver, vm); - libxlDomainCleanup(driver, vm); - if (libxlDomainStartNew(driver, vm, false) < 0) { - VIR_ERROR(_("Failed to restart VM '%s': %s"), - vm->def->name, virGetLastErrorMessage()); } endjob:
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor