From 2ba5aaceffa1cbb6a0a8ac79c6b530d41c63b532 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 15 2020 14:11:17 +0000 Subject: import libvirt-6.0.0-29.module+el8.4.0+8389+a260c754 --- diff --git a/SOURCES/libvirt-check-for-NULL-before-calling-g_regex_unref.patch b/SOURCES/libvirt-check-for-NULL-before-calling-g_regex_unref.patch new file mode 100644 index 0000000..a0c6d04 --- /dev/null +++ b/SOURCES/libvirt-check-for-NULL-before-calling-g_regex_unref.patch @@ -0,0 +1,77 @@ +From 5fe7795d5fa5061f0ba615472f9351f9d29abf48 Mon Sep 17 00:00:00 2001 +Message-Id: <5fe7795d5fa5061f0ba615472f9351f9d29abf48@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 2 Oct 2020 13:44:44 +0200 +Subject: [PATCH] check for NULL before calling g_regex_unref +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +g_regex_unref reports an error if called with a NULL argument. + +We have two cases in the code where we (possibly) call it on a NULL +argument. The interesting one is in virDomainQemuMonitorEventCleanup. + +Based on VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX, we unref +data->regex, which has two problems: + +* On the client side, flags is -1 so the comparison is true even if no + regex was used, reproducible by: + $ virsh qemu-monitor-event --timeout 1 + which results in an ugly error: +(process:1289846): GLib-CRITICAL **: 14:58:42.631: g_regex_unref: assertion 'regex != NULL' failed +* On the server side, we only create the regex if both the flag and the + string are present, so it's possible to trigger this message by: + $ virsh qemu-monitor-event --regex --timeout 1 + +Use a non-NULL comparison instead of the flag to decide whether we need +to unref the regex. And add a non-NULL check to the unref in the +VirtualBox test too. + +Signed-off-by: Ján Tomko +Fixes: 71efb59a4de7c51b1bc889a316f1796ebf55738f +https://bugzilla.redhat.com/show_bug.cgi?id=1876907 +Reviewed-by: Peter Krempa +Reviewed-by: Martin Kletzander +(cherry picked from commit 92b252456ee6d6ffc6e39e62ce1ce6c50113e00e) + +https://bugzilla.redhat.com/show_bug.cgi?id=1861176 + +Signed-off-by: Ján Tomko +Message-Id: <7d3c84f6556d0d46ada037d5e56c831babba609f.1601639064.git.jtomko@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/conf/domain_event.c | 2 +- + tests/vboxsnapshotxmltest.c | 3 ++- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c +index 33fbf10406..d3acde0236 100644 +--- a/src/conf/domain_event.c ++++ b/src/conf/domain_event.c +@@ -2194,7 +2194,7 @@ virDomainQemuMonitorEventCleanup(void *opaque) + virDomainQemuMonitorEventData *data = opaque; + + VIR_FREE(data->event); +- if (data->flags & VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX) ++ if (data->regex) + g_regex_unref(data->regex); + if (data->freecb) + (data->freecb)(data->opaque); +diff --git a/tests/vboxsnapshotxmltest.c b/tests/vboxsnapshotxmltest.c +index d1a7522931..8577157020 100644 +--- a/tests/vboxsnapshotxmltest.c ++++ b/tests/vboxsnapshotxmltest.c +@@ -134,7 +134,8 @@ mymain(void) + DO_TEST("2disks-3snap-brother"); + + cleanup: +- g_regex_unref(testSnapshotXMLVariableLineRegex); ++ if (testSnapshotXMLVariableLineRegex) ++ g_regex_unref(testSnapshotXMLVariableLineRegex); + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + } + +-- +2.28.0 + diff --git a/SOURCES/libvirt-node_device-detect-CSS-devices.patch b/SOURCES/libvirt-node_device-detect-CSS-devices.patch new file mode 100644 index 0000000..a25595a --- /dev/null +++ b/SOURCES/libvirt-node_device-detect-CSS-devices.patch @@ -0,0 +1,261 @@ +From 7604b24349c47ff008b1366eb19fc2959614fb71 Mon Sep 17 00:00:00 2001 +Message-Id: <7604b24349c47ff008b1366eb19fc2959614fb71@dist-git> +From: Boris Fiuczynski +Date: Thu, 8 Oct 2020 11:06:57 -0400 +Subject: [PATCH] node_device: detect CSS devices + +Make channel subsystem (CSS) devices available in the node_device driver. +The CCS devices reside in the computer system and provide CCW devices, e.g.: + + +- css_0_0_003a + | + +- ccw_0_0_1a2b + | + +- scsi_host0 + | + +- scsi_target0_0_0 + | + +- scsi_0_0_0_0 + +Reviewed-by: Erik Skultety +Reviewed-by: Bjoern Walk +Signed-off-by: Boris Fiuczynski +(cherry picked from commit 05e6cdafa6e083a1d83e1f2e34b6472c60cc67ac) +https://bugzilla.redhat.com/show_bug.cgi?id=1853289 +https://bugzilla.redhat.com/show_bug.cgi?id=1865932 +Message-Id: <20201008150700.52157-3-bfiuczyn@redhat.com> +Reviewed-by: Erik Skultety +--- + docs/schemas/nodedev.rng | 16 ++++++++++++++ + src/conf/node_device_conf.c | 5 +++++ + src/conf/node_device_conf.h | 1 + + src/conf/virnodedeviceobj.c | 1 + + src/node_device/node_device_udev.c | 22 +++++++++++++++++++ + .../ccw_0_0_10000-invalid.xml | 4 ++-- + tests/nodedevschemadata/ccw_0_0_ffff.xml | 4 ++-- + tests/nodedevschemadata/css_0_0_ffff.xml | 10 +++++++++ + tests/nodedevxml2xmltest.c | 1 + + tools/virsh-nodedev.c | 1 + + 10 files changed, 61 insertions(+), 4 deletions(-) + create mode 100644 tests/nodedevschemadata/css_0_0_ffff.xml + +diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng +index fe6ffa0b53..6ac5804bfb 100644 +--- a/docs/schemas/nodedev.rng ++++ b/docs/schemas/nodedev.rng +@@ -85,6 +85,7 @@ + + + ++ + + + +@@ -651,6 +652,21 @@ + + + ++ ++ ++ css ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 4cf5b6e3d7..0a34faa29a 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -65,6 +65,7 @@ VIR_ENUM_IMPL(virNodeDevCap, + "mdev_types", + "mdev", + "ccw", ++ "css", + ); + + VIR_ENUM_IMPL(virNodeDevNetCap, +@@ -588,6 +589,7 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) + data->mdev.iommuGroupNumber); + break; + case VIR_NODE_DEV_CAP_CCW_DEV: ++ case VIR_NODE_DEV_CAP_CSS_DEV: + virBufferAsprintf(&buf, "0x%x\n", + data->ccw_dev.cssid); + virBufferAsprintf(&buf, "0x%x\n", +@@ -1893,6 +1895,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, + ret = virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mdev); + break; + case VIR_NODE_DEV_CAP_CCW_DEV: ++ case VIR_NODE_DEV_CAP_CSS_DEV: + ret = virNodeDevCapCCWParseXML(ctxt, def, node, &caps->data.ccw_dev); + break; + case VIR_NODE_DEV_CAP_MDEV_TYPES: +@@ -2211,6 +2214,7 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_CCW_DEV: ++ case VIR_NODE_DEV_CAP_CSS_DEV: + case VIR_NODE_DEV_CAP_LAST: + /* This case is here to shutup the compiler */ + break; +@@ -2264,6 +2268,7 @@ virNodeDeviceUpdateCaps(virNodeDeviceDefPtr def) + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_CCW_DEV: ++ case VIR_NODE_DEV_CAP_CSS_DEV: + case VIR_NODE_DEV_CAP_LAST: + break; + } +diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h +index bf7939fbb3..19ea3fc7c2 100644 +--- a/src/conf/node_device_conf.h ++++ b/src/conf/node_device_conf.h +@@ -65,6 +65,7 @@ typedef enum { + VIR_NODE_DEV_CAP_MDEV_TYPES, /* Device capable of mediated devices */ + VIR_NODE_DEV_CAP_MDEV, /* Mediated device */ + VIR_NODE_DEV_CAP_CCW_DEV, /* s390 CCW device */ ++ VIR_NODE_DEV_CAP_CSS_DEV, /* s390 channel subsystem device */ + + VIR_NODE_DEV_CAP_LAST + } virNodeDevCapType; +diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c +index 3a34a324ca..8c8ffd6d24 100644 +--- a/src/conf/virnodedeviceobj.c ++++ b/src/conf/virnodedeviceobj.c +@@ -676,6 +676,7 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *obj, + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_CCW_DEV: ++ case VIR_NODE_DEV_CAP_CSS_DEV: + case VIR_NODE_DEV_CAP_LAST: + break; + } +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index 9667a042bd..efe3cebd6a 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1097,6 +1097,24 @@ udevProcessCCW(struct udev_device *device, + } + + ++static int ++udevProcessCSS(struct udev_device *device, ++ virNodeDeviceDefPtr def) ++{ ++ /* only process IO subchannel and vfio-ccw devices to keep the list sane */ ++ if (STRNEQ(def->driver, "io_subchannel") && ++ STRNEQ(def->driver, "vfio_ccw")) ++ return -1; ++ ++ if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) ++ return -1; ++ ++ if (udevGenerateDeviceName(device, def, NULL) != 0) ++ return -1; ++ ++ return 0; ++} ++ + static int + udevGetDeviceNodes(struct udev_device *device, + virNodeDeviceDefPtr def) +@@ -1175,6 +1193,8 @@ udevGetDeviceType(struct udev_device *device, + *type = VIR_NODE_DEV_CAP_MDEV; + else if (STREQ_NULLABLE(subsystem, "ccw")) + *type = VIR_NODE_DEV_CAP_CCW_DEV; ++ else if (STREQ_NULLABLE(subsystem, "css")) ++ *type = VIR_NODE_DEV_CAP_CSS_DEV; + + VIR_FREE(subsystem); + } +@@ -1219,6 +1239,8 @@ udevGetDeviceDetails(struct udev_device *device, + return udevProcessMediatedDevice(device, def); + case VIR_NODE_DEV_CAP_CCW_DEV: + return udevProcessCCW(device, def); ++ case VIR_NODE_DEV_CAP_CSS_DEV: ++ return udevProcessCSS(device, def); + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_FC_HOST: +diff --git a/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml b/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml +index d840555c09..f3cf0c1c66 100644 +--- a/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml ++++ b/tests/nodedevschemadata/ccw_0_0_10000-invalid.xml +@@ -1,7 +1,7 @@ + + ccw_0_0_10000 +- /sys/devices/css0/0.0.0000/0.0.10000 +- computer ++ /sys/devices/css0/0.0.0070/0.0.10000 ++ css_0_0_0070 + + 0x0 + 0x0 +diff --git a/tests/nodedevschemadata/ccw_0_0_ffff.xml b/tests/nodedevschemadata/ccw_0_0_ffff.xml +index 5ecd0b0aae..3b8ea46e37 100644 +--- a/tests/nodedevschemadata/ccw_0_0_ffff.xml ++++ b/tests/nodedevschemadata/ccw_0_0_ffff.xml +@@ -1,7 +1,7 @@ + + ccw_0_0_ffff +- /sys/devices/css0/0.0.0000/0.0.ffff +- computer ++ /sys/devices/css0/0.0.0070/0.0.ffff ++ css_0_0_0070 + + 0x0 + 0x0 +diff --git a/tests/nodedevschemadata/css_0_0_ffff.xml b/tests/nodedevschemadata/css_0_0_ffff.xml +new file mode 100644 +index 0000000000..312e07fe65 +--- /dev/null ++++ b/tests/nodedevschemadata/css_0_0_ffff.xml +@@ -0,0 +1,10 @@ ++ ++ css_0_0_ffff ++ /sys/devices/css0/0.0.ffff ++ computer ++ ++ 0x0 ++ 0x0 ++ 0xffff ++ ++ +diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c +index 6168c29c70..3cb23b1df4 100644 +--- a/tests/nodedevxml2xmltest.c ++++ b/tests/nodedevxml2xmltest.c +@@ -123,6 +123,7 @@ mymain(void) + DO_TEST("pci_0000_02_10_7_mdev_types"); + DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b"); + DO_TEST("ccw_0_0_ffff"); ++ DO_TEST("css_0_0_ffff"); + + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + } +diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c +index cb2fc26d1a..26b3acc608 100644 +--- a/tools/virsh-nodedev.c ++++ b/tools/virsh-nodedev.c +@@ -461,6 +461,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) + case VIR_NODE_DEV_CAP_CCW_DEV: + flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV; + break; ++ case VIR_NODE_DEV_CAP_CSS_DEV: + case VIR_NODE_DEV_CAP_LAST: + break; + } +-- +2.28.0 + diff --git a/SOURCES/libvirt-node_device-detect-DASD-devices.patch b/SOURCES/libvirt-node_device-detect-DASD-devices.patch new file mode 100644 index 0000000..626d59f --- /dev/null +++ b/SOURCES/libvirt-node_device-detect-DASD-devices.patch @@ -0,0 +1,76 @@ +From c83c1121508cc4283f372789398a909146803b72 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Boris Fiuczynski +Date: Thu, 8 Oct 2020 11:06:59 -0400 +Subject: [PATCH] node_device: detect DASD devices + +Make Direct Access Storage Devices (DASDs) available in the node_device driver. + +Reviewed-by: Bjoern Walk +Reviewed-by: Erik Skultety +Signed-off-by: Boris Fiuczynski +(cherry picked from commit 33bbf589dd739c48ff20d2120e8c4018d241d32f) +https://bugzilla.redhat.com/show_bug.cgi?id=1853289 +https://bugzilla.redhat.com/show_bug.cgi?id=1865932 +Message-Id: <20201008150700.52157-5-bfiuczyn@redhat.com> +Reviewed-by: Erik Skultety +--- + src/node_device/node_device_udev.c | 28 ++++++++++++++++++++++++++++ + 1 file changed, 28 insertions(+) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index efe3cebd6a..b6b28bc35a 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -870,6 +870,19 @@ udevProcessSD(struct udev_device *device, + } + + ++static int ++udevProcessDASD(struct udev_device *device, ++ virNodeDeviceDefPtr def) ++{ ++ virNodeDevCapStoragePtr storage = &def->caps->data.storage; ++ ++ if (udevGetStringSysfsAttr(device, "device/uid", &storage->serial) < 0) ++ return -1; ++ ++ return udevProcessDisk(device, def); ++} ++ ++ + /* This function exists to deal with the case in which a driver does + * not provide a device type in the usual place, but udev told us it's + * a storage device, and we can make a good guess at what kind of +@@ -890,6 +903,19 @@ udevKludgeStorageType(virNodeDeviceDefPtr def) + def->sysfs_path); + return 0; + } ++ ++ /* For Direct Access Storage Devices (DASDs) there are ++ * currently no identifiers in udev besides ID_PATH. Since ++ * ID_TYPE=disk does not exist on DASDs they fall through ++ * the udevProcessStorage detection logic. */ ++ if (STRPREFIX(def->caps->data.storage.block, "/dev/dasd")) { ++ def->caps->data.storage.drive_type = g_strdup("dasd"); ++ VIR_DEBUG("Found storage type '%s' for device " ++ "with sysfs path '%s'", ++ def->caps->data.storage.drive_type, ++ def->sysfs_path); ++ return 0; ++ } + VIR_DEBUG("Could not determine storage type " + "for device with sysfs path '%s'", def->sysfs_path); + return -1; +@@ -977,6 +1003,8 @@ udevProcessStorage(struct udev_device *device, + ret = udevProcessFloppy(device, def); + } else if (STREQ(def->caps->data.storage.drive_type, "sd")) { + ret = udevProcessSD(device, def); ++ } else if (STREQ(def->caps->data.storage.drive_type, "dasd")) { ++ ret = udevProcessDASD(device, def); + } else { + VIR_DEBUG("Unsupported storage type '%s'", + def->caps->data.storage.drive_type); +-- +2.28.0 + diff --git a/SOURCES/libvirt-node_device-refactor-udevProcessCCW.patch b/SOURCES/libvirt-node_device-refactor-udevProcessCCW.patch new file mode 100644 index 0000000..1b6621c --- /dev/null +++ b/SOURCES/libvirt-node_device-refactor-udevProcessCCW.patch @@ -0,0 +1,76 @@ +From a89df2d899e6e93ab7bccdaa1afb130d01d9b286 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Boris Fiuczynski +Date: Thu, 8 Oct 2020 11:06:56 -0400 +Subject: [PATCH] node_device: refactor udevProcessCCW + +Refactor out CCW address parsing for later reuse. + +Reviewed-by: Erik Skultety +Reviewed-by: Bjoern Walk +Signed-off-by: Boris Fiuczynski +(cherry picked from commit 0e7f8bb6c1c3a63cf892f7afcd34fcb979ef0155) +https://bugzilla.redhat.com/show_bug.cgi?id=1853289 +https://bugzilla.redhat.com/show_bug.cgi?id=1865932 +Message-Id: <20201008150700.52157-2-bfiuczyn@redhat.com> +Reviewed-by: Erik Skultety +--- + src/node_device/node_device_udev.c | 31 ++++++++++++++++++++---------- + 1 file changed, 21 insertions(+), 10 deletions(-) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index ae3d081e66..9667a042bd 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1058,27 +1058,38 @@ udevProcessMediatedDevice(struct udev_device *dev, + + + static int +-udevProcessCCW(struct udev_device *device, +- virNodeDeviceDefPtr def) ++udevGetCCWAddress(const char *sysfs_path, ++ virNodeDevCapDataPtr data) + { +- int online; + char *p; +- virNodeDevCapDataPtr data = &def->caps->data; +- +- /* process only online devices to keep the list sane */ +- if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1) +- return -1; + +- if ((p = strrchr(def->sysfs_path, '/')) == NULL || ++ if ((p = strrchr(sysfs_path, '/')) == NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.cssid) < 0 || p == NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.ssid) < 0 || p == NULL || + virStrToLong_ui(p + 1, &p, 16, &data->ccw_dev.devno) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse the CCW address from sysfs path: '%s'"), +- def->sysfs_path); ++ sysfs_path); + return -1; + } + ++ return 0; ++} ++ ++ ++static int ++udevProcessCCW(struct udev_device *device, ++ virNodeDeviceDefPtr def) ++{ ++ int online; ++ ++ /* process only online devices to keep the list sane */ ++ if (udevGetIntSysfsAttr(device, "online", &online, 0) < 0 || online != 1) ++ return -1; ++ ++ if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) ++ return -1; ++ + if (udevGenerateDeviceName(device, def, NULL) != 0) + return -1; + +-- +2.28.0 + diff --git a/SOURCES/libvirt-qemu-Fix-domfsinfo-for-non-PCI-device-information-from-guest-agent.patch b/SOURCES/libvirt-qemu-Fix-domfsinfo-for-non-PCI-device-information-from-guest-agent.patch new file mode 100644 index 0000000..d1f5cda --- /dev/null +++ b/SOURCES/libvirt-qemu-Fix-domfsinfo-for-non-PCI-device-information-from-guest-agent.patch @@ -0,0 +1,70 @@ +From c1605fba8512fc77f3e2e2bdbbca56e14a086893 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Thomas Huth +Date: Fri, 2 Oct 2020 12:32:11 +0200 +Subject: [PATCH] qemu: Fix domfsinfo for non-PCI device information from guest + agent +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +qemuAgentFSInfoToPublic() currently only sets the devAlias for PCI devices. +However, the QEMU guest agent could also provide the device name in the +"dev" field of the response for other devices instead (well, at least after +fixing another problem in the current QEMU guest agent...). So if creating +the devAlias from the PCI information failed, let's fall back to the name +provided by the guest agent. This helps to fix the empty "Target" fields +that occur when running "virsh domfsinfo" on s390x where CCW devices are +used for the guest instead of PCI devices. + +Also add a proper debug message here in case we completely failed to set the +device alias, since this problem here was very hard to debug: The only two +error messages that I've seen were "Unable to get filesystem information" +and "Unable to encode message payload" - which only indicates that something +went wrong in the RPC call. No debug message indicated the real problem, so +I had to learn the hard way why the RPC call failed (it apparently does not +like devAlias left to be NULL) and where the real problem comes from. + +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Thomas Huth +(cherry picked from commit f8333b3b0a7fdbc1f18ed501c043ac7618b86a16) +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1858771 +Message-Id: <20201002103211.250169-2-thuth@redhat.com> +Reviewed-by: Michal Privoznik +--- + src/qemu/qemu_driver.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 0f06974a1b..80a4a43e2e 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -21996,14 +21996,17 @@ qemuAgentFSInfoToPublic(qemuAgentFSInfoPtr agent, + qemuAgentDiskInfoPtr agentdisk = agent->disks[i]; + virDomainDiskDefPtr diskDef; + +- if (!(diskDef = virDomainDiskByAddress(vmdef, +- &agentdisk->pci_controller, +- agentdisk->bus, +- agentdisk->target, +- agentdisk->unit))) +- continue; +- +- ret->devAlias[i] = g_strdup(diskDef->dst); ++ diskDef = virDomainDiskByAddress(vmdef, ++ &agentdisk->pci_controller, ++ agentdisk->bus, ++ agentdisk->target, ++ agentdisk->unit); ++ if (diskDef != NULL) ++ ret->devAlias[i] = g_strdup(diskDef->dst); ++ else if (agentdisk->devnode != NULL) ++ ret->devAlias[i] = g_strdup(agentdisk->devnode); ++ else ++ VIR_DEBUG("Missing devnode name for '%s'.", ret->mountpoint); + } + + return ret; +-- +2.28.0 + diff --git a/SOURCES/libvirt-qemu-agent-set-ifname-to-NULL-after-freeing.patch b/SOURCES/libvirt-qemu-agent-set-ifname-to-NULL-after-freeing.patch new file mode 100644 index 0000000..4eabc76 --- /dev/null +++ b/SOURCES/libvirt-qemu-agent-set-ifname-to-NULL-after-freeing.patch @@ -0,0 +1,42 @@ +From 1b7381da7db7092bf774779a610f153532efa5d4 Mon Sep 17 00:00:00 2001 +Message-Id: <1b7381da7db7092bf774779a610f153532efa5d4@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 29 Sep 2020 14:43:06 +0200 +Subject: [PATCH] qemu: agent: set ifname to NULL after freeing +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +CVE-2020-25637 + +Signed-off-by: Ján Tomko +Reported-by: Ilja Van Sprundel +Fixes: 0977b8aa071de550e1a013d35e2c72615e65d520 +Reviewed-by: Mauro Matteo Cascella +(cherry picked from commit a63b48c5ecef077bf0f909a85f453a605600cf05) +Signed-off-by: Ján Tomko + +Conflicts: src/qemu/qemu_agent.c + Commit ee247e1d which switched virStringListFree + to g_strfreev is missing downstream. +Message-Id: <01acbf07b5b165b89cc73a127fe7bda666bdf235.1601383236.git.jtomko@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/qemu/qemu_agent.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c +index f13126aeee..968534b594 100644 +--- a/src/qemu/qemu_agent.c ++++ b/src/qemu/qemu_agent.c +@@ -2192,6 +2192,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon, + + /* Has to be freed for each interface. */ + virStringListFree(ifname); ++ ifname = NULL; + + /* as well as IP address which - moreover - + * can be presented multiple times */ +-- +2.28.0 + diff --git a/SOURCES/libvirt-qemu-substitute-missing-model-name-for-host-passthrough.patch b/SOURCES/libvirt-qemu-substitute-missing-model-name-for-host-passthrough.patch new file mode 100644 index 0000000..2bb13d9 --- /dev/null +++ b/SOURCES/libvirt-qemu-substitute-missing-model-name-for-host-passthrough.patch @@ -0,0 +1,58 @@ +From 961deedc28962b55c37430f974016aced31e1120 Mon Sep 17 00:00:00 2001 +Message-Id: <961deedc28962b55c37430f974016aced31e1120@dist-git> +From: Collin Walling +Date: Fri, 2 Oct 2020 10:13:11 +0200 +Subject: [PATCH] qemu: substitute missing model name for host-passthrough + +Before: + $ uname -m + s390x + $ cat passthrough-cpu.xml + + $ virsh hypervisor-cpu-compare passthrough-cpu.xml + error: Failed to compare hypervisor CPU with passthrough-cpu.xml + error: internal error: unable to execute QEMU command 'query-cpu-model-comp + arison': Invalid parameter type for 'modelb.name', expected: string + +After: + $ virsh hypervisor-cpu-compare passthrough-cpu.xml + CPU described in passthrough-cpu.xml is identical to the CPU provided by hy + pervisor on the host + +Signed-off-by: Tim Wiederhake +Signed-off-by: Collin Walling +Reviewed-by: Jiri Denemark +(cherry picked from commit 9c6996124f4ef1635fbfe47090dadaf5a12b42e9) + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1850680 + +Signed-off-by: Tim Wiederhake +Message-Id: <20201002081311.449901-2-twiederh@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/qemu/qemu_driver.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index b5df0c63d4..f8a259e020 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -13539,6 +13539,15 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn, + if (virCPUDefParseXMLString(xmlCPU, VIR_CPU_TYPE_AUTO, &cpu) < 0) + goto cleanup; + ++ if (!cpu->model) { ++ if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) { ++ cpu->model = g_strdup("host"); ++ } else { ++ virReportError(VIR_ERR_INVALID_ARG, "%s", ++ _("cpu parameter is missing a model name")); ++ goto cleanup; ++ } ++ } + ret = qemuConnectCPUModelComparison(qemuCaps, cfg->libDir, + cfg->user, cfg->group, + hvCPU, cpu, failIncompatible); +-- +2.28.0 + diff --git a/SOURCES/libvirt-qemuFirmwareFillDomain-Fill-NVRAM-template-on-migration-too.patch b/SOURCES/libvirt-qemuFirmwareFillDomain-Fill-NVRAM-template-on-migration-too.patch new file mode 100644 index 0000000..51fabce --- /dev/null +++ b/SOURCES/libvirt-qemuFirmwareFillDomain-Fill-NVRAM-template-on-migration-too.patch @@ -0,0 +1,69 @@ +From 1824bb0b44b47af95f50afd626776acfba91174d Mon Sep 17 00:00:00 2001 +Message-Id: <1824bb0b44b47af95f50afd626776acfba91174d@dist-git> +From: Michal Privoznik +Date: Wed, 7 Oct 2020 13:20:04 +0200 +Subject: [PATCH] qemuFirmwareFillDomain: Fill NVRAM template on migration too + +In 8e1804f9f66 I've tried to fix the following use case: domain +is started with path to UEFI only and relies on libvirt to figure +out corresponding NVRAM template to create a per-domain copy +from. The fix consisted of having a check tailored exactly for +this use case and if it's hit then using FW autoselection to +figure it out. Unfortunately, the NVRAM template is not saved in +the inactive XML (well, the domain might be transient anyway). +Then, as a part of that check we see whether the per-domain copy +doesn't exist already and if it does then no template is looked +up hence no template will appear in the live XML. + +This works, until the domain is migrated. At the destination, the +per-domain copy will not exist so we need to know the template to +create the per-domain copy from. But we don't even get to the +check because we are not starting a fresh new domain and thus the +qemuFirmwareFillDomain() function quits early. + +The solution is to switch order of these two checks. That is +evaluate the check for the old style before checking flags. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1852910 +Signed-off-by: Michal Privoznik +Reviewed-by: Andrea Bolognani +(cherry picked from commit c43622f06e295edcb9cedf33583f0bd18fb04b10) + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1880418 + +Signed-off-by: Michal Privoznik +Message-Id: <9b91110a238eba22f4b876e7b15a25d5113ee91e.1602069592.git.mprivozn@redhat.com> +Reviewed-by: Andrea Bolognani +--- + src/qemu/qemu_firmware.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c +index 68e2c6b40f..c84d03f0a8 100644 +--- a/src/qemu/qemu_firmware.c ++++ b/src/qemu/qemu_firmware.c +@@ -1241,9 +1241,6 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, + size_t i; + int ret = -1; + +- if (!(flags & VIR_QEMU_PROCESS_START_NEW)) +- return 0; +- + /* Fill in FW paths if either os.firmware is enabled, or + * loader path was provided with no nvram varstore. */ + if (def->os.firmware == VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) { +@@ -1259,6 +1256,11 @@ qemuFirmwareFillDomain(virQEMUDriverPtr driver, + /* ... then we want to consult JSON FW descriptors first, + * but we don't want to fail if we haven't found a match. */ + needResult = false; ++ } else { ++ /* Domain has FW autoselection enabled => do nothing if ++ * we are not starting it from scratch. */ ++ if (!(flags & VIR_QEMU_PROCESS_START_NEW)) ++ return 0; + } + + if ((nfirmwares = qemuFirmwareFetchParsedConfigs(driver->privileged, +-- +2.28.0 + diff --git a/SOURCES/libvirt-rpc-add-support-for-filtering-acls-by-uint-params.patch b/SOURCES/libvirt-rpc-add-support-for-filtering-acls-by-uint-params.patch new file mode 100644 index 0000000..78f2dcc --- /dev/null +++ b/SOURCES/libvirt-rpc-add-support-for-filtering-acls-by-uint-params.patch @@ -0,0 +1,104 @@ +From ea90c1e23120e8bde86d22d83d179bc393bc2daa Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 29 Sep 2020 14:43:04 +0200 +Subject: [PATCH] rpc: add support for filtering @acls by uint params +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +CVE-2020-25637 + +Add a new field to @acl annotations for filtering by +unsigned int parameters. + +Signed-off-by: Ján Tomko +(cherry picked from commit 50864dcda191eb35732dbd80fb6ca251a6bba923) +Signed-off-by: Ján Tomko +Message-Id: <7900a5f9e8479789a5cc427a85f385095e517e87.1601383236.git.jtomko@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/remote/remote_protocol.x | 3 +++ + src/rpc/gendispatch.pl | 21 ++++++++++++++++++++- + 2 files changed, 23 insertions(+), 1 deletion(-) + +diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x +index 79cdb13a90..2527a78142 100644 +--- a/src/remote/remote_protocol.x ++++ b/src/remote/remote_protocol.x +@@ -3805,6 +3805,7 @@ enum remote_procedure { + * + * - @acl: : + * - @acl: :: ++ * - @acl: :::: + * + * Declare the access control requirements for the API. May be repeated + * multiple times, if multiple rules are required. +@@ -3814,6 +3815,8 @@ enum remote_procedure { + * is one of the permissions in access/viraccessperm.h + * indicates the rule only applies if the named flag + * is set in the API call ++ * and can be used to check an unsigned int parameter ++ * against value + * + * - @aclfilter: : + * +diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl +index 4cb9701e59..6a4f8074ad 100755 +--- a/src/rpc/gendispatch.pl ++++ b/src/rpc/gendispatch.pl +@@ -2104,10 +2104,12 @@ elsif ($mode eq "client") { + my @acl; + foreach (@{$acl}) { + my @bits = split /:/; +- push @acl, { object => $bits[0], perm => $bits[1], flags => $bits[2] } ++ push @acl, { object => $bits[0], perm => $bits[1], flags => $bits[2], ++ param => $bits[3], value => $bits[4] } + } + + my $checkflags = 0; ++ my $paramtocheck = undef; + for (my $i = 1 ; $i <= $#acl ; $i++) { + if ($acl[$i]->{object} ne $acl[0]->{object}) { + die "acl for '$call->{ProcName}' cannot check different objects"; +@@ -2115,6 +2117,9 @@ elsif ($mode eq "client") { + if (defined $acl[$i]->{flags} && length $acl[$i]->{flags}) { + $checkflags = 1; + } ++ if (defined $acl[$i]->{param}) { ++ $paramtocheck = $acl[$i]->{param}; ++ } + } + + my $apiname = $prefix . $call->{ProcName}; +@@ -2150,6 +2155,9 @@ elsif ($mode eq "client") { + if ($checkflags) { + push @argdecls, "unsigned int flags"; + } ++ if (defined $paramtocheck) { ++ push @argdecls, "unsigned int " . $paramtocheck; ++ } + + my $ret; + my $pass; +@@ -2210,6 +2218,17 @@ elsif ($mode eq "client") { + } + print " "; + } ++ if (defined $acl->{param}) { ++ my $param = $acl->{param}; ++ my $value = $acl->{value}; ++ if ($value =~ /^\!/) { ++ $value = substr $value, 1; ++ print "($param != ($value)) &&\n"; ++ } else { ++ print "($param == ($value)) &&\n"; ++ } ++ print " "; ++ } + print "(rv = $method(" . join(", ", @argvars, $perm) . ")) <= 0) {\n"; + print " virObjectUnref(mgr);\n"; + if ($action eq "Ensure") { +-- +2.28.0 + diff --git a/SOURCES/libvirt-rpc-gendispatch-handle-empty-flags.patch b/SOURCES/libvirt-rpc-gendispatch-handle-empty-flags.patch new file mode 100644 index 0000000..f279dc2 --- /dev/null +++ b/SOURCES/libvirt-rpc-gendispatch-handle-empty-flags.patch @@ -0,0 +1,51 @@ +From fa5b4100c32d3125eeb0d6b0024892af86ecddb0 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 29 Sep 2020 14:43:03 +0200 +Subject: [PATCH] rpc: gendispatch: handle empty flags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +CVE-2020-25637 + +Prepare for omission of the in remote_protocol.x +@acl annotations: + @acl: :: +so that we can add more fields after, e.g.: + @acl: ::: + +Signed-off-by: Ján Tomko +(cherry picked from commit 955029bd0ad7ef96000f529ac38204a8f4a96401) +Signed-off-by: Ján Tomko +Message-Id: <5fda9fc6cfe45eace10b8c2565a8b0c46b51f46c.1601383236.git.jtomko@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/rpc/gendispatch.pl | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl +index 8656c8f205..4cb9701e59 100755 +--- a/src/rpc/gendispatch.pl ++++ b/src/rpc/gendispatch.pl +@@ -2112,7 +2112,7 @@ elsif ($mode eq "client") { + if ($acl[$i]->{object} ne $acl[0]->{object}) { + die "acl for '$call->{ProcName}' cannot check different objects"; + } +- if (defined $acl[$i]->{flags}) { ++ if (defined $acl[$i]->{flags} && length $acl[$i]->{flags}) { + $checkflags = 1; + } + } +@@ -2200,7 +2200,7 @@ elsif ($mode eq "client") { + my $method = "virAccessManagerCheck" . $object; + my $space = ' ' x length($method); + print " if ("; +- if (defined $acl->{flags}) { ++ if (defined $acl->{flags} && length $acl->{flags}) { + my $flags = $acl->{flags}; + if ($flags =~ /^\!/) { + $flags = substr $flags, 1; +-- +2.28.0 + diff --git a/SOURCES/libvirt-rpc-require-write-acl-for-guest-agent-in-virDomainInterfaceAddresses.patch b/SOURCES/libvirt-rpc-require-write-acl-for-guest-agent-in-virDomainInterfaceAddresses.patch new file mode 100644 index 0000000..fdc0d5e --- /dev/null +++ b/SOURCES/libvirt-rpc-require-write-acl-for-guest-agent-in-virDomainInterfaceAddresses.patch @@ -0,0 +1,72 @@ +From 48f74599ffc86aa632ee39aff1aa8459880ec283 Mon Sep 17 00:00:00 2001 +Message-Id: <48f74599ffc86aa632ee39aff1aa8459880ec283@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 29 Sep 2020 14:43:05 +0200 +Subject: [PATCH] rpc: require write acl for guest agent in + virDomainInterfaceAddresses +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +CVE-2020-25637 + +Add a requirement for domain:write if source is set to +VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT. + +Signed-off-by: Ján Tomko +Reported-by: Ilja Van Sprundel +(cherry picked from commit e4116eaa44cb366b59f7fe98f4b88d04c04970ad) +Signed-off-by: Ján Tomko + +Conflicts: src/lxc/lxc_driver.c + The LXC implementation of the API was introduced + in libvirt 6.1.0, so it's not present downstream. +Message-Id: <5fdc2ebf7621698c8136b354922c687fc09286de.1601383236.git.jtomko@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/libxl/libxl_driver.c | 2 +- + src/qemu/qemu_driver.c | 2 +- + src/remote/remote_protocol.x | 1 + + 3 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c +index f021ec9c5d..1449795494 100644 +--- a/src/libxl/libxl_driver.c ++++ b/src/libxl/libxl_driver.c +@@ -6318,7 +6318,7 @@ libxlDomainInterfaceAddresses(virDomainPtr dom, + if (!(vm = libxlDomObjFromDomain(dom))) + goto cleanup; + +- if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) ++ if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def, source) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index f8a259e020..0f06974a1b 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -22240,7 +22240,7 @@ qemuDomainInterfaceAddresses(virDomainPtr dom, + if (!(vm = qemuDomainObjFromDomain(dom))) + goto cleanup; + +- if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def) < 0) ++ if (virDomainInterfaceAddressesEnsureACL(dom->conn, vm->def, source) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) +diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x +index 2527a78142..fbd30085b2 100644 +--- a/src/remote/remote_protocol.x ++++ b/src/remote/remote_protocol.x +@@ -6211,6 +6211,7 @@ enum remote_procedure { + /** + * @generate: none + * @acl: domain:read ++ * @acl: domain:write::source:VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT + */ + REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES = 353, + +-- +2.28.0 + diff --git a/SOURCES/libvirt-udevProcessCSS-Check-if-def-driver-is-non-NULL.patch b/SOURCES/libvirt-udevProcessCSS-Check-if-def-driver-is-non-NULL.patch new file mode 100644 index 0000000..82ec9ba --- /dev/null +++ b/SOURCES/libvirt-udevProcessCSS-Check-if-def-driver-is-non-NULL.patch @@ -0,0 +1,69 @@ +From 32957eca8129f926d205310ee7efbc1168e8ebdc Mon Sep 17 00:00:00 2001 +Message-Id: <32957eca8129f926d205310ee7efbc1168e8ebdc@dist-git> +From: Marc Hartmayer +Date: Thu, 8 Oct 2020 11:07:00 -0400 +Subject: [PATCH] udevProcessCSS: Check if def->driver is non-NULL + +Don't process subchannel devices where `def->driver` is not set. This +fixes the following segfault: + +Thread 21 "nodedev-init" received signal SIGSEGV, Segmentation fault. +[Switching to Thread 0x3ffb08fc910 (LWP 64303)] +(gdb) bt + #0 0x000003fffd1272b4 in __strcmp_vx () at /lib64/libc.so.6 + #1 0x000003ffc260c3a8 in udevProcessCSS (device=0x3ff9018d130, def=0x3ff90194a90) + #2 0x000003ffc260cb78 in udevGetDeviceDetails (device=0x3ff9018d130, def=0x3ff90194a90) + #3 0x000003ffc260d126 in udevAddOneDevice (device=0x3ff9018d130) + #4 0x000003ffc260d414 in udevProcessDeviceListEntry (udev=0x3ffa810d800, list_entry=0x3ff90001990) + #5 0x000003ffc260d638 in udevEnumerateDevices (udev=0x3ffa810d800) + #6 0x000003ffc260e08e in nodeStateInitializeEnumerate (opaque=0x3ffa810d800) + #7 0x000003fffdaa14b6 in virThreadHelper (data=0x3ffa810df00) + #8 0x000003fffc309ed6 in start_thread () + #9 0x000003fffd185e66 in thread_start () +(gdb) p *def +$2 = { + name = 0x0, + sysfs_path = 0x3ff90198e80 "/sys/devices/css0/0.0.ff40", + parent = 0x0, + parent_sysfs_path = 0x0, + parent_wwnn = 0x0, + parent_wwpn = 0x0, + parent_fabric_wwn = 0x0, + driver = 0x0, + devnode = 0x0, + devlinks = 0x3ff90194670, + caps = 0x3ff90194380 +} + +Fixes: 05e6cdafa6e0 ("node_device: detect CSS devices") +Reviewed-by: Boris Fiuczynski +Reviewed-by: Erik Skultety +Signed-off-by: Marc Hartmayer +(cherry picked from commit cb09344a2cccc0cc9bcefa3cb53d7af45ba92631) +https://bugzilla.redhat.com/show_bug.cgi?id=1853289 +https://bugzilla.redhat.com/show_bug.cgi?id=1865932 +Message-Id: <20201008150700.52157-6-bfiuczyn@redhat.com> +Reviewed-by: Erik Skultety +--- + src/node_device/node_device_udev.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index b6b28bc35a..88cf1edf50 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1130,8 +1130,9 @@ udevProcessCSS(struct udev_device *device, + virNodeDeviceDefPtr def) + { + /* only process IO subchannel and vfio-ccw devices to keep the list sane */ +- if (STRNEQ(def->driver, "io_subchannel") && +- STRNEQ(def->driver, "vfio_ccw")) ++ if (!def->driver || ++ (STRNEQ(def->driver, "io_subchannel") && ++ STRNEQ(def->driver, "vfio_ccw"))) + return -1; + + if (udevGetCCWAddress(def->sysfs_path, &def->caps->data) < 0) +-- +2.28.0 + diff --git a/SOURCES/libvirt-virDomainNetFindIdx-add-support-for-CCW-addresses.patch b/SOURCES/libvirt-virDomainNetFindIdx-add-support-for-CCW-addresses.patch new file mode 100644 index 0000000..44beadb --- /dev/null +++ b/SOURCES/libvirt-virDomainNetFindIdx-add-support-for-CCW-addresses.patch @@ -0,0 +1,138 @@ +From 606da680fb4c7ee0f8a7ecc76057592433ea6ac9 Mon Sep 17 00:00:00 2001 +Message-Id: <606da680fb4c7ee0f8a7ecc76057592433ea6ac9@dist-git> +From: Cornelia Huck +Date: Fri, 2 Oct 2020 13:39:12 +0200 +Subject: [PATCH] virDomainNetFindIdx: add support for CCW addresses +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Allow to match with CCW addresses in addition to PCI addresses +(and MAC addresses). + +Signed-off-by: Cornelia Huck +Reviewed-by: Ján Tomko +Signed-off-by: Ján Tomko +(cherry picked from commit 2fefbd03ab09f32b1b15d093096fa44870817751) + +https://bugzilla.redhat.com/show_bug.cgi?id=1837495 + +Signed-off-by: Ján Tomko +Message-Id: +Acked-by: Cornelia Huck +--- + src/conf/device_conf.c | 12 ++++++++++++ + src/conf/device_conf.h | 3 +++ + src/conf/domain_conf.c | 23 ++++++++++++++++++++++- + src/libvirt_private.syms | 1 + + 4 files changed, 38 insertions(+), 1 deletion(-) + +diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c +index 4dbd5c1ac9..9e96d08394 100644 +--- a/src/conf/device_conf.c ++++ b/src/conf/device_conf.c +@@ -370,6 +370,18 @@ virDomainDeviceCCWAddressParseXML(xmlNodePtr node, + return ret; + } + ++bool ++virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddressPtr addr1, ++ virDomainDeviceCCWAddressPtr addr2) ++{ ++ if (addr1->cssid == addr2->cssid && ++ addr1->ssid == addr2->ssid && ++ addr1->devno == addr2->devno) { ++ return true; ++ } ++ return false; ++} ++ + int + virDomainDeviceDriveAddressParseXML(xmlNodePtr node, + virDomainDeviceDriveAddressPtr addr) +diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h +index e091d7cfe2..7a8227e743 100644 +--- a/src/conf/device_conf.h ++++ b/src/conf/device_conf.h +@@ -208,6 +208,9 @@ void virPCIDeviceAddressFormat(virBufferPtr buf, + bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddressPtr addr); + int virDomainDeviceCCWAddressParseXML(xmlNodePtr node, + virDomainDeviceCCWAddressPtr addr); ++bool virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddressPtr addr1, ++ virDomainDeviceCCWAddressPtr addr2); ++#define VIR_CCW_DEVICE_ADDRESS_FMT "%x.%x.%04x" + + int virDomainDeviceDriveAddressParseXML(xmlNodePtr node, + virDomainDeviceDriveAddressPtr addr); +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 60962ee7c1..306926b64c 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -17385,6 +17385,8 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) + bool MACAddrSpecified = !net->mac_generated; + bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI); ++ bool CCWAddrSpecified = virDomainDeviceAddressIsValid(&net->info, ++ VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW); + + for (i = 0; i < def->nnets; i++) { + if (MACAddrSpecified && +@@ -17396,9 +17398,14 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) + &net->info.addr.pci)) + continue; + ++ if (CCWAddrSpecified && ++ !virDomainDeviceCCWAddressEqual(&def->nets[i]->info.addr.ccw, ++ &net->info.addr.ccw)) ++ continue; ++ + if (matchidx >= 0) { + /* there were multiple matches on mac address, and no +- * qualifying guest-side PCI address was given, so we must ++ * qualifying guest-side PCI/CCW address was given, so we must + * fail (NB: a USB address isn't adequate, since it may + * specify only vendor and product ID, and there may be + * multiples of those. +@@ -17428,6 +17435,14 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) + net->info.addr.pci.bus, + net->info.addr.pci.slot, + net->info.addr.pci.function); ++ } else if (MACAddrSpecified && CCWAddrSpecified) { ++ virReportError(VIR_ERR_DEVICE_MISSING, ++ _("no device matching MAC address %s found on " ++ VIR_CCW_DEVICE_ADDRESS_FMT), ++ virMacAddrFormat(&net->mac, mac), ++ net->info.addr.ccw.cssid, ++ net->info.addr.ccw.ssid, ++ net->info.addr.ccw.devno); + } else if (PCIAddrSpecified) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("no device found on " VIR_PCI_DEVICE_ADDRESS_FMT), +@@ -17435,6 +17450,12 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) + net->info.addr.pci.bus, + net->info.addr.pci.slot, + net->info.addr.pci.function); ++ } else if (CCWAddrSpecified) { ++ virReportError(VIR_ERR_DEVICE_MISSING, ++ _("no device found on " VIR_CCW_DEVICE_ADDRESS_FMT), ++ net->info.addr.ccw.cssid, ++ net->info.addr.ccw.ssid, ++ net->info.addr.ccw.devno); + } else if (MACAddrSpecified) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("no device matching MAC address %s found"), +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 9e290c7bdf..130828706a 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -128,6 +128,7 @@ virDeviceInfoPCIAddressIsWanted; + virDomainDeviceAddressIsValid; + virDomainDeviceAddressTypeToString; + virDomainDeviceCcidAddressParseXML; ++virDomainDeviceCCWAddressEqual; + virDomainDeviceCCWAddressIsValid; + virDomainDeviceCCWAddressParseXML; + virDomainDeviceDriveAddressParseXML; +-- +2.28.0 + diff --git a/SOURCES/libvirt-virhostcpu.c-fix-die_id-parsing-for-Power-hosts.patch b/SOURCES/libvirt-virhostcpu.c-fix-die_id-parsing-for-Power-hosts.patch new file mode 100644 index 0000000..2257052 --- /dev/null +++ b/SOURCES/libvirt-virhostcpu.c-fix-die_id-parsing-for-Power-hosts.patch @@ -0,0 +1,94 @@ +From b5aa3a33bc770714f8a68954c05ea362fcfd4d47 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Daniel Henrique Barboza +Date: Mon, 5 Oct 2020 10:25:30 -0400 +Subject: [PATCH] virhostcpu.c: fix 'die_id' parsing for Power hosts + +Commit 7b79ee2f78 makes assumptions about die_id parsing in +the sysfs that aren't true for Power hosts. In both Power8 +and Power9, running 5.6 and 4.18 kernel respectively, +'die_id' is set to -1: + +$ cat /sys/devices/system/cpu/cpu0/topology/die_id +-1 + +This breaks virHostCPUGetDie() parsing because it is trying to +retrieve an unsigned integer, causing problems during VM start: + +virFileReadValueUint:4128 : internal error: Invalid unsigned integer +value '-1' in file '/sys/devices/system/cpu/cpu0/topology/die_id' + +This isn't necessarily a PowerPC only behavior. Linux kernel commit +0e344d8c70 added in the former Documentation/cputopology.txt, now +Documentation/admin-guide/cputopology.rst, that: + + To be consistent on all architectures, include/linux/topology.h + provides default definitions for any of the above macros that are + not defined by include/asm-XXX/topology.h: + + 1) topology_physical_package_id: -1 + 2) topology_die_id: -1 + (...) + +This means that it might be expected that an architecture that +does not implement the die_id element will mark it as -1 in +sysfs. + +It is not required to change die_id implementation from uInt to +Int because of that. Instead, let's change the parsing of the +die_id in virHostCPUGetDie() to read an integer value and, in +case it's -1, default it to zero like in case of file not found. +This is enough to solve the issue Power hosts are experiencing. + +Fixes: 7b79ee2f78bbf2af76df2f6466919e19ae05aeeb +Signed-off-by: Daniel Henrique Barboza +Reviewed-by: Michal Privoznik +(cherry picked from commit 0137bf0dab2738d5443e2f407239856e2aa25bb3) + +https://bugzilla.redhat.com/show_bug.cgi?id=1876742 + +Signed-off-by: Daniel Henrique Barboza +Message-Id: <20201005142530.3961036-1-dbarboza@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/util/virhostcpu.c | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c +index 09c959cd25..218272d7ec 100644 +--- a/src/util/virhostcpu.c ++++ b/src/util/virhostcpu.c +@@ -221,16 +221,23 @@ virHostCPUGetSocket(unsigned int cpu, unsigned int *socket) + int + virHostCPUGetDie(unsigned int cpu, unsigned int *die) + { +- int ret = virFileReadValueUint(die, +- "%s/cpu/cpu%u/topology/die_id", +- SYSFS_SYSTEM_PATH, cpu); ++ int die_id; ++ int ret = virFileReadValueInt(&die_id, ++ "%s/cpu/cpu%u/topology/die_id", ++ SYSFS_SYSTEM_PATH, cpu); + +- /* If the file is not there, it's 0 */ +- if (ret == -2) +- *die = 0; +- else if (ret < 0) ++ if (ret == -1) + return -1; + ++ /* If the file is not there, it's 0. ++ * Another alternative is die_id set to -1, meaning that ++ * the arch does not have die_id support. Set @die to ++ * 0 in this case too. */ ++ if (ret == -2 || die_id < 0) ++ *die = 0; ++ else ++ *die = die_id; ++ + return 0; + } + +-- +2.28.0 + diff --git a/SOURCES/libvirt-virsh-nodedev-ability-to-filter-CSS-capabilities.patch b/SOURCES/libvirt-virsh-nodedev-ability-to-filter-CSS-capabilities.patch new file mode 100644 index 0000000..ec533f6 --- /dev/null +++ b/SOURCES/libvirt-virsh-nodedev-ability-to-filter-CSS-capabilities.patch @@ -0,0 +1,130 @@ +From 09ce043fb64e92147992898ccdfc9a6c31c6051e Mon Sep 17 00:00:00 2001 +Message-Id: <09ce043fb64e92147992898ccdfc9a6c31c6051e@dist-git> +From: Boris Fiuczynski +Date: Thu, 8 Oct 2020 11:06:58 -0400 +Subject: [PATCH] virsh: nodedev: ability to filter CSS capabilities + +Allow to filter for CSS devices. + +Reviewed-by: Bjoern Walk +Reviewed-by: Erik Skultety +Signed-off-by: Boris Fiuczynski +(cherry picked from commit ab655afa186a81ddfd247d2c187c160dd05740e5) +https://bugzilla.redhat.com/show_bug.cgi?id=1853289 +https://bugzilla.redhat.com/show_bug.cgi?id=1865932 +Message-Id: <20201008150700.52157-4-bfiuczyn@redhat.com> +Reviewed-by: Erik Skultety +--- + docs/formatnode.html.in | 12 ++++++++++++ + docs/manpages/virsh.rst | 2 +- + include/libvirt/libvirt-nodedev.h | 1 + + src/conf/node_device_conf.h | 3 ++- + src/conf/virnodedeviceobj.c | 3 ++- + src/libvirt-nodedev.c | 1 + + tools/virsh-nodedev.c | 2 ++ + 7 files changed, 21 insertions(+), 3 deletions(-) + +diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in +index c2a8f8fb7a..0e9658fd29 100644 +--- a/docs/formatnode.html.in ++++ b/docs/formatnode.html.in +@@ -341,6 +341,18 @@ +
The device number.
+ + ++
css
++
Describes a Channel SubSystem (CSS) device commonly found on ++ the S390 architecture. Sub-elements include: ++
++
cssid
++
The channel subsystem identifier.
++
ssid
++
The subchannel-set identifier.
++
devno
++
The device number.
++
++
+ + + +diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst +index c637caa583..0804465d44 100644 +--- a/docs/manpages/virsh.rst ++++ b/docs/manpages/virsh.rst +@@ -4886,7 +4886,7 @@ List all of the devices available on the node that are known by libvirt. + separated by comma, e.g. --cap pci,scsi. Valid capability types include + 'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target', + 'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev', +-'mdev_types', 'ccw'. ++'mdev_types', 'ccw', 'css'. + If *--tree* is used, the output is formatted in a tree representing parents of each + node. *cap* and *--tree* are mutually exclusive. + +diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h +index a2ad61ac6d..dd2ffd5782 100644 +--- a/include/libvirt/libvirt-nodedev.h ++++ b/include/libvirt/libvirt-nodedev.h +@@ -81,6 +81,7 @@ typedef enum { + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES = 1 << 13, /* Capable of mediated devices */ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV = 1 << 14, /* Mediated device */ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV = 1 << 15, /* CCW device */ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV = 1 << 16, /* CSS device */ + } virConnectListAllNodeDeviceFlags; + + int virConnectListAllNodeDevices (virConnectPtr conn, +diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h +index 19ea3fc7c2..6fe51ed04c 100644 +--- a/src/conf/node_device_conf.h ++++ b/src/conf/node_device_conf.h +@@ -364,7 +364,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); + VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV | \ +- VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV) ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV | \ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV) + + int + virNodeDeviceGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host); +diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c +index 8c8ffd6d24..a27a84355a 100644 +--- a/src/conf/virnodedeviceobj.c ++++ b/src/conf/virnodedeviceobj.c +@@ -827,7 +827,8 @@ virNodeDeviceObjMatch(virNodeDeviceObjPtr obj, + MATCH(DRM) || + MATCH(MDEV_TYPES) || + MATCH(MDEV) || +- MATCH(CCW_DEV))) ++ MATCH(CCW_DEV) || ++ MATCH(CSS_DEV))) + return false; + } + +diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c +index dce46b7181..71d81f6278 100644 +--- a/src/libvirt-nodedev.c ++++ b/src/libvirt-nodedev.c +@@ -101,6 +101,7 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV ++ * VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV + * + * Returns the number of node devices found or -1 and sets @devices to NULL in + * case of error. On success, the array stored into @devices is guaranteed to +diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c +index 26b3acc608..f4e402c35d 100644 +--- a/tools/virsh-nodedev.c ++++ b/tools/virsh-nodedev.c +@@ -462,6 +462,8 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) + flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CCW_DEV; + break; + case VIR_NODE_DEV_CAP_CSS_DEV: ++ flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_CSS_DEV; ++ break; + case VIR_NODE_DEV_CAP_LAST: + break; + } +-- +2.28.0 + diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index f221a1b..33d7e2b 100644 --- a/SPECS/libvirt.spec +++ b/SPECS/libvirt.spec @@ -219,7 +219,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 6.0.0 -Release: 28%{?dist}%{?extra_release} +Release: 29%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -669,6 +669,21 @@ Patch437: libvirt-virDevMapperGetTargets-Don-t-ignore-EBADF.patch Patch438: libvirt-virdevmapper-Don-t-cache-device-mapper-major.patch Patch439: libvirt-virdevmapper-Handle-kernel-without-device-mapper-support.patch Patch440: libvirt-virdevmapper-Ignore-all-errors-when-opening-dev-mapper-control.patch +Patch441: libvirt-qemu-substitute-missing-model-name-for-host-passthrough.patch +Patch442: libvirt-rpc-gendispatch-handle-empty-flags.patch +Patch443: libvirt-rpc-add-support-for-filtering-acls-by-uint-params.patch +Patch444: libvirt-rpc-require-write-acl-for-guest-agent-in-virDomainInterfaceAddresses.patch +Patch445: libvirt-qemu-agent-set-ifname-to-NULL-after-freeing.patch +Patch446: libvirt-qemu-Fix-domfsinfo-for-non-PCI-device-information-from-guest-agent.patch +Patch447: libvirt-virDomainNetFindIdx-add-support-for-CCW-addresses.patch +Patch448: libvirt-check-for-NULL-before-calling-g_regex_unref.patch +Patch449: libvirt-virhostcpu.c-fix-die_id-parsing-for-Power-hosts.patch +Patch450: libvirt-qemuFirmwareFillDomain-Fill-NVRAM-template-on-migration-too.patch +Patch451: libvirt-node_device-refactor-udevProcessCCW.patch +Patch452: libvirt-node_device-detect-CSS-devices.patch +Patch453: libvirt-virsh-nodedev-ability-to-filter-CSS-capabilities.patch +Patch454: libvirt-node_device-detect-DASD-devices.patch +Patch455: libvirt-udevProcessCSS-Check-if-def-driver-is-non-NULL.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2445,6 +2460,23 @@ exit 0 %changelog +* Fri Oct 9 2020 Jiri Denemark - 6.0.0-29 +- qemu: substitute missing model name for host-passthrough (rhbz#1850680) +- rpc: gendispatch: handle empty flags (CVE-2020-25637) +- rpc: add support for filtering @acls by uint params (CVE-2020-25637) +- rpc: require write acl for guest agent in virDomainInterfaceAddresses (CVE-2020-25637) +- qemu: agent: set ifname to NULL after freeing (CVE-2020-25637) +- qemu: Fix domfsinfo for non-PCI device information from guest agent (rhbz#1858771) +- virDomainNetFindIdx: add support for CCW addresses (rhbz#1837495) +- check for NULL before calling g_regex_unref (rhbz#1861176) +- virhostcpu.c: fix 'die_id' parsing for Power hosts (rhbz#1876742) +- qemuFirmwareFillDomain: Fill NVRAM template on migration too (rhbz#1880418) +- node_device: refactor udevProcessCCW (rhbz#1853289, rhbz#1865932) +- node_device: detect CSS devices (rhbz#1853289, rhbz#1865932) +- virsh: nodedev: ability to filter CSS capabilities (rhbz#1853289, rhbz#1865932) +- node_device: detect DASD devices (rhbz#1853289, rhbz#1865932) +- udevProcessCSS: Check if def->driver is non-NULL (rhbz#1853289, rhbz#1865932) + * Wed Aug 26 2020 Jiri Denemark - 6.0.0-28 - virdevmapper: Don't cache device-mapper major (rhbz#1860421) - virdevmapper: Handle kernel without device-mapper support (rhbz#1860421)