Skip to content
Snippets Groups Projects
  1. Sep 01, 2023
  2. Jul 10, 2023
  3. May 16, 2023
  4. Jan 09, 2023
  5. Oct 31, 2022
    • Claudio Imbrenda's avatar
      os-posix: asynchronous teardown for shutdown on Linux · c891c24b
      Claudio Imbrenda authored
      This patch adds support for asynchronously tearing down a VM on Linux.
      
      When qemu terminates, either naturally or because of a fatal signal,
      the VM is torn down. If the VM is huge, it can take a considerable
      amount of time for it to be cleaned up. In case of a protected VM, it
      might take even longer than a non-protected VM (this is the case on
      s390x, for example).
      
      Some users might want to shut down a VM and restart it immediately,
      without having to wait. This is especially true if management
      infrastructure like libvirt is used.
      
      This patch implements a simple trick on Linux to allow qemu to return
      immediately, with the teardown of the VM being performed
      asynchronously.
      
      If the new commandline option -async-teardown is used, a new process is
      spawned from qemu at startup, using the clone syscall, in such way that
      it will share its address space with qemu.The new process will have the
      name "cleanup/<QEMU_PID>". It will wait until qemu terminates
      completely, and then it will exit itself.
      
      This allows qemu to terminate quickly, without having to wait for the
      whole address space to be torn down. The cleanup process will exit
      after qemu, so it will be the last user of the address space, and
      therefore it will take care of the actual teardown. The cleanup
      process will share the same cgroups as qemu, so both memory usage and
      cpu time will be accounted properly.
      
      If possible, close_range will be used in the cleanup process to close
      all open file descriptors. If it is not available or if it fails, /proc
      will be used to determine which file descriptors to close.
      
      If the cleanup process is forcefully killed with SIGKILL before the
      main qemu process has terminated completely, the mechanism is defeated
      and the teardown will not be asynchronous.
      
      This feature can already be used with libvirt by adding the following
      to the XML domain definition to pass the parameter to qemu directly:
      
        <commandline xmlns="http://libvirt.org/schemas/domain/qemu/1.0
      
      ">
        <arg value='-async-teardown'/>
        </commandline>
      
      Signed-off-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
      Reviewed-by: default avatarMurilo Opsfelder Araujo <muriloo@linux.ibm.com>
      Tested-by: default avatarMurilo Opsfelder Araujo <muriloo@linux.ibm.com>
      Message-Id: <20220812133453.82671-1-imbrenda@linux.ibm.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      c891c24b
  6. May 03, 2022
  7. Apr 26, 2022
  8. Apr 20, 2022
  9. Apr 06, 2022
  10. Mar 04, 2022
    • Hanna Reitz's avatar
      os-posix: Add os_set_daemonize() · f22ac472
      Hanna Reitz authored
      
      The daemonizing functions in os-posix (os_daemonize() and
      os_setup_post()) only daemonize the process if the static `daemonize`
      variable is set.  Right now, it can only be set by os_parse_cmd_args().
      
      In order to use os_daemonize() and os_setup_post() from the storage
      daemon to have it be daemonized, we need some other way to set this
      `daemonize` variable, because I would rather not tap into the system
      emulator's arg-parsing code.  Therefore, this patch adds an
      os_set_daemonize() function, which will return an error on os-win32
      (because daemonizing is not supported there).
      
      Signed-off-by: default avatarHanna Reitz <hreitz@redhat.com>
      Message-Id: <20220303164814.284974-2-hreitz@redhat.com>
      Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
      f22ac472
  11. May 26, 2021
  12. Jan 29, 2021
    • Daniel P. Berrangé's avatar
      os: deprecate the -enable-fips option and QEMU's FIPS enforcement · 16631029
      Daniel P. Berrangé authored
      
      The -enable-fips option was added a long time ago to prevent the use of
      single DES when VNC when FIPS mode is enabled. It should never have been
      added, because apps are supposed to unconditionally honour FIPS mode
      based on the '/proc/sys/crypto/fips_enabled' file contents.
      
      In addition there is more to achieving FIPS compliance than merely
      blocking use of certain algorithms. Those algorithms which are used
      need to perform self-tests at runtime.
      
      QEMU's built-in cryptography provider has no support for self-tests,
      and neither does the nettle library.
      
      If QEMU is required to be used in a FIPS enabled host, then it must be
      built with the libgcrypt library enabled, which will unconditionally
      enforce FIPS compliance in any algorithm usage.
      
      Thus there is no need to keep either the -enable-fips option in QEMU, or
      QEMU's internal FIPS checking methods.
      
      Reviewed-by: default avatarJohn Snow <jsnow@redhat.com>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      Signed-off-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
      16631029
  13. Sep 30, 2020
  14. Sep 16, 2020
  15. Aug 21, 2020
  16. Jul 21, 2020
  17. Jul 13, 2020
  18. Dec 17, 2019
  19. Aug 16, 2019
    • Markus Armbruster's avatar
      sysemu: Split sysemu/runstate.h off sysemu/sysemu.h · 54d31236
      Markus Armbruster authored
      
      sysemu/sysemu.h is a rather unfocused dumping ground for stuff related
      to the system-emulator.  Evidence:
      
      * It's included widely: in my "build everything" tree, changing
        sysemu/sysemu.h still triggers a recompile of some 1100 out of 6600
        objects (not counting tests and objects that don't depend on
        qemu/osdep.h, down from 5400 due to the previous two commits).
      
      * It pulls in more than a dozen additional headers.
      
      Split stuff related to run state management into its own header
      sysemu/runstate.h.
      
      Touching sysemu/sysemu.h now recompiles some 850 objects.  qemu/uuid.h
      also drops from 1100 to 850, and qapi/qapi-types-run-state.h from 4400
      to 4200.  Touching new sysemu/runstate.h recompiles some 500 objects.
      
      Since I'm touching MAINTAINERS to add sysemu/runstate.h anyway, also
      add qemu/main-loop.h.
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190812052359.30071-30-armbru@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      [Unbreak OS-X build]
      54d31236
  20. Jun 12, 2019
    • Markus Armbruster's avatar
      Include qemu-common.h exactly where needed · a8d25326
      Markus Armbruster authored
      
      No header includes qemu-common.h after this commit, as prescribed by
      qemu-common.h's file comment.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190523143508.25387-5-armbru@redhat.com>
      [Rebased with conflicts resolved automatically, except for
      include/hw/arm/xlnx-zynqmp.h hw/arm/nrf51_soc.c hw/arm/msf2-soc.c
      block/qcow2-refcount.c block/qcow2-cluster.c block/qcow2-cache.c
      target/arm/cpu.h target/lm32/cpu.h target/m68k/cpu.h target/mips/cpu.h
      target/moxie/cpu.h target/nios2/cpu.h target/openrisc/cpu.h
      target/riscv/cpu.h target/tilegx/cpu.h target/tricore/cpu.h
      target/unicore32/cpu.h target/xtensa/cpu.h; bsd-user/main.c and
      net/tap-bsd.c fixed up]
      a8d25326
  21. Oct 02, 2018
    • Marc-André Lureau's avatar
      util: add qemu_write_pidfile() · 9e6bdef2
      Marc-André Lureau authored
      
      There are variants of qemu_create_pidfile() in qemu-pr-helper and
      qemu-ga. Let's have a common implementation in libqemuutil.
      
      The code is initially based from pr-helper write_pidfile(), with
      various improvements and suggestions from Daniel Berrangé:
      
        QEMU will leave the pidfile existing on disk when it exits which
        initially made me think it avoids the deletion race. The app
        managing QEMU, however, may well delete the pidfile after it has
        seen QEMU exit, and even if the app locks the pidfile before
        deleting it, there is still a race.
      
        eg consider the following sequence
      
              QEMU 1        libvirtd        QEMU 2
      
        1.    lock(pidfile)
      
        2.    exit()
      
        3.                 open(pidfile)
      
        4.                 lock(pidfile)
      
        5.                                  open(pidfile)
      
        6.                 unlink(pidfile)
      
        7.                 close(pidfile)
      
        8.                                  lock(pidfile)
      
        IOW, at step 8 the new QEMU has successfully acquired the lock, but
        the pidfile no longer exists on disk because it was deleted after
        the original QEMU exited.
      
        While we could just say no external app should ever delete the
        pidfile, I don't think that is satisfactory as people don't read
        docs, and admins don't like stale pidfiles being left around on
        disk.
      
        To make this robust, I think we might want to copy libvirt's
        approach to pidfile acquisition which runs in a loop and checks that
        the file on disk /after/ acquiring the lock matches the file that
        was locked. Then we could in fact safely let QEMU delete its own
        pidfiles on clean exit..
      
      Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20180831145314.14736-2-marcandre.lureau@redhat.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9e6bdef2
  22. Aug 31, 2018
  23. May 08, 2018
  24. Apr 26, 2018
  25. Oct 16, 2017
  26. Aug 08, 2017
  27. Jul 17, 2016
  28. Jun 16, 2016
  29. Mar 22, 2016
  30. Feb 22, 2016
  31. Feb 04, 2016
Loading