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