[pve-devel] [PATCH qemu-server v6 0/3] add qmeventd

Dominik Csapak d.csapak at proxmox.com
Wed Nov 14 14:59:55 CET 2018


this series adds qmeventd, a binary which listens on a socket
and waits for qemu to connect to it, and thenfor the shutdown event of qemu

i use this to execute 'qm cleanup' when a vm exits, and can detect
if a qemu crashed/was stopped from within/etc.

like i discussed this with wolfgang off-list, i send it without the
docs patch

changes from v5:
* fixed typo
* fixed function signature formatting
* changed exit(0) to exit(EXIT_SUCCESS)
* fixed the path to qmeventd socket in config_to_command

changes from v4:
* incorporated feedback from wolfgang
    - initialize with NULL
    - use < len
    - use stdbool
    - better error handling for pid
    - exit code 0 with -h
    - dependecy
    - whitespace
    - put args on the stack
* sorted headers
* moved service socket to /var/run/qmeventd.sock and have
  that directory as RequiresMountsFor=/var/run
  (that fixed the issue that qmeventd could not start after a reboot because
  /var/run/qemu-server was not created yet)
* added some logging to qm cleanup

changes from v3:
* added missing build dependency
* fixed string handling in get_vmid_from_pid
* use strtoul instead of custom code
* changed multiple fatal errors to simply logging
* added SIGCLD handler
* changed manpage from rst to adoc and moved to pve-docs
* changed fds to have CLOEXEC
* changed from accept to accept4
* whitespace fixes
* changed error handling from macro to inline function
* put buf/vmid limits in struct and use sizeof instead of #define

changes from v2:
* completely reversed the logic: instead of having one binary
  per vm, we now have one proper daemon which listens and waits
  for qemu to connect to it, this way the race is on the qemu side
  (if it crashes/gets killed before connecting to the socket) instead
  of with us (connecting to a non existing qemu process)
* dropped the --no-reboot patch/logic, as my patch upstream was not accepted,
  but i will send another version of it there soon
* added a manpage, option parsing, etc.

changes from v1:
* 1/5 is new and contains changes that we want for qemu 2.12
* incorporated feedback from w.bumiller
* fixed the -no-reboot check

Dominik Csapak (3):
  add qmeventd
  add 'qm cleanup'
  use qmeventd to execute qm cleanup

 Makefile          |  19 ++-
 PVE/CLI/qm.pm     |  62 ++++++++
 PVE/QemuServer.pm |   3 +-
 debian/control    |   2 +
 debian/rules      |   2 +-
 qmeventd.c        | 429 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 qmeventd.h        |  55 +++++++
 qmeventd.service  |  10 ++
 8 files changed, 576 insertions(+), 6 deletions(-)
 create mode 100644 qmeventd.c
 create mode 100644 qmeventd.h
 create mode 100644 qmeventd.service

-- 
2.11.0





More information about the pve-devel mailing list