diff --git a/0125-network-make-it-safe-to-call-networkSetupPrivateChai.patch b/0125-network-make-it-safe-to-call-networkSetupPrivateChai.patch new file mode 100644 index 0000000..29d7111 --- /dev/null +++ b/0125-network-make-it-safe-to-call-networkSetupPrivateChai.patch @@ -0,0 +1,55 @@ +From: Laine Stump +Date: Thu, 7 May 2020 22:32:59 -0400 +Subject: [PATCH] network: make it safe to call networkSetupPrivateChains() + multiple times +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +networkSetupPrivateChains() is currently called only once per run of +libvirtd, so it can assume that errInitV4 and errInitV6 are empty/null +when it is called. In preparation for potentially calling this +function multiple times during one run, this patch moves the reset of +errInitV[46] to the top of the function, to assure no memory is +leaked. + +Signed-off-by: Laine Stump +Reviewed-by: Daniel P. Berrangé +(cherry picked from commit de110f110fb917a31b9f33ad8e4b3c1d3284766a) +--- + src/network/bridge_driver_linux.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c +index 35459c10d1..f4e4e2df76 100644 +--- a/src/network/bridge_driver_linux.c ++++ b/src/network/bridge_driver_linux.c +@@ -48,6 +48,10 @@ static void networkSetupPrivateChains(void) + VIR_DEBUG("Setting up global firewall chains"); + + createdChains = false; ++ virFreeError(errInitV4); ++ errInitV4 = NULL; ++ virFreeError(errInitV6); ++ errInitV6 = NULL; + + rc = iptablesSetupPrivateChains(VIR_FIREWALL_LAYER_IPV4); + if (rc < 0) { +@@ -56,8 +60,6 @@ static void networkSetupPrivateChains(void) + errInitV4 = virSaveLastError(); + virResetLastError(); + } else { +- virFreeError(errInitV4); +- errInitV4 = NULL; + if (rc) { + VIR_DEBUG("Created global IPv4 chains"); + createdChains = true; +@@ -73,8 +75,6 @@ static void networkSetupPrivateChains(void) + errInitV6 = virSaveLastError(); + virResetLastError(); + } else { +- virFreeError(errInitV6); +- errInitV6 = NULL; + if (rc) { + VIR_DEBUG("Created global IPv6 chains"); + createdChains = true; diff --git a/0126-network-force-re-creation-of-iptables-private-chains.patch b/0126-network-force-re-creation-of-iptables-private-chains.patch new file mode 100644 index 0000000..cc81c2d --- /dev/null +++ b/0126-network-force-re-creation-of-iptables-private-chains.patch @@ -0,0 +1,265 @@ +From: Laine Stump +Date: Thu, 7 May 2020 21:54:39 -0400 +Subject: [PATCH] network: force re-creation of iptables private chains on + firewalld restart +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When firewalld is stopped, it removes *all* iptables rules and chains, +including those added by libvirt. Since restarting firewalld means +stopping and then starting it, any time it is restarted, libvirt needs +to recreate all the private iptables chains it uses, along with all +the rules it adds. + +We already have code in place to call networkReloadFirewallRules() any +time we're notified of a firewalld start, and +networkReloadFirewallRules() will call +networkPreReloadFirewallRules(), which calls +networkSetupPrivateChains(); unfortunately that last call is called +using virOnce(), meaning that it will only be called the first time +through networkPreReloadFirewallRules() after libvirtd starts - so of +course when firewalld is later restarted, the call to +networkSetupPrivateChains() is skipped. + +The neat and tidy way to fix this would be if there was a standard way +to reset a pthread_once_t object so that the next time virOnce was +called, it would think the function hadn't been called, and call it +again. Unfortunately, there isn't any official way of doing that (we +*could* just fill it with 0 and hope for the best, but that doesn't +seem very safe. + +So instead, this patch just adds a static variable called +chainInitDone, which is set to true after networkSetupPrivateChains() +is called for the first time, and then during calls to +networkPreReloadFirewallRules(), if chainInitDone is set, we call +networkSetupPrivateChains() directly instead of via virOnce(). + +It may seem unsafe to directly call a function that is meant to be +called only once, but I think in this case we're safe - there's +nothing in the function that is inherently "once only" - it doesn't +initialize anything that can't safely be re-initialized (as long as +two threads don't try to do it at the same time), and it only happens +when responding to a dbus message that firewalld has been started (and +I don't think it's possible for us to be processing two of those at +once), and even then only if the initial call to the function has +already been completed (so we're safe if we receive a firewalld +restart call at a time when we haven't yet called it, or even if +another thread is already in the process of executing it. The only +problematic bit I can think of is if another thread is in the process +of adding an iptable rule at the time we're executing this function, +but 1) none of those threads will be trying to add chains, and 2) if +there was a concurrency problem with other threads adding iptables +rules while firewalld was being restarted, it would still be a problem +even without this change. + +This is yet another patch that fixes an occurrence of this error: + +COMMAND_FAILED: '/usr/sbin/iptables -w10 -w --table filter --insert LIBVIRT_INP --in-interface virbr0 --protocol tcp --destination-port 67 --jump ACCEPT' failed: iptables: No chain/target/match by that name. + +In particular, this resolves: https://bugzilla.redhat.com/1813830 + +Signed-off-by: Laine Stump +Reviewed-by: Daniel P. Berrangé +(cherry picked from commit f5418b427e7d2f26803880309478de9103680826) +--- + src/network/bridge_driver.c | 16 ++++--- + src/network/bridge_driver_linux.c | 69 ++++++++++++++++++---------- + src/network/bridge_driver_nop.c | 3 +- + src/network/bridge_driver_platform.h | 2 +- + 4 files changed, 58 insertions(+), 32 deletions(-) + +diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c +index d5c544f556..981b4e4578 100644 +--- a/src/network/bridge_driver.c ++++ b/src/network/bridge_driver.c +@@ -289,7 +289,9 @@ static int + networkShutdownNetworkExternal(virNetworkObjPtr obj); + + static void +-networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup); ++networkReloadFirewallRules(virNetworkDriverStatePtr driver, ++ bool startup, ++ bool force); + + static void + networkRefreshDaemons(virNetworkDriverStatePtr driver); +@@ -695,7 +697,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED, + + if (reload) { + VIR_DEBUG("Reload in bridge_driver because of firewalld."); +- networkReloadFirewallRules(driver, false); ++ networkReloadFirewallRules(driver, false, true); + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +@@ -814,7 +816,7 @@ networkStateInitialize(bool privileged, + virNetworkObjListPrune(network_driver->networks, + VIR_CONNECT_LIST_NETWORKS_INACTIVE | + VIR_CONNECT_LIST_NETWORKS_TRANSIENT); +- networkReloadFirewallRules(network_driver, true); ++ networkReloadFirewallRules(network_driver, true, false); + networkRefreshDaemons(network_driver); + + if (virDriverShouldAutostart(network_driver->stateDir, &autostart) < 0) +@@ -884,7 +886,7 @@ networkStateReload(void) + network_driver->networkConfigDir, + network_driver->networkAutostartDir, + network_driver->xmlopt); +- networkReloadFirewallRules(network_driver, false); ++ networkReloadFirewallRules(network_driver, false, false); + networkRefreshDaemons(network_driver); + virNetworkObjListForEach(network_driver->networks, + networkAutostartConfig, +@@ -2267,14 +2269,16 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr obj, + + + static void +-networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup) ++networkReloadFirewallRules(virNetworkDriverStatePtr driver, ++ bool startup, ++ bool force) + { + VIR_INFO("Reloading iptables rules"); + /* Ideally we'd not even register the driver when unprivilegd + * but until we untangle the virt driver that's not viable */ + if (!driver->privileged) + return; +- networkPreReloadFirewallRules(driver, startup); ++ networkPreReloadFirewallRules(driver, startup, force); + virNetworkObjListForEach(driver->networks, + networkReloadFirewallRulesHelper, + NULL); +diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c +index f4e4e2df76..f65928e556 100644 +--- a/src/network/bridge_driver_linux.c ++++ b/src/network/bridge_driver_linux.c +@@ -36,11 +36,14 @@ VIR_LOG_INIT("network.bridge_driver_linux"); + #define PROC_NET_ROUTE "/proc/net/route" + + static virOnceControl createdOnce; +-static bool createdChains; ++static bool chainInitDone; /* true iff networkSetupPrivateChains was ever called */ ++static bool createdChains; /* true iff networkSetupPrivateChains created chains during most recent call */ + static virErrorPtr errInitV4; + static virErrorPtr errInitV6; + +-/* Only call via virOnce */ ++/* Usually only called via virOnce, but can also be called directly in ++ * response to firewalld reload (if chainInitDone == true) ++ */ + static void networkSetupPrivateChains(void) + { + int rc; +@@ -82,6 +85,8 @@ static void networkSetupPrivateChains(void) + VIR_DEBUG("Global IPv6 chains already exist"); + } + } ++ ++ chainInitDone = true; + } + + +@@ -111,7 +116,10 @@ networkHasRunningNetworks(virNetworkDriverStatePtr driver) + } + + +-void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup) ++void ++networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, ++ bool startup, ++ bool force) + { + /* + * If there are any running networks, we need to +@@ -130,29 +138,42 @@ void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup + * of starting the network though as that makes them + * more likely to be seen by a human + */ +- if (!networkHasRunningNetworks(driver)) { +- VIR_DEBUG("Delayed global rule setup as no networks are running"); +- return; +- } ++ if (chainInitDone && force) { ++ /* The Private chains have already been initialized once ++ * during this run of libvirtd, so 1) we can't do it again via ++ * virOnce(), and 2) we need to re-add the private chains even ++ * if there are currently no running networks, because the ++ * next time a network is started, libvirt will expect that ++ * the chains have already been added. So we call directly ++ * instead of via virOnce(). ++ */ ++ networkSetupPrivateChains(); + +- ignore_value(virOnce(&createdOnce, networkSetupPrivateChains)); ++ } else { ++ if (!networkHasRunningNetworks(driver)) { ++ VIR_DEBUG("Delayed global rule setup as no networks are running"); ++ return; ++ } + +- /* +- * If this is initial startup, and we just created the +- * top level private chains we either +- * +- * - upgraded from old libvirt +- * - freshly booted from clean state +- * +- * In the first case we must delete the old rules from +- * the built-in chains, instead of our new private chains. +- * In the second case it doesn't matter, since no existing +- * rules will be present. Thus we can safely just tell it +- * to always delete from the builin chain +- */ +- if (startup && createdChains) { +- VIR_DEBUG("Requesting cleanup of legacy firewall rules"); +- iptablesSetDeletePrivate(false); ++ ignore_value(virOnce(&createdOnce, networkSetupPrivateChains)); ++ ++ /* ++ * If this is initial startup, and we just created the ++ * top level private chains we either ++ * ++ * - upgraded from old libvirt ++ * - freshly booted from clean state ++ * ++ * In the first case we must delete the old rules from ++ * the built-in chains, instead of our new private chains. ++ * In the second case it doesn't matter, since no existing ++ * rules will be present. Thus we can safely just tell it ++ * to always delete from the builin chain ++ */ ++ if (startup && createdChains) { ++ VIR_DEBUG("Requesting cleanup of legacy firewall rules"); ++ iptablesSetDeletePrivate(false); ++ } + } + } + +diff --git a/src/network/bridge_driver_nop.c b/src/network/bridge_driver_nop.c +index ec7b1ed8b7..74a9b87158 100644 +--- a/src/network/bridge_driver_nop.c ++++ b/src/network/bridge_driver_nop.c +@@ -20,7 +20,8 @@ + #include + + void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver ATTRIBUTE_UNUSED, +- bool startup ATTRIBUTE_UNUSED) ++ bool startup ATTRIBUTE_UNUSED, ++ bool force ATTRIBUTE_UNUSED) + { + } + +diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driver_platform.h +index 169417a6c0..48ab52c160 100644 +--- a/src/network/bridge_driver_platform.h ++++ b/src/network/bridge_driver_platform.h +@@ -62,7 +62,7 @@ struct _virNetworkDriverState { + typedef struct _virNetworkDriverState virNetworkDriverState; + typedef virNetworkDriverState *virNetworkDriverStatePtr; + +-void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup); ++void networkPreReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup, bool force); + void networkPostReloadFirewallRules(bool startup); + + int networkCheckRouteCollision(virNetworkDefPtr def); diff --git a/0127-systemd-start-libvirtd-after-firewalld-iptables-serv.patch b/0127-systemd-start-libvirtd-after-firewalld-iptables-serv.patch new file mode 100644 index 0000000..df66fa5 --- /dev/null +++ b/0127-systemd-start-libvirtd-after-firewalld-iptables-serv.patch @@ -0,0 +1,85 @@ +From: Laine Stump +Date: Fri, 1 May 2020 00:05:50 -0400 +Subject: [PATCH] systemd: start libvirtd after firewalld/iptables services + +When a system has enabled the iptables/ip6tables services rather than +firewalld, there is no explicit ordering of the start of those +services vs. libvirtd. This creates a problem when libvirtd.service is +started before ip[6]tables, as the latter, when it finally is started, +will remove all of the iptables rules that had previously been added +by libvirt, including the custom chains where libvirt's rules are +kept. This results in an error message similar to the following when a +user subsequently tries to start a new libvirt network: + + "Error while activating network: Call to virNetworkCreate failed: + internal error: Failed to apply firewall rules + /usr/sbin/ip6tables -w --table filter --insert LIBVIRT_FWO \ + --in-interface virbr2 --jump REJECT: + ip6tables: No chain/target/match by that name." + +(Prior to logging this error, it also would have caused failure to +forward (or block) traffic in some cases, e.g. for guests on a NATed +network, since libvirt's rules to forward/block had all been deleted +and libvirt didn't know about it, so it couldn't fix the problem) + +When this happens, the problem can be remedied by simply restarting +libvirtd.service (which has the side-effect of reloading all +libvirt-generated firewall rules) + +Instead, we can just explicitly stating in the libvirtd.service file +that libvirtd.service should start after ip6tables.service and +ip6tables.service, eliminating the race condition that leads to the +error. + +There is also nothing (that I can see) in the systemd .service files +to guarantee that firewalld.service will be started (if enabled) prior +to libvirtd.service. The same error scenario given above would occur +if libvirtd.service started before firewalld.service. Even before +that, though libvirtd would have detected that firewalld.service was +disabled, and then turn off all firewalld support. So, for example, +firewalld's libvirt zone wouldn't be used, and most likely traffic +from guests would therefore be blocked (all with no external +indication of the source of the problem other than a debug-level log +when libvirtd was started saying that firewalld wasn't in use); also +libvirtd wouldn't notice when firewalld reloaded its rules (which also +simultaneously deletes all of libvirt's rules). + +I'm not aware of any reports that have been traced back to +libvirtd.service starting before firewalld.service, but have seen that +error reported multiple times, and also don't see an existing +dependency that would guarantee firewalld.service starts before +libvirtd.service, so it's possible it's been happening and we just +haven't gotten to the bottom of it. + +This patch adds an After= line to the libvirtd.service file for each +of iptables.service, ip6tables.service, and firewalld.servicee, which +should guarantee that libvirtd.service isn't started until systemd has +started whichever of the others is enabled. + +This race was diagnosed, and patch proposed, by Jason Montleon in +https://bugzilla.redhat.com/1723698 . At the time (April 2019) danpb +agreed with him that this change to libvirtd.service was a reasonable +thing to do, but I guess everyone thought someone else was going to +post a patch, so in the end nobody did. + +Signed-off-by: Laine Stump +Reviewed-by: Michal Privoznik +(cherry picked from commit 0756415f147dda15a417bd79eef9a62027d176e6) +--- + src/remote/libvirtd.service.in | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/remote/libvirtd.service.in b/src/remote/libvirtd.service.in +index d5d98f0c12..ada5be62e6 100644 +--- a/src/remote/libvirtd.service.in ++++ b/src/remote/libvirtd.service.in +@@ -11,6 +11,9 @@ Wants=libvirtd-admin.socket + Wants=systemd-machined.service + Before=libvirt-guests.service + After=network.target ++After=firewalld.service ++After=iptables.service ++After=ip6tables.service + After=dbus.service + After=iscsid.service + After=apparmor.service diff --git a/0128-qemuDomainGetStatsIOThread-Don-t-leak-array-with-0-i.patch b/0128-qemuDomainGetStatsIOThread-Don-t-leak-array-with-0-i.patch new file mode 100644 index 0000000..2c6207e --- /dev/null +++ b/0128-qemuDomainGetStatsIOThread-Don-t-leak-array-with-0-i.patch @@ -0,0 +1,41 @@ +From: Peter Krempa +Date: Wed, 19 Feb 2020 08:40:59 +0100 +Subject: [PATCH] qemuDomainGetStatsIOThread: Don't leak array with 0 iothreads +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +qemuMonitorGetIOThreads returns a NULL-terminated list even when 0 +iothreads are present. The caller didn't perform cleanup if there were 0 +iothreads leaking the array. + +https://bugzilla.redhat.com/show_bug.cgi?id=1804548 + +Fixes: d1eac92784573559b6fd56836e33b215c89308e3 +Reported-by: Jing Yan +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 9bf9e0ae6af38c806f4672ca7b12a6b38d5a9581) +--- + src/qemu/qemu_driver.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 5dd2616c7b..331e53b971 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -21632,8 +21632,12 @@ qemuDomainGetStatsIOThread(virQEMUDriverPtr driver, + if ((niothreads = qemuDomainGetIOThreadsMon(driver, dom, &iothreads)) < 0) + return -1; + +- if (niothreads == 0) +- return 0; ++ /* qemuDomainGetIOThreadsMon returns a NULL-terminated list, so we must free ++ * it even if it returns 0 */ ++ if (niothreads == 0) { ++ ret = 0; ++ goto cleanup; ++ } + + QEMU_ADD_COUNT_PARAM(record, maxparams, "iothread", niothreads); + diff --git a/0129-storage-Fix-daemon-crash-on-lookup-storagepool-by-ta.patch b/0129-storage-Fix-daemon-crash-on-lookup-storagepool-by-ta.patch new file mode 100644 index 0000000..e2d0a8a --- /dev/null +++ b/0129-storage-Fix-daemon-crash-on-lookup-storagepool-by-ta.patch @@ -0,0 +1,47 @@ +From: Yi Li +Date: Sat, 21 Dec 2019 08:33:33 +0800 +Subject: [PATCH] storage: Fix daemon crash on lookup storagepool by targetpath + +Causing a crash when storagePoolLookupByTargetPath beacuse of +Some types of storage pool have no target elements. +Use STREQ_NULLABLE instead of STREQ +Avoids segfaults when using NULL arguments. + +Core was generated by `/usr/sbin/libvirtd'. +Program terminated with signal 11, Segmentation fault. +(gdb) bt +0 0x0000ffff9e951388 in strcmp () from /lib64/libc.so.6 +1 0x0000ffff92103e9c in storagePoolLookupByTargetPathCallback ( + obj=0xffff7009aab0, opaque=0xffff801058b0) at storage/storage_driver.c:1649 +2 0x0000ffff9f2c52a4 in virStoragePoolObjListSearchCb ( + payload=0xffff801058b0, name=, opaque=) + at conf/virstorageobj.c:476 +3 0x0000ffff9f1f2f7c in virHashSearch (ctable=0xffff800f4f60, + iter=iter@entry=0xffff9f2c5278 , + data=data@entry=0xffff95af7488, name=name@entry=0x0) at util/virhash.c:696 +4 0x0000ffff9f2c64f0 in virStoragePoolObjListSearch (pools=0xffff800f2ce0, + searcher=searcher@entry=0xffff92103e68 , + opaque=) at conf/virstorageobj.c:505 +5 0x0000ffff92101f54 in storagePoolLookupByTargetPath (conn=0xffff5c0009f0, +path=0xffff7009a850 "/vms/images") at storage/storage_driver.c:1672 + +Reviewed-by: Cole Robinson +Signed-off-by: Yi Li +(cherry picked from commit dfff16a7c261f8d28e3abe60a47165f845fa952f) +--- + src/storage/storage_driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c +index 05192027d6..d878b0be92 100644 +--- a/src/storage/storage_driver.c ++++ b/src/storage/storage_driver.c +@@ -1675,7 +1675,7 @@ storagePoolLookupByTargetPathCallback(virStoragePoolObjPtr obj, + return false; + + def = virStoragePoolObjGetDef(obj); +- return STREQ(path, def->target.path); ++ return STREQ_NULLABLE(path, def->target.path); + } + + diff --git a/0130-qemu-don-t-hold-both-jobs-for-suspend.patch b/0130-qemu-don-t-hold-both-jobs-for-suspend.patch new file mode 100644 index 0000000..58d94e6 --- /dev/null +++ b/0130-qemu-don-t-hold-both-jobs-for-suspend.patch @@ -0,0 +1,168 @@ +From: Jonathon Jongsma +Date: Thu, 5 Dec 2019 10:08:52 -0600 +Subject: [PATCH] qemu: don't hold both jobs for suspend + +We have to assume that the guest agent may be malicious so we don't want +to allow any agent queries to block any other libvirt API. By holding a +monitor job while we're querying the agent, we open ourselves up to a +DoS. + +So split the function up a bit to only hold the monitor job while +querying qemu for whether the domain supports suspend. Then acquire only +an agent job while issuing the agent suspend command. + +Signed-off-by: Jonathon Jongsma +Signed-off-by: Michal Privoznik +Reviewed-by: Michal Privoznik +(cherry picked from commit a663a860819287e041c3de672aad1d8543098ecc) +--- + src/qemu/qemu_driver.c | 94 ++++++++++++++++++++++++++---------------- + 1 file changed, 59 insertions(+), 35 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 331e53b971..96c0b3505a 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -19867,6 +19867,59 @@ qemuDomainProbeQMPCurrentMachine(virQEMUDriverPtr driver, + } + + ++/* returns -1 on error, or if query is not supported, 0 if query was successful */ ++static int ++qemuDomainQueryWakeupSuspendSupport(virQEMUDriverPtr driver, ++ virDomainObjPtr vm, ++ bool *wakeupSupported) ++{ ++ qemuDomainObjPrivatePtr priv = vm->privateData; ++ int ret = -1; ++ ++ if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CURRENT_MACHINE)) ++ return -1; ++ ++ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0) ++ return -1; ++ ++ if ((ret = virDomainObjCheckActive(vm)) < 0) ++ goto endjob; ++ ++ ret = qemuDomainProbeQMPCurrentMachine(driver, vm, wakeupSupported); ++ ++ endjob: ++ qemuDomainObjEndJob(driver, vm); ++ return ret; ++} ++ ++ ++static int ++qemuDomainPMSuspendAgent(virQEMUDriverPtr driver, ++ virDomainObjPtr vm, ++ unsigned int target) ++{ ++ qemuAgentPtr agent; ++ int ret = -1; ++ ++ if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) < 0) ++ return -1; ++ ++ if ((ret = virDomainObjCheckActive(vm)) < 0) ++ goto endjob; ++ ++ if (!qemuDomainAgentAvailable(vm, true)) ++ goto endjob; ++ ++ agent = qemuDomainObjEnterAgent(vm); ++ ret = qemuAgentSuspend(agent, target); ++ qemuDomainObjExitAgent(vm, agent); ++ ++ endjob: ++ qemuDomainObjEndAgentJob(vm); ++ return ret; ++} ++ ++ + static int + qemuDomainPMSuspendForDuration(virDomainPtr dom, + unsigned int target, +@@ -19874,11 +19927,9 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, + unsigned int flags) + { + virQEMUDriverPtr driver = dom->conn->privateData; +- qemuDomainObjPrivatePtr priv; + virDomainObjPtr vm; +- qemuAgentPtr agent; +- qemuDomainJob job = QEMU_JOB_NONE; + int ret = -1; ++ bool wakeupSupported; + + virCheckFlags(0, -1); + +@@ -19903,17 +19954,6 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, + if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + +- priv = vm->privateData; +- +- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CURRENT_MACHINE)) +- job = QEMU_JOB_MODIFY; +- +- if (qemuDomainObjBeginJobWithAgent(driver, vm, job, QEMU_AGENT_JOB_MODIFY) < 0) +- goto cleanup; +- +- if (virDomainObjCheckActive(vm) < 0) +- goto endjob; +- + /* + * The case we want to handle here is when QEMU has the API (i.e. + * QEMU_CAPS_QUERY_CURRENT_MACHINE is set). Otherwise, do not interfere +@@ -19921,16 +19961,11 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, + * that don't know about this cap, will keep their old behavior of + * suspending 'in the dark'. + */ +- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_QUERY_CURRENT_MACHINE)) { +- bool wakeupSupported; +- +- if (qemuDomainProbeQMPCurrentMachine(driver, vm, &wakeupSupported) < 0) +- goto endjob; +- ++ if (qemuDomainQueryWakeupSuspendSupport(driver, vm, &wakeupSupported) == 0) { + if (!wakeupSupported) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Domain does not have suspend support")); +- goto endjob; ++ goto cleanup; + } + } + +@@ -19940,29 +19975,18 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, + target == VIR_NODE_SUSPEND_TARGET_HYBRID)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("S3 state is disabled for this domain")); +- goto endjob; ++ goto cleanup; + } + + if (vm->def->pm.s4 == VIR_TRISTATE_BOOL_NO && + target == VIR_NODE_SUSPEND_TARGET_DISK) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("S4 state is disabled for this domain")); +- goto endjob; ++ goto cleanup; + } + } + +- if (!qemuDomainAgentAvailable(vm, true)) +- goto endjob; +- +- agent = qemuDomainObjEnterAgent(vm); +- ret = qemuAgentSuspend(agent, target); +- qemuDomainObjExitAgent(vm, agent); +- +- endjob: +- if (job) +- qemuDomainObjEndJobWithAgent(driver, vm); +- else +- qemuDomainObjEndAgentJob(vm); ++ ret = qemuDomainPMSuspendAgent(driver, vm, target); + + cleanup: + virDomainObjEndAPI(&vm); diff --git a/libvirt.spec b/libvirt.spec index b4b21ab..bdd7124 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -218,7 +218,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 5.6.0 -Release: 6%{?dist} +Release: 7%{?dist} License: LGPLv2+ URL: https://libvirt.org/ @@ -276,6 +276,20 @@ Patch0121: 0121-virhostuptime-Add-linux-stub-for-musl.patch Patch0122: 0122-virhostuptime-Wrap-virHostGetBootTimeProcfs-call-in-.patch Patch0123: 0123-virhostuptime-Introduce-virHostBootTimeInit.patch Patch0124: 0124-remote_daemon-Initialize-host-boot-time-global-varia.patch +# Fix iptables No chain/target/match by that name (bz #1813830) +Patch0125: 0125-network-make-it-safe-to-call-networkSetupPrivateChai.patch +Patch0126: 0126-network-force-re-creation-of-iptables-private-chains.patch +# systemd: start libvirtd after firewalld/iptables services (bz #1697636) +Patch0127: 0127-systemd-start-libvirtd-after-firewalld-iptables-serv.patch +# CVE-2020-12430: memory leak in domstats may allow read-only user to +# perform DoS attack (bz #1828216, bz #1828190) +Patch0128: 0128-qemuDomainGetStatsIOThread-Don-t-leak-array-with-0-i.patch +# CVE-2020-10703: Potential denial of service via active pool without target +# path (bz #1820690, bz #1816650) +Patch0129: 0129-storage-Fix-daemon-crash-on-lookup-storagepool-by-ta.patch +# CVE-2019-20485: potential DoS by holding a monitor job while querying QEMU +# guest-agent (bz #1809741, bz #1809740) +Patch0130: 0130-qemu-don-t-hold-both-jobs-for-suspend.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -1940,6 +1954,16 @@ exit 0 %changelog +* Wed May 27 2020 Cole Robinson - 5.6.0-7 +- Fix iptables No chain/target/match by that name (bz #1813830) +- systemd: start libvirtd after firewalld/iptables services (bz #1697636) +- CVE-2020-12430: memory leak in domstats may allow read-only user to + perform DoS attack (bz #1828216, bz #1828190) +- CVE-2020-10703: Potential denial of service via active pool without target + path (bz #1820690, bz #1816650) +- CVE-2019-20485: potential DoS by holding a monitor job while querying QEMU + guest-agent (bz #1809741, bz #1809740) + * Tue Apr 07 2020 Cole Robinson - 5.6.0-6 - Fix issues with uptime detection (bz #1783715)