|
|
fbe740 |
From c9fc757c867d197c17350b6a9cabc63cc08105d2 Mon Sep 17 00:00:00 2001
|
|
|
fbe740 |
Message-Id: <c9fc757c867d197c17350b6a9cabc63cc08105d2@dist-git>
|
|
|
fbe740 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
fbe740 |
Date: Fri, 6 Mar 2020 15:52:23 +0100
|
|
|
fbe740 |
Subject: [PATCH] RHEL: virscsi: Introduce and use
|
|
|
fbe740 |
virSCSIDeviceGetUnprivSGIOSysfsPath()
|
|
|
fbe740 |
|
|
|
fbe740 |
When constructing a path to the 'unpriv_sgio' file of given SCSI
|
|
|
fbe740 |
device we don't need to go through /dev/* and major() + minor()
|
|
|
fbe740 |
path. The generated path points to
|
|
|
fbe740 |
/sys/dev/block/MAJ:MIN/queue/unpriv_sgio which is wrong if the
|
|
|
fbe740 |
SCSI device in question is not a block device. We can generate a
|
|
|
fbe740 |
different path: /sys/bus/scsi/devices/X:X:X:X/unpriv_sgio where
|
|
|
fbe740 |
the file is directly accessible regardless of the SCSI device
|
|
|
fbe740 |
type.
|
|
|
fbe740 |
|
|
|
fbe740 |
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
|
|
|
fbe740 |
|
|
|
fbe740 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
fbe740 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
fbe740 |
Message-Id: <20200306145226.1610708-4-abologna@redhat.com>
|
|
|
fbe740 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
fbe740 |
---
|
|
|
fbe740 |
src/libvirt_private.syms | 1 +
|
|
|
fbe740 |
src/qemu/qemu_conf.c | 18 +++++++++++-------
|
|
|
fbe740 |
src/util/virscsi.c | 18 ++++++++++++++++++
|
|
|
fbe740 |
src/util/virscsi.h | 5 +++++
|
|
|
fbe740 |
4 files changed, 35 insertions(+), 7 deletions(-)
|
|
|
fbe740 |
|
|
|
fbe740 |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
fbe740 |
index 5dc99e03cf..1f97879faa 100644
|
|
|
fbe740 |
--- a/src/libvirt_private.syms
|
|
|
fbe740 |
+++ b/src/libvirt_private.syms
|
|
|
fbe740 |
@@ -2959,6 +2959,7 @@ virSCSIDeviceGetSgName;
|
|
|
fbe740 |
virSCSIDeviceGetShareable;
|
|
|
fbe740 |
virSCSIDeviceGetTarget;
|
|
|
fbe740 |
virSCSIDeviceGetUnit;
|
|
|
fbe740 |
+virSCSIDeviceGetUnprivSGIOSysfsPath;
|
|
|
fbe740 |
virSCSIDeviceIsAvailable;
|
|
|
fbe740 |
virSCSIDeviceListAdd;
|
|
|
fbe740 |
virSCSIDeviceListCount;
|
|
|
fbe740 |
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
|
fbe740 |
index 7aaf2862a4..6d6feb97cd 100644
|
|
|
fbe740 |
--- a/src/qemu/qemu_conf.c
|
|
|
fbe740 |
+++ b/src/qemu/qemu_conf.c
|
|
|
fbe740 |
@@ -1789,7 +1789,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
|
fbe740 |
virDomainDiskDefPtr disk = NULL;
|
|
|
fbe740 |
virDomainHostdevDefPtr hostdev = NULL;
|
|
|
fbe740 |
g_autofree char *sysfs_path = NULL;
|
|
|
fbe740 |
- g_autofree char *hostdev_path = NULL;
|
|
|
fbe740 |
const char *path = NULL;
|
|
|
fbe740 |
int val = 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
@@ -1804,24 +1803,29 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
path = virDomainDiskGetSource(disk);
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
|
|
fbe740 |
+ return -1;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
} else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
|
|
|
fbe740 |
hostdev = dev->data.hostdev;
|
|
|
fbe740 |
+ virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
|
|
|
fbe740 |
+ virDomainHostdevSubsysSCSIHostPtr scsihostsrc = &scsisrc->u.host;
|
|
|
fbe740 |
|
|
|
fbe740 |
if (hostdev->source.subsys.u.scsi.protocol ==
|
|
|
fbe740 |
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (!(hostdev_path = qemuGetHostdevPath(hostdev)))
|
|
|
fbe740 |
+ if (!(sysfs_path = virSCSIDeviceGetUnprivSGIOSysfsPath(NULL,
|
|
|
fbe740 |
+ scsihostsrc->adapter,
|
|
|
fbe740 |
+ scsihostsrc->bus,
|
|
|
fbe740 |
+ scsihostsrc->target,
|
|
|
fbe740 |
+ scsihostsrc->unit)))
|
|
|
fbe740 |
return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
- path = hostdev_path;
|
|
|
fbe740 |
} else {
|
|
|
fbe740 |
return 0;
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
|
|
fbe740 |
- return -1;
|
|
|
fbe740 |
-
|
|
|
fbe740 |
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
|
|
|
fbe740 |
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
|
|
fbe740 |
if (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED)
|
|
|
fbe740 |
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
|
|
|
fbe740 |
index 57958c06ea..1bba4051b6 100644
|
|
|
fbe740 |
--- a/src/util/virscsi.c
|
|
|
fbe740 |
+++ b/src/util/virscsi.c
|
|
|
fbe740 |
@@ -322,6 +322,24 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
|
|
|
fbe740 |
}
|
|
|
fbe740 |
|
|
|
fbe740 |
|
|
|
fbe740 |
+char *
|
|
|
fbe740 |
+virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
|
|
|
fbe740 |
+ const char *adapter,
|
|
|
fbe740 |
+ unsigned int bus,
|
|
|
fbe740 |
+ unsigned int target,
|
|
|
fbe740 |
+ unsigned long long unit)
|
|
|
fbe740 |
+{
|
|
|
fbe740 |
+ unsigned int adapter_id;
|
|
|
fbe740 |
+ const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ if (virSCSIDeviceGetAdapterId(adapter, &adapter_id) < 0)
|
|
|
fbe740 |
+ return NULL;
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+ return g_strdup_printf("%s/%d:%u:%u:%llu/unpriv_sgio",
|
|
|
fbe740 |
+ prefix, adapter_id, bus, target, unit);
|
|
|
fbe740 |
+}
|
|
|
fbe740 |
+
|
|
|
fbe740 |
+
|
|
|
fbe740 |
virSCSIDevicePtr
|
|
|
fbe740 |
virSCSIDeviceNew(const char *sysfs_prefix,
|
|
|
fbe740 |
const char *adapter,
|
|
|
fbe740 |
diff --git a/src/util/virscsi.h b/src/util/virscsi.h
|
|
|
fbe740 |
index 51627e0c05..c040d76716 100644
|
|
|
fbe740 |
--- a/src/util/virscsi.h
|
|
|
fbe740 |
+++ b/src/util/virscsi.h
|
|
|
fbe740 |
@@ -42,6 +42,11 @@ char *virSCSIDeviceGetDevName(const char *sysfs_prefix,
|
|
|
fbe740 |
unsigned int bus,
|
|
|
fbe740 |
unsigned int target,
|
|
|
fbe740 |
unsigned long long unit);
|
|
|
fbe740 |
+char *virSCSIDeviceGetUnprivSGIOSysfsPath(const char *sysfs_prefix,
|
|
|
fbe740 |
+ const char *adapter,
|
|
|
fbe740 |
+ unsigned int bus,
|
|
|
fbe740 |
+ unsigned int target,
|
|
|
fbe740 |
+ unsigned long long unit);
|
|
|
fbe740 |
|
|
|
fbe740 |
virSCSIDevicePtr virSCSIDeviceNew(const char *sysfs_prefix,
|
|
|
fbe740 |
const char *adapter,
|
|
|
fbe740 |
--
|
|
|
fbe740 |
2.25.1
|
|
|
fbe740 |
|