When the daemon is starting it autostarts all guests marked as autostartable. This is not an ideal solution for autostarting if there's a lot of domains configured so. After autostarting all right away the guests start competing for disk I/O and the boot is prolonged unnecessarily. This patch adds a config option to disable autostarting to leave it on user scripts that may use mechanisms to reduce load of the host by limiting the number of guests started in parallel. Unfortunately, there's no simple way we could do this in libvirt. The problem is how to detect that the guest has finished booting as it's mostly a black box for libvirt. There area few options: 1) Wait until I/O load of the guest drops. - This is insufficient on guests that do heavy I/O all the time. 2) Let the guest tell us. - Not every OS has the ability to have a guest agent. 3) Wait for certain amount of time. - Very limited amount of control on diverse guests. With this functionality, the user may write his own script that load balances the autostart in a sane way with accordance to his infrastructure (Query agents, check I/O, use configurable timeouts) while stil being able to mark the domains as autostartable with all the benefits (virsh list --all --autostart). --- We could also add an example script based on parts of libvirt-guests to show how to use this. --- src/qemu/qemu.conf | 7 +++++++ src/qemu/qemu_conf.c | 4 ++++ src/qemu/qemu_conf.h | 2 ++ src/qemu/qemu_driver.c | 5 ++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index dd853c8..91115bf 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -2,6 +2,13 @@ # All settings described here are optional - if omitted, sensible # defaults are used. +# When the qemu driver starts all guests that are marked to be +# started automaticaly are started (at once). This option disables +# autostarting of the guests. The user can use a script to do so in +# a more sensible way. Eg. wait for guest to start up, before continuing. +# +#disable_autostart = 1 + # VNC is configured to listen on 127.0.0.1 by default. # To make it listen on all public interfaces, uncomment # this next option. diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index dc4d680..598b34e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -153,6 +153,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver, return -1; \ } + p = virConfGetValue(conf, "disable_autostart"); + CHECK_TYPE("disable_autostart", VIR_CONF_LONG); + if (p && p->l) driver->disableAutoStart = true; + p = virConfGetValue(conf, "vnc_auto_unix_socket"); CHECK_TYPE("vnc_auto_unix_socket", VIR_CONF_LONG); if (p) driver->vncAutoUnixSocket = p->l; diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 2c7f70c..fb6e317 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -156,6 +156,8 @@ struct qemud_driver { int keepAliveInterval; unsigned int keepAliveCount; int seccompSandbox; + + bool disableAutoStart; }; typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 978af57..3b4928f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -888,7 +888,10 @@ qemudStartup(int privileged) { qemuDriverUnlock(qemu_driver); - qemuAutostartDomains(qemu_driver); + if (!qemu_driver->disableAutoStart) + qemuAutostartDomains(qemu_driver); + else + VIR_WARN("QEMU domain autostarting is disabled"); if (conn) virConnectClose(conn); -- 1.8.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list