Skip to content

Commit

Permalink
fix: Fix stop() to poweroff instead of saving state
Browse files Browse the repository at this point in the history
feat: saveState() to save state of vm (renamed old functionality)
  • Loading branch information
ssmirr committed Nov 22, 2018
1 parent 9ae99fb commit 57b0cea
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/VBoxProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class VBoxProvider {
})
}

async stop(name) {
async saveState(name) {
return new Promise(function (resolve, reject) {
exec(`${VBexe} controlvm ${name} savestate`, (error, stdout, stderr) => {
if(error && stderr.indexOf('VBOX_E_OBJECT_NOT_FOUND') == -1) {
Expand All @@ -374,6 +374,19 @@ class VBoxProvider {
});
}

async stop(name) {
return new Promise(function (resolve, reject) {
exec(`${VBexe} controlvm ${name} poweroff soft`, (error, stdout, stderr) => {
if(error && stderr.indexOf('VBOX_E_OBJECT_NOT_FOUND') == -1) {
console.error(`exec error: stop`);
console.error(`=> ${error}, ${stderr}`);
reject(error);
}
resolve("");
});
});
}

async delete(name) {
return new Promise(function (resolve, reject) {
exec(`${VBexe} unregistervm ${name} --delete`, (error, stdout, stderr) => {
Expand Down

0 comments on commit 57b0cea

Please sign in to comment.