From 984721287e251ec75478dad42d13f66722ca3680 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sep 29 2020 19:36:00 +0000 Subject: import libvirt-4.5.0-36.el7_9.2 --- diff --git a/SOURCES/libvirt-qemu-Create-multipath-targets-for-PRs.patch b/SOURCES/libvirt-qemu-Create-multipath-targets-for-PRs.patch new file mode 100644 index 0000000..2684b7c --- /dev/null +++ b/SOURCES/libvirt-qemu-Create-multipath-targets-for-PRs.patch @@ -0,0 +1,166 @@ +From d415286e93faf2f9c4fa5c5c589aa8d3f433d01d Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Fri, 19 Jun 2020 11:43:13 +0200 +Subject: [PATCH] qemu: Create multipath targets for PRs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If a disk has persistent reservations enabled, qemu-pr-helper +might open not only /dev/mapper/control but also individual +targets of the multipath device. We are already querying for them +in CGroups, but now we have to create them in the namespace too. +This was brought up in [1]. + +1: https://bugzilla.redhat.com/show_bug.cgi?id=1711045#c61 + +Signed-off-by: Michal Privoznik +Tested-by: Lin Ma +Reviewed-by: Jim Fehlig +(cherry picked from commit a30078cb832646177defd256e77c632905f1e6d0) + +https://bugzilla.redhat.com/show_bug.cgi?id=1839992 + +Conflicts: +- src/qemu/qemu_domain.c: Well, the upstream has NVMe and + downstream doesn't. So the functions I'm modifying look + different in the upstream. Tough luck. +- src/util/virdevmapper.h: The upstream moved to gnulib macros + (G_GNUC_NO_INLINE in this case). But since I'm removing changes + to qemuhotplugtest below, this particular change wasn't needed. + The include of "internal.h" is though (because of next commit). +- tests/qemuhotplugmock.c: +- tests/qemuhotplugtest.c: I'm completely dropping these two + changes because the upstream went a long way since and these + are only tests. + +Signed-off-by: Michal Privoznik +Message-Id: +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_domain.c | 59 ++++++++++++++++++++++++++++------------- + src/util/virdevmapper.h | 2 ++ + 2 files changed, 42 insertions(+), 19 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index b4792c9476..489e20a28a 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -57,6 +57,7 @@ + #include "secret_util.h" + #include "logging/log_manager.h" + #include "locking/domain_lock.h" ++#include "virdevmapper.h" + + #ifdef MAJOR_IN_MKDEV + # include +@@ -11325,13 +11326,29 @@ qemuDomainSetupDisk(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED, + int ret = -1; + + for (next = disk->src; virStorageSourceIsBacking(next); next = next->backingStore) { ++ VIR_AUTOSTRINGLIST targetPaths = NULL; ++ size_t i; ++ + if (!next->path || !virStorageSourceIsLocalStorage(next)) { + /* Not creating device. Just continue. */ + continue; + } + + if (qemuDomainCreateDevice(next->path, data, false) < 0) +- goto cleanup; ++ return -1; ++ ++ if (virDevMapperGetTargets(next->path, &targetPaths) < 0 && ++ errno != ENOSYS && errno != EBADF) { ++ virReportSystemError(errno, ++ _("Unable to get devmapper targets for %s"), ++ next->path); ++ return -1; ++ } ++ ++ for (i = 0; targetPaths && targetPaths[i]; i++) { ++ if (qemuDomainCreateDevice(targetPaths[i], data, false) < 0) ++ return -1; ++ } + } + + /* qemu-pr-helper might require access to /dev/mapper/control. */ +@@ -12342,39 +12359,43 @@ qemuDomainNamespaceSetupDisk(virDomainObjPtr vm, + virStorageSourcePtr src) + { + virStorageSourcePtr next; +- const char **paths = NULL; ++ VIR_AUTOSTRINGLIST paths = NULL; + size_t npaths = 0; +- char *dmPath = NULL; +- int ret = -1; +- +- if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) +- return 0; + + for (next = src; virStorageSourceIsBacking(next); next = next->backingStore) { ++ VIR_AUTOSTRINGLIST targetPaths = NULL; ++ + if (virStorageSourceIsEmpty(next) || + !virStorageSourceIsLocalStorage(next)) { + /* Not creating device. Just continue. */ + continue; + } + +- if (VIR_APPEND_ELEMENT_COPY(paths, npaths, next->path) < 0) +- goto cleanup; ++ if (virStringListAdd(&paths, next->path) < 0) ++ return -1; ++ ++ if (virDevMapperGetTargets(next->path, &targetPaths) < 0 && ++ errno != ENOSYS && errno != EBADF) { ++ virReportSystemError(errno, ++ _("Unable to get devmapper targets for %s"), ++ next->path); ++ return -1; ++ } ++ ++ if (virStringListMerge(&paths, &targetPaths) < 0) ++ return -1; + } + + /* qemu-pr-helper might require access to /dev/mapper/control. */ + if (src->pr && +- (VIR_STRDUP(dmPath, DEVICE_MAPPER_CONTROL_PATH) < 0 || +- VIR_APPEND_ELEMENT_COPY(paths, npaths, dmPath) < 0)) +- goto cleanup; ++ virStringListAdd(&paths, DEVICE_MAPPER_CONTROL_PATH) < 0) ++ return -1; + +- if (qemuDomainNamespaceMknodPaths(vm, paths, npaths) < 0) +- goto cleanup; ++ npaths = virStringListLength((const char **) paths); ++ if (qemuDomainNamespaceMknodPaths(vm, (const char **) paths, npaths) < 0) ++ return -1; + +- ret = 0; +- cleanup: +- VIR_FREE(dmPath); +- VIR_FREE(paths); +- return ret; ++ return 0; + } + + +diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h +index 34d6655e77..42a7828fde 100644 +--- a/src/util/virdevmapper.h ++++ b/src/util/virdevmapper.h +@@ -24,6 +24,8 @@ + #ifndef __VIR_DEVMAPPER_H__ + # define __VIR_DEVMAPPER_H__ + ++#include "internal.h" ++ + int + virDevMapperGetTargets(const char *path, + char ***devPaths); +-- +2.27.0 + diff --git a/SOURCES/libvirt-qemu-end-the-agent-job-in-qemuDomainSetTimeAgent.patch b/SOURCES/libvirt-qemu-end-the-agent-job-in-qemuDomainSetTimeAgent.patch new file mode 100644 index 0000000..5b6dced --- /dev/null +++ b/SOURCES/libvirt-qemu-end-the-agent-job-in-qemuDomainSetTimeAgent.patch @@ -0,0 +1,43 @@ +From 34188b9f1bb1e53d2372e02c0388430a85f4cad5 Mon Sep 17 00:00:00 2001 +Message-Id: <34188b9f1bb1e53d2372e02c0388430a85f4cad5@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Thu, 18 Jun 2020 12:31:46 +0200 +Subject: [PATCH] qemu: end the agent job in qemuDomainSetTimeAgent +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This function grabs an agent job but ends a monitor job. +End the agent job instead. + +https://bugzilla.redhat.com/show_bug.cgi?id=1792723 + +Signed-off-by: Ján Tomko +Reported-by: Dan Zheng +Fixes: e005c95f56fee9ed780be7f8db103d690bd34cbd +(cherry picked from commit d61f95cf6a6fbd564e104c168d325581acd9cd8d) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1844952 +Message-Id: <7fa0860281f9f2a08acf488784738f54a8158e63.1592476262.git.jtomko@redhat.com> +Reviewed-by: Michal Privoznik +--- + src/qemu/qemu_driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index e1d9bbae99..449d869f98 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -19478,7 +19478,7 @@ qemuDomainSetTimeAgent(virQEMUDriverPtr driver, + qemuDomainObjExitAgent(vm, agent); + + endjob: +- qemuDomainObjEndJob(driver, vm); ++ qemuDomainObjEndAgentJob(vm); + return ret; + } + +-- +2.27.0 + diff --git a/SOURCES/libvirt-util-Move-virIsDevMapperDevice-to-virdevmapper.c.patch b/SOURCES/libvirt-util-Move-virIsDevMapperDevice-to-virdevmapper.c.patch new file mode 100644 index 0000000..e754269 --- /dev/null +++ b/SOURCES/libvirt-util-Move-virIsDevMapperDevice-to-virdevmapper.c.patch @@ -0,0 +1,189 @@ +From a7197541f467bfd39d5504c438a90ef00ef0bc1e Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Fri, 19 Jun 2020 11:43:14 +0200 +Subject: [PATCH] util: Move virIsDevMapperDevice() to virdevmapper.c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When introducing virdevmapper.c (in v4.3.0-rc1~427) I didn't +realize there is a function that calls in devmapper. The function +is called virIsDevMapperDevice() and lives in virutil.c. Now that +we have a special file for handling devmapper move it there. + +Signed-off-by: Michal Privoznik +Reviewed-by: Jiri Denemark +(cherry picked from commit dfa0e118f745fe3f4fe95975c6100f0fc6d788be) + +https://bugzilla.redhat.com/show_bug.cgi?id=1839992 + +Conflicts: +- src/libvirt_private.syms: Context, the downstream still has + virIsSUID() which was removed in upstream commit of v5.7.0-rc1~351 +- src/util/virdevmapper.h: Context, the downstream code hasn't + switched to #pragma once and still uses #endif. +- src/util/virutil.c: Again, context. + +Signed-off-by: Michal Privoznik +Message-Id: <31b696f526d21c5ce61b10ebe2c77c8fd0557ccc.1592559697.git.mprivozn@redhat.com> +Reviewed-by: Ján Tomko +--- + src/libvirt_private.syms | 2 +- + src/storage/parthelper.c | 2 +- + src/storage/storage_backend_disk.c | 1 + + src/util/virdevmapper.c | 24 ++++++++++++++++++++++++ + src/util/virdevmapper.h | 2 ++ + src/util/virutil.c | 23 ----------------------- + src/util/virutil.h | 2 -- + 7 files changed, 29 insertions(+), 27 deletions(-) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 3e5448af94..ef78b290db 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -1716,6 +1716,7 @@ virDBusSetSharedBus; + + # util/virdevmapper.h + virDevMapperGetTargets; ++virIsDevMapperDevice; + + + # util/virdnsmasq.h +@@ -3132,7 +3133,6 @@ virHexToBin; + virHostGetDRMRenderNode; + virHostHasIOMMU; + virIndexToDiskName; +-virIsDevMapperDevice; + virIsSUID; + virMemoryLimitIsSet; + virMemoryLimitTruncate; +diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c +index afdaa1cee2..d098356164 100644 +--- a/src/storage/parthelper.c ++++ b/src/storage/parthelper.c +@@ -40,11 +40,11 @@ + #include + #include + +-#include "virutil.h" + #include "virfile.h" + #include "c-ctype.h" + #include "virstring.h" + #include "virgettext.h" ++#include "virdevmapper.h" + + /* we don't need to include the full internal.h just for this */ + #define STREQ(a, b) (strcmp(a, b) == 0) +diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c +index c638e2db25..742510d986 100644 +--- a/src/storage/storage_backend_disk.c ++++ b/src/storage/storage_backend_disk.c +@@ -36,6 +36,7 @@ + #include "virfile.h" + #include "configmake.h" + #include "virstring.h" ++#include "virdevmapper.h" + + #define VIR_FROM_THIS VIR_FROM_STORAGE + +diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c +index a360c3e677..944baad562 100644 +--- a/src/util/virdevmapper.c ++++ b/src/util/virdevmapper.c +@@ -218,3 +218,27 @@ virDevMapperGetTargets(const char *path ATTRIBUTE_UNUSED, + return -1; + } + #endif /* ! WITH_DEVMAPPER */ ++ ++ ++#if WITH_DEVMAPPER ++bool ++virIsDevMapperDevice(const char *dev_name) ++{ ++ struct stat buf; ++ ++ if (!stat(dev_name, &buf) && ++ S_ISBLK(buf.st_mode) && ++ dm_is_dm_major(major(buf.st_rdev))) ++ return true; ++ ++ return false; ++} ++ ++#else /* ! WITH_DEVMAPPER */ ++ ++bool ++virIsDevMapperDevice(const char *dev_name G_GNUC_UNUSED) ++{ ++ return false; ++} ++#endif /* ! WITH_DEVMAPPER */ +diff --git a/src/util/virdevmapper.h b/src/util/virdevmapper.h +index 42a7828fde..78dc47e888 100644 +--- a/src/util/virdevmapper.h ++++ b/src/util/virdevmapper.h +@@ -30,4 +30,6 @@ int + virDevMapperGetTargets(const char *path, + char ***devPaths); + ++bool ++virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); + #endif /* __VIR_DEVMAPPER_H__ */ +diff --git a/src/util/virutil.c b/src/util/virutil.c +index fd70df120b..e803fee993 100644 +--- a/src/util/virutil.c ++++ b/src/util/virutil.c +@@ -44,9 +44,6 @@ + #include + #include + +-#if WITH_DEVMAPPER +-# include +-#endif + + #include + #ifdef HAVE_GETPWUID_R +@@ -1620,26 +1617,6 @@ void virWaitForDevices(void) + {} + #endif + +-#if WITH_DEVMAPPER +-bool +-virIsDevMapperDevice(const char *dev_name) +-{ +- struct stat buf; +- +- if (!stat(dev_name, &buf) && +- S_ISBLK(buf.st_mode) && +- dm_is_dm_major(major(buf.st_rdev))) +- return true; +- +- return false; +-} +-#else +-bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED) +-{ +- return false; +-} +-#endif +- + bool + virValidateWWN(const char *wwn) + { +diff --git a/src/util/virutil.h b/src/util/virutil.h +index b0ee8329e2..dbd6a40bce 100644 +--- a/src/util/virutil.h ++++ b/src/util/virutil.h +@@ -152,8 +152,6 @@ int virGetUserID(const char *name, + int virGetGroupID(const char *name, + gid_t *gid) ATTRIBUTE_RETURN_CHECK; + +-bool virIsDevMapperDevice(const char *dev_name) ATTRIBUTE_NONNULL(1); +- + bool virValidateWWN(const char *wwn); + + int virGetDeviceID(const char *path, +-- +2.27.0 + diff --git a/SOURCES/libvirt-util-Rework-virStringListAdd.patch b/SOURCES/libvirt-util-Rework-virStringListAdd.patch new file mode 100644 index 0000000..da41814 --- /dev/null +++ b/SOURCES/libvirt-util-Rework-virStringListAdd.patch @@ -0,0 +1,145 @@ +From 4727de9e9048ffa25784eb0cd536a13ac9644529 Mon Sep 17 00:00:00 2001 +Message-Id: <4727de9e9048ffa25784eb0cd536a13ac9644529@dist-git> +From: Michal Privoznik +Date: Fri, 19 Jun 2020 11:43:12 +0200 +Subject: [PATCH] util: Rework virStringListAdd +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +So every caller does the same: they use virStringListAdd() to add +new item into the list and then free the old copy to replace it +with new list. It's not very memory effective, nor environmental +friendly. + +Signed-off-by: Michal Privoznik +Reviewed-by: Erik Skultety +(cherry picked from commit 71a390e0fdb4e6cbeaef4c9045a501a6c8de5412) + +https://bugzilla.redhat.com/show_bug.cgi?id=1839992 + +Signed-off-by: Michal Privoznik +Message-Id: <75aadf9f9464504bd1feec27d082b28c9fec0cbe.1592559697.git.mprivozn@redhat.com> +Reviewed-by: Ján Tomko +--- + src/util/virmacmap.c | 8 ++------ + src/util/virstring.c | 33 ++++++++++++--------------------- + src/util/virstring.h | 4 ++-- + tests/virstringtest.c | 6 +----- + 4 files changed, 17 insertions(+), 34 deletions(-) + +diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c +index 88ca9b3f36..c7b700fa05 100644 +--- a/src/util/virmacmap.c ++++ b/src/util/virmacmap.c +@@ -90,7 +90,6 @@ virMacMapAddLocked(virMacMapPtr mgr, + { + int ret = -1; + char **macsList = NULL; +- char **newMacsList = NULL; + + if ((macsList = virHashLookup(mgr->macs, domain)) && + virStringListHasString((const char**) macsList, mac)) { +@@ -98,15 +97,12 @@ virMacMapAddLocked(virMacMapPtr mgr, + goto cleanup; + } + +- if (!(newMacsList = virStringListAdd((const char **) macsList, mac)) || +- virHashUpdateEntry(mgr->macs, domain, newMacsList) < 0) ++ if (virStringListAdd(&macsList, mac) < 0 || ++ virHashUpdateEntry(mgr->macs, domain, macsList) < 0) + goto cleanup; +- newMacsList = NULL; +- virStringListFree(macsList); + + ret = 0; + cleanup: +- virStringListFree(newMacsList); + return ret; + } + +diff --git a/src/util/virstring.c b/src/util/virstring.c +index 0f13b6c664..74fa2f6a94 100644 +--- a/src/util/virstring.c ++++ b/src/util/virstring.c +@@ -175,32 +175,23 @@ char *virStringListJoin(const char **strings, + * @strings: a NULL-terminated array of strings + * @item: string to add + * +- * Creates new strings list with all strings duplicated and @item +- * at the end of the list. Callers is responsible for freeing +- * both @strings and returned list. ++ * Appends @item into string list @strings. If *@strings is not ++ * allocated yet new string list is created. ++ * ++ * Returns: 0 on success, ++ * -1 otherwise + */ +-char ** +-virStringListAdd(const char **strings, ++int ++virStringListAdd(char ***strings, + const char *item) + { +- char **ret = NULL; +- size_t i = virStringListLength(strings); +- +- if (VIR_ALLOC_N(ret, i + 2) < 0) +- goto error; +- +- for (i = 0; strings && strings[i]; i++) { +- if (VIR_STRDUP(ret[i], strings[i]) < 0) +- goto error; +- } ++ size_t i = virStringListLength((const char **) *strings); + +- if (VIR_STRDUP(ret[i], item) < 0) +- goto error; ++ if (VIR_EXPAND_N(*strings, i, 2) < 0 || ++ VIR_STRDUP((*strings)[i - 2], item) < 0) ++ return -1; + +- return ret; +- error: +- virStringListFree(ret); +- return NULL; ++ return 0; + } + + +diff --git a/src/util/virstring.h b/src/util/virstring.h +index e68b9eec79..a3db08ce58 100644 +--- a/src/util/virstring.h ++++ b/src/util/virstring.h +@@ -41,8 +41,8 @@ char *virStringListJoin(const char **strings, + const char *delim) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + +-char **virStringListAdd(const char **strings, +- const char *item); ++int virStringListAdd(char ***strings, ++ const char *item); + void virStringListRemove(char ***strings, + const char *item); + +diff --git a/tests/virstringtest.c b/tests/virstringtest.c +index 1230aba5b7..1a1e6364d1 100644 +--- a/tests/virstringtest.c ++++ b/tests/virstringtest.c +@@ -179,12 +179,8 @@ static int testAdd(const void *args) + size_t i; + + for (i = 0; data->tokens[i]; i++) { +- char **tmp = virStringListAdd((const char **)list, data->tokens[i]); +- if (!tmp) ++ if (virStringListAdd(&list, data->tokens[i]) < 0) + goto cleanup; +- virStringListFree(list); +- list = tmp; +- tmp = NULL; + } + + if (!list && +-- +2.27.0 + diff --git a/SOURCES/libvirt-util-string-Introduce-macro-for-automatic-string-lists.patch b/SOURCES/libvirt-util-string-Introduce-macro-for-automatic-string-lists.patch new file mode 100644 index 0000000..d28b610 --- /dev/null +++ b/SOURCES/libvirt-util-string-Introduce-macro-for-automatic-string-lists.patch @@ -0,0 +1,94 @@ +From 62e22785c706e7ee7f99a6600d4505dc890838ef Mon Sep 17 00:00:00 2001 +Message-Id: <62e22785c706e7ee7f99a6600d4505dc890838ef@dist-git> +From: Peter Krempa +Date: Fri, 19 Jun 2020 11:43:11 +0200 +Subject: [PATCH] util: string: Introduce macro for automatic string lists +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Similar to VIR_AUTOPTR, VIR_AUTOSTRINGLIST defines a list of strings +which will be freed if the pointer is leaving scope. + +Signed-off-by: Peter Krempa +Reviewed-by: Erik Skultety +(cherry picked from commit daefda165b28b399478137c75b5466f865c65be5) + +https://bugzilla.redhat.com/show_bug.cgi?id=1839992 + +Conflicts: +- src/util/virstring.h - Context. This is RHEL-7.9; did you + really think this would be a clean backport? Plenty of + patches changed virstring.h in the last two years. + +Signed-off-by: Michal Privoznik +Message-Id: +Reviewed-by: Ján Tomko +--- + src/libvirt_private.syms | 1 + + src/util/virstring.c | 10 ++++++++++ + src/util/virstring.h | 10 ++++++++++ + 3 files changed, 21 insertions(+) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 2a3950fd35..3e5448af94 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -2917,6 +2917,7 @@ virStringHasControlChars; + virStringIsEmpty; + virStringIsPrintable; + virStringListAdd; ++virStringListAutoFree; + virStringListFree; + virStringListFreeCount; + virStringListGetFirstWithPrefix; +diff --git a/src/util/virstring.c b/src/util/virstring.c +index 15f367af7c..0f13b6c664 100644 +--- a/src/util/virstring.c ++++ b/src/util/virstring.c +@@ -332,6 +332,16 @@ void virStringListFree(char **strings) + } + + ++void virStringListAutoFree(char ***strings) ++{ ++ if (!*strings) ++ return; ++ ++ virStringListFree(*strings); ++ *strings = NULL; ++} ++ ++ + /** + * virStringListFreeCount: + * @strings: array of strings to free +diff --git a/src/util/virstring.h b/src/util/virstring.h +index 607ae66e99..e68b9eec79 100644 +--- a/src/util/virstring.h ++++ b/src/util/virstring.h +@@ -53,6 +53,7 @@ int virStringListCopy(char ***dst, + const char **src); + + void virStringListFree(char **strings); ++void virStringListAutoFree(char ***strings); + void virStringListFreeCount(char **strings, + size_t count); + +@@ -309,4 +310,13 @@ int virStringParsePort(const char *str, + unsigned int *port) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; + ++/** ++ * VIR_AUTOSTRINGLIST: ++ * ++ * Declares a NULL-terminated list of strings which will be automatically freed ++ * when the pointer goes out of scope. ++ */ ++# define VIR_AUTOSTRINGLIST \ ++ __attribute__((cleanup(virStringListAutoFree))) char ** ++ + #endif /* __VIR_STRING_H__ */ +-- +2.27.0 + diff --git a/SOURCES/libvirt-virDevMapperGetTargetsImpl-Check-for-dm-major-properly.patch b/SOURCES/libvirt-virDevMapperGetTargetsImpl-Check-for-dm-major-properly.patch new file mode 100644 index 0000000..fda9943 --- /dev/null +++ b/SOURCES/libvirt-virDevMapperGetTargetsImpl-Check-for-dm-major-properly.patch @@ -0,0 +1,66 @@ +From a3ac7f49d3592fb9acdf2c4de6f2bf7329745faa Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Fri, 19 Jun 2020 11:43:15 +0200 +Subject: [PATCH] virDevMapperGetTargetsImpl: Check for dm major properly +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In v6.4.0-rc1~143 I've introduced a check that is supposed to +return from the function early, if given path is not a dm target. +While the idea is still valid, the implementation had a flaw. +It calls stat() over given path and the uses major(sb.st_dev) to +learn the major of the device. This is then passed to +dm_is_dm_major() which returns true or false depending whether +the device is under devmapper's control or not. + +The problem with this approach is in how the major of the device +is obtained - paths managed by devmapper are special files and +thus we want to be using st_rdev instead of st_dev to obtain the +major number. Well, that's what virIsDevMapperDevice() does +already so might as well us that. + +Fixes: 01626c668ecfbe465d18799ac4628e6127ea1d47 +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1839992 + +Signed-off-by: Michal Privoznik +Reviewed-by: Jiri Denemark +(cherry picked from commit d53ab9f54ea8d6cc1e5c3b04c4eb743cae9518ce) +Signed-off-by: Michal Privoznik +Message-Id: +Reviewed-by: Ján Tomko +--- + src/util/virdevmapper.c | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +diff --git a/src/util/virdevmapper.c b/src/util/virdevmapper.c +index 944baad562..c69830ac70 100644 +--- a/src/util/virdevmapper.c ++++ b/src/util/virdevmapper.c +@@ -69,7 +69,6 @@ virDevMapperGetTargetsImpl(const char *path, + char ***devPaths_ret, + unsigned int ttl) + { +- struct stat sb; + struct dm_task *dmt = NULL; + struct dm_deps *deps; + struct dm_info info; +@@ -88,13 +87,7 @@ virDevMapperGetTargetsImpl(const char *path, + return ret; + } + +- if (stat(path, &sb) < 0) { +- if (errno == ENOENT) +- return 0; +- return -1; +- } +- +- if (!dm_is_dm_major(major(sb.st_dev))) ++ if (!virIsDevMapperDevice(path)) + return 0; + + if (!(dmt = dm_task_create(DM_DEVICE_DEPS))) { +-- +2.27.0 + diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index 62685ce..9195d8f 100644 --- a/SPECS/libvirt.spec +++ b/SPECS/libvirt.spec @@ -253,7 +253,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 4.5.0 -Release: 36%{?dist}%{?extra_release} +Release: 36%{?dist}.2%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -641,6 +641,12 @@ Patch375: libvirt-qemu-remove-qemuDomainObjBegin-EndJobWithAgent.patch Patch376: libvirt-storage-Fix-daemon-crash-on-lookup-storagepool-by-targetpath.patch Patch377: libvirt-virDevMapperGetTargetsImpl-Be-tolerant-to-kernels-without-DM-support.patch Patch378: libvirt-virDevMapperGetTargetsImpl-quit-early-if-device-is-not-a-devmapper-target.patch +Patch379: libvirt-qemu-end-the-agent-job-in-qemuDomainSetTimeAgent.patch +Patch380: libvirt-util-string-Introduce-macro-for-automatic-string-lists.patch +Patch381: libvirt-util-Rework-virStringListAdd.patch +Patch382: libvirt-qemu-Create-multipath-targets-for-PRs.patch +Patch383: libvirt-util-Move-virIsDevMapperDevice-to-virdevmapper.c.patch +Patch384: libvirt-virDevMapperGetTargetsImpl-Check-for-dm-major-properly.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2543,6 +2549,17 @@ exit 0 %changelog +* Wed Jul 22 2020 Jiri Denemark - 4.5.0-36.el7_9.2 +- Rebuild to correct invalid dist tag + +* Thu Jul 16 2020 Jiri Denemark - 4.5.0-36.el7_9.1 +- qemu: end the agent job in qemuDomainSetTimeAgent (rhbz#1844952) +- util: string: Introduce macro for automatic string lists (rhbz#1839992) +- util: Rework virStringListAdd (rhbz#1839992) +- qemu: Create multipath targets for PRs (rhbz#1839992) +- util: Move virIsDevMapperDevice() to virdevmapper.c (rhbz#1839992) +- virDevMapperGetTargetsImpl: Check for dm major properly (rhbz#1839992) + * Wed May 13 2020 Jiri Denemark - 4.5.0-36 - virDevMapperGetTargetsImpl: Be tolerant to kernels without DM support (rhbz#1823976) - virDevMapperGetTargetsImpl: quit early if device is not a devmapper target (rhbz#1823976)