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