|
Pablo Greco |
40546a |
From 785d2dd780b472bf857dd962d910addd9ff7b07f Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <785d2dd780b472bf857dd962d910addd9ff7b07f@dist-git>
|
|
Pablo Greco |
40546a |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Fri, 6 Mar 2020 15:51:48 +0100
|
|
Pablo Greco |
40546a |
Subject: [PATCH] RHEL: qemuSetUnprivSGIO: Actually use calculated @sysfs_path
|
|
Pablo Greco |
40546a |
to set unpriv_sgio
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
In previous commits I've attempted to make qemuSetUnprivSGIO()
|
|
Pablo Greco |
40546a |
construct a generic enough path for SCSI devices to set
|
|
Pablo Greco |
40546a |
unpriv_sgio. However, virSetDeviceUnprivSGIO() does not care
|
|
Pablo Greco |
40546a |
about that - it constructs the path on it's own again. This is
|
|
Pablo Greco |
40546a |
suboptimal in either case - we already have the path constructed.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
https://bugzilla.redhat.com/show_bug.cgi?id=1808388
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Pablo Greco |
40546a |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <20200306145149.1610286-6-abologna@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/qemu/qemu_conf.c | 8 +++-----
|
|
Pablo Greco |
40546a |
src/util/virutil.c | 24 ++++++------------------
|
|
Pablo Greco |
40546a |
src/util/virutil.h | 2 --
|
|
Pablo Greco |
40546a |
3 files changed, 9 insertions(+), 25 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
Pablo Greco |
40546a |
index 5636277888..5788354444 100644
|
|
Pablo Greco |
40546a |
--- a/src/qemu/qemu_conf.c
|
|
Pablo Greco |
40546a |
+++ b/src/qemu/qemu_conf.c
|
|
Pablo Greco |
40546a |
@@ -1255,7 +1255,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices,
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0)
|
|
Pablo Greco |
40546a |
+ if (virGetDeviceUnprivSGIO(device_path, &val) < 0)
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/* Error message on failure needs to be handled in caller
|
|
Pablo Greco |
40546a |
@@ -1648,7 +1648,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
Pablo Greco |
40546a |
virDomainDiskDefPtr disk = NULL;
|
|
Pablo Greco |
40546a |
virDomainHostdevDefPtr hostdev = NULL;
|
|
Pablo Greco |
40546a |
char *sysfs_path = NULL;
|
|
Pablo Greco |
40546a |
- const char *path = NULL;
|
|
Pablo Greco |
40546a |
int val = 0;
|
|
Pablo Greco |
40546a |
int ret = -1;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1657,13 +1656,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
Pablo Greco |
40546a |
*/
|
|
Pablo Greco |
40546a |
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
|
Pablo Greco |
40546a |
disk = dev->data.disk;
|
|
Pablo Greco |
40546a |
+ const char *path = virDomainDiskGetSource(disk);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
|
|
Pablo Greco |
40546a |
!virStorageSourceIsBlockLocal(disk->src))
|
|
Pablo Greco |
40546a |
return 0;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- path = virDomainDiskGetSource(disk);
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1703,7 +1701,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
Pablo Greco |
40546a |
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
|
|
Pablo Greco |
40546a |
*/
|
|
Pablo Greco |
40546a |
if ((virFileExists(sysfs_path) || val == 1) &&
|
|
Pablo Greco |
40546a |
- virSetDeviceUnprivSGIO(path, NULL, val) < 0)
|
|
Pablo Greco |
40546a |
+ virSetDeviceUnprivSGIO(sysfs_path, val) < 0)
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
ret = 0;
|
|
Pablo Greco |
40546a |
diff --git a/src/util/virutil.c b/src/util/virutil.c
|
|
Pablo Greco |
40546a |
index 2448eba073..ad2b8cb3a2 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/virutil.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/virutil.c
|
|
Pablo Greco |
40546a |
@@ -1736,18 +1736,13 @@ virGetUnprivSGIOSysfsPath(const char *path,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virSetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
- const char *sysfs_dir,
|
|
Pablo Greco |
40546a |
int unpriv_sgio)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- char *sysfs_path = NULL;
|
|
Pablo Greco |
40546a |
char *val = NULL;
|
|
Pablo Greco |
40546a |
int ret = -1;
|
|
Pablo Greco |
40546a |
int rc;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (!virFileExists(sysfs_path)) {
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
_("unpriv_sgio is not supported by this kernel"));
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
@@ -1756,38 +1751,32 @@ virSetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
if (virAsprintf(&val, "%d", unpriv_sgio) < 0)
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
|
|
Pablo Greco |
40546a |
- virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
|
|
Pablo Greco |
40546a |
+ if ((rc = virFileWriteStr(path, val, 0)) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportSystemError(-rc, _("failed to set %s"), path);
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
ret = 0;
|
|
Pablo Greco |
40546a |
cleanup:
|
|
Pablo Greco |
40546a |
- VIR_FREE(sysfs_path);
|
|
Pablo Greco |
40546a |
VIR_FREE(val);
|
|
Pablo Greco |
40546a |
return ret;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virGetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
- const char *sysfs_dir,
|
|
Pablo Greco |
40546a |
int *unpriv_sgio)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- char *sysfs_path = NULL;
|
|
Pablo Greco |
40546a |
char *buf = NULL;
|
|
Pablo Greco |
40546a |
char *tmp = NULL;
|
|
Pablo Greco |
40546a |
int ret = -1;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (!virFileExists(sysfs_path)) {
|
|
Pablo Greco |
40546a |
+ if (!virFileExists(path)) {
|
|
Pablo Greco |
40546a |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
Pablo Greco |
40546a |
_("unpriv_sgio is not supported by this kernel"));
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
- if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
|
|
Pablo Greco |
40546a |
+ if (virFileReadAll(path, 1024, &buf) < 0)
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if ((tmp = strchr(buf, '\n')))
|
|
Pablo Greco |
40546a |
@@ -1795,13 +1784,12 @@ virGetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) {
|
|
Pablo Greco |
40546a |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
- _("failed to parse value of %s"), sysfs_path);
|
|
Pablo Greco |
40546a |
+ _("failed to parse value of %s"), path);
|
|
Pablo Greco |
40546a |
goto cleanup;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
ret = 0;
|
|
Pablo Greco |
40546a |
cleanup:
|
|
Pablo Greco |
40546a |
- VIR_FREE(sysfs_path);
|
|
Pablo Greco |
40546a |
VIR_FREE(buf);
|
|
Pablo Greco |
40546a |
return ret;
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
diff --git a/src/util/virutil.h b/src/util/virutil.h
|
|
Pablo Greco |
40546a |
index 1ba9635bd9..1a1313cfa3 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/virutil.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/virutil.h
|
|
Pablo Greco |
40546a |
@@ -160,10 +160,8 @@ int virGetDeviceID(const char *path,
|
|
Pablo Greco |
40546a |
int *maj,
|
|
Pablo Greco |
40546a |
int *min);
|
|
Pablo Greco |
40546a |
int virSetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
- const char *sysfs_dir,
|
|
Pablo Greco |
40546a |
int unpriv_sgio);
|
|
Pablo Greco |
40546a |
int virGetDeviceUnprivSGIO(const char *path,
|
|
Pablo Greco |
40546a |
- const char *sysfs_dir,
|
|
Pablo Greco |
40546a |
int *unpriv_sgio);
|
|
Pablo Greco |
40546a |
char *virGetUnprivSGIOSysfsPath(const char *path,
|
|
Pablo Greco |
40546a |
const char *sysfs_dir);
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.25.1
|
|
Pablo Greco |
40546a |
|