2020-11-03 12:01:38 +00:00
|
|
|
From c9fc757c867d197c17350b6a9cabc63cc08105d2 Mon Sep 17 00:00:00 2001
|
|
|
|
Message-Id: <c9fc757c867d197c17350b6a9cabc63cc08105d2@dist-git>
|
2020-04-28 09:33:33 +00:00
|
|
|
From: Michal Privoznik <mprivozn@redhat.com>
|
2020-11-03 12:01:38 +00:00
|
|
|
Date: Fri, 6 Mar 2020 15:52:23 +0100
|
2020-04-28 09:33:33 +00:00
|
|
|
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.
|
|
|
|
|
2020-11-03 12:01:38 +00:00
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
|
2020-04-28 09:33:33 +00:00
|
|
|
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
|
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
2020-11-03 12:01:38 +00:00
|
|
|
Message-Id: <20200306145226.1610708-4-abologna@redhat.com>
|
2020-04-28 09:33:33 +00:00
|
|
|
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
|
---
|
|
|
|
src/libvirt_private.syms | 1 +
|
2020-11-03 12:01:38 +00:00
|
|
|
src/qemu/qemu_conf.c | 18 +++++++++++-------
|
|
|
|
src/util/virscsi.c | 18 ++++++++++++++++++
|
2020-04-28 09:33:33 +00:00
|
|
|
src/util/virscsi.h | 5 +++++
|
2020-11-03 12:01:38 +00:00
|
|
|
4 files changed, 35 insertions(+), 7 deletions(-)
|
2020-04-28 09:33:33 +00:00
|
|
|
|
|
|
|
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
2020-11-03 12:01:38 +00:00
|
|
|
index 5dc99e03cf..1f97879faa 100644
|
2020-04-28 09:33:33 +00:00
|
|
|
--- a/src/libvirt_private.syms
|
|
|
|
+++ b/src/libvirt_private.syms
|
2020-11-03 12:01:38 +00:00
|
|
|
@@ -2959,6 +2959,7 @@ virSCSIDeviceGetSgName;
|
2020-04-28 09:33:33 +00:00
|
|
|
virSCSIDeviceGetShareable;
|
|
|
|
virSCSIDeviceGetTarget;
|
|
|
|
virSCSIDeviceGetUnit;
|
|
|
|
+virSCSIDeviceGetUnprivSGIOSysfsPath;
|
|
|
|
virSCSIDeviceIsAvailable;
|
|
|
|
virSCSIDeviceListAdd;
|
|
|
|
virSCSIDeviceListCount;
|
|
|
|
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
2020-11-03 12:01:38 +00:00
|
|
|
index 7aaf2862a4..6d6feb97cd 100644
|
2020-04-28 09:33:33 +00:00
|
|
|
--- a/src/qemu/qemu_conf.c
|
|
|
|
+++ b/src/qemu/qemu_conf.c
|
2020-11-03 12:01:38 +00:00
|
|
|
@@ -1789,7 +1789,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
2020-04-28 09:33:33 +00:00
|
|
|
virDomainDiskDefPtr disk = NULL;
|
|
|
|
virDomainHostdevDefPtr hostdev = NULL;
|
2020-11-03 12:01:38 +00:00
|
|
|
g_autofree char *sysfs_path = NULL;
|
|
|
|
- g_autofree char *hostdev_path = NULL;
|
2020-04-28 09:33:33 +00:00
|
|
|
const char *path = NULL;
|
|
|
|
int val = 0;
|
2020-11-03 12:01:38 +00:00
|
|
|
|
|
|
|
@@ -1804,24 +1803,29 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
2020-04-28 09:33:33 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
path = virDomainDiskGetSource(disk);
|
|
|
|
+
|
|
|
|
+ if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
2020-11-03 12:01:38 +00:00
|
|
|
+ return -1;
|
2020-04-28 09:33:33 +00:00
|
|
|
+
|
|
|
|
} 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)))
|
2020-11-03 12:01:38 +00:00
|
|
|
return -1;
|
2020-04-28 09:33:33 +00:00
|
|
|
-
|
|
|
|
- path = hostdev_path;
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
2020-11-03 12:01:38 +00:00
|
|
|
- return -1;
|
2020-04-28 09:33:33 +00:00
|
|
|
-
|
|
|
|
/* 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)
|
|
|
|
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
|
2020-11-03 12:01:38 +00:00
|
|
|
index 57958c06ea..1bba4051b6 100644
|
2020-04-28 09:33:33 +00:00
|
|
|
--- a/src/util/virscsi.c
|
|
|
|
+++ b/src/util/virscsi.c
|
2020-11-03 12:01:38 +00:00
|
|
|
@@ -322,6 +322,24 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
|
2020-04-28 09:33:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+char *
|
|
|
|
+virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
|
|
|
|
+ const char *adapter,
|
|
|
|
+ unsigned int bus,
|
|
|
|
+ unsigned int target,
|
|
|
|
+ unsigned long long unit)
|
|
|
|
+{
|
|
|
|
+ unsigned int adapter_id;
|
|
|
|
+ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
|
|
|
|
+
|
|
|
|
+ if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
2020-11-03 12:01:38 +00:00
|
|
|
+ return g_strdup_printf("%s/%d:%u:%u:%llu/unpriv_sgio",
|
|
|
|
+ prefix, adapter_id, bus, target, unit);
|
2020-04-28 09:33:33 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
virSCSIDevicePtr
|
|
|
|
virSCSIDeviceNew(const char *sysfs_prefix,
|
|
|
|
const char *adapter,
|
|
|
|
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
|
2020-11-03 12:01:38 +00:00
|
|
|
index 51627e0c05..c040d76716 100644
|
2020-04-28 09:33:33 +00:00
|
|
|
--- a/src/util/virscsi.h
|
|
|
|
+++ b/src/util/virscsi.h
|
2020-11-03 12:01:38 +00:00
|
|
|
@@ -42,6 +42,11 @@ char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
|
2020-04-28 09:33:33 +00:00
|
|
|
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.25.1
|
|
|
|
|