diff --git a/SOURCES/libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch b/SOURCES/libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch index 7b8d712..a0bc853 100644 --- a/SOURCES/libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch +++ b/SOURCES/libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch @@ -1,7 +1,7 @@ -From 85ac61a95b3817ffcb653856f40b7c4ee86c876e Mon Sep 17 00:00:00 2001 -Message-Id: <85ac61a95b3817ffcb653856f40b7c4ee86c876e@dist-git> +From 6244ce5a6ff5121fff9aaffe1689912955af6372 Mon Sep 17 00:00:00 2001 +Message-Id: <6244ce5a6ff5121fff9aaffe1689912955af6372@dist-git> From: Jiri Denemark -Date: Mon, 6 Jan 2020 16:43:40 +0100 +Date: Fri, 29 Nov 2019 19:14:36 +0100 Subject: [PATCH] RHEL: qemu: Enable virt-ssbd for host-model with old QEMU RHEL-only hack for qemu-kvm-1.5.3-* @@ -22,23 +22,16 @@ https://bugzilla.redhat.com/show_bug.cgi?id=1745181 Signed-off-by: Jiri Denemark Message-Id: Reviewed-by: Michal Privoznik -(cherry picked from commit 6244ce5a6ff5121fff9aaffe1689912955af6372) - -https://bugzilla.redhat.com/show_bug.cgi?id=1787556 - -Signed-off-by: Jiri Denemark -Message-Id: <0ac3b5185c3a0aa514742752c84fae8d23c5e2c8.1578325371.git.jdenemar@redhat.com> -Reviewed-by: Pavel Hrdina --- libvirt.spec.in | 1 + src/qemu/qemu_process.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 307098cd63..b8b12491a3 100644 +index 4a2864af27..0add197af5 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c -@@ -5776,6 +5776,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, +@@ -5780,6 +5780,7 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, unsigned int flags) { int ret = -1; @@ -46,7 +39,7 @@ index 307098cd63..b8b12491a3 100644 if (!def->cpu) return 0; -@@ -5822,6 +5823,8 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, +@@ -5826,6 +5827,8 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, def->cpu, true) < 0) return -1; @@ -55,7 +48,7 @@ index 307098cd63..b8b12491a3 100644 if (virCPUUpdate(def->os.arch, def->cpu, virQEMUCapsGetHostModel(qemuCaps, def->virtType, VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE)) < 0) -@@ -5831,6 +5834,17 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, +@@ -5835,6 +5838,17 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def, virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType)) < 0) goto cleanup; @@ -74,5 +67,5 @@ index 307098cd63..b8b12491a3 100644 ret = 0; -- -2.24.1 +2.24.0 diff --git a/SOURCES/libvirt-RHEL-qemuCheckUnprivSGIO-use-sysfs_path-to-get-unpriv_sgio.patch b/SOURCES/libvirt-RHEL-qemuCheckUnprivSGIO-use-sysfs_path-to-get-unpriv_sgio.patch new file mode 100644 index 0000000..052b2b5 --- /dev/null +++ b/SOURCES/libvirt-RHEL-qemuCheckUnprivSGIO-use-sysfs_path-to-get-unpriv_sgio.patch @@ -0,0 +1,40 @@ +From 0f85e65a6d4ce41d05464129fddb3d28171519b2 Mon Sep 17 00:00:00 2001 +Message-Id: <0f85e65a6d4ce41d05464129fddb3d28171519b2@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 11 Feb 2020 03:15:00 +0100 +Subject: [PATCH] RHEL: qemuCheckUnprivSGIO: use @sysfs_path to get unpriv_sgio +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Downstream commit 65f4ff0e2c9a968b7ec65c8d751d4055cc212628 + RHEL: qemuSetUnprivSGIO: Actually use calculated + @sysfs_path to set unpriv_sgio +removed the device_path -> sysfs_path conversion from +both virGetDeviceUnprivSGIO and virSetDeviceUnprivSGIO, +but only adjusted one of the callers. + +Signed-off-by: Ján Tomko +https://bugzilla.redhat.com/show_bug.cgi?id=1801139 +Message-Id: +Reviewed-by: Andrea Bolognani +--- + src/qemu/qemu_conf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index 5788354444..a86e340013 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -1255,7 +1255,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices, + goto cleanup; + } + +- if (virGetDeviceUnprivSGIO(device_path, &val) < 0) ++ if (virGetDeviceUnprivSGIO(sysfs_path, &val) < 0) + goto cleanup; + + /* Error message on failure needs to be handled in caller +-- +2.25.0 + diff --git a/SOURCES/libvirt-RHEL-qemuSetUnprivSGIO-Actually-use-calculated-sysfs_path-to-set-unpriv_sgio.patch b/SOURCES/libvirt-RHEL-qemuSetUnprivSGIO-Actually-use-calculated-sysfs_path-to-set-unpriv_sgio.patch new file mode 100644 index 0000000..3c9dd48 --- /dev/null +++ b/SOURCES/libvirt-RHEL-qemuSetUnprivSGIO-Actually-use-calculated-sysfs_path-to-set-unpriv_sgio.patch @@ -0,0 +1,169 @@ +From 65f4ff0e2c9a968b7ec65c8d751d4055cc212628 Mon Sep 17 00:00:00 2001 +Message-Id: <65f4ff0e2c9a968b7ec65c8d751d4055cc212628@dist-git> +From: Michal Privoznik +Date: Thu, 10 Oct 2019 14:20:58 +0200 +Subject: [PATCH] RHEL: qemuSetUnprivSGIO: Actually use calculated @sysfs_path + to set unpriv_sgio + +In previous commits I've attempted to make qemuSetUnprivSGIO() +construct a generic enough path for SCSI devices to set +unpriv_sgio. However, virSetDeviceUnprivSGIO() does not care +about that - it constructs the path on it's own again. This is +suboptimal in either case - we already have the path constructed. + +https://bugzilla.redhat.com/show_bug.cgi?id=1754241 + +Signed-off-by: Michal Privoznik +Message-Id: <1f6fa49bd2fec4e3b144cb8c1a27a9d0456c9431.1570709916.git.mprivozn@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/qemu/qemu_conf.c | 8 +++----- + src/util/virutil.c | 24 ++++++------------------ + src/util/virutil.h | 2 -- + 3 files changed, 9 insertions(+), 25 deletions(-) + +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index 5636277888..5788354444 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -1255,7 +1255,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices, + goto cleanup; + } + +- if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0) ++ if (virGetDeviceUnprivSGIO(device_path, &val) < 0) + goto cleanup; + + /* Error message on failure needs to be handled in caller +@@ -1648,7 +1648,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + virDomainDiskDefPtr disk = NULL; + virDomainHostdevDefPtr hostdev = NULL; + char *sysfs_path = NULL; +- const char *path = NULL; + int val = 0; + int ret = -1; + +@@ -1657,13 +1656,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + */ + if (dev->type == VIR_DOMAIN_DEVICE_DISK) { + disk = dev->data.disk; ++ const char *path = virDomainDiskGetSource(disk); + + if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN || + !virStorageSourceIsBlockLocal(disk->src)) + return 0; + +- path = virDomainDiskGetSource(disk); +- + if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL))) + goto cleanup; + +@@ -1703,7 +1701,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + * virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio. + */ + if ((virFileExists(sysfs_path) || val == 1) && +- virSetDeviceUnprivSGIO(path, NULL, val) < 0) ++ virSetDeviceUnprivSGIO(sysfs_path, val) < 0) + goto cleanup; + + ret = 0; +diff --git a/src/util/virutil.c b/src/util/virutil.c +index fb2a95041a..fd70df120b 100644 +--- a/src/util/virutil.c ++++ b/src/util/virutil.c +@@ -1715,18 +1715,13 @@ virGetUnprivSGIOSysfsPath(const char *path, + + int + virSetDeviceUnprivSGIO(const char *path, +- const char *sysfs_dir, + int unpriv_sgio) + { +- char *sysfs_path = NULL; + char *val = NULL; + int ret = -1; + int rc; + +- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir))) +- return -1; +- +- if (!virFileExists(sysfs_path)) { ++ if (!virFileExists(path)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("unpriv_sgio is not supported by this kernel")); + goto cleanup; +@@ -1735,38 +1730,32 @@ virSetDeviceUnprivSGIO(const char *path, + if (virAsprintf(&val, "%d", unpriv_sgio) < 0) + goto cleanup; + +- if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) { +- virReportSystemError(-rc, _("failed to set %s"), sysfs_path); ++ if ((rc = virFileWriteStr(path, val, 0)) < 0) { ++ virReportSystemError(-rc, _("failed to set %s"), path); + goto cleanup; + } + + ret = 0; + cleanup: +- VIR_FREE(sysfs_path); + VIR_FREE(val); + return ret; + } + + int + virGetDeviceUnprivSGIO(const char *path, +- const char *sysfs_dir, + int *unpriv_sgio) + { +- char *sysfs_path = NULL; + char *buf = NULL; + char *tmp = NULL; + int ret = -1; + +- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir))) +- return -1; +- +- if (!virFileExists(sysfs_path)) { ++ if (!virFileExists(path)) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("unpriv_sgio is not supported by this kernel")); + goto cleanup; + } + +- if (virFileReadAll(sysfs_path, 1024, &buf) < 0) ++ if (virFileReadAll(path, 1024, &buf) < 0) + goto cleanup; + + if ((tmp = strchr(buf, '\n'))) +@@ -1774,13 +1763,12 @@ virGetDeviceUnprivSGIO(const char *path, + + if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("failed to parse value of %s"), sysfs_path); ++ _("failed to parse value of %s"), path); + goto cleanup; + } + + ret = 0; + cleanup: +- VIR_FREE(sysfs_path); + VIR_FREE(buf); + return ret; + } +diff --git a/src/util/virutil.h b/src/util/virutil.h +index abbbb7101e..b0ee8329e2 100644 +--- a/src/util/virutil.h ++++ b/src/util/virutil.h +@@ -160,10 +160,8 @@ int virGetDeviceID(const char *path, + int *maj, + int *min); + int virSetDeviceUnprivSGIO(const char *path, +- const char *sysfs_dir, + int unpriv_sgio); + int virGetDeviceUnprivSGIO(const char *path, +- const char *sysfs_dir, + int *unpriv_sgio); + char *virGetUnprivSGIOSysfsPath(const char *path, + const char *sysfs_dir); +-- +2.23.0 + diff --git a/SOURCES/libvirt-RHEL-virscsi-Check-device-type-before-getting-it-s-dev-node-name.patch b/SOURCES/libvirt-RHEL-virscsi-Check-device-type-before-getting-it-s-dev-node-name.patch new file mode 100644 index 0000000..7263d4f --- /dev/null +++ b/SOURCES/libvirt-RHEL-virscsi-Check-device-type-before-getting-it-s-dev-node-name.patch @@ -0,0 +1,231 @@ +From 2cb3950bd3540f1f5f6ffaf93116556a92f2ab8c Mon Sep 17 00:00:00 2001 +Message-Id: <2cb3950bd3540f1f5f6ffaf93116556a92f2ab8c@dist-git> +From: Michal Privoznik +Date: Tue, 8 Oct 2019 14:14:19 +0200 +Subject: [PATCH] RHEL: virscsi: Check device type before getting it's /dev + node name + +Not all SCSI devices are block devices, therefore +/sys/bus/scsi/devices/X:X:X:X/block/ directory does not always +exist. Check if the SCSI device is a block device beforehand. + +https://bugzilla.redhat.com/show_bug.cgi?id=1754241 + +Signed-off-by: Michal Privoznik +Message-Id: +Reviewed-by: Jiri Denemark +--- + src/util/virscsi.c | 149 ++++++++++++++++++++++++++++++--- + tests/virscsidata/0-0-0-0/type | 1 + + tests/virscsidata/1-0-0-0/type | 1 + + 3 files changed, 138 insertions(+), 13 deletions(-) + create mode 100644 tests/virscsidata/0-0-0-0/type + create mode 100644 tests/virscsidata/1-0-0-0/type + +diff --git a/src/util/virscsi.c b/src/util/virscsi.c +index b51103a86d..af908107d9 100644 +--- a/src/util/virscsi.c ++++ b/src/util/virscsi.c +@@ -56,6 +56,32 @@ struct _virUsedByInfo { + }; + typedef struct _virUsedByInfo *virUsedByInfoPtr; + ++ ++/* Keep in sync with scsi/scsi_proto.h */ ++typedef enum { ++ VIR_SCSI_DEVICE_TYPE_NONE = -1, ++ VIR_SCSI_DEVICE_TYPE_DISK = 0x00, ++ VIR_SCSI_DEVICE_TYPE_TAPE = 0x01, ++ VIR_SCSI_DEVICE_TYPE_PRINTER = 0x02, ++ VIR_SCSI_DEVICE_TYPE_PROCESSOR = 0x03, ++ VIR_SCSI_DEVICE_TYPE_WORM = 0x04, ++ VIR_SCSI_DEVICE_TYPE_ROM = 0x05, ++ VIR_SCSI_DEVICE_TYPE_SCANNER = 0x06, ++ VIR_SCSI_DEVICE_TYPE_MOD = 0x07, ++ VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER = 0x08, ++ VIR_SCSI_DEVICE_TYPE_COMM = 0x09, ++ VIR_SCSI_DEVICE_TYPE_RAID = 0x0c, ++ VIR_SCSI_DEVICE_TYPE_ENCLOSURE = 0x0d, ++ VIR_SCSI_DEVICE_TYPE_RBC = 0x0e, ++ VIR_SCSI_DEVICE_TYPE_OSD = 0x11, ++ VIR_SCSI_DEVICE_TYPE_ZBC = 0x14, ++ VIR_SCSI_DEVICE_TYPE_WLUN = 0x1e, ++ VIR_SCSI_DEVICE_TYPE_NO_LUN = 0x7f, ++ ++ VIR_SCSI_DEVICE_TYPE_LAST, ++} virSCSIDeviceType; ++ ++ + struct _virSCSIDevice { + unsigned int adapter; + unsigned int bus; +@@ -143,6 +169,86 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, + return sg; + } + ++ ++static int ++virSCSIDeviceGetType(const char *prefix, ++ unsigned int adapter, ++ unsigned int bus, ++ unsigned int target, ++ unsigned long long unit, ++ virSCSIDeviceType *type) ++{ ++ int intType; ++ ++ if (virFileReadValueInt(&intType, ++ "%s/%d:%u:%u:%llu/type", ++ prefix, adapter, bus, target, unit) < 0) ++ return -1; ++ ++ switch (intType) { ++ case VIR_SCSI_DEVICE_TYPE_DISK: ++ case VIR_SCSI_DEVICE_TYPE_TAPE: ++ case VIR_SCSI_DEVICE_TYPE_PRINTER: ++ case VIR_SCSI_DEVICE_TYPE_PROCESSOR: ++ case VIR_SCSI_DEVICE_TYPE_WORM: ++ case VIR_SCSI_DEVICE_TYPE_ROM: ++ case VIR_SCSI_DEVICE_TYPE_SCANNER: ++ case VIR_SCSI_DEVICE_TYPE_MOD: ++ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER: ++ case VIR_SCSI_DEVICE_TYPE_COMM: ++ case VIR_SCSI_DEVICE_TYPE_RAID: ++ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE: ++ case VIR_SCSI_DEVICE_TYPE_RBC: ++ case VIR_SCSI_DEVICE_TYPE_OSD: ++ case VIR_SCSI_DEVICE_TYPE_ZBC: ++ case VIR_SCSI_DEVICE_TYPE_WLUN: ++ case VIR_SCSI_DEVICE_TYPE_NO_LUN: ++ *type = intType; ++ break; ++ ++ default: ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("unknown SCSI device type: %x"), ++ intType); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ ++static char * ++virSCSIDeviceGetDevNameBlock(const char *prefix, ++ unsigned int adapter, ++ unsigned int bus, ++ unsigned int target, ++ unsigned long long unit) ++{ ++ DIR *dir = NULL; ++ struct dirent *entry; ++ char *path = NULL; ++ char *name = NULL; ++ ++ if (virAsprintf(&path, ++ "%s/%d:%u:%u:%llu/block", ++ prefix, adapter, bus, target, unit) < 0) ++ return NULL; ++ ++ if (virDirOpen(&dir, path) < 0) ++ goto cleanup; ++ ++ while (virDirRead(dir, &entry, path) > 0) { ++ ignore_value(VIR_STRDUP(name, entry->d_name)); ++ break; ++ } ++ ++ cleanup: ++ VIR_DIR_CLOSE(dir); ++ VIR_FREE(path); ++ return name; ++} ++ ++ + /* Returns device name (e.g. "sdc") on success, or NULL + * on failure. + */ +@@ -153,35 +259,52 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, + unsigned int target, + unsigned long long unit) + { +- DIR *dir = NULL; +- struct dirent *entry; +- char *path = NULL; + char *name = NULL; + unsigned int adapter_id; ++ virSCSIDeviceType type; + const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES; + + if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0) + return NULL; + +- if (virAsprintf(&path, +- "%s/%d:%u:%u:%llu/block", +- prefix, adapter_id, bus, target, unit) < 0) ++ if (virSCSIDeviceGetType(prefix, adapter_id, ++ bus, target, unit, &type) < 0) + return NULL; + +- if (virDirOpen(&dir, path) < 0) +- goto cleanup; ++ switch (type) { ++ case VIR_SCSI_DEVICE_TYPE_DISK: ++ name = virSCSIDeviceGetDevNameBlock(prefix, adapter_id, bus, target, unit); ++ break; + +- while (virDirRead(dir, &entry, path) > 0) { +- ignore_value(VIR_STRDUP(name, entry->d_name)); ++ case VIR_SCSI_DEVICE_TYPE_TAPE: ++ case VIR_SCSI_DEVICE_TYPE_PRINTER: ++ case VIR_SCSI_DEVICE_TYPE_PROCESSOR: ++ case VIR_SCSI_DEVICE_TYPE_WORM: ++ case VIR_SCSI_DEVICE_TYPE_ROM: ++ case VIR_SCSI_DEVICE_TYPE_SCANNER: ++ case VIR_SCSI_DEVICE_TYPE_MOD: ++ case VIR_SCSI_DEVICE_TYPE_MEDIUM_CHANGER: ++ case VIR_SCSI_DEVICE_TYPE_COMM: ++ case VIR_SCSI_DEVICE_TYPE_RAID: ++ case VIR_SCSI_DEVICE_TYPE_ENCLOSURE: ++ case VIR_SCSI_DEVICE_TYPE_RBC: ++ case VIR_SCSI_DEVICE_TYPE_OSD: ++ case VIR_SCSI_DEVICE_TYPE_ZBC: ++ case VIR_SCSI_DEVICE_TYPE_WLUN: ++ case VIR_SCSI_DEVICE_TYPE_NO_LUN: ++ case VIR_SCSI_DEVICE_TYPE_NONE: ++ case VIR_SCSI_DEVICE_TYPE_LAST: ++ default: ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("unsupported SCSI device type: %x"), ++ type); + break; + } + +- cleanup: +- VIR_DIR_CLOSE(dir); +- VIR_FREE(path); + return name; + } + ++ + virSCSIDevicePtr + virSCSIDeviceNew(const char *sysfs_prefix, + const char *adapter, +diff --git a/tests/virscsidata/0-0-0-0/type b/tests/virscsidata/0-0-0-0/type +new file mode 100644 +index 0000000000..573541ac97 +--- /dev/null ++++ b/tests/virscsidata/0-0-0-0/type +@@ -0,0 +1 @@ ++0 +diff --git a/tests/virscsidata/1-0-0-0/type b/tests/virscsidata/1-0-0-0/type +new file mode 100644 +index 0000000000..573541ac97 +--- /dev/null ++++ b/tests/virscsidata/1-0-0-0/type +@@ -0,0 +1 @@ ++0 +-- +2.23.0 + diff --git a/SOURCES/libvirt-RHEL-virscsi-Introduce-and-use-virSCSIDeviceGetUnprivSGIOSysfsPath.patch b/SOURCES/libvirt-RHEL-virscsi-Introduce-and-use-virSCSIDeviceGetUnprivSGIOSysfsPath.patch new file mode 100644 index 0000000..7f363d1 --- /dev/null +++ b/SOURCES/libvirt-RHEL-virscsi-Introduce-and-use-virSCSIDeviceGetUnprivSGIOSysfsPath.patch @@ -0,0 +1,147 @@ +From 1f219561662a850309e4c19418167fc1d33a8cf7 Mon Sep 17 00:00:00 2001 +Message-Id: <1f219561662a850309e4c19418167fc1d33a8cf7@dist-git> +From: Michal Privoznik +Date: Tue, 8 Oct 2019 14:14:21 +0200 +Subject: [PATCH] RHEL: virscsi: Introduce and use + virSCSIDeviceGetUnprivSGIOSysfsPath() + +When constructing a path to the 'unpriv_sgio' file of given SCSI +device we don't need to go through /dev/* and major() + minor() +path. The generated path points to +/sys/dev/block/MAJ:MIN/queue/unpriv_sgio which is wrong if the +SCSI device in question is not a block device. We can generate a +different path: /sys/bus/scsi/devices/X:X:X:X/unpriv_sgio where +the file is directly accessible regardless of the SCSI device +type. + +https://bugzilla.redhat.com/show_bug.cgi?id=1754241 + +Signed-off-by: Michal Privoznik +Message-Id: <36bac569fd66de8dcbec73085016b16a0371dfe6.1570536610.git.mprivozn@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/libvirt_private.syms | 1 + + src/qemu/qemu_conf.c | 19 +++++++++++-------- + src/util/virscsi.c | 21 +++++++++++++++++++++ + src/util/virscsi.h | 5 +++++ + 4 files changed, 38 insertions(+), 8 deletions(-) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index b213e5764b..1bc43293fd 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -2704,6 +2704,7 @@ virSCSIDeviceGetSgName; + virSCSIDeviceGetShareable; + virSCSIDeviceGetTarget; + virSCSIDeviceGetUnit; ++virSCSIDeviceGetUnprivSGIOSysfsPath; + virSCSIDeviceIsAvailable; + virSCSIDeviceListAdd; + virSCSIDeviceListCount; +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index a81298326f..5636277888 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -1648,7 +1648,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + virDomainDiskDefPtr disk = NULL; + virDomainHostdevDefPtr hostdev = NULL; + char *sysfs_path = NULL; +- char *hostdev_path = NULL; + const char *path = NULL; + int val = 0; + int ret = -1; +@@ -1664,24 +1663,29 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + return 0; + + path = virDomainDiskGetSource(disk); ++ ++ if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL))) ++ goto cleanup; ++ + } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { + hostdev = dev->data.hostdev; ++ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi; ++ virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host; + + if (hostdev->source.subsys.u.scsi.protocol == + VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) + return 0; + +- if (!(hostdev_path = qemuGetHostdevPath(hostdev))) ++ if (!(sysfs_path = virSCSIDeviceGetUnprivSGIOSysfsPath(NULL, ++ scsihostsrc->adapter, ++ scsihostsrc->bus, ++ scsihostsrc->target, ++ scsihostsrc->unit))) + goto cleanup; +- +- path = hostdev_path; + } else { + return 0; + } + +- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL))) +- goto cleanup; +- + /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */ + if (dev->type == VIR_DOMAIN_DEVICE_DISK) { + if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED) +@@ -1705,7 +1709,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) + ret = 0; + + cleanup: +- VIR_FREE(hostdev_path); + VIR_FREE(sysfs_path); + return ret; + } +diff --git a/src/util/virscsi.c b/src/util/virscsi.c +index 6c3fd8a562..5aab43fc88 100644 +--- a/src/util/virscsi.c ++++ b/src/util/virscsi.c +@@ -342,6 +342,27 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, + } + + ++char * ++virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix, ++ const char *adapter, ++ unsigned int bus, ++ unsigned int target, ++ unsigned long long unit) ++{ ++ char *path = NULL; ++ unsigned int adapter_id; ++ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES; ++ ++ if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0) ++ return NULL; ++ ++ ignore_value(virAsprintf(&path, ++ "%s/%d:%u:%u:%llu/unpriv_sgio", ++ prefix, adapter_id, bus, target, unit)); ++ return path; ++} ++ ++ + virSCSIDevicePtr + virSCSIDeviceNew(const char *sysfs_prefix, + const char *adapter, +diff --git a/src/util/virscsi.h b/src/util/virscsi.h +index 9f8b3ecf1e..5dea2a9f5d 100644 +--- a/src/util/virscsi.h ++++ b/src/util/virscsi.h +@@ -43,6 +43,11 @@ char *virSCSIDeviceGetDevName(const char *sysfs_prefix, + unsigned int bus, + unsigned int target, + unsigned long long unit); ++char *virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix, ++ const char *adapter, ++ unsigned int bus, ++ unsigned int target, ++ unsigned long long unit); + + virSCSIDevicePtr virSCSIDeviceNew(const char *sysfs_prefix, + const char *adapter, +-- +2.23.0 + diff --git a/SOURCES/libvirt-RHEL-virscsi-Support-TAPEs-in-virSCSIDeviceGetDevName.patch b/SOURCES/libvirt-RHEL-virscsi-Support-TAPEs-in-virSCSIDeviceGetDevName.patch new file mode 100644 index 0000000..fe9aba5 --- /dev/null +++ b/SOURCES/libvirt-RHEL-virscsi-Support-TAPEs-in-virSCSIDeviceGetDevName.patch @@ -0,0 +1,218 @@ +From 227bf0ec28c4ace3b90d383393a9e93c3c0c727c Mon Sep 17 00:00:00 2001 +Message-Id: <227bf0ec28c4ace3b90d383393a9e93c3c0c727c@dist-git> +From: Michal Privoznik +Date: Tue, 8 Oct 2019 14:14:20 +0200 +Subject: [PATCH] RHEL: virscsi: Support TAPEs in virSCSIDeviceGetDevName() + +If the SCSI device we want to get /dev node name for is TAPE +device we need to look at 'tape' symlink in the sysfs dir +corresponding to the device. + +https://bugzilla.redhat.com/show_bug.cgi?id=1754241 + +Signed-off-by: Michal Privoznik +Message-Id: <3c722bc2e0627583f26111441f37027c256878c7.1570536610.git.mprivozn@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/util/virscsi.c | 37 ++++++++++++++++++++ + tests/virscsidata/2-0-0-0/model | 1 + + tests/virscsidata/2-0-0-0/scsi_tape/st0/dev | 1 + + tests/virscsidata/2-0-0-0/sg3/dev | 1 + + tests/virscsidata/2-0-0-0/tape | 1 + + tests/virscsidata/2-0-0-0/type | 1 + + tests/virscsidata/2-0-0-0/vendor | 1 + + tests/virscsidata/sg3 | 0 + tests/virscsitest.c | 38 ++++++++++++++++++--- + 9 files changed, 76 insertions(+), 5 deletions(-) + create mode 100644 tests/virscsidata/2-0-0-0/model + create mode 100644 tests/virscsidata/2-0-0-0/scsi_tape/st0/dev + create mode 100644 tests/virscsidata/2-0-0-0/sg3/dev + create mode 120000 tests/virscsidata/2-0-0-0/tape + create mode 100644 tests/virscsidata/2-0-0-0/type + create mode 100644 tests/virscsidata/2-0-0-0/vendor + create mode 100644 tests/virscsidata/sg3 + +diff --git a/src/util/virscsi.c b/src/util/virscsi.c +index af908107d9..6c3fd8a562 100644 +--- a/src/util/virscsi.c ++++ b/src/util/virscsi.c +@@ -42,6 +42,7 @@ + #include "virutil.h" + #include "virstring.h" + #include "virerror.h" ++#include "dirname.h" + + #define SYSFS_SCSI_DEVICES "/sys/bus/scsi/devices" + +@@ -249,6 +250,39 @@ virSCSIDeviceGetDevNameBlock(const char *prefix, + } + + ++static char * ++virSCSIDeviceGetDevNameTape(const char *prefix, ++ unsigned int adapter, ++ unsigned int bus, ++ unsigned int target, ++ unsigned long long unit) ++{ ++ char *path = NULL; ++ char *resolvedPath = NULL; ++ char *name = NULL; ++ ++ if (virAsprintf(&path, ++ "%s/%d:%u:%u:%llu/tape", ++ prefix, adapter, bus, target, unit) < 0) ++ return NULL; ++ ++ if (virFileReadLink(path, &resolvedPath) < 0) { ++ virReportSystemError(errno, ++ _("Unable to read link: %s"), ++ path); ++ goto cleanup; ++ } ++ ++ if (VIR_STRDUP(name, last_component(resolvedPath)) < 0) ++ goto cleanup; ++ ++ cleanup: ++ VIR_FREE(resolvedPath); ++ VIR_FREE(path); ++ return name; ++} ++ ++ + /* Returns device name (e.g. "sdc") on success, or NULL + * on failure. + */ +@@ -277,6 +311,9 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, + break; + + case VIR_SCSI_DEVICE_TYPE_TAPE: ++ name = virSCSIDeviceGetDevNameTape(prefix, adapter_id, bus, target, unit); ++ break; ++ + case VIR_SCSI_DEVICE_TYPE_PRINTER: + case VIR_SCSI_DEVICE_TYPE_PROCESSOR: + case VIR_SCSI_DEVICE_TYPE_WORM: +diff --git a/tests/virscsidata/2-0-0-0/model b/tests/virscsidata/2-0-0-0/model +new file mode 100644 +index 0000000000..d2ab4715c3 +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/model +@@ -0,0 +1 @@ ++scsi_debug +diff --git a/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev +new file mode 100644 +index 0000000000..3dd777e840 +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/scsi_tape/st0/dev +@@ -0,0 +1 @@ ++9:0 +diff --git a/tests/virscsidata/2-0-0-0/sg3/dev b/tests/virscsidata/2-0-0-0/sg3/dev +new file mode 100644 +index 0000000000..b369a59b3e +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/sg3/dev +@@ -0,0 +1 @@ ++21:3 +diff --git a/tests/virscsidata/2-0-0-0/tape b/tests/virscsidata/2-0-0-0/tape +new file mode 120000 +index 0000000000..6ca7f77539 +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/tape +@@ -0,0 +1 @@ ++scsi_tape/st0 +\ No newline at end of file +diff --git a/tests/virscsidata/2-0-0-0/type b/tests/virscsidata/2-0-0-0/type +new file mode 100644 +index 0000000000..d00491fd7e +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/type +@@ -0,0 +1 @@ ++1 +diff --git a/tests/virscsidata/2-0-0-0/vendor b/tests/virscsidata/2-0-0-0/vendor +new file mode 100644 +index 0000000000..9b075671ea +--- /dev/null ++++ b/tests/virscsidata/2-0-0-0/vendor +@@ -0,0 +1 @@ ++Linux +diff --git a/tests/virscsidata/sg3 b/tests/virscsidata/sg3 +new file mode 100644 +index 0000000000..e69de29bb2 +diff --git a/tests/virscsitest.c b/tests/virscsitest.c +index 1215adbfab..880fa22ca8 100644 +--- a/tests/virscsitest.c ++++ b/tests/virscsitest.c +@@ -36,18 +36,34 @@ VIR_LOG_INIT("tests.scsitest"); + static const char *abs_top_srcdir; + static char *virscsi_prefix; + ++typedef struct { ++ const char *adapter; ++ unsigned int bus; ++ unsigned int target; ++ unsigned int unit; ++ const char *expectedName; ++} testGetDevNameData; ++ + static int +-test1(const void *data ATTRIBUTE_UNUSED) ++testGetDevName(const void *opaque) + { ++ const testGetDevNameData *data = opaque; + char *name = NULL; + int ret = -1; + + if (!(name = virSCSIDeviceGetDevName(virscsi_prefix, +- "scsi_host1", 0, 0, 0))) ++ data->adapter, ++ data->bus, ++ data->target, ++ data->unit))) + return -1; + +- if (STRNEQ(name, "sdh")) ++ if (STRNEQ(name, data->expectedName)) { ++ fprintf(stderr, ++ "SCSI dev name mismatch, expected %s got %s", ++ data->expectedName, name); + goto cleanup; ++ } + + ret = 0; + cleanup: +@@ -225,7 +241,9 @@ mymain(void) + + CREATE_SYMLINK("0-0-0-0", "0:0:0:0"); + CREATE_SYMLINK("1-0-0-0", "1:0:0:0"); ++ CREATE_SYMLINK("2-0-0-0", "2:0:0:0"); + CREATE_SYMLINK("sg0", "sg0"); ++ CREATE_SYMLINK("sg3", "sg3"); + CREATE_SYMLINK("sg8", "sg8"); + + VIR_FREE(virscsi_prefix); +@@ -235,8 +253,18 @@ mymain(void) + goto cleanup; + } + +- if (virTestRun("test1", test1, NULL) < 0) +- ret = -1; ++#define TEST_GET_DEV_NAME(adapter, bus, target, unit, expectedName) \ ++ do { \ ++ testGetDevNameData data = {adapter, bus, target, unit, expectedName}; \ ++ if (virTestRun("test getDevname " expectedName, \ ++ testGetDevName, &data) < 0) \ ++ ret = -1; \ ++ } while (0) ++ ++ TEST_GET_DEV_NAME("scsi_host0", 0, 0, 0, "sda"); ++ TEST_GET_DEV_NAME("scsi_host1", 0, 0, 0, "sdh"); ++ TEST_GET_DEV_NAME("scsi_host2", 0, 0, 0, "st0"); ++ + if (virTestRun("test2", test2, NULL) < 0) + ret = -1; + +-- +2.23.0 + diff --git a/SOURCES/libvirt-RHEL-virutil-Accept-non-block-devices-in-virGetDeviceID.patch b/SOURCES/libvirt-RHEL-virutil-Accept-non-block-devices-in-virGetDeviceID.patch new file mode 100644 index 0000000..8e4de4d --- /dev/null +++ b/SOURCES/libvirt-RHEL-virutil-Accept-non-block-devices-in-virGetDeviceID.patch @@ -0,0 +1,36 @@ +From a87147a0bb1bf52cb0646e5776bce19fdc51d80d Mon Sep 17 00:00:00 2001 +Message-Id: +From: Michal Privoznik +Date: Tue, 8 Oct 2019 14:14:22 +0200 +Subject: [PATCH] RHEL: virutil: Accept non-block devices in virGetDeviceID() + +If a caller wants to learn major or minor number for a device, +let them. There's no need to check if the device is a block +device here. + +https://bugzilla.redhat.com/show_bug.cgi?id=1754241 + +Signed-off-by: Michal Privoznik +Message-Id: <354b68e431cc5179ab57895536afebc0d68b2a4b.1570536610.git.mprivozn@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/util/virutil.c | 3 --- + 1 file changed, 3 deletions(-) + +diff --git a/src/util/virutil.c b/src/util/virutil.c +index b25d2a5ca4..fb2a95041a 100644 +--- a/src/util/virutil.c ++++ b/src/util/virutil.c +@@ -1672,9 +1672,6 @@ virGetDeviceID(const char *path, int *maj, int *min) + if (stat(path, &sb) < 0) + return -errno; + +- if (!S_ISBLK(sb.st_mode)) +- return -EINVAL; +- + if (maj) + *maj = major(sb.st_rdev); + if (min) +-- +2.23.0 + diff --git a/SOURCES/libvirt-conf-make-arg-to-virDomainNetGetActualVirtPortProfile-a-const.patch b/SOURCES/libvirt-conf-make-arg-to-virDomainNetGetActualVirtPortProfile-a-const.patch new file mode 100644 index 0000000..cb7000b --- /dev/null +++ b/SOURCES/libvirt-conf-make-arg-to-virDomainNetGetActualVirtPortProfile-a-const.patch @@ -0,0 +1,56 @@ +From b1ce2d024e4049c1e103f56a2ed86db9aa0e14d1 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Laine Stump +Date: Mon, 16 Sep 2019 09:54:04 -0400 +Subject: [PATCH] conf: make arg to virDomainNetGetActualVirtPortProfile() a + const +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It needs to be used by a function that only has a const pointer to +virDomainNetDef. + +Signed-off-by: Laine Stump +Reviewed-by: Michal Privoznik +(cherry picked from commit 57de1988c4c2b015a5f459a5504a814833ffa194) + + https://bugzilla.redhat.com/1502754 + +Signed-off-by: Laine Stump +Message-Id: <20190916135406.18523-2-laine@redhat.com> +Reviewed-by: Ján Tomko +--- + src/conf/domain_conf.c | 2 +- + src/conf/domain_conf.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 637d971e21..0352fad245 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -29384,7 +29384,7 @@ virDomainNetGetActualHostdev(virDomainNetDefPtr iface) + } + + virNetDevVPortProfilePtr +-virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface) ++virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface) + { + switch (iface->type) { + case VIR_DOMAIN_NET_TYPE_DIRECT: +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 0989368e7c..1c4556cecd 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -3193,7 +3193,7 @@ const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); + int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface); + virDomainHostdevDefPtr virDomainNetGetActualHostdev(virDomainNetDefPtr iface); + virNetDevVPortProfilePtr +-virDomainNetGetActualVirtPortProfile(virDomainNetDefPtr iface); ++virDomainNetGetActualVirtPortProfile(const virDomainNetDef *iface); + virNetDevBandwidthPtr + virDomainNetGetActualBandwidth(virDomainNetDefPtr iface); + virNetDevVlanPtr virDomainNetGetActualVlan(virDomainNetDefPtr iface); +-- +2.23.0 + diff --git a/SOURCES/libvirt-conf-utility-function-to-update-entry-in-def-nets-array.patch b/SOURCES/libvirt-conf-utility-function-to-update-entry-in-def-nets-array.patch new file mode 100644 index 0000000..c524c73 --- /dev/null +++ b/SOURCES/libvirt-conf-utility-function-to-update-entry-in-def-nets-array.patch @@ -0,0 +1,150 @@ +From 9bf517748d9fed50a0bee163625f119b25fdb0ea Mon Sep 17 00:00:00 2001 +Message-Id: <9bf517748d9fed50a0bee163625f119b25fdb0ea@dist-git> +From: Laine Stump +Date: Thu, 26 Sep 2019 18:05:26 -0400 +Subject: [PATCH] conf: utility function to update entry in def->nets array + +A virDomainNetDef object in a domain's nets array might contain a +virDomainHostdevDef, and when this is the case, the domain's hostdevs +array will also have a pointer to this embedded hostdev (this is done +so that internal functions that need to perform some operation on all +hostdevs won't leave out the type='hostdev' network interfaces). + +When a network device was updated with virDomainUpdateDeviceFlags(), +we were replacing the entry in the nets array (and free'ing the +original) but forgetting about the pointer in the hostdevs array +(which would then point to the now-free'd hostdev contained in the old +net object.) This often resulted in a libvirtd crash. + +The solution is to add a function, virDomainNetUpdate(), called by +qemuDomainUpdateDeviceConfig(), that updates the hostdevs array +appropriately along with the nets array. + +Resolves: https://bugzilla.redhat.com/1558934 + +Signed-off-by: Laine Stump +Reviewed-by: Michal Privoznik +(cherry picked from commit 7e490cdad6364c82b326d5d9251826c757e8f77b) +Message-Id: <20190926220526.12970-1-laine@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/conf/domain_conf.c | 41 ++++++++++++++++++++++++++++++++++++++++ + src/conf/domain_conf.h | 1 + + src/libvirt_private.syms | 1 + + src/lxc/lxc_driver.c | 6 ++++-- + src/qemu/qemu_driver.c | 6 ++++-- + 5 files changed, 51 insertions(+), 4 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 0352fad245..60f426df04 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -17119,6 +17119,47 @@ virDomainNetRemove(virDomainDefPtr def, size_t i) + return net; + } + ++ ++int ++virDomainNetUpdate(virDomainDefPtr def, ++ size_t netidx, ++ virDomainNetDefPtr newnet) ++{ ++ size_t hostdevidx; ++ virDomainNetDefPtr oldnet = def->nets[netidx]; ++ virDomainHostdevDefPtr oldhostdev = virDomainNetGetActualHostdev(oldnet); ++ virDomainHostdevDefPtr newhostdev = virDomainNetGetActualHostdev(newnet); ++ ++ /* ++ * if newnet or oldnet has a valid hostdev*, we need to update the ++ * hostdevs list ++ */ ++ if (oldhostdev) { ++ for (hostdevidx = 0; hostdevidx < def->nhostdevs; hostdevidx++) { ++ if (def->hostdevs[hostdevidx] == oldhostdev) ++ break; ++ } ++ } ++ ++ if (oldhostdev && hostdevidx < def->nhostdevs) { ++ if (newhostdev) { ++ /* update existing entry in def->hostdevs */ ++ def->hostdevs[hostdevidx] = newhostdev; ++ } else { ++ /* delete oldhostdev from def->hostdevs */ ++ virDomainHostdevRemove(def, hostdevidx); ++ } ++ } else if (newhostdev) { ++ /* add newhostdev to end of def->hostdevs */ ++ if (VIR_APPEND_ELEMENT(def->hostdevs, def->nhostdevs, newhostdev) < 0) ++ return -1; ++ } ++ ++ def->nets[netidx] = newnet; ++ return 0; ++} ++ ++ + int virDomainControllerInsert(virDomainDefPtr def, + virDomainControllerDefPtr controller) + { +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 1c4556cecd..ef8f061ae2 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -3168,6 +3168,7 @@ virDomainNetDefPtr virDomainNetFind(virDomainDefPtr def, const char *device); + virDomainNetDefPtr virDomainNetFindByName(virDomainDefPtr def, const char *ifname); + bool virDomainHasNet(virDomainDefPtr def, virDomainNetDefPtr net); + int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net); ++int virDomainNetUpdate(virDomainDefPtr def, size_t netidx, virDomainNetDefPtr newnet); + virDomainNetDefPtr virDomainNetRemove(virDomainDefPtr def, size_t i); + void virDomainNetRemoveHostdev(virDomainDefPtr def, virDomainNetDefPtr net); + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 9b5e1350f0..b213e5764b 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -476,6 +476,7 @@ virDomainNetSetDeviceImpl; + virDomainNetTypeFromString; + virDomainNetTypeSharesHostView; + virDomainNetTypeToString; ++virDomainNetUpdate; + virDomainNostateReasonTypeFromString; + virDomainNostateReasonTypeToString; + virDomainObjAssignDef; +diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c +index 5978183e7f..0f2ef47bb5 100644 +--- a/src/lxc/lxc_driver.c ++++ b/src/lxc/lxc_driver.c +@@ -3526,8 +3526,10 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef, + false) < 0) + return -1; + +- virDomainNetDefFree(vmdef->nets[idx]); +- vmdef->nets[idx] = net; ++ if (virDomainNetUpdate(vmdef, idx, net) < 0) ++ return -1; ++ ++ virDomainNetDefFree(oldDev.data.net); + dev->data.net = NULL; + ret = 0; + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index d95c97928d..2852b96edd 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -8341,8 +8341,10 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, + false) < 0) + return -1; + +- virDomainNetDefFree(vmdef->nets[pos]); +- vmdef->nets[pos] = net; ++ if (virDomainNetUpdate(vmdef, pos, net)) ++ return -1; ++ ++ virDomainNetDefFree(oldDev.data.net); + dev->data.net = NULL; + break; + +-- +2.23.0 + diff --git a/SOURCES/libvirt-docs-schemas-Add-seclabel-for-external-disk-snapshot.patch b/SOURCES/libvirt-docs-schemas-Add-seclabel-for-external-disk-snapshot.patch new file mode 100644 index 0000000..56c1322 --- /dev/null +++ b/SOURCES/libvirt-docs-schemas-Add-seclabel-for-external-disk-snapshot.patch @@ -0,0 +1,94 @@ +From f1589cb88dc71bb7bf20a4a3a14f79b36228fdd2 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Thu, 20 Jun 2019 17:45:02 +0200 +Subject: [PATCH] docs: schemas: Add 'seclabel' for external disk snapshot + +Allow using seclabels the same way as disk images allow it. Currently +the snapshot code copies the seclabels from the original image if no +seclabel is provided. Also there's no code change required as the +snapshot XML parser actually uses parts of the disk parser thus +seclabels are already parsed and formatted and even applied thus this is +just a formalization of our support for this. + +Signed-off-by: Peter Krempa +Reviewed-by: Martin Kletzander +(cherry picked from commit ac88a8cfad1c93897ddbbfa1cc1aabcf0245255c) +https: //bugzilla.redhat.com/show_bug.cgi?id=1584682 +Message-Id: <9a9636c4fb2cf2f6d08056ad13b6c7dc94611b90.1561045343.git.pkrempa@redhat.com> +Reviewed-by: Jiri Denemark +--- + docs/formatsnapshot.html.in | 12 ++++++++++++ + docs/schemas/domainsnapshot.rng | 6 ++++++ + .../{disk-seclabel-invalid.xml => disk-seclabel.xml} | 0 + 3 files changed, 18 insertions(+) + rename tests/domainsnapshotxml2xmlin/{disk-seclabel-invalid.xml => disk-seclabel.xml} (100%) + +diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in +index 23f20d7c33..bcd9e72983 100644 +--- a/docs/formatsnapshot.html.in ++++ b/docs/formatsnapshot.html.in +@@ -173,6 +173,12 @@ + snapshots, the original file name becomes the read-only + snapshot, and the new file name contains the read-write + delta of all disk changes since the snapshot. ++

++ The source element also may contain the ++ seclabel element (described in the ++ domain XML documentation) ++ which can be used to override the domain security labeling policy ++ for source. + +

driver
+
An optional sub-element driver, +@@ -180,6 +186,7 @@ + as qcow2), of the new file created by the external + snapshot of the new file. +
++
seclabel
+ + + Since 1.2.2 the disk element +@@ -255,6 +262,11 @@ + <source file='/path/to/new'/> + </disk> + <disk name='vdb' snapshot='no'/> ++ <disk name='vdc'> ++ <source file='/path/to/newc'> ++ <seclabel model='dac' relabel='no'/> ++ </source> ++ </disk> + </disks> + </domainsnapshot> + +diff --git a/docs/schemas/domainsnapshot.rng b/docs/schemas/domainsnapshot.rng +index 2680887095..005a573928 100644 +--- a/docs/schemas/domainsnapshot.rng ++++ b/docs/schemas/domainsnapshot.rng +@@ -158,6 +158,9 @@ + + + ++ ++ ++ + + + +@@ -174,6 +177,9 @@ + + + ++ ++ ++ + + + +diff --git a/tests/domainsnapshotxml2xmlin/disk-seclabel-invalid.xml b/tests/domainsnapshotxml2xmlin/disk-seclabel.xml +similarity index 100% +rename from tests/domainsnapshotxml2xmlin/disk-seclabel-invalid.xml +rename to tests/domainsnapshotxml2xmlin/disk-seclabel.xml +-- +2.22.1 + diff --git a/SOURCES/libvirt-docs-snapshot-Encourage-people-ot-use-disk-target-to-refer-to-disks.patch b/SOURCES/libvirt-docs-snapshot-Encourage-people-ot-use-disk-target-to-refer-to-disks.patch new file mode 100644 index 0000000..0cb7cf0 --- /dev/null +++ b/SOURCES/libvirt-docs-snapshot-Encourage-people-ot-use-disk-target-to-refer-to-disks.patch @@ -0,0 +1,47 @@ +From 3fbdec4eee43aec8501e0e2cb93133b477d4b354 Mon Sep 17 00:00:00 2001 +Message-Id: <3fbdec4eee43aec8501e0e2cb93133b477d4b354@dist-git> +From: Peter Krempa +Date: Thu, 20 Jun 2019 17:45:01 +0200 +Subject: [PATCH] docs: snapshot: Encourage people ot use disk 'target' to + refer to disks + +Change the example and add a recommendation to use disk target rather +than path. + +Signed-off-by: Peter Krempa +Reviewed-by: Martin Kletzander +(cherry picked from commit c79ef73c37b1f91d38745cb1197026e702ce42fe) +https: //bugzilla.redhat.com/show_bug.cgi?id=1584682 +Message-Id: +Reviewed-by: Jiri Denemark +--- + docs/formatsnapshot.html.in | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/docs/formatsnapshot.html.in b/docs/formatsnapshot.html.in +index fbbecfd242..23f20d7c33 100644 +--- a/docs/formatsnapshot.html.in ++++ b/docs/formatsnapshot.html.in +@@ -143,8 +143,8 @@ +
This sub-element describes the snapshot properties of a + specific disk. The attribute name is + mandatory, and must match either the <target +- dev='name'/> or an unambiguous <source +- file='name'/> of one of ++ dev='name'/> (recommended) or an unambiguous ++ <source file='name'/> of one of + the disk + devices specified for the domain at the time of the + snapshot. The attribute snapshot is +@@ -251,7 +251,7 @@ + <domainsnapshot> + <description>Snapshot of OS install and updates</description> + <disks> +- <disk name='/path/to/old'> ++ <disk name='vda'> + <source file='/path/to/new'/> + </disk> + <disk name='vdb' snapshot='no'/> +-- +2.22.1 + diff --git a/SOURCES/libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch b/SOURCES/libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch index 7a633e8..d820fba 100644 --- a/SOURCES/libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch +++ b/SOURCES/libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch @@ -1,7 +1,7 @@ -From 0c063a84897d357af0c1d04ec70deee47f97a3a1 Mon Sep 17 00:00:00 2001 -Message-Id: <0c063a84897d357af0c1d04ec70deee47f97a3a1@dist-git> +From 62bd04e98582005d38a17850afbd25465015ae1b Mon Sep 17 00:00:00 2001 +Message-Id: <62bd04e98582005d38a17850afbd25465015ae1b@dist-git> From: Michal Privoznik -Date: Mon, 28 Oct 2019 14:02:22 +0100 +Date: Thu, 24 Oct 2019 08:45:49 +0200 Subject: [PATCH] domain_conf: Make virDomainDeviceFindSCSIController accept virDomainDeviceDriveAddress struct MIME-Version: 1.0 @@ -17,10 +17,10 @@ Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrangé (cherry picked from commit 9cddc6e8ee9d9ce62dd20a6317c3148f4cd1c0e9) -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1766086 +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741782 Signed-off-by: Michal Privoznik -Message-Id: +Message-Id: Reviewed-by: Jiri Denemark --- src/conf/domain_conf.c | 6 +++--- @@ -30,7 +30,7 @@ Reviewed-by: Jiri Denemark 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 637d971e21..3bc603b48c 100644 +index 60f426df04..333d9836c1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8235,13 +8235,13 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED, @@ -49,7 +49,7 @@ index 637d971e21..3bc603b48c 100644 return def->controllers[i]; } -@@ -18565,7 +18565,7 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def) +@@ -18606,7 +18606,7 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def) * So let's grab the model from it and update the model we're * going to add as long as this one isn't undefined. The premise * being keeping the same controller model for all SCSI hostdevs. */ @@ -59,7 +59,7 @@ index 637d971e21..3bc603b48c 100644 newModel = cont->model; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 0989368e7c..934850b28d 100644 +index ef8f061ae2..5eb9b257a7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2866,7 +2866,7 @@ int virDomainDiskGetFormat(virDomainDiskDefPtr def); diff --git a/SOURCES/libvirt-domain_conf-Relax-SCSI-addr-used-check.patch b/SOURCES/libvirt-domain_conf-Relax-SCSI-addr-used-check.patch index 471b3d5..e79f4eb 100644 --- a/SOURCES/libvirt-domain_conf-Relax-SCSI-addr-used-check.patch +++ b/SOURCES/libvirt-domain_conf-Relax-SCSI-addr-used-check.patch @@ -1,7 +1,7 @@ -From 99a886eeddb5d208871d149e720b13365cc6d261 Mon Sep 17 00:00:00 2001 -Message-Id: <99a886eeddb5d208871d149e720b13365cc6d261@dist-git> +From dfc8270c27d1eaad36b85d6eab8f912b5bd7e334 Mon Sep 17 00:00:00 2001 +Message-Id: From: Michal Privoznik -Date: Mon, 28 Oct 2019 14:02:23 +0100 +Date: Thu, 24 Oct 2019 08:45:50 +0200 Subject: [PATCH] domain_conf: Relax SCSI addr used check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -22,23 +22,23 @@ Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrangé (cherry picked from commit c8007fdc5d2ce43fec2753cda60fb4963f55abd5) -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1766086 +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741782 I had to drop VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_TRANSITIONAL and VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL from virDomainSCSIDriveAddressIsUsed() because those don't exist in -RHEL-7.7 branch. +RHEL-7.8 branch. Signed-off-by: Michal Privoznik -Message-Id: <1408596266780329bf02f2537aeb4eae3aa589cf.1572267657.git.mprivozn@redhat.com> +Message-Id: <9e70aa28937fa3ea1bbeb792f848b2be2a6ae2e7.1571899509.git.mprivozn@redhat.com> Reviewed-by: Jiri Denemark --- src/conf/domain_conf.c | 49 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 3bc603b48c..f0e948d80a 100644 +index 333d9836c1..8bd527cfa1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4407,11 +4407,50 @@ bool diff --git a/SOURCES/libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch b/SOURCES/libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch index f6c26a4..3555b27 100644 --- a/SOURCES/libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch +++ b/SOURCES/libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch @@ -1,5 +1,5 @@ -From 8274ae3935c8ce7386320a76ac4f665372fad417 Mon Sep 17 00:00:00 2001 -Message-Id: <8274ae3935c8ce7386320a76ac4f665372fad417@dist-git> +From f05fe59ebbdfc07d738b393c18f951925dd3814d Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiang Kun Date: Mon, 20 Jan 2020 08:51:25 +0100 Subject: [PATCH] node_device_conf: Don't leak @physical_function in diff --git a/SOURCES/libvirt-nwfilter-Remove-redundant-check-if-object-exists.patch b/SOURCES/libvirt-nwfilter-Remove-redundant-check-if-object-exists.patch new file mode 100644 index 0000000..1faf408 --- /dev/null +++ b/SOURCES/libvirt-nwfilter-Remove-redundant-check-if-object-exists.patch @@ -0,0 +1,48 @@ +From fb8458440bb6c36a04400f83595da821dd445039 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Pavel Hrdina +Date: Fri, 29 Nov 2019 08:54:55 +0100 +Subject: [PATCH] nwfilter: Remove redundant check if object exists +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The same check is done by virNWFilterBindingObjListAdd(). The main +issue with the current code is that if the object already exists we +would leak 'def' because 'obj' would be set and the cleanup code frees +'def' only if 'obj' is NULL. + +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Pavel Hrdina +(cherry picked from commit 3379193f1c73a7be6bd797a3cf790e6960195d3a) + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1766475 + +Signed-off-by: Pavel Hrdina +Message-Id: <22531b7498d6fc2609c654d6efab9e5b2eac3819.1575014076.git.phrdina@redhat.com> +Reviewed-by: Ján Tomko +--- + src/nwfilter/nwfilter_driver.c | 7 ------- + 1 file changed, 7 deletions(-) + +diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c +index ed34586105..ac3a964388 100644 +--- a/src/nwfilter/nwfilter_driver.c ++++ b/src/nwfilter/nwfilter_driver.c +@@ -752,13 +752,6 @@ nwfilterBindingCreateXML(virConnectPtr conn, + if (virNWFilterBindingCreateXMLEnsureACL(conn, def) < 0) + goto cleanup; + +- obj = virNWFilterBindingObjListFindByPortDev(driver->bindings, def->portdevname); +- if (obj) { +- virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Filter already present for NIC %s"), def->portdevname); +- goto cleanup; +- } +- + obj = virNWFilterBindingObjListAdd(driver->bindings, + def); + if (!obj) +-- +2.24.0 + diff --git a/SOURCES/libvirt-process-wait-longer-5-30s-on-hard-shutdown.patch b/SOURCES/libvirt-process-wait-longer-5-30s-on-hard-shutdown.patch new file mode 100644 index 0000000..1fe1ddd --- /dev/null +++ b/SOURCES/libvirt-process-wait-longer-5-30s-on-hard-shutdown.patch @@ -0,0 +1,56 @@ +From 744c445c2b259649afd0f8c715e30d7ae51b35b0 Mon Sep 17 00:00:00 2001 +Message-Id: <744c445c2b259649afd0f8c715e30d7ae51b35b0@dist-git> +From: Christian Ehrhardt +Date: Wed, 4 Dec 2019 16:18:14 +0100 +Subject: [PATCH] process: wait longer 5->30s on hard shutdown +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +In cases where virProcessKillPainfully already reailizes that +SIGTERM wasn't enough we are partially on a bad path already. +Maybe the system is overloaded or having serious trouble to free and +reap resources in time. + +In those case give the SIGKILL that was sent after 10 seconds some more +time to take effect if force was set (only then we are falling back to +SIGKILL anyway). + +Signed-off-by: Christian Ehrhardt +Reviewed-by: Daniel P. Berrangé +(cherry picked from commit 9a4e4b942df0474503e7524ea427351a46c0eabe) + +https://bugzilla.redhat.com/show_bug.cgi?id=1771204 + +Signed-off-by: Ján Tomko +Message-Id: <963a2cb9ac181322394bc475b200b8fc65e1245a.1575472548.git.jtomko@redhat.com> +Reviewed-by: Andrea Bolognani +--- + src/util/virprocess.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/util/virprocess.c b/src/util/virprocess.c +index 297c96a8e5..1085e6cd5d 100644 +--- a/src/util/virprocess.c ++++ b/src/util/virprocess.c +@@ -354,7 +354,7 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay) + size_t i; + int ret = -1; + /* This is in 1/5th seconds since polling is on a 0.2s interval */ +- unsigned int polldelay = 75 + (extradelay*5); ++ unsigned int polldelay = (force ? 200 : 75) + (extradelay*5); + const char *signame = "TERM"; + + VIR_DEBUG("vpid=%lld force=%d extradelay=%u", +@@ -363,7 +363,7 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay) + /* This loop sends SIGTERM, then waits a few iterations (10 seconds) + * to see if it dies. If the process still hasn't exited, and + * @force is requested, a SIGKILL will be sent, and this will +- * wait up to 5 seconds more for the process to exit before ++ * wait up to 30 seconds more for the process to exit before + * returning. + * + * An extra delay can be passed by the caller for cases that are +-- +2.24.0 + diff --git a/SOURCES/libvirt-process-wait-longer-on-kill-per-assigned-Hostdev.patch b/SOURCES/libvirt-process-wait-longer-on-kill-per-assigned-Hostdev.patch new file mode 100644 index 0000000..a5515f7 --- /dev/null +++ b/SOURCES/libvirt-process-wait-longer-on-kill-per-assigned-Hostdev.patch @@ -0,0 +1,138 @@ +From 3e06f98a83d5f23c345a71e48115659a83f673b5 Mon Sep 17 00:00:00 2001 +Message-Id: <3e06f98a83d5f23c345a71e48115659a83f673b5@dist-git> +From: Christian Ehrhardt +Date: Wed, 4 Dec 2019 16:18:13 +0100 +Subject: [PATCH] process: wait longer on kill per assigned Hostdev +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +It was found that in cases with host devices virProcessKillPainfully +might be able to send signal zero to the target PID for quite a while +with the process already being gone from /proc/. + +That is due to cleanup and reset of devices which might include a +secondary bus reset that on top of the actions taken has a 1s delay +to let the bus settle. Due to that guests with plenty of Host devices +could easily exceed the default timeouts. + +To solve that, this adds an extra delay of 2s per hostdev that is associated +to a VM. + +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Christian Ehrhardt +(cherry picked from commit be2ca0444728edd12a000653d3693d68a5c9102f) + +https://bugzilla.redhat.com/show_bug.cgi?id=1771204 + +Signed-off-by: Ján Tomko +Message-Id: <6d18f7131fe022cb2ee4613ad4c58faefa9d574c.1575472548.git.jtomko@redhat.com> +Reviewed-by: Andrea Bolognani +--- + src/libvirt_private.syms | 1 + + src/qemu/qemu_process.c | 7 +++++-- + src/util/virprocess.c | 20 +++++++++++++++++--- + src/util/virprocess.h | 3 +++ + 4 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 53dbce7cfe..2a3950fd35 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -2623,6 +2623,7 @@ virProcessGetPids; + virProcessGetStartTime; + virProcessKill; + virProcessKillPainfully; ++virProcessKillPainfullyDelay; + virProcessNamespaceAvailable; + virProcessRunInMountNamespace; + virProcessSchedPolicyTypeFromString; +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index 0add197af5..d813c59c0d 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -6937,8 +6937,11 @@ qemuProcessKill(virDomainObjPtr vm, unsigned int flags) + return 0; + } + +- ret = virProcessKillPainfully(vm->pid, +- !!(flags & VIR_QEMU_PROCESS_KILL_FORCE)); ++ /* Request an extra delay of two seconds per current nhostdevs ++ * to be safe against stalls by the kernel freeing up the resources */ ++ ret = virProcessKillPainfullyDelay(vm->pid, ++ !!(flags & VIR_QEMU_PROCESS_KILL_FORCE), ++ vm->def->nhostdevs * 2); + + return ret; + } +diff --git a/src/util/virprocess.c b/src/util/virprocess.c +index f92b0dce37..297c96a8e5 100644 +--- a/src/util/virprocess.c ++++ b/src/util/virprocess.c +@@ -344,15 +344,21 @@ int virProcessKill(pid_t pid, int sig) + * Returns 0 if it was killed gracefully, 1 if it + * was killed forcibly, -1 if it is still alive, + * or another error occurred. ++ * ++ * Callers can proide an extra delay in seconds to ++ * wait longer than the default. + */ + int +-virProcessKillPainfully(pid_t pid, bool force) ++virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay) + { + size_t i; + int ret = -1; ++ /* This is in 1/5th seconds since polling is on a 0.2s interval */ ++ unsigned int polldelay = 75 + (extradelay*5); + const char *signame = "TERM"; + +- VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force); ++ VIR_DEBUG("vpid=%lld force=%d extradelay=%u", ++ (long long)pid, force, extradelay); + + /* This loop sends SIGTERM, then waits a few iterations (10 seconds) + * to see if it dies. If the process still hasn't exited, and +@@ -360,9 +366,12 @@ virProcessKillPainfully(pid_t pid, bool force) + * wait up to 5 seconds more for the process to exit before + * returning. + * ++ * An extra delay can be passed by the caller for cases that are ++ * expected to clean up slower than usual. ++ * + * Note that setting @force could result in dataloss for the process. + */ +- for (i = 0; i < 75; i++) { ++ for (i = 0; i < polldelay; i++) { + int signum; + if (i == 0) { + signum = SIGTERM; /* kindly suggest it should exit */ +@@ -405,6 +414,11 @@ virProcessKillPainfully(pid_t pid, bool force) + } + + ++int virProcessKillPainfully(pid_t pid, bool force) ++{ ++ return virProcessKillPainfullyDelay(pid, force, 0); ++} ++ + #if HAVE_SCHED_GETAFFINITY + + int virProcessSetAffinity(pid_t pid, virBitmapPtr map) +diff --git a/src/util/virprocess.h b/src/util/virprocess.h +index 3c5a882772..5faa0892fe 100644 +--- a/src/util/virprocess.h ++++ b/src/util/virprocess.h +@@ -55,6 +55,9 @@ virProcessWait(pid_t pid, int *exitstatus, bool raw) + int virProcessKill(pid_t pid, int sig); + + int virProcessKillPainfully(pid_t pid, bool force); ++int virProcessKillPainfullyDelay(pid_t pid, ++ bool force, ++ unsigned int extradelay); + + int virProcessSetAffinity(pid_t pid, virBitmapPtr map); + +-- +2.24.0 + diff --git a/SOURCES/libvirt-qemu-Allow-skipping-some-errors-in-qemuDomainStorageOpenStat.patch b/SOURCES/libvirt-qemu-Allow-skipping-some-errors-in-qemuDomainStorageOpenStat.patch new file mode 100644 index 0000000..746f997 --- /dev/null +++ b/SOURCES/libvirt-qemu-Allow-skipping-some-errors-in-qemuDomainStorageOpenStat.patch @@ -0,0 +1,112 @@ +From d108926463da19a2b025c845c60cfd78da850291 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:54 +0200 +Subject: [PATCH] qemu: Allow skipping some errors in qemuDomainStorageOpenStat +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Some callers of this function actually don't care about errors and reset +it. The message is still logged which might irritate users in this case. + +Add a boolean flag which will do few checks whether it actually makes +sense to even try opening the storage file. For local files we check +whether it exists and for remote files we at first see whether we even +have a storage driver backend for it in the first place before trying to +open it. + +Other problems will still report errors but these are the most common +scenarios which can happen here. + +This patch changes the return value of the function so that the caller +is able to differentiate the possibilities. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit ba6c12df2ceb4df9bfb7ce95deef04f96bf29462) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_driver.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 8ecdcf3440..91eeb05319 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -11778,6 +11778,7 @@ qemuDomainMemoryPeek(virDomainPtr dom, + * @src: storage source data + * @ret_fd: pointer to return open'd file descriptor + * @ret_sb: pointer to return stat buffer (local or remote) ++ * @skipInaccessible: Don't report error if files are not accessible + * + * For local storage, open the file using qemuOpenFile and then use + * fstat() to grab the stat struct data for the caller. +@@ -11785,7 +11786,9 @@ qemuDomainMemoryPeek(virDomainPtr dom, + * For remote storage, attempt to access the file and grab the stat + * struct data if the remote connection supports it. + * +- * Returns 0 on success with @ret_fd and @ret_sb populated, -1 on failure ++ * Returns 1 if @src was successfully opened (@ret_fd and @ret_sb is populated), ++ * 0 if @src can't be opened and @skipInaccessible is true (no errors are ++ * reported) or -1 otherwise (errors are reported). + */ + static int + qemuDomainStorageOpenStat(virQEMUDriverPtr driver, +@@ -11793,9 +11796,13 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virStorageSourcePtr src, + int *ret_fd, +- struct stat *ret_sb) ++ struct stat *ret_sb, ++ bool skipInaccessible) + { + if (virStorageSourceIsLocalStorage(src)) { ++ if (skipInaccessible && !virFileExists(src->path)) ++ return 0; ++ + if ((*ret_fd = qemuOpenFile(driver, vm, src->path, O_RDONLY, + NULL)) < 0) + return -1; +@@ -11806,6 +11813,9 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, + return -1; + } + } else { ++ if (skipInaccessible && virStorageFileSupportsBackingChainTraversal(src) <= 0) ++ return 0; ++ + if (virStorageFileInitAs(src, cfg->user, cfg->group) < 0) + return -1; + +@@ -11817,7 +11827,7 @@ qemuDomainStorageOpenStat(virQEMUDriverPtr driver, + } + } + +- return 0; ++ return 1; + } + + +@@ -11852,7 +11862,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, + if (virStorageSourceIsEmpty(src)) + return 0; + +- if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0) ++ if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0) + return -1; + + ret = virStorageSourceUpdatePhysicalSize(src, fd, &sb); +@@ -11903,7 +11913,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver, + char *buf = NULL; + ssize_t len; + +- if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb) < 0) ++ if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0) + goto cleanup; + + if (virStorageSourceIsLocalStorage(src)) { +-- +2.22.1 + diff --git a/SOURCES/libvirt-qemu-Allow-suppressing-errors-from-qemuStorageLimitsRefresh.patch b/SOURCES/libvirt-qemu-Allow-suppressing-errors-from-qemuStorageLimitsRefresh.patch new file mode 100644 index 0000000..84f6fd9 --- /dev/null +++ b/SOURCES/libvirt-qemu-Allow-suppressing-errors-from-qemuStorageLimitsRefresh.patch @@ -0,0 +1,99 @@ +From 829716665e195f34e484c1aec691a02d5035ae3a Mon Sep 17 00:00:00 2001 +Message-Id: <829716665e195f34e484c1aec691a02d5035ae3a@dist-git> +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:57 +0200 +Subject: [PATCH] qemu: Allow suppressing errors from qemuStorageLimitsRefresh +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +qemuStorageLimitsRefresh uses qemuDomainStorageOpenStat internally and +there are callers which don't care about the error. Propagate the +skipInaccessible flag so that we can log less errors. + +Callers currently don't care about the return value change. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit ea26e22f94cea989b566e13e1930d76e06baf2c9) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_driver.c | 20 +++++++++++++------- + 1 file changed, 13 insertions(+), 7 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 72c75e308b..88a9f565c4 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -11894,6 +11894,7 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, + * @cfg: driver configuration data + * @vm: domain object + * @src: storage source data ++ * @skipInaccessible: Suppress reporting of common errors when accessing @src + * + * Refresh the capacity and allocation limits of a given storage source. + * +@@ -11915,22 +11916,27 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, + * is sparse, but the amount of sparseness changes due to writes or + * punching holes), and physical size of a non-raw file can change. + * +- * Returns 0 on success, -1 on failure ++ * Returns 1 if @src was successfully updated, 0 if @src can't be opened and ++ * @skipInaccessible is true (no errors are reported) or -1 otherwise (errors ++ * are reported). + */ + static int + qemuStorageLimitsRefresh(virQEMUDriverPtr driver, + virQEMUDriverConfigPtr cfg, + virDomainObjPtr vm, +- virStorageSourcePtr src) ++ virStorageSourcePtr src, ++ bool skipInaccessible) + { ++ int rc; + int ret = -1; + int fd = -1; + struct stat sb; + char *buf = NULL; + ssize_t len; + +- if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0) +- goto cleanup; ++ if ((rc = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, ++ skipInaccessible)) <= 0) ++ return rc; + + if (virStorageSourceIsLocalStorage(src)) { + if ((len = virFileReadHeaderFD(fd, VIR_STORAGE_MAX_HEADER, &buf)) < 0) { +@@ -11958,7 +11964,7 @@ qemuStorageLimitsRefresh(virQEMUDriverPtr driver, + S_ISBLK(sb.st_mode)) + src->allocation = 0; + +- ret = 0; ++ ret = 1; + + cleanup: + VIR_FREE(buf); +@@ -12011,7 +12017,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom, + + /* for inactive domains we have to peek into the files */ + if (!virDomainObjIsActive(vm)) { +- if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src)) < 0) ++ if ((qemuStorageLimitsRefresh(driver, cfg, vm, disk->src, false)) < 0) + goto endjob; + + info->capacity = disk->src->capacity; +@@ -20029,7 +20035,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver, + if (virStorageSourceIsEmpty(src)) + return 0; + +- if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) { ++ if (qemuStorageLimitsRefresh(driver, cfg, dom, src, false) < 0) { + virResetLastError(); + return 0; + } +-- +2.22.1 + diff --git a/SOURCES/libvirt-qemu-Don-t-emit-SUSPENDED_POSTCOPY-event-on-destination.patch b/SOURCES/libvirt-qemu-Don-t-emit-SUSPENDED_POSTCOPY-event-on-destination.patch new file mode 100644 index 0000000..26f7c77 --- /dev/null +++ b/SOURCES/libvirt-qemu-Don-t-emit-SUSPENDED_POSTCOPY-event-on-destination.patch @@ -0,0 +1,53 @@ +From 1099f7c0e8741dd232d0f4568d2925cd791c6b69 Mon Sep 17 00:00:00 2001 +Message-Id: <1099f7c0e8741dd232d0f4568d2925cd791c6b69@dist-git> +From: Jiri Denemark +Date: Thu, 16 Jan 2020 19:57:53 +0100 +Subject: [PATCH] qemu: Don't emit SUSPENDED_POSTCOPY event on destination +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When pause-before-switchover QEMU capability is enabled, we get STOP +event before MIGRATION event with postcopy-active state. To properly +handle post-copy migration and emit correct events commit +v4.10.0-rc1-4-geca9d21e6c added a hack to +qemuProcessHandleMigrationStatus which translates the paused state +reason to VIR_DOMAIN_PAUSED_POSTCOPY and emits +VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY event when migration state changes +to post-copy. + +However, the code was effective on both sides of migration resulting in +a confusing VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY event on the destination +host, where entering post-copy mode is already properly advertised by +VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event. + +https://bugzilla.redhat.com/show_bug.cgi?id=1791458 + +Signed-off-by: Jiri Denemark +Reviewed-by: Ján Tomko +(cherry picked from commit bd04d63ad97c21b6955710e6473a502f49816a3c) + +https://bugzilla.redhat.com/show_bug.cgi?id=1791886 + +Signed-off-by: Jiri Denemark +Message-Id: <9b32d5af0dd1d3bf7108abc426dc4d6ceeaa84f8.1579193220.git.jdenemar@redhat.com> +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_process.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index d813c59c0d..7a7fc8f205 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -1546,6 +1546,7 @@ qemuProcessHandleMigrationStatus(qemuMonitorPtr mon ATTRIBUTE_UNUSED, + virDomainObjBroadcast(vm); + + if (status == QEMU_MONITOR_MIGRATION_STATUS_POSTCOPY && ++ priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT && + virDomainObjGetState(vm, &reason) == VIR_DOMAIN_PAUSED && + reason == VIR_DOMAIN_PAUSED_MIGRATION) { + VIR_DEBUG("Correcting paused state reason for domain %s to %s", +-- +2.25.0 + diff --git a/SOURCES/libvirt-qemu-Don-t-report-some-ignored-errors-in-qemuDomainGetStatsOneBlockFallback.patch b/SOURCES/libvirt-qemu-Don-t-report-some-ignored-errors-in-qemuDomainGetStatsOneBlockFallback.patch new file mode 100644 index 0000000..8eaba5d --- /dev/null +++ b/SOURCES/libvirt-qemu-Don-t-report-some-ignored-errors-in-qemuDomainGetStatsOneBlockFallback.patch @@ -0,0 +1,40 @@ +From 9fba5e8ed9e58e65e2e043e39eea5c9792df64df Mon Sep 17 00:00:00 2001 +Message-Id: <9fba5e8ed9e58e65e2e043e39eea5c9792df64df@dist-git> +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:58 +0200 +Subject: [PATCH] qemu: Don't report some ignored errors in + qemuDomainGetStatsOneBlockFallback +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function ignores all errors from qemuStorageLimitsRefresh by calling +virResetLastError. This still logs them. Since qemuStorageLimitsRefresh +allows suppressing some, do so. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 60b862cf9d6a335db65bbf2b011499dfa729ca2e) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: <8d6542c54e9518384b1c1eca081edae31a74fed6.1565958906.git.pkrempa@redhat.com> +Reviewed-by: Ján Tomko +--- + 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 88a9f565c4..d95c97928d 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -20035,7 +20035,7 @@ qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver, + if (virStorageSourceIsEmpty(src)) + return 0; + +- if (qemuStorageLimitsRefresh(driver, cfg, dom, src, false) < 0) { ++ if (qemuStorageLimitsRefresh(driver, cfg, dom, src, true) <= 0) { + virResetLastError(); + return 0; + } +-- +2.22.1 + diff --git a/SOURCES/libvirt-qemu-Fix-crash-on-incoming-migration.patch b/SOURCES/libvirt-qemu-Fix-crash-on-incoming-migration.patch index be2a6e5..ccf9675 100644 --- a/SOURCES/libvirt-qemu-Fix-crash-on-incoming-migration.patch +++ b/SOURCES/libvirt-qemu-Fix-crash-on-incoming-migration.patch @@ -1,5 +1,5 @@ -From f8aa84166ddd8a603cce1ec02ff7630e78bb1a9b Mon Sep 17 00:00:00 2001 -Message-Id: +From 843c097b76de7b49feca15e35189419ecb184cae Mon Sep 17 00:00:00 2001 +Message-Id: <843c097b76de7b49feca15e35189419ecb184cae@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:37 +0200 Subject: [PATCH] qemu: Fix crash on incoming migration @@ -18,7 +18,6 @@ Reviewed-by: Erik Skultety (cherry picked from commit 69b1ecde25aef6545cc077fe3c92ba19f1623828) https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <7e7b2059ff2bcbc082c3fdd8f6723b1771db289b.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch b/SOURCES/libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch index f31dbd4..d02ac6d 100644 --- a/SOURCES/libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch +++ b/SOURCES/libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch @@ -1,7 +1,7 @@ -From c7c9c9aba8445df4dcdf46e67860d4ab1ee6cf6b Mon Sep 17 00:00:00 2001 -Message-Id: +From 29a17260cc1875640e62f63bfe7fa9661dc9fe70 Mon Sep 17 00:00:00 2001 +Message-Id: <29a17260cc1875640e62f63bfe7fa9661dc9fe70@dist-git> From: Michal Privoznik -Date: Fri, 22 Nov 2019 16:43:59 +0100 +Date: Wed, 20 Nov 2019 14:34:11 +0100 Subject: [PATCH] qemu: Forcibly mknod() even if it exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 @@ -30,24 +30,23 @@ namespace. We do plain mknod() and ignore EEXIST which obviously is not enough because it doesn't guarantee that the node has updated MAJ:MIN pair. +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1752978 + Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrangé (cherry picked from commit cdd8a6690ee3fa4b4b8ca1d4531924bd33be136a) - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1775680 - Signed-off-by: Michal Privoznik -Message-Id: +Message-Id: <058a9025fdcb817d3334e6c5a7c6a4fe1e95e761.1574256841.git.mprivozn@redhat.com> Reviewed-by: Jiri Denemark --- src/qemu/qemu_domain.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 249ec4d259..f2ff610750 100644 +index e7d7a3baeb..3c67769771 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c -@@ -11111,16 +11111,14 @@ qemuDomainCreateDeviceRecursive(const char *device, +@@ -11191,16 +11191,14 @@ qemuDomainCreateDeviceRecursive(const char *device, allow_noent, ttl - 1) < 0) goto cleanup; } else if (isDev) { @@ -68,7 +67,7 @@ index 249ec4d259..f2ff610750 100644 } } else if (isReg) { if (create && -@@ -11889,17 +11887,12 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED, +@@ -11969,17 +11967,12 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED, } else if (isDev) { VIR_DEBUG("Creating dev %s (%d,%d)", data->file, major(data->sb.st_rdev), minor(data->sb.st_rdev)); diff --git a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch index 7df7726..d798f43 100644 --- a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch +++ b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch @@ -1,5 +1,5 @@ -From bdb0a40645dc91fe4fea4327634e118cc22c3c1c Mon Sep 17 00:00:00 2001 -Message-Id: +From 04780ba930ff77532ed56d3b41bde0aa6cd5caee Mon Sep 17 00:00:00 2001 +Message-Id: <04780ba930ff77532ed56d3b41bde0aa6cd5caee@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:33 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefCopy @@ -37,7 +37,6 @@ Conflicts: - uml driver was removed upstream https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: diff --git a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch index 1d3fb94..272a0cd 100644 --- a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch +++ b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch @@ -1,5 +1,5 @@ -From d563ed75402973b6df254268c17b93edbbaee651 Mon Sep 17 00:00:00 2001 -Message-Id: +From 8f8cc927a643f9bd02ff37f0fe6167e44359fb12 Mon Sep 17 00:00:00 2001 +Message-Id: <8f8cc927a643f9bd02ff37f0fe6167e44359fb12@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:35 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefParseNode @@ -41,7 +41,6 @@ Conflicts: - snapshot parsing APIs do not have bool *current parameter https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: @@ -244,7 +243,7 @@ index 664650f217..46d2b7afa3 100644 VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE); if (!def) { diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c -index 5ea0f325de..061da9fbca 100644 +index 2b594e626c..a4e31de811 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -96,7 +96,7 @@ testCompareXMLToXMLFiles(const char *inxml, diff --git a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch index c54782b..5d7a960 100644 --- a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch +++ b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch @@ -1,5 +1,5 @@ -From 05516528f7ef69e84eb3edc8a00bc9fba44ea538 Mon Sep 17 00:00:00 2001 -Message-Id: <05516528f7ef69e84eb3edc8a00bc9fba44ea538@dist-git> +From 6390ac69fb3686455e81c562c5cd319ed02ac2aa Mon Sep 17 00:00:00 2001 +Message-Id: <6390ac69fb3686455e81c562c5cd319ed02ac2aa@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:31 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefParseString @@ -27,7 +27,6 @@ Conflicts: - no checkpoint APIs https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <2728b24106e1e361cf9766ea8f9eeec782df6b20.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch index 6bc638e..641d2ec 100644 --- a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch +++ b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch @@ -1,5 +1,5 @@ -From f5bfc6725c28833ee0e4cb202e33507cd24ac089 Mon Sep 17 00:00:00 2001 -Message-Id: +From c6dcec2dc7cb4060850587a0e5f9f90c4c2b3a95 Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:34 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDefPostParse @@ -26,7 +26,6 @@ Conflicts: - context https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <816c373facf7f779dc22d8a8e6e382cadf5cc2b7.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch index 3d2bc15..62a84a8 100644 --- a/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch +++ b/SOURCES/libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch @@ -1,5 +1,5 @@ -From 9ca9c90ecfc021f735769307253319a730bc2565 Mon Sep 17 00:00:00 2001 -Message-Id: <9ca9c90ecfc021f735769307253319a730bc2565@dist-git> +From 9b636a691bab67fbce7455501e0b1a9036a56643 Mon Sep 17 00:00:00 2001 +Message-Id: <9b636a691bab67fbce7455501e0b1a9036a56643@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:36 +0200 Subject: [PATCH] qemu: Pass correct qemuCaps to virDomainDeviceDefPostParse @@ -39,7 +39,6 @@ Conflicts: - uml driver was removed upstream https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <26b6c56b3da907b14e201b23bec6164037151fb6.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch index 0995015..d3c3287 100644 --- a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch +++ b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch @@ -1,5 +1,5 @@ -From 7a3e5357cdd44f372dc8020395bdfd818d3453ed Mon Sep 17 00:00:00 2001 -Message-Id: <7a3e5357cdd44f372dc8020395bdfd818d3453ed@dist-git> +From 317ea40b7e1bedecfad0fca4d9d314e41d1f2819 Mon Sep 17 00:00:00 2001 +Message-Id: <317ea40b7e1bedecfad0fca4d9d314e41d1f2819@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:27 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuDomainDefCopy @@ -26,7 +26,6 @@ Conflicts: - context https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <6ecee413894eadadaf37884be7dd4136ad2de403.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch index f193446..da8733f 100644 --- a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch +++ b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch @@ -1,5 +1,5 @@ -From 0379563f7961e019ceef28ed28e56bb24f78d778 Mon Sep 17 00:00:00 2001 -Message-Id: <0379563f7961e019ceef28ed28e56bb24f78d778@dist-git> +From f901375a7380837428cbbc80d24e4bb7b91db427 Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:28 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuDomainDefFormatBufInternal @@ -28,7 +28,6 @@ Conflicts: - ProcessAttach and XMLFromNative APIs were removed upstream https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: diff --git a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch index 2b3871e..92b3783 100644 --- a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch +++ b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch @@ -1,5 +1,5 @@ -From b0e155481dd03971fe3d24b9abbe3cdf0e2373c4 Mon Sep 17 00:00:00 2001 -Message-Id: +From a6af039d4a7810cbc4f00018acc7a7fa0b8d304e Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:29 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuDomainSaveImageOpen @@ -22,7 +22,6 @@ Reviewed-by: Michal Privoznik (cherry picked from commit fd60aefec7f49d1053efdd5119db494bb474aeec) https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <6206f14c127037e0822fb6c1e04e8f2d8e6069ce.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch index 088d279..e63d8e6 100644 --- a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch +++ b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch @@ -1,5 +1,5 @@ -From 54ca487f3777497fb419884d187bf2be00ed60f1 Mon Sep 17 00:00:00 2001 -Message-Id: <54ca487f3777497fb419884d187bf2be00ed60f1@dist-git> +From ff519677375acb8592f88c3a17f62b3aee07431e Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:30 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef @@ -22,7 +22,6 @@ Reviewed-by: Michal Privoznik (cherry picked from commit b900f7387fca1cf3567935c81136579d6bee95ca) https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: <9c8ee8580063e52b001b969a2fbb1f1cc3ebfc37.1565959866.git.jdenemar@redhat.com> diff --git a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch index d50d577..31276d8 100644 --- a/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch +++ b/SOURCES/libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch @@ -1,5 +1,5 @@ -From 2178a6fc22688ff6c6464593823f11ead8cbe981 Mon Sep 17 00:00:00 2001 -Message-Id: <2178a6fc22688ff6c6464593823f11ead8cbe981@dist-git> +From 67d392063da158ac25b350fa5f7c4d17c1ea7c79 Mon Sep 17 00:00:00 2001 +Message-Id: <67d392063da158ac25b350fa5f7c4d17c1ea7c79@dist-git> From: Jiri Denemark Date: Fri, 16 Aug 2019 14:52:32 +0200 Subject: [PATCH] qemu: Pass qemuCaps to qemuMigrationCookieXMLParse @@ -22,7 +22,6 @@ Reviewed-by: Michal Privoznik (cherry picked from commit bf15b145ec473c0ca5bfe8aee2bf0eb1691b6f1c) https://bugzilla.redhat.com/show_bug.cgi?id=1731783 -https://bugzilla.redhat.com/show_bug.cgi?id=1742023 Signed-off-by: Jiri Denemark Message-Id: diff --git a/SOURCES/libvirt-qemu-Prefer-nvdimmPath-over-hugepages-for-memory-backend-file.patch b/SOURCES/libvirt-qemu-Prefer-nvdimmPath-over-hugepages-for-memory-backend-file.patch new file mode 100644 index 0000000..2c89531 --- /dev/null +++ b/SOURCES/libvirt-qemu-Prefer-nvdimmPath-over-hugepages-for-memory-backend-file.patch @@ -0,0 +1,187 @@ +From 52c101b96262131e4ed94aacff24f826db7302c4 Mon Sep 17 00:00:00 2001 +Message-Id: <52c101b96262131e4ed94aacff24f826db7302c4@dist-git> +From: Michal Privoznik +Date: Fri, 28 Jun 2019 17:12:41 +0200 +Subject: [PATCH] qemu: Prefer nvdimmPath over hugepages for + memory-backend-file +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If a domain has hugepages configured and we're currently building +memory-backend-file for a nvdimm device that domain has we will +put hugepages path onto the command line. It should have been +nvdimm path configured in the XML. + +Signed-off-by: Michal Privoznik +Reviewed-by: Pavel Hrdina +(cherry picked from commit 9eae8398edde9446ecc99f4f393bea94652fb6a2) + +https://bugzilla.redhat.com/show_bug.cgi?id=1724980 + +Signed-off-by: Michal Privoznik +Message-Id: <349f7180359c4b9e447602a760f639b7030d9c57.1561734747.git.mprivozn@redhat.com> +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_command.c | 8 ++-- + .../hugepages-nvdimm.x86_64-latest.args | 35 ++++++++++++++ + tests/qemuxml2argvdata/hugepages-nvdimm.xml | 48 +++++++++++++++++++ + tests/qemuxml2argvtest.c | 1 + + tests/qemuxml2xmloutdata/hugepages-nvdimm.xml | 1 + + tests/qemuxml2xmltest.c | 1 + + 6 files changed, 90 insertions(+), 4 deletions(-) + create mode 100644 tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args + create mode 100644 tests/qemuxml2argvdata/hugepages-nvdimm.xml + create mode 120000 tests/qemuxml2xmloutdata/hugepages-nvdimm.xml + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 929f549a69..08660abbe4 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -3113,12 +3113,12 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps, + if (useHugepage || mem->nvdimmPath || memAccess || + def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) { + +- if (useHugepage) { +- if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0) ++ if (mem->nvdimmPath) { ++ if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0) + goto cleanup; + prealloc = true; +- } else if (mem->nvdimmPath) { +- if (VIR_STRDUP(memPath, mem->nvdimmPath) < 0) ++ } else if (useHugepage) { ++ if (qemuGetDomainHupageMemPath(def, cfg, pagesize, &memPath) < 0) + goto cleanup; + prealloc = true; + } else { +diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args +new file mode 100644 +index 0000000000..bc3e64948a +--- /dev/null ++++ b/tests/qemuxml2argvdata/hugepages-nvdimm.x86_64-latest.args +@@ -0,0 +1,35 @@ ++LC_ALL=C \ ++PATH=/bin \ ++HOME=/home/test \ ++USER=test \ ++LOGNAME=test \ ++QEMU_AUDIO_DRV=none \ ++/usr/bin/qemu-system-i686 \ ++-name guest=QEMUGuest1,debug-threads=on \ ++-S \ ++-object secret,id=masterKey0,format=raw,\ ++file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ ++-machine pc,accel=tcg,usb=off,dump-guest-core=off,nvdimm=on \ ++-m size=1048576k,slots=16,maxmem=1099511627776k \ ++-realtime mlock=off \ ++-smp 2,sockets=2,cores=1,threads=1 \ ++-object memory-backend-file,id=ram-node0,prealloc=yes,\ ++mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,share=yes,size=1073741824 \ ++-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \ ++-object memory-backend-file,id=memnvdimm0,prealloc=yes,mem-path=/tmp/nvdimm,\ ++share=yes,size=536870912 \ ++-device nvdimm,node=0,memdev=memnvdimm0,id=nvdimm0,slot=0 \ ++-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ ++-display none \ ++-no-user-config \ ++-nodefaults \ ++-chardev socket,id=charmonitor,fd=1729,server,nowait \ ++-mon chardev=charmonitor,id=monitor,mode=control \ ++-rtc base=utc \ ++-no-shutdown \ ++-no-acpi \ ++-boot strict=on \ ++-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ ++-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\ ++resourcecontrol=deny \ ++-msg timestamp=on +diff --git a/tests/qemuxml2argvdata/hugepages-nvdimm.xml b/tests/qemuxml2argvdata/hugepages-nvdimm.xml +new file mode 100644 +index 0000000000..babb3a6179 +--- /dev/null ++++ b/tests/qemuxml2argvdata/hugepages-nvdimm.xml +@@ -0,0 +1,48 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 1099511627776 ++ 1267710 ++ 1267710 ++ ++ ++ ++ ++ ++ ++ 2 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu-system-i686 ++ ++
++ ++ ++ ++ ++ ++ ++ ++ /tmp/nvdimm ++ ++ ++ 523264 ++ 0 ++ ++
++ ++ ++ +diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c +index 9933e4bde1..6c09c6bb4a 100644 +--- a/tests/qemuxml2argvtest.c ++++ b/tests/qemuxml2argvtest.c +@@ -994,6 +994,7 @@ mymain(void) + DO_TEST_FAILURE("hugepages-memaccess3", + QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE, + QEMU_CAPS_VIRTIO_SCSI); ++ DO_TEST_CAPS_LATEST("hugepages-nvdimm"); + DO_TEST("nosharepages", QEMU_CAPS_MEM_MERGE); + DO_TEST("disk-cdrom", NONE); + DO_TEST("disk-iscsi", NONE); +diff --git a/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml b/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml +new file mode 120000 +index 0000000000..8288d3c58f +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/hugepages-nvdimm.xml +@@ -0,0 +1 @@ ++../qemuxml2argvdata/hugepages-nvdimm.xml +\ No newline at end of file +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index 1f67d74797..341b7cbcc6 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -344,6 +344,7 @@ mymain(void) + DO_TEST("hugepages-shared", NONE); + DO_TEST("hugepages-memaccess", NONE); + DO_TEST("hugepages-memaccess2", NONE); ++ DO_TEST("hugepages-nvdimm", NONE); + DO_TEST("nosharepages", NONE); + DO_TEST("restore-v2", NONE); + DO_TEST("migrate", NONE); +-- +2.22.1 + diff --git a/SOURCES/libvirt-qemu-call-common-NetDef-validation-for-hotplug-and-device-update.patch b/SOURCES/libvirt-qemu-call-common-NetDef-validation-for-hotplug-and-device-update.patch new file mode 100644 index 0000000..219280a --- /dev/null +++ b/SOURCES/libvirt-qemu-call-common-NetDef-validation-for-hotplug-and-device-update.patch @@ -0,0 +1,91 @@ +From 1b3ded7e3b24f927a7941178e2bb75d1d8052c3f Mon Sep 17 00:00:00 2001 +Message-Id: <1b3ded7e3b24f927a7941178e2bb75d1d8052c3f@dist-git> +From: Laine Stump +Date: Mon, 16 Sep 2019 09:54:06 -0400 +Subject: [PATCH] qemu: call common NetDef validation for hotplug and device + update +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +qemuDomainAttachNetDevice() (hotplug) previously had some of the +validation that is in qemuDomainValidateActualNetDef(), but it was +incomplete. qemuDomainChangeNet() had none of that validation, but it +is all appropriate in both cases. + +This is the final piece of a previously partial resolution to +https://bugzilla.redhat.com/1502754 + +Signed-off-by: Laine Stump +Reviewed-by: Michal Privoznik +(cherry picked from commit 70a29b378a397f6f4571c95b9d3cbba711a90859) + +Signed-off-by: Laine Stump +Message-Id: <20190916135406.18523-4-laine@redhat.com> +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_hotplug.c | 32 ++++++++------------------------ + 1 file changed, 8 insertions(+), 24 deletions(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index ca8b0aaf62..3b888e31b9 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -848,32 +848,11 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + if (virDomainNetAllocateActualDevice(vm->def, net) < 0) + goto cleanup; + +- actualType = virDomainNetGetActualType(net); +- +- /* Currently only TAP/macvtap devices supports multiqueue. */ +- if (net->driver.virtio.queues > 0 && +- !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_DIRECT || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || +- actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Multiqueue network is not supported for: %s"), +- virDomainNetTypeToString(actualType)); ++ /* final validation now that we have full info on the type */ ++ if (qemuDomainValidateActualNetDef(net, priv->qemuCaps) < 0) + return -1; +- } + +- /* and only TAP devices support nwfilter rules */ +- if (net->filter && +- !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("filterref is not supported for " +- "network interfaces of type %s"), +- virDomainNetTypeToString(actualType)); +- return -1; +- } ++ actualType = virDomainNetGetActualType(net); + + if (qemuAssignDeviceNetAlias(vm->def, net, -1) < 0) + goto cleanup; +@@ -3154,6 +3133,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, + virDomainObjPtr vm, + virDomainDeviceDefPtr dev) + { ++ qemuDomainObjPrivatePtr priv = vm->privateData; + virDomainNetDefPtr newdev = dev->data.net; + virDomainNetDefPtr *devslot = NULL; + virDomainNetDefPtr olddev; +@@ -3333,6 +3313,10 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, + goto cleanup; + } + ++ /* final validation now that we have full info on the type */ ++ if (qemuDomainValidateActualNetDef(newdev, priv->qemuCaps) < 0) ++ goto cleanup; ++ + newType = virDomainNetGetActualType(newdev); + + if (newType == VIR_DOMAIN_NET_TYPE_HOSTDEV) { +-- +2.23.0 + diff --git a/SOURCES/libvirt-qemu-driver-Improve-error-suppression-in-qemuDomainStorageUpdatePhysical.patch b/SOURCES/libvirt-qemu-driver-Improve-error-suppression-in-qemuDomainStorageUpdatePhysical.patch new file mode 100644 index 0000000..e934074 --- /dev/null +++ b/SOURCES/libvirt-qemu-driver-Improve-error-suppression-in-qemuDomainStorageUpdatePhysical.patch @@ -0,0 +1,89 @@ +From 2c1a60343710fc11a5c8bcfd022fd2a8aa6681ff Mon Sep 17 00:00:00 2001 +Message-Id: <2c1a60343710fc11a5c8bcfd022fd2a8aa6681ff@dist-git> +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:56 +0200 +Subject: [PATCH] qemu: driver: Improve error suppression in + qemuDomainStorageUpdatePhysical +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +None of the callers of qemuDomainStorageUpdatePhysical care about +errors. + +Use the new flag for qemuDomainStorageOpenStat which suppresses some +errors and move the reset of the rest of the uncommon errors into this +function. Document what is happening in a comment for the function. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 3d7ea4165b890880f43074e1e5e6e10bf0ad21d6) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: <65325f9c156ebab937b81e89c9bfe6c1b6d8251b.1565958905.git.pkrempa@redhat.com> +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_driver.c | 24 ++++++++++++++++++------ + 1 file changed, 18 insertions(+), 6 deletions(-) + +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 91eeb05319..72c75e308b 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -11849,6 +11849,19 @@ qemuDomainStorageCloseStat(virStorageSourcePtr src, + } + + ++/** ++ * qemuDomainStorageUpdatePhysical: ++ * @driver: qemu driver ++ * @cfg: qemu driver configuration object ++ * @vm: domain object ++ * @src: storage source to update ++ * ++ * Update the physical size of the disk by reading the actual size of the image ++ * on disk. ++ * ++ * Returns 0 on successful update and -1 otherwise (some uncommon errors may be ++ * reported but are reset (thus only logged)). ++ */ + static int + qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, + virQEMUDriverConfigPtr cfg, +@@ -11862,8 +11875,11 @@ qemuDomainStorageUpdatePhysical(virQEMUDriverPtr driver, + if (virStorageSourceIsEmpty(src)) + return 0; + +- if (qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, false) < 0) ++ if ((ret = qemuDomainStorageOpenStat(driver, cfg, vm, src, &fd, &sb, true)) <= 0) { ++ if (ret < 0) ++ virResetLastError(); + return -1; ++ } + + ret = virStorageSourceUpdatePhysicalSize(src, fd, &sb); + +@@ -12058,7 +12074,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom, + if (qemuDomainStorageUpdatePhysical(driver, cfg, vm, disk->src) == 0) { + info->physical = disk->src->physical; + } else { +- virResetLastError(); + info->physical = entry->physical; + } + } else { +@@ -20132,12 +20147,9 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver, + QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, + "physical", entry->physical); + } else { +- if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0) { ++ if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0) + QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx, + "physical", src->physical); +- } else { +- virResetLastError(); +- } + } + + if (qemuDomainGetStatsOneBlockNode(record, maxparams, src, block_idx, +-- +2.22.1 + diff --git a/SOURCES/libvirt-qemu-move-runtime-netdev-validation-into-a-separate-function.patch b/SOURCES/libvirt-qemu-move-runtime-netdev-validation-into-a-separate-function.patch new file mode 100644 index 0000000..cdd6609 --- /dev/null +++ b/SOURCES/libvirt-qemu-move-runtime-netdev-validation-into-a-separate-function.patch @@ -0,0 +1,215 @@ +From ac2be13722d4533246a4ec3bc37b07d6e3fc9882 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Laine Stump +Date: Mon, 16 Sep 2019 09:54:05 -0400 +Subject: [PATCH] qemu: move runtime netdev validation into a separate function +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The same validation should be done for both static network devices and +hotplugged devices, but they are currently inconsistent. Move all the +relevant validation from qemuBuildInterfaceCommandLine() into the new +function qemuDomainValidateActualNetDef() and call the latter from +the former. + +Signed-off-by: Laine Stump +Reviewed-by: Michal Privoznik +(cherry picked from commit 3cff23f7f16dc2b74d54f14b77790dc37df01ded) + + https://bugzilla.redhat.com/1502754 + +Conflicts: + * src/qemu/qemu_command.c - vhostuser check for queues > 1 was + moved upstream in commit 4de4e4bc9, so had to be removed from + the old location downstream. + + * src/qemu/qemu_domain.h - other functions were also added + +Signed-off-by: Laine Stump +Message-Id: <20190916135406.18523-3-laine@redhat.com> +Reviewed-by: Ján Tomko +--- + src/qemu/qemu_command.c | 52 +-------------------------- + src/qemu/qemu_domain.c | 80 +++++++++++++++++++++++++++++++++++++++++ + src/qemu/qemu_domain.h | 4 +++ + 3 files changed, 85 insertions(+), 51 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 08660abbe4..237f8878b9 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -8335,14 +8335,6 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + goto cleanup; + } + +- if (queues > 1 && +- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("multi-queue is not supported for vhost-user " +- "with this QEMU binary")); +- goto cleanup; +- } +- + if (!(netdev = qemuBuildHostNetStr(net, driver, + NULL, 0, NULL, 0))) + goto cleanup; +@@ -8404,50 +8396,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + if (!bootindex) + bootindex = net->info.bootIndex; + +- /* Currently nothing besides TAP devices supports multiqueue. */ +- if (net->driver.virtio.queues > 0 && +- !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_DIRECT || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || +- actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Multiqueue network is not supported for: %s"), +- virDomainNetTypeToString(actualType)); ++ if (qemuDomainValidateActualNetDef(net, qemuCaps) < 0) + return -1; +- } +- +- /* and only TAP devices support nwfilter rules */ +- if (net->filter) { +- virNetDevVPortProfilePtr vport = virDomainNetGetActualVirtPortProfile(net); +- if (!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("filterref is not supported for " +- "network interfaces of type %s"), +- virDomainNetTypeToString(actualType)); +- return -1; +- } +- if (vport && vport->virtPortType != VIR_NETDEV_VPORT_PROFILE_NONE) { +- /* currently none of the defined virtualport types support iptables */ +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("filterref is not supported for " +- "network interfaces with virtualport type %s"), +- virNetDevVPortTypeToString(vport->virtPortType)); +- return -1; +- } +- } +- +- if (net->backend.tap && +- !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || +- actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || +- actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Custom tap device path is not supported for: %s"), +- virDomainNetTypeToString(actualType)); +- return -1; +- } + + switch (actualType) { + case VIR_DOMAIN_NET_TYPE_NETWORK: +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 249ec4d259..e7d7a3baeb 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -4353,6 +4353,86 @@ qemuDomainWatchdogDefValidate(const virDomainWatchdogDef *dev, + } + + ++int ++qemuDomainValidateActualNetDef(const virDomainNetDef *net, ++ virQEMUCapsPtr qemuCaps) ++{ ++ /* ++ * Validations that can only be properly checked at runtime (after ++ * an has been resolved to its actual ++ * type. ++ * ++ * (In its current form this function can still be called before ++ * the actual type has been resolved (e.g. at domain definition ++ * time), but only if the validations would SUCCEED for ++ * type='network'.) ++ */ ++ virDomainNetType actualType = virDomainNetGetActualType(net); ++ ++ /* Only tap/macvtap devices support multiqueue. */ ++ if (net->driver.virtio.queues > 0) { ++ ++ if (!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || ++ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || ++ actualType == VIR_DOMAIN_NET_TYPE_DIRECT || ++ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET || ++ actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("multiqueue network is not supported for: %s"), ++ virDomainNetTypeToString(actualType)); ++ return -1; ++ } ++ ++ if (net->driver.virtio.queues > 1 && ++ actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER && ++ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("multiqueue network is not supported for vhost-user " ++ "with this QEMU binary")); ++ return -1; ++ } ++ } ++ ++ /* ++ * Only standard tap devices support nwfilter rules, and even then only ++ * when *not* connected to an OVS bridge or midonet (indicated by having ++ * a element in the config) ++ */ ++ if (net->filter) { ++ virNetDevVPortProfilePtr vport = virDomainNetGetActualVirtPortProfile(net); ++ if (!(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || ++ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || ++ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("filterref is not supported for " ++ "network interfaces of type %s"), ++ virDomainNetTypeToString(actualType)); ++ return -1; ++ } ++ if (vport && vport->virtPortType != VIR_NETDEV_VPORT_PROFILE_NONE) { ++ /* currently none of the defined virtualport types support iptables */ ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("filterref is not supported for " ++ "network interfaces with virtualport type %s"), ++ virNetDevVPortTypeToString(vport->virtPortType)); ++ return -1; ++ } ++ } ++ ++ if (net->backend.tap && ++ !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK || ++ actualType == VIR_DOMAIN_NET_TYPE_BRIDGE || ++ actualType == VIR_DOMAIN_NET_TYPE_ETHERNET)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Custom tap device path is not supported for: %s"), ++ virDomainNetTypeToString(actualType)); ++ return -1; ++ } ++ ++ return 0; ++} ++ ++ + static int + qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net) + { +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index 9546216f30..daed69e856 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -1074,4 +1074,8 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv); + virDomainEventResumedDetailType + qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); + ++int ++qemuDomainValidateActualNetDef(const virDomainNetDef *net, ++ virQEMUCapsPtr qemuCaps); ++ + #endif /* __QEMU_DOMAIN_H__ */ +-- +2.23.0 + diff --git a/SOURCES/libvirt-qemu_process-fix-starting-VMs-if-machine-group-has-limited-cpuset.cpus.patch b/SOURCES/libvirt-qemu_process-fix-starting-VMs-if-machine-group-has-limited-cpuset.cpus.patch new file mode 100644 index 0000000..2656a60 --- /dev/null +++ b/SOURCES/libvirt-qemu_process-fix-starting-VMs-if-machine-group-has-limited-cpuset.cpus.patch @@ -0,0 +1,72 @@ +From ba8699bf038f3fe588cc0e40bf484260c08e6f48 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Pavel Hrdina +Date: Mon, 25 Nov 2019 11:02:21 +0100 +Subject: [PATCH] qemu_process: fix starting VMs if machine group has limited + cpuset.cpus + +Commit reworked process +affinity setting but did not take cgroups into account which introduced +an issue when starting VM with custom cpuset.cpus for the whole machine +group. + +If the machine group is limited to some pCPUs libvirt should not try to +set a VM to run on all pCPUs as it will result in permission denied when +writing to cpuset.cpus. + +To fix this the affinity has to be set separately from cgroups cpuset. + +Resolves: + +Signed-off-by: Pavel Hrdina +Reviewed-by: Michal Privoznik +(cherry picked from commit 4c0398b5284d14c55eca51095673b6fadbbd85fb) + +Conflicts: + src/qemu/qemu_process.c - upstream commit that introduced this + issue was modified to not use VIR_AUTOFREE + +Signed-off-by: Pavel Hrdina +Message-Id: <86eec31e53a4d061e098919d145e6a89cc8740c4.1574676123.git.phrdina@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/qemu/qemu_process.c | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index 307098cd63..4a2864af27 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -2476,6 +2476,7 @@ qemuProcessSetupPid(virDomainObjPtr vm, + virDomainNumatuneMemMode mem_mode; + virCgroupPtr cgroup = NULL; + virBitmapPtr use_cpumask = NULL; ++ virBitmapPtr afinity_cpumask = NULL; + virBitmapPtr hostcpumap = NULL; + char *mem_mask = NULL; + int ret = -1; +@@ -2501,7 +2502,7 @@ qemuProcessSetupPid(virDomainObjPtr vm, + * its config file */ + if (qemuProcessGetAllCpuAffinity(&hostcpumap) < 0) + goto cleanup; +- use_cpumask = hostcpumap; ++ afinity_cpumask = hostcpumap; + } + + /* +@@ -2542,8 +2543,11 @@ qemuProcessSetupPid(virDomainObjPtr vm, + + } + ++ if (!afinity_cpumask) ++ afinity_cpumask = use_cpumask; ++ + /* Setup legacy affinity. */ +- if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0) ++ if (afinity_cpumask && virProcessSetAffinity(pid, afinity_cpumask) < 0) + goto cleanup; + + /* Set scheduler type and priority. */ +-- +2.24.0 + diff --git a/SOURCES/libvirt-test-Introduce-virnetdevopenvswitchtest.patch b/SOURCES/libvirt-test-Introduce-virnetdevopenvswitchtest.patch index 69a4dd0..7523ed0 100644 --- a/SOURCES/libvirt-test-Introduce-virnetdevopenvswitchtest.patch +++ b/SOURCES/libvirt-test-Introduce-virnetdevopenvswitchtest.patch @@ -1,5 +1,5 @@ -From 4654a9aba4691204f083d6742940437cca0d87b9 Mon Sep 17 00:00:00 2001 -Message-Id: <4654a9aba4691204f083d6742940437cca0d87b9@dist-git> +From b08e42e2ea6ba1366d9cb9b58fcca22c68b4281a Mon Sep 17 00:00:00 2001 +Message-Id: From: Michal Privoznik Date: Wed, 9 Oct 2019 14:27:42 +0200 Subject: [PATCH] test: Introduce virnetdevopenvswitchtest @@ -17,7 +17,6 @@ Reviewed-by: Ján Tomko (cherry picked from commit cc34260f5a8715d208ee45a6ebaa79e5264cbe68) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: @@ -36,10 +35,10 @@ Reviewed-by: Jiri Denemark create mode 100644 tests/virnetdevopenvswitchtest.c diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index bf99930802..ac34ea0290 100644 +index 1bc43293fd..53dbce7cfe 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms -@@ -2400,6 +2400,7 @@ virNetDevMidonetUnbindPort; +@@ -2401,6 +2401,7 @@ virNetDevMidonetUnbindPort; virNetDevOpenvswitchAddPort; virNetDevOpenvswitchGetMigrateData; virNetDevOpenvswitchGetVhostuserIfname; diff --git a/SOURCES/libvirt-tests-domainsnapshotxml2xml-make-disk-seclabel-test-operational.patch b/SOURCES/libvirt-tests-domainsnapshotxml2xml-make-disk-seclabel-test-operational.patch new file mode 100644 index 0000000..cb144e0 --- /dev/null +++ b/SOURCES/libvirt-tests-domainsnapshotxml2xml-make-disk-seclabel-test-operational.patch @@ -0,0 +1,64 @@ +From d2b1f0101b75663b8ae31adfb008bdf0b111e873 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Thu, 20 Jun 2019 17:45:03 +0200 +Subject: [PATCH] tests: domainsnapshotxml2xml: make 'disk-seclabel' test + operational + +Now that we added the seclabels to the schema we can test that they are +parsed and formatted correctly. + +Signed-off-by: Peter Krempa +Reviewed-by: Martin Kletzander +(cherry picked from commit 3203681e5e8513425acdf3f25d0981f5157f0ddf) + + Conflicts: +tests/domainsnapshotxml2xmltest.c: + - refactors to the testsuite (a10c6b300e9, 0ea43b55a40, ...) were not + backported. Test invocation needed to be changed. + +https: //bugzilla.redhat.com/show_bug.cgi?id=1584682 +Message-Id: <9e8368c18a7b3746dcc750953170771f49453afc.1561045343.git.pkrempa@redhat.com> +Reviewed-by: Jiri Denemark +--- + tests/domainsnapshotxml2xmlout/disk-seclabel.xml | 15 +++++++++++++++ + tests/domainsnapshotxml2xmltest.c | 1 + + 2 files changed, 16 insertions(+) + create mode 100644 tests/domainsnapshotxml2xmlout/disk-seclabel.xml + +diff --git a/tests/domainsnapshotxml2xmlout/disk-seclabel.xml b/tests/domainsnapshotxml2xmlout/disk-seclabel.xml +new file mode 100644 +index 0000000000..989cfc4964 +--- /dev/null ++++ b/tests/domainsnapshotxml2xmlout/disk-seclabel.xml +@@ -0,0 +1,15 @@ ++ ++ my snap name ++ !@#$%^ ++ 581484660 ++ ++ ++ ++ ++ ++ ++ ++ ++ 9d37b878-a7cc-9f9a-b78f-49b3abad25a8 ++ ++ +diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c +index 5ea0f325de..2b594e626c 100644 +--- a/tests/domainsnapshotxml2xmltest.c ++++ b/tests/domainsnapshotxml2xmltest.c +@@ -214,6 +214,7 @@ mymain(void) + DO_TEST_INOUT("noparent", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", false, false); + DO_TEST_INOUT("disk_snapshot", NULL, false, false); + DO_TEST_INOUT("disk_driver_name_null", NULL, false, false); ++ DO_TEST_INOUT("disk-seclabel", "9d37b878-a7cc-9f9a-b78f-49b3abad25a8", false, false); + + DO_TEST_IN("name_and_description", NULL); + DO_TEST_IN("description_only", NULL); +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch b/SOURCES/libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch index c10fbc5..f289fe9 100644 --- a/SOURCES/libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch +++ b/SOURCES/libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch @@ -1,5 +1,5 @@ -From 6f186e44c26abd373c927215a0aba4f5892bcd32 Mon Sep 17 00:00:00 2001 -Message-Id: <6f186e44c26abd373c927215a0aba4f5892bcd32@dist-git> +From 78713fc280ae0cb18e389ff9ba1eee97eedb7050 Mon Sep 17 00:00:00 2001 +Message-Id: <78713fc280ae0cb18e389ff9ba1eee97eedb7050@dist-git> From: John Ferlan Date: Wed, 9 Oct 2019 14:27:46 +0200 Subject: [PATCH] util: Avoid possible error in virCommandMassClose @@ -15,7 +15,6 @@ ACKed-by: Peter Krempa (cherry picked from commit 6ae4f4a4ceb123417b732e869d53099983ae8d3f) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: <69ca4c7bcf0e3c7588fad50d68dbf75180109b31.1570623892.git.mprivozn@redhat.com> diff --git a/SOURCES/libvirt-util-Export-virStorageFileSupportsBackingChainTraversal.patch b/SOURCES/libvirt-util-Export-virStorageFileSupportsBackingChainTraversal.patch new file mode 100644 index 0000000..4b66b8a --- /dev/null +++ b/SOURCES/libvirt-util-Export-virStorageFileSupportsBackingChainTraversal.patch @@ -0,0 +1,67 @@ +From dbf1be7595d6b8d3816c997669eb8fc20719cb10 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:53 +0200 +Subject: [PATCH] util: Export virStorageFileSupportsBackingChainTraversal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function will be reused in the qemu snapshot code. The argument is +turned into const similarly to the other virStorageFileSupports* +functions. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit 68639829c69ba3ed369413771bf0abceb33c3668) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: <3c6996022aa58404d1c977e0e3468acdf9f7f1a5.1565958905.git.pkrempa@redhat.com> +Reviewed-by: Ján Tomko +--- + src/libvirt_private.syms | 1 + + src/util/virstoragefile.c | 4 ++-- + src/util/virstoragefile.h | 1 + + 3 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index e696fa512c..9b5e1350f0 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -2845,6 +2845,7 @@ virStorageFileReportBrokenChain; + virStorageFileResize; + virStorageFileStat; + virStorageFileSupportsAccess; ++virStorageFileSupportsBackingChainTraversal; + virStorageFileSupportsCreate; + virStorageFileSupportsSecurityDriver; + virStorageFileUnlink; +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index faf21db567..099ff62f75 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -4389,8 +4389,8 @@ virStorageFileGetBackendForSupportCheck(const virStorageSource *src, + } + + +-static int +-virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) ++int ++virStorageFileSupportsBackingChainTraversal(const virStorageSource *src) + { + virStorageFileBackendPtr backend; + int rv; +diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h +index b99afee437..dcc48ad0b9 100644 +--- a/src/util/virstoragefile.h ++++ b/src/util/virstoragefile.h +@@ -506,6 +506,7 @@ int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid); + int virStorageFileSupportsSecurityDriver(const virStorageSource *src); + int virStorageFileSupportsAccess(const virStorageSource *src); + int virStorageFileSupportsCreate(const virStorageSource *src); ++int virStorageFileSupportsBackingChainTraversal(const virStorageSource *src); + + int virStorageFileGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch b/SOURCES/libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch index 7c50a31..8335623 100644 --- a/SOURCES/libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch +++ b/SOURCES/libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch @@ -1,5 +1,5 @@ -From a84a200ecb3867645f051e5c09826facf34786e0 Mon Sep 17 00:00:00 2001 -Message-Id: +From 89288ed330ea3afb25547e7809ea1df3d4a857bd Mon Sep 17 00:00:00 2001 +Message-Id: <89288ed330ea3afb25547e7809ea1df3d4a857bd@dist-git> From: Peter Krempa Date: Wed, 9 Oct 2019 14:27:45 +0200 Subject: [PATCH] util: command: Ignore bitmap errors when enumerating file @@ -28,7 +28,6 @@ Reviewed-by: Michal Privoznik (cherry picked from commit 728343983787cbd4d7ae8fa2007a157bb140f02a) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: <30a3508e2903b58e695d467844f6d84cd008a0d9.1570623892.git.mprivozn@redhat.com> diff --git a/SOURCES/libvirt-util-storage-Allow-checking-whether-virStorageFileCreate-is-supported.patch b/SOURCES/libvirt-util-storage-Allow-checking-whether-virStorageFileCreate-is-supported.patch new file mode 100644 index 0000000..3d5d0c8 --- /dev/null +++ b/SOURCES/libvirt-util-storage-Allow-checking-whether-virStorageFileCreate-is-supported.patch @@ -0,0 +1,83 @@ +From 080e123711e8c31634567836c9ca1adf79bcf904 Mon Sep 17 00:00:00 2001 +Message-Id: <080e123711e8c31634567836c9ca1adf79bcf904@dist-git> +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:52 +0200 +Subject: [PATCH] util: storage: Allow checking whether virStorageFileCreate is + supported +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add virStorageFileSupportsCreate which allows silent check whether +virStorageFileCreate is implemented. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit e776194ad2501c9dcba8b4d9f1272342cd7f7c41) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: +Reviewed-by: Ján Tomko +--- + src/libvirt_private.syms | 1 + + src/util/virstoragefile.c | 20 ++++++++++++++++++++ + src/util/virstoragefile.h | 1 + + 3 files changed, 22 insertions(+) + +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index bf99930802..e696fa512c 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -2845,6 +2845,7 @@ virStorageFileReportBrokenChain; + virStorageFileResize; + virStorageFileStat; + virStorageFileSupportsAccess; ++virStorageFileSupportsCreate; + virStorageFileSupportsSecurityDriver; + virStorageFileUnlink; + virStorageIsFile; +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index f320bc1928..faf21db567 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -4446,6 +4446,26 @@ virStorageFileSupportsAccess(const virStorageSource *src) + } + + ++/** ++ * virStorageFileSupportsCreate: ++ * @src: a storage file structure ++ * ++ * Check if the storage driver supports creating storage described by @src ++ * via virStorageFileCreate. ++ */ ++int ++virStorageFileSupportsCreate(const virStorageSource *src) ++{ ++ virStorageFileBackendPtr backend; ++ int rv; ++ ++ if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1) ++ return rv; ++ ++ return backend->storageFileCreate ? 1 : 0; ++} ++ ++ + void + virStorageFileDeinit(virStorageSourcePtr src) + { +diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h +index 7d28dcfe65..b99afee437 100644 +--- a/src/util/virstoragefile.h ++++ b/src/util/virstoragefile.h +@@ -505,6 +505,7 @@ int virStorageFileChown(const virStorageSource *src, uid_t uid, gid_t gid); + + int virStorageFileSupportsSecurityDriver(const virStorageSource *src); + int virStorageFileSupportsAccess(const virStorageSource *src); ++int virStorageFileSupportsCreate(const virStorageSource *src); + + int virStorageFileGetMetadata(virStorageSourcePtr src, + uid_t uid, gid_t gid, +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGetMetadataInternal.patch b/SOURCES/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGetMetadataInternal.patch new file mode 100644 index 0000000..7eac95e --- /dev/null +++ b/SOURCES/libvirt-util-storage-Clean-up-label-use-in-virStorageFileGetMetadataInternal.patch @@ -0,0 +1,121 @@ +From c2819b4e2789a1515a10f80e591cdbda1ce6a7d5 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Fri, 19 Jul 2019 15:34:52 +0200 +Subject: [PATCH] util: storage: Clean up label use in + virStorageFileGetMetadataInternal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The function does not do any cleanup, so replace the 'cleanup' label +with return of -1 and the 'done' label with return of 0. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +Reviewed-by: Michal Privoznik +(cherry picked from commit 5b8e64f0bcbbab826cff5be1b0adb000923abfb4) +https: //bugzilla.redhat.com/show_bug.cgi?id=1731329 +Message-Id: +Reviewed-by: Jiri Denemark +--- + src/util/virstoragefile.c | 27 +++++++++++---------------- + 1 file changed, 11 insertions(+), 16 deletions(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 52c9dc0e1a..f516a7c7f3 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -969,7 +969,6 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + int *backingFormat) + { + int dummy; +- int ret = -1; + size_t i; + + if (!backingFormat) +@@ -985,7 +984,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + meta->format >= VIR_STORAGE_FILE_LAST) { + virReportSystemError(EINVAL, _("unknown storage file meta->format %d"), + meta->format); +- goto cleanup; ++ return -1; + } + + if (fileTypeInfo[meta->format].cryptInfo != NULL) { +@@ -995,7 +994,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + int expt_fmt = fileTypeInfo[meta->format].cryptInfo[i].format; + if (!meta->encryption) { + if (VIR_ALLOC(meta->encryption) < 0) +- goto cleanup; ++ return -1; + + meta->encryption->format = expt_fmt; + } else { +@@ -1004,7 +1003,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + _("encryption format %d doesn't match " + "expected format %d"), + meta->encryption->format, expt_fmt); +- goto cleanup; ++ return -1; + } + } + meta->encryption->payload_offset = +@@ -1017,12 +1016,12 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + * code into this method, for non-magic files + */ + if (!fileTypeInfo[meta->format].magic) +- goto done; ++ return 0; + + /* Optionally extract capacity from file */ + if (fileTypeInfo[meta->format].sizeOffset != -1) { + if ((fileTypeInfo[meta->format].sizeOffset + 8) > len) +- goto done; ++ return 0; + + if (fileTypeInfo[meta->format].endian == LV_LITTLE_ENDIAN) + meta->capacity = virReadBufInt64LE(buf + +@@ -1033,7 +1032,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + /* Avoid unlikely, but theoretically possible overflow */ + if (meta->capacity > (ULLONG_MAX / + fileTypeInfo[meta->format].sizeMultiplier)) +- goto done; ++ return 0; + meta->capacity *= fileTypeInfo[meta->format].sizeMultiplier; + } + +@@ -1043,25 +1042,21 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + backingFormat, + buf, len); + if (store == BACKING_STORE_INVALID) +- goto done; ++ return 0; + + if (store == BACKING_STORE_ERROR) +- goto cleanup; ++ return -1; + } + + if (fileTypeInfo[meta->format].getFeatures != NULL && + fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) +- goto cleanup; ++ return -1; + + if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && + VIR_STRDUP(meta->compat, "1.1") < 0) +- goto cleanup; ++ return -1; + +- done: +- ret = 0; +- +- cleanup: +- return ret; ++ return 0; + } + + +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-of-virStorageFileGetMetadata.patch b/SOURCES/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-of-virStorageFileGetMetadata.patch new file mode 100644 index 0000000..5ae1e8f --- /dev/null +++ b/SOURCES/libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-of-virStorageFileGetMetadata.patch @@ -0,0 +1,63 @@ +From 46fe53ae905497a84d33065a9d8c31c9cd0c44bf Mon Sep 17 00:00:00 2001 +Message-Id: <46fe53ae905497a84d33065a9d8c31c9cd0c44bf@dist-git> +From: Peter Krempa +Date: Fri, 19 Jul 2019 15:34:53 +0200 +Subject: [PATCH] util: storage: Don't leak metadata on repeated calls of + virStorageFileGetMetadata +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When querying storage metadata after a block job we re-run +virStorageFileGetMetadata on the top level storage file. This means that +the workers (virStorageFileGetMetadataInternal) must not overwrite any +pointers without freeing them. + +This was not considered for src->compat and src->features. Fix it and +add a comment mentioning that. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +Reviewed-by: Michal Privoznik +(cherry picked from commit f0430d069af991475de6fa83ed62a45f8669c645) +https: //bugzilla.redhat.com/show_bug.cgi?id=1731329 +Message-Id: <80801e221bea1a4e33fbdd62845d790e390a1632.1563542241.git.pkrempa@redhat.com> +Reviewed-by: Jiri Denemark +--- + src/util/virstoragefile.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index f516a7c7f3..0187c8d2c9 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -961,7 +961,11 @@ virStorageFileGetEncryptionPayloadOffset(const struct FileEncryptionInfo *info, + * assuming it has the given FORMAT, populate information into META + * with information about the file and its backing store. Return format + * of the backing store as BACKING_FORMAT. PATH and FORMAT have to be +- * pre-populated in META */ ++ * pre-populated in META. ++ * ++ * Note that this function may be called repeatedly on @meta, so it must ++ * clean up any existing allocated memory which would be overwritten. ++ */ + int + virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + char *buf, +@@ -1048,10 +1052,13 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, + return -1; + } + ++ virBitmapFree(meta->features); ++ meta->features = NULL; + if (fileTypeInfo[meta->format].getFeatures != NULL && + fileTypeInfo[meta->format].getFeatures(&meta->features, meta->format, buf, len) < 0) + return -1; + ++ VIR_FREE(meta->compat); + if (meta->format == VIR_STORAGE_FILE_QCOW2 && meta->features && + VIR_STRDUP(meta->compat, "1.1") < 0) + return -1; +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-storage-Refactor-logic-for-using-virStorageFileGetBackendForSupportCheck.patch b/SOURCES/libvirt-util-storage-Refactor-logic-for-using-virStorageFileGetBackendForSupportCheck.patch new file mode 100644 index 0000000..6c1b6bc --- /dev/null +++ b/SOURCES/libvirt-util-storage-Refactor-logic-for-using-virStorageFileGetBackendForSupportCheck.patch @@ -0,0 +1,111 @@ +From e308683f879155b6912f979f3e2cd17f93d35c87 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:51 +0200 +Subject: [PATCH] util: storage: Refactor logic for using + virStorageFileGetBackendForSupportCheck +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Modify the return value so that callers don't have to repeat logic. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit d30e0d3abc0cb082d8d97c53dcff2b978e3eb372) +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: <73fad4d39daf47dc1c7ebd6da52a021670d113d6.1565958905.git.pkrempa@redhat.com> +Reviewed-by: Ján Tomko +--- + src/util/virstoragefile.c | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 0187c8d2c9..f320bc1928 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -4352,6 +4352,14 @@ virStorageFileIsInitialized(const virStorageSource *src) + } + + ++/** ++ * virStorageFileGetBackendForSupportCheck: ++ * @src: storage source to check support for ++ * @backend: pointer to the storage backend for @src if it's supported ++ * ++ * Returns 0 if @src is not supported by any storage backend currently linked ++ * 1 if it is supported and -1 on error with an error reported. ++ */ + static int + virStorageFileGetBackendForSupportCheck(const virStorageSource *src, + virStorageFileBackendPtr *backend) +@@ -4366,7 +4374,7 @@ virStorageFileGetBackendForSupportCheck(const virStorageSource *src, + + if (src->drv) { + *backend = src->drv->backend; +- return 0; ++ return 1; + } + + actualType = virStorageSourceGetActualType(src); +@@ -4374,7 +4382,10 @@ virStorageFileGetBackendForSupportCheck(const virStorageSource *src, + if (virStorageFileBackendForType(actualType, src->protocol, false, backend) < 0) + return -1; + +- return 0; ++ if (!*backend) ++ return 0; ++ ++ return 1; + } + + +@@ -4384,12 +4395,8 @@ virStorageFileSupportsBackingChainTraversal(virStorageSourcePtr src) + virStorageFileBackendPtr backend; + int rv; + +- rv = virStorageFileGetBackendForSupportCheck(src, &backend); +- if (rv < 0) +- return -1; +- +- if (!backend) +- return 0; ++ if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1) ++ return rv; + + return backend->storageFileGetUniqueIdentifier && + backend->storageFileRead && +@@ -4411,11 +4418,8 @@ virStorageFileSupportsSecurityDriver(const virStorageSource *src) + virStorageFileBackendPtr backend; + int rv; + +- rv = virStorageFileGetBackendForSupportCheck(src, &backend); +- if (rv < 0) +- return -1; +- if (backend == NULL) +- return 0; ++ if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1) ++ return rv; + + return backend->storageFileChown ? 1 : 0; + } +@@ -4433,13 +4437,10 @@ int + virStorageFileSupportsAccess(const virStorageSource *src) + { + virStorageFileBackendPtr backend; +- int ret; ++ int rv; + +- ret = virStorageFileGetBackendForSupportCheck(src, &backend); +- if (ret < 0) +- return -1; +- if (backend == NULL) +- return 0; ++ if ((rv = virStorageFileGetBackendForSupportCheck(src, &backend)) < 1) ++ return rv; + + return backend->storageFileAccess ? 1 : 0; + } +-- +2.22.1 + diff --git a/SOURCES/libvirt-util-storagefile-Don-t-report-errors-from-virStorageSourceUpdatePhysicalSize.patch b/SOURCES/libvirt-util-storagefile-Don-t-report-errors-from-virStorageSourceUpdatePhysicalSize.patch new file mode 100644 index 0000000..f92c43c --- /dev/null +++ b/SOURCES/libvirt-util-storagefile-Don-t-report-errors-from-virStorageSourceUpdatePhysicalSize.patch @@ -0,0 +1,74 @@ +From 78d68159183b07c1ab1d148dc6ddd05abbf0c5f4 Mon Sep 17 00:00:00 2001 +Message-Id: <78d68159183b07c1ab1d148dc6ddd05abbf0c5f4@dist-git> +From: Peter Krempa +Date: Fri, 16 Aug 2019 14:36:55 +0200 +Subject: [PATCH] util: storagefile: Don't report errors from + virStorageSourceUpdatePhysicalSize +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +virStorageSourceUpdatePhysicalSize is called only from +qemuDomainStorageUpdatePhysical and all callers of it reset the libvirt +error if -1 is returned. + +Don't bother setting the error in the first place. + +Signed-off-by: Peter Krempa +Reviewed-by: Ján Tomko +(cherry picked from commit b074363136ddcf1599c36f11b9f5a5fe45c5b3e5) + + Conflicts: + src/util/virstoragefile.c: + Code reformatting patch 34e9c29357e not backported so the + context was different. + +https: //bugzilla.redhat.com/show_bug.cgi?id=1724808 +Message-Id: +Reviewed-by: Ján Tomko +--- + src/util/virstoragefile.c | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) + +diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c +index 099ff62f75..09dd8e3084 100644 +--- a/src/util/virstoragefile.c ++++ b/src/util/virstoragefile.c +@@ -3699,7 +3699,7 @@ virStorageSourceNewFromBacking(virStorageSourcePtr parent) + * To be called for domain storage source reporting as the volume code does + * not set/use the 'type' field for the voldef->source.target + * +- * Returns 0 on success, -1 on error. ++ * Returns 0 on success, -1 on error. No libvirt errors are reported. + */ + int + virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src, +@@ -3716,11 +3716,8 @@ virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src, + break; + + case VIR_STORAGE_TYPE_BLOCK: +- if ((end = lseek(fd, 0, SEEK_END)) == (off_t) -1) { +- virReportSystemError(errno, _("failed to seek to end of '%s'"), +- src->path); ++ if ((end = lseek(fd, 0, SEEK_END)) == (off_t) -1) + return -1; +- } + + src->physical = end; + break; +@@ -3733,12 +3730,7 @@ virStorageSourceUpdatePhysicalSize(virStorageSourcePtr src, + case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: +- virReportError(VIR_ERR_INTERNAL_ERROR, +- _("cannot retrieve physical for path '%s' type '%s'"), +- NULLSTR(src->path), +- virStorageTypeToString(actual_type)); + return -1; +- break; + } + + return 0; +-- +2.22.1 + diff --git a/SOURCES/libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch b/SOURCES/libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch index 242fa48..468a9aa 100644 --- a/SOURCES/libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch +++ b/SOURCES/libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch @@ -1,5 +1,5 @@ -From bff0534793ef6097fda6806b40c016f2757cabec Mon Sep 17 00:00:00 2001 -Message-Id: +From de87d273266404f3d8fc079efda3d325f6031cc5 Mon Sep 17 00:00:00 2001 +Message-Id: From: Michal Privoznik Date: Wed, 9 Oct 2019 14:27:44 +0200 Subject: [PATCH] virCommand: use procfs to learn opened FDs @@ -22,7 +22,6 @@ Reviewed-by: Ján Tomko (cherry picked from commit 432faf259b696043ee5d7e8f657d855419a9a3fa) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: diff --git a/SOURCES/libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch b/SOURCES/libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch index 4cbdce3..a65530d 100644 --- a/SOURCES/libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch +++ b/SOURCES/libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch @@ -1,5 +1,5 @@ -From 0a75670e62729ab806f23b10df8556a540d4479d Mon Sep 17 00:00:00 2001 -Message-Id: <0a75670e62729ab806f23b10df8556a540d4479d@dist-git> +From 5ca75531afd1244898ee7c8d2307857ba8260cba Mon Sep 17 00:00:00 2001 +Message-Id: <5ca75531afd1244898ee7c8d2307857ba8260cba@dist-git> From: Michal Privoznik Date: Wed, 9 Oct 2019 14:27:41 +0200 Subject: [PATCH] virNetDevOpenvswitchInterfaceStats: Optimize for speed @@ -18,7 +18,6 @@ Reviewed-by: Ján Tomko (cherry picked from commit c297eab52599c91a4cb26b66dbdfe9d07c3142d3) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: <9904d3bee93a9e103012d088b77999f023acaa2b.1570623892.git.mprivozn@redhat.com> diff --git a/SOURCES/libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch b/SOURCES/libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch index 8a6afe5..c651daf 100644 --- a/SOURCES/libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch +++ b/SOURCES/libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch @@ -1,5 +1,5 @@ -From 307d9f2713d86653375d719020698d858d5c753d Mon Sep 17 00:00:00 2001 -Message-Id: <307d9f2713d86653375d719020698d858d5c753d@dist-git> +From 42f610677fc7d38d687ec0703b4c7552f922b598 Mon Sep 17 00:00:00 2001 +Message-Id: <42f610677fc7d38d687ec0703b4c7552f922b598@dist-git> From: Michal Privoznik Date: Wed, 9 Oct 2019 14:27:43 +0200 Subject: [PATCH] vircommand: Separate mass FD closing into a function @@ -15,7 +15,6 @@ Reviewed-by: Ján Tomko (cherry picked from commit c1a9bfbbba48fea44fdfbe532e084c5323c9c9b3) https://bugzilla.redhat.com/show_bug.cgi?id=1759904 -https://bugzilla.redhat.com/show_bug.cgi?id=1760470 Signed-off-by: Michal Privoznik Message-Id: <0198a865d008ec9fb80376062049e05522413d3e.1570623892.git.mprivozn@redhat.com> diff --git a/SPECS/libvirt.spec b/SPECS/libvirt.spec index 039b197..d68df15 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: 23%{?dist}.6%{?extra_release} +Release: 33%{?dist}%{?extra_release} License: LGPLv2+ URL: https://libvirt.org/ @@ -579,28 +579,57 @@ Patch313: libvirt-api-disallow-virDomainSaveImageGetXMLDesc-on-read-only-connect Patch314: libvirt-api-disallow-virDomainManagedSaveDefineXML-on-read-only-connections.patch Patch315: libvirt-api-disallow-virConnectGetDomainCapabilities-on-read-only-connections.patch Patch316: libvirt-api-disallow-virConnect-HypervisorCPU-on-read-only-connections.patch -Patch317: libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch -Patch318: libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch -Patch319: libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch -Patch320: libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch -Patch321: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch -Patch322: libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch -Patch323: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch -Patch324: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch -Patch325: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch -Patch326: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch -Patch327: libvirt-qemu-Fix-crash-on-incoming-migration.patch -Patch328: libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch -Patch329: libvirt-test-Introduce-virnetdevopenvswitchtest.patch -Patch330: libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch -Patch331: libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch -Patch332: libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch -Patch333: libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch -Patch334: libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch -Patch335: libvirt-domain_conf-Relax-SCSI-addr-used-check.patch -Patch336: libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch -Patch337: libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch -Patch338: libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch +Patch317: libvirt-qemu-Prefer-nvdimmPath-over-hugepages-for-memory-backend-file.patch +Patch318: libvirt-docs-snapshot-Encourage-people-ot-use-disk-target-to-refer-to-disks.patch +Patch319: libvirt-docs-schemas-Add-seclabel-for-external-disk-snapshot.patch +Patch320: libvirt-tests-domainsnapshotxml2xml-make-disk-seclabel-test-operational.patch +Patch321: libvirt-util-storage-Clean-up-label-use-in-virStorageFileGetMetadataInternal.patch +Patch322: libvirt-util-storage-Don-t-leak-metadata-on-repeated-calls-of-virStorageFileGetMetadata.patch +Patch323: libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefCopy.patch +Patch324: libvirt-qemu-Pass-qemuCaps-to-qemuDomainDefFormatBufInternal.patch +Patch325: libvirt-qemu-Pass-qemuCaps-to-qemuDomainSaveImageOpen.patch +Patch326: libvirt-qemu-Pass-qemuCaps-to-qemuMigrationAnyPrepareDef.patch +Patch327: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseString.patch +Patch328: libvirt-qemu-Pass-qemuCaps-to-qemuMigrationCookieXMLParse.patch +Patch329: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefCopy.patch +Patch330: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefPostParse.patch +Patch331: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDefParseNode.patch +Patch332: libvirt-qemu-Pass-correct-qemuCaps-to-virDomainDeviceDefPostParse.patch +Patch333: libvirt-qemu-Fix-crash-on-incoming-migration.patch +Patch334: libvirt-util-storage-Refactor-logic-for-using-virStorageFileGetBackendForSupportCheck.patch +Patch335: libvirt-util-storage-Allow-checking-whether-virStorageFileCreate-is-supported.patch +Patch336: libvirt-util-Export-virStorageFileSupportsBackingChainTraversal.patch +Patch337: libvirt-qemu-Allow-skipping-some-errors-in-qemuDomainStorageOpenStat.patch +Patch338: libvirt-util-storagefile-Don-t-report-errors-from-virStorageSourceUpdatePhysicalSize.patch +Patch339: libvirt-qemu-driver-Improve-error-suppression-in-qemuDomainStorageUpdatePhysical.patch +Patch340: libvirt-qemu-Allow-suppressing-errors-from-qemuStorageLimitsRefresh.patch +Patch341: libvirt-qemu-Don-t-report-some-ignored-errors-in-qemuDomainGetStatsOneBlockFallback.patch +Patch342: libvirt-conf-make-arg-to-virDomainNetGetActualVirtPortProfile-a-const.patch +Patch343: libvirt-qemu-move-runtime-netdev-validation-into-a-separate-function.patch +Patch344: libvirt-qemu-call-common-NetDef-validation-for-hotplug-and-device-update.patch +Patch345: libvirt-conf-utility-function-to-update-entry-in-def-nets-array.patch +Patch346: libvirt-RHEL-virscsi-Check-device-type-before-getting-it-s-dev-node-name.patch +Patch347: libvirt-RHEL-virscsi-Support-TAPEs-in-virSCSIDeviceGetDevName.patch +Patch348: libvirt-RHEL-virscsi-Introduce-and-use-virSCSIDeviceGetUnprivSGIOSysfsPath.patch +Patch349: libvirt-RHEL-virutil-Accept-non-block-devices-in-virGetDeviceID.patch +Patch350: libvirt-virNetDevOpenvswitchInterfaceStats-Optimize-for-speed.patch +Patch351: libvirt-test-Introduce-virnetdevopenvswitchtest.patch +Patch352: libvirt-vircommand-Separate-mass-FD-closing-into-a-function.patch +Patch353: libvirt-virCommand-use-procfs-to-learn-opened-FDs.patch +Patch354: libvirt-util-command-Ignore-bitmap-errors-when-enumerating-file-descriptors-to-close.patch +Patch355: libvirt-util-Avoid-possible-error-in-virCommandMassClose.patch +Patch356: libvirt-RHEL-qemuSetUnprivSGIO-Actually-use-calculated-sysfs_path-to-set-unpriv_sgio.patch +Patch357: libvirt-domain_conf-Make-virDomainDeviceFindSCSIController-accept-virDomainDeviceDriveAddress-struct.patch +Patch358: libvirt-domain_conf-Relax-SCSI-addr-used-check.patch +Patch359: libvirt-qemu-Forcibly-mknod-even-if-it-exists.patch +Patch360: libvirt-qemu_process-fix-starting-VMs-if-machine-group-has-limited-cpuset.cpus.patch +Patch361: libvirt-nwfilter-Remove-redundant-check-if-object-exists.patch +Patch362: libvirt-RHEL-qemu-Enable-virt-ssbd-for-host-model-with-old-QEMU.patch +Patch363: libvirt-process-wait-longer-on-kill-per-assigned-Hostdev.patch +Patch364: libvirt-process-wait-longer-5-30s-on-hard-shutdown.patch +Patch365: libvirt-qemu-Don-t-emit-SUSPENDED_POSTCOPY-event-on-destination.patch +Patch366: libvirt-node_device_conf-Don-t-leak-physical_function-in-virNodeDeviceGetPCISRIOVCaps.patch +Patch367: libvirt-RHEL-qemuCheckUnprivSGIO-use-sysfs_path-to-get-unpriv_sgio.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2280,7 +2309,7 @@ exit 0 %config(noreplace) %{_sysconfdir}/libvirt/qemu.conf %config(noreplace) %{_sysconfdir}/libvirt/qemu-lockd.conf %config(noreplace) %{_sysconfdir}/logrotate.d/libvirtd.qemu -%ghost %dir %attr(0700, root, root) %{_localstatedir}/run/libvirt/qemu/ +%ghost %dir %{_localstatedir}/run/libvirt/qemu/ %dir %attr(0751, %{qemu_user}, %{qemu_group}) %{_localstatedir}/lib/libvirt/qemu/ %dir %attr(0750, %{qemu_user}, %{qemu_group}) %{_localstatedir}/cache/libvirt/qemu/ %{_datadir}/augeas/lenses/libvirtd_qemu.aug @@ -2503,39 +2532,77 @@ exit 0 %changelog -* Wed Jan 29 2020 Jiri Denemark - 4.5.0-23.el7_7.6 -- node_device_conf: Don't leak @physical_function in virNodeDeviceGetPCISRIOVCaps (rhbz#1793576) - -* Mon Jan 13 2020 Jiri Denemark - 4.5.0-23.el7_7.5 -- RHEL: qemu: Enable virt-ssbd for host-model with old QEMU (rhbz#1787556) - -* Fri Nov 22 2019 Jiri Denemark - 4.5.0-23.el7_7.4 -- qemu: Forcibly mknod() even if it exists (rhbz#1775680) - -* Mon Oct 28 2019 Jiri Denemark - 4.5.0-23.el7_7.3 -- domain_conf: Make virDomainDeviceFindSCSIController accept virDomainDeviceDriveAddress struct (rhbz#1766086) -- domain_conf: Relax SCSI addr used check (rhbz#1766086) - -* Mon Oct 14 2019 Jiri Denemark - 4.5.0-23.el7_7.2 -- virNetDevOpenvswitchInterfaceStats: Optimize for speed (rhbz#1760470) -- test: Introduce virnetdevopenvswitchtest (rhbz#1760470) -- vircommand: Separate mass FD closing into a function (rhbz#1760470) -- virCommand: use procfs to learn opened FDs (rhbz#1760470) -- util: command: Ignore bitmap errors when enumerating file descriptors to close (rhbz#1760470) -- util: Avoid possible error in virCommandMassClose (rhbz#1760470) - -* Fri Aug 16 2019 Jiri Denemark - 4.5.0-23.el7_7.1 -- qemu: Pass qemuCaps to qemuDomainDefCopy (rhbz#1742023) -- qemu: Pass qemuCaps to qemuDomainDefFormatBufInternal (rhbz#1742023) -- qemu: Pass qemuCaps to qemuDomainSaveImageOpen (rhbz#1742023) -- qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef (rhbz#1742023) -- qemu: Pass correct qemuCaps to virDomainDefParseString (rhbz#1742023) -- qemu: Pass qemuCaps to qemuMigrationCookieXMLParse (rhbz#1742023) -- qemu: Pass correct qemuCaps to virDomainDefCopy (rhbz#1742023) -- qemu: Pass correct qemuCaps to virDomainDefPostParse (rhbz#1742023) -- qemu: Pass correct qemuCaps to virDomainDefParseNode (rhbz#1742023) -- qemu: Pass correct qemuCaps to virDomainDeviceDefPostParse (rhbz#1742023) -- qemu: Fix crash on incoming migration (rhbz#1742023) +* Fri Feb 14 2020 Jiri Denemark - 4.5.0-33 +- RHEL: qemuCheckUnprivSGIO: use @sysfs_path to get unpriv_sgio (rhbz#1801139) + +* Thu Jan 30 2020 Jiri Denemark - 4.5.0-32 +- qemu: Don't emit SUSPENDED_POSTCOPY event on destination (rhbz#1791886) +- node_device_conf: Don't leak @physical_function in virNodeDeviceGetPCISRIOVCaps (rhbz#1792831) + +* Thu Dec 5 2019 Jiri Denemark - 4.5.0-31 +- process: wait longer on kill per assigned Hostdev (rhbz#1771204) +- process: wait longer 5->30s on hard shutdown (rhbz#1771204) + +* Wed Dec 4 2019 Jiri Denemark - 4.5.0-30 +- nwfilter: Remove redundant check if object exists (rhbz#1766475) +- RHEL: qemu: Enable virt-ssbd for host-model with old QEMU (rhbz#1745181) + +* Thu Nov 28 2019 Jiri Denemark - 4.5.0-29 +- qemu: Forcibly mknod() even if it exists (rhbz#1752978) +- qemu_process: fix starting VMs if machine group has limited cpuset.cpus (rhbz#1746517) + +* Thu Oct 24 2019 Jiri Denemark - 4.5.0-28 +- domain_conf: Make virDomainDeviceFindSCSIController accept virDomainDeviceDriveAddress struct (rhbz#1741782) +- domain_conf: Relax SCSI addr used check (rhbz#1741782) + +* Thu Oct 10 2019 Jiri Denemark - 4.5.0-27 +- conf: utility function to update entry in def->nets array (rhbz#1558934) +- spec: Fix permissions of /var/run/libvirt/qemu (rhbz#1738693) +- RHEL: virscsi: Check device type before getting it's /dev node name (rhbz#1754241) +- RHEL: virscsi: Support TAPEs in virSCSIDeviceGetDevName() (rhbz#1754241) +- RHEL: virscsi: Introduce and use virSCSIDeviceGetUnprivSGIOSysfsPath() (rhbz#1754241) +- RHEL: virutil: Accept non-block devices in virGetDeviceID() (rhbz#1754241) +- virNetDevOpenvswitchInterfaceStats: Optimize for speed (rhbz#1759904) +- test: Introduce virnetdevopenvswitchtest (rhbz#1759904) +- vircommand: Separate mass FD closing into a function (rhbz#1759904) +- virCommand: use procfs to learn opened FDs (rhbz#1759904) +- util: command: Ignore bitmap errors when enumerating file descriptors to close (rhbz#1759904) +- util: Avoid possible error in virCommandMassClose (rhbz#1759904) +- RHEL: qemuSetUnprivSGIO: Actually use calculated @sysfs_path to set unpriv_sgio (rhbz#1754241) + +* Thu Sep 19 2019 Jiri Denemark - 4.5.0-26 +- conf: make arg to virDomainNetGetActualVirtPortProfile() a const (rhbz#1502754) +- qemu: move runtime netdev validation into a separate function (rhbz#1502754) +- qemu: call common NetDef validation for hotplug and device update (rhbz#1502754) + +* Mon Aug 19 2019 Jiri Denemark - 4.5.0-25 +- qemu: Pass qemuCaps to qemuDomainDefCopy (rhbz#1731783) +- qemu: Pass qemuCaps to qemuDomainDefFormatBufInternal (rhbz#1731783) +- qemu: Pass qemuCaps to qemuDomainSaveImageOpen (rhbz#1731783) +- qemu: Pass qemuCaps to qemuMigrationAnyPrepareDef (rhbz#1731783) +- qemu: Pass correct qemuCaps to virDomainDefParseString (rhbz#1731783) +- qemu: Pass qemuCaps to qemuMigrationCookieXMLParse (rhbz#1731783) +- qemu: Pass correct qemuCaps to virDomainDefCopy (rhbz#1731783) +- qemu: Pass correct qemuCaps to virDomainDefPostParse (rhbz#1731783) +- qemu: Pass correct qemuCaps to virDomainDefParseNode (rhbz#1731783) +- qemu: Pass correct qemuCaps to virDomainDeviceDefPostParse (rhbz#1731783) +- qemu: Fix crash on incoming migration (rhbz#1731783) +- util: storage: Refactor logic for using virStorageFileGetBackendForSupportCheck (rhbz#1724808) +- util: storage: Allow checking whether virStorageFileCreate is supported (rhbz#1724808) +- util: Export virStorageFileSupportsBackingChainTraversal (rhbz#1724808) +- qemu: Allow skipping some errors in qemuDomainStorageOpenStat (rhbz#1724808) +- util: storagefile: Don't report errors from virStorageSourceUpdatePhysicalSize (rhbz#1724808) +- qemu: driver: Improve error suppression in qemuDomainStorageUpdatePhysical (rhbz#1724808) +- qemu: Allow suppressing errors from qemuStorageLimitsRefresh (rhbz#1724808) +- qemu: Don't report some ignored errors in qemuDomainGetStatsOneBlockFallback (rhbz#1724808) + +* Fri Aug 16 2019 Jiri Denemark - 4.5.0-24 +- qemu: Prefer nvdimmPath over hugepages for memory-backend-file (rhbz#1724980) +- docs: snapshot: Encourage people ot use disk 'target' to refer to disks (rhbz#1584682) +- docs: schemas: Add 'seclabel' for external disk snapshot (rhbz#1584682) +- tests: domainsnapshotxml2xml: make 'disk-seclabel' test operational (rhbz#1584682) +- util: storage: Clean up label use in virStorageFileGetMetadataInternal (rhbz#1731329) +- util: storage: Don't leak metadata on repeated calls of virStorageFileGetMetadata (rhbz#1731329) * Thu Jun 20 2019 Jiri Denemark - 4.5.0-23 - api: disallow virDomainSaveImageGetXMLDesc on read-only connections (CVE-2019-10161)