diff --git a/pages/index.vue b/pages/index.vue
index 523799a..ef70cd9 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -33,6 +33,7 @@ const shutdownVm = async (vm: any) => {
try {
const response = await axios.post('/api/controlVM', {
action: 'shutdown',
+ force: settings.force_shutdown,
vm: vm
});
console.log(response.data);
@@ -53,6 +54,7 @@ const settings = reactive({
ignoreCache: false,
enable_services: false,
enable_qemu_controls: false,
+ force_shutdown: false
});
const vmInfo = reactive({
@@ -274,6 +276,16 @@ onMounted(async () => {
QEMU Virtual Machines
+
+
+
{
Max Memory: {{ vm.maxMemory }} MB
Autostart: {{ vm.autostart ? 'Enabled' : 'Disabled' }}
+
-
+
+
Services
{
Name: {{ service.name }}
State: {{ service.state ? "Running" : "Not Running" }}
-
-
-
-
diff --git a/server/api/controlVM.ts b/server/api/controlVM.ts
index 5636008..83dd54f 100644
--- a/server/api/controlVM.ts
+++ b/server/api/controlVM.ts
@@ -3,17 +3,17 @@ import Logger from "~/core/logger";
export default defineEventHandler(async (event) => {
const body = await readBody(event);
- const { action, vm } = body;
+ const { action, force, vm } = body;
try {
- const command = action === 'start'
- ? `virsh start ${vm.name}`
- : `virsh shutdown ${vm.name}`;
+ const command = action === 'start' ? `virsh start ${vm.name}` : (force ? `virsh destroy ${vm.name}` : `virsh shutdown ${vm.name}`);
+
+ console.log(command);
await new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
- if (error || stderr) {;
+ if (error || stderr) {
Logger.error(`Error: ${stderr || error?.message}`);
reject(`Error: ${stderr || error?.message}`)
}