+ // try to send a 'quit' command first, fallback to SIGTERM of the pid
+ static const char qmp_quit_command[] = "{\"execute\":\"quit\"}\n";
+ VERBOSE_PRINT("%s: sending 'quit' via QMP\n", client->qemu.vmid);
+ if (!must_write(client->fd, qmp_quit_command, sizeof(qmp_quit_command) - 1)) {
+ VERBOSE_PRINT("%s: sending 'SIGTERM' to pid %d\n", client->qemu.vmid, client->pid);
+ int err = kill(client->pid, SIGTERM);
+ log_neg(err, "kill");
+ }
+
+ time_t timeout = time(NULL) + kill_timeout;