Skip to content

Commit

Permalink
Store VM's state's reason
Browse files Browse the repository at this point in the history
  • Loading branch information
skobyda committed Jun 21, 2023
1 parent 053be16 commit 0f349f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libvirtApi/domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,12 @@ export function domainGet({
})
.then(state => {
const stateStr = DOMAINSTATE[state[0][0]];
const stateReason = state[0][1];

if (!domainIsRunning(stateStr))
props.actualTimeInMs = -1;

return store.dispatch(updateOrAddVm({ state: stateStr, ...props }));
return store.dispatch(updateOrAddVm({ state: stateStr, stateReason, ...props }));
})
.then(() => {
clearVmUiState(props.name, connectionName);
Expand Down
15 changes: 15 additions & 0 deletions src/libvirtApi/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ export const Enum = {
VIR_MIGRATE_UNDEFINE_SOURCE: 16,
VIR_MIGRATE_NON_SHARED_DISK: 64,
VIR_MIGRATE_OFFLINE: 1024,
// Running reasons (how the VM was booted)
// https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainRunningReason
VIR_DOMAIN_RUNNING_UNKNOWN: 0,
VIR_DOMAIN_RUNNING_BOOTED: 1, // normal startup from boot
VIR_DOMAIN_RUNNING_MIGRATED: 2, // migrated from another host
VIR_DOMAIN_RUNNING_RESTORED: 3, // restored from a state file
VIR_DOMAIN_RUNNING_FROM_SNAPSHOT: 4, // restored from snapshot
VIR_DOMAIN_RUNNING_UNPAUSED: 5, // returned from paused state
VIR_DOMAIN_RUNNING_MIGRATION_CANCELED: 6, // returned from migration
VIR_DOMAIN_RUNNING_SAVE_CANCELED: 7, // returned from failed save process
VIR_DOMAIN_RUNNING_WAKEUP: 8, // returned from pmsuspended due to wakeup event
VIR_DOMAIN_RUNNING_CRASHED: 9, // resumed from crashed
VIR_DOMAIN_RUNNING_POSTCOPY: 10, // running in post-copy migration mode
VIR_DOMAIN_RUNNING_POSTCOPY_FAILED: 11, // running in failed post-copy migration
VIR_DOMAIN_RUNNING_LAST: 12,
};

/**
Expand Down

0 comments on commit 0f349f5

Please sign in to comment.