For some architectures and setups, device removal can take longer than the default 5 seconds. This results in commands such as 'virsh setvcpus' to fire timeout messages even if the actual operation happened in the guest, causing confusion for the user. This patch adds a new qemu.conf parameter called 'unplug_timeout' to handle these cases. If left unset, the current default timeout is used. To avoid user 'experimentation' with small timeouts, the current timeout is also the minimal value allowed. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/libvirtd_qemu.aug | 3 +++ src/qemu/qemu.conf | 4 ++++ src/qemu/qemu_conf.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 5 +++++ src/qemu/qemu_driver.c | 2 ++ src/qemu/test_libvirtd_qemu.aug.in | 1 + 6 files changed, 41 insertions(+) diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug index 2a99a0c55f..3bf94c9235 100644 --- a/src/qemu/libvirtd_qemu.aug +++ b/src/qemu/libvirtd_qemu.aug @@ -130,6 +130,8 @@ module Libvirtd_qemu = let capability_filters_entry = str_array_entry "capability_filters" + let unplug_timeout_entry = int_entry "unplug_timeout" + (* Each entry in the config is one of the following ... *) let entry = default_tls_entry | vnc_entry @@ -152,6 +154,7 @@ module Libvirtd_qemu = | nbd_entry | swtpm_entry | capability_filters_entry + | unplug_timeout_entry let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ] let empty = [ label "#empty" . eol ] diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf index 8cabeccacb..c6d0f0940c 100644 --- a/src/qemu/qemu.conf +++ b/src/qemu/qemu.conf @@ -847,3 +847,7 @@ # may change across versions. # #capability_filters = [ "capname" ] + +# Timeout, in seconds, for unplug operations. Default and minimal value +# is 5. +#unplug_timeout = 5 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 2953893337..83d4ac8310 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -69,6 +69,8 @@ VIR_LOG_INIT("qemu.qemu_conf"); #define QEMU_MIGRATION_PORT_MIN 49152 #define QEMU_MIGRATION_PORT_MAX 49215 +#define QEMU_UNPLUG_TIMEOUT 5 + static virClassPtr virQEMUDriverConfigClass; static void virQEMUDriverConfigDispose(void *obj); @@ -298,6 +300,8 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) cfg->glusterDebugLevel = 4; cfg->stdioLogD = true; + cfg->unplugTimeout = QEMU_UNPLUG_TIMEOUT; + if (!(cfg->namespaces = virBitmapNew(QEMU_DOMAIN_NS_LAST))) goto error; @@ -1009,6 +1013,24 @@ virQEMUDriverConfigLoadCapsFiltersEntry(virQEMUDriverConfigPtr cfg, } +static int +virQEMUDriverConfigLoadUnplugTimeoutEntry(virQEMUDriverConfigPtr cfg, + virConfPtr conf) +{ + if (virConfGetValueUInt(conf, "unplug_timeout", &cfg->unplugTimeout) < 0) + return -1; + + if (cfg->unplugTimeout < QEMU_UNPLUG_TIMEOUT) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unplug_timeout: value must be greater " + "than or equal to %d"), QEMU_UNPLUG_TIMEOUT); + return -1; + } + + return 0; +} + + int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, const char *filename, bool privileged) @@ -1081,6 +1103,10 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg, if (virQEMUDriverConfigLoadCapsFiltersEntry(cfg, conf) < 0) goto cleanup; + if (virQEMUDriverConfigLoadUnplugTimeoutEntry(cfg, conf) < 0) + goto cleanup; + + ret = 0; cleanup: diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 0cbddd7a9c..29824e4e35 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -214,6 +214,8 @@ struct _virQEMUDriverConfig { gid_t swtpm_group; char **capabilityfilters; + + unsigned int unplugTimeout; }; /* Main driver state */ @@ -294,6 +296,9 @@ struct _virQEMUDriver { /* Immutable pointer, self-locking APIs */ virHashAtomicPtr migrationErrors; + + /* Immutable value */ + unsigned int unplugTimeout; }; virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 11f97dbc65..5e86d4cfe6 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1078,6 +1078,8 @@ qemuStateInitialize(bool privileged, if (!qemu_driver->workerPool) goto error; + qemu_driver->unplugTimeout = cfg->unplugTimeout * 1000ul; + qemuProcessReconnectAll(qemu_driver); qemuAutostartDomains(qemu_driver); diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in index 9f81759cb5..a1cd48f1ee 100644 --- a/src/qemu/test_libvirtd_qemu.aug.in +++ b/src/qemu/test_libvirtd_qemu.aug.in @@ -109,3 +109,4 @@ module Test_libvirtd_qemu = { "capability_filters" { "1" = "capname" } } +unplug_timeout = 5 -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list