Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging
pc,pci,virtio,crypto: bugfixes
fixes all over the place.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# -----BEGIN PGP SIGNATURE-----
#
# iQFDBAABCAAtFiEEXQn9CHHI+FuUyooNKB8NuNKNVGkFAmTMJ90PHG1zdEByZWRo
# YXQuY29tAAoJECgfDbjSjVRprTAH/1YxxP9Dhn71BjkwGQ18SmpNp0wlmP9GRJEy
# 7aQNO7ativ8njAX1fLEo0ZRJ5qX1MCw+/ZuEvIUZD+0biwimsVCPjWVLs3Q8geUs
# LzQWuvUoRGp136BtaZUrlS/cWr8TQY+4/lyK/xOBUOiI+5AP1Yi7eL9162RDQR3D
# cV/0eH8QNY+93n+VnyFY6Y55YnHyH9EBkxdtnVkt7NOCms4qMRf9IBiWOMaktp4w
# iTfvOfKbTCKhWDsNWIJEJUtWItRFp6OIRdO3KoMXBHuE8S/0C19fc2eBfbeN/bUK
# I5b4xO181ibzoPGWkDfLYi1wFfvGDDxFe119EzvDKU8dDtNFBoY=
# =FRdM
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 03 Aug 2023 03:19:09 PM PDT
# gpg: using RSA key 5D09FD0871C8F85B94CA8A0D281F0DB8D28D5469
# gpg: issuer "mst@redhat.com"
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" [undefined]
# gpg: aka "Michael S. Tsirkin <mst@redhat.com>" [undefined]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67
# Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469
* tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu: (22 commits)
cryptodev: Handle unexpected request to avoid crash
virtio-crypto: verify src&dst buffer length for sym request
include/hw/i386/x86-iommu: Fix struct X86IOMMU_MSIMessage for big endian hosts
hw/i386/x86-iommu: Fix endianness issue in x86_iommu_irq_to_msi_message()
hw/i386/intel_iommu: Fix index calculation in vtd_interrupt_remap_msi()
hw/i386/intel_iommu: Fix struct VTDInvDescIEC on big endian hosts
hw/i386/intel_iommu: Fix endianness problems related to VTD_IR_TableEntry
hw/i386/intel_iommu: Fix trivial endianness problems
vhost: fix the fd leak
pci: do not respond config requests after PCI device eject
virtio: Fix packed virtqueue used_idx mask
hw/virtio: qmp: add RING_RESET to 'info virtio-status'
tests: acpi: update expected blobs
acpi: x86: remove _ADR on host bridges
tests: acpi: whitelist expected blobs
tests: acpi: x86: update expected blobs
x86: acpi: workaround Windows not handling name references in Package properly
tests: acpi: x86: whitelist expected blobs
hw/virtio: Add a protection against duplicate vu_scmi_stop calls
virtio-iommu: Standardize granule extraction and formatting
...
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/block/blkio.c b/block/blkio.c
index 8e7ce42..1dd4956 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -678,7 +678,7 @@
const char *path = qdict_get_try_str(options, "path");
BDRVBlkioState *s = bs->opaque;
bool fd_supported = false;
- int fd, ret;
+ int fd = -1, ret;
if (!path) {
error_setg(errp, "missing 'path' option");
@@ -713,12 +713,19 @@
*/
fd = qemu_open(path, O_RDWR, NULL);
if (fd < 0) {
+ /*
+ * qemu_open() can fail if the user specifies a path that is not
+ * a file or device, for example in the case of Unix Domain Socket
+ * for the virtio-blk-vhost-user driver. In such cases let's have
+ * libblkio open the path directly.
+ */
fd_supported = false;
} else {
ret = blkio_set_int(s->blkio, "fd", fd);
if (ret < 0) {
fd_supported = false;
qemu_close(fd);
+ fd = -1;
}
}
}
@@ -733,14 +740,21 @@
}
ret = blkio_connect(s->blkio);
+ if (ret < 0 && fd >= 0) {
+ /* Failed to give the FD to libblkio, close it */
+ qemu_close(fd);
+ fd = -1;
+ }
+
/*
- * If the libblkio driver doesn't support the `fd` property, blkio_connect()
- * will fail with -EINVAL. So let's try calling blkio_connect() again by
- * directly setting `path`.
+ * Before https://gitlab.com/libblkio/libblkio/-/merge_requests/208
+ * (libblkio <= v1.3.0), setting the `fd` property is not enough to check
+ * whether the driver supports the `fd` property or not. In that case,
+ * blkio_connect() will fail with -EINVAL.
+ * So let's try calling blkio_connect() again by directly setting `path`
+ * to cover this scenario.
*/
if (fd_supported && ret == -EINVAL) {
- qemu_close(fd);
-
/*
* We need to clear the `fd` property we set previously by setting
* it to -1.