|
|
d76c62 |
From 717423e7a452b0715e95b492b15dc08983677d12 Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <717423e7a452b0715e95b492b15dc08983677d12@dist-git>
|
|
|
d76c62 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
d76c62 |
Date: Fri, 6 Mar 2020 15:52:25 +0100
|
|
|
d76c62 |
Subject: [PATCH] RHEL: qemuSetUnprivSGIO: Actually use calculated @sysfs_path
|
|
|
d76c62 |
to set unpriv_sgio
|
|
|
d76c62 |
|
|
|
d76c62 |
In previous commits I've attempted to make qemuSetUnprivSGIO()
|
|
|
d76c62 |
construct a generic enough path for SCSI devices to set
|
|
|
d76c62 |
unpriv_sgio. However, virSetDeviceUnprivSGIO() does not care
|
|
|
d76c62 |
about that - it constructs the path on it's own again. This is
|
|
|
d76c62 |
suboptimal in either case - we already have the path constructed.
|
|
|
d76c62 |
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1808390
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
d76c62 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
d76c62 |
Message-Id: <20200306145226.1610708-6-abologna@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
src/qemu/qemu_conf.c | 8 +++-----
|
|
|
d76c62 |
src/util/virutil.c | 24 ++++++------------------
|
|
|
d76c62 |
src/util/virutil.h | 2 --
|
|
|
d76c62 |
3 files changed, 9 insertions(+), 25 deletions(-)
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
|
|
|
d76c62 |
index 6d6feb97cd..b61d7e59fa 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_conf.c
|
|
|
d76c62 |
+++ b/src/qemu/qemu_conf.c
|
|
|
d76c62 |
@@ -1430,7 +1430,7 @@ qemuCheckUnprivSGIO(virHashTablePtr sharedDevices,
|
|
|
d76c62 |
if (!(virHashLookup(sharedDevices, key)))
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0)
|
|
|
d76c62 |
+ if (virGetDeviceUnprivSGIO(device_path, &val) < 0)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
/* Error message on failure needs to be handled in caller
|
|
|
d76c62 |
@@ -1789,7 +1789,6 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
|
d76c62 |
virDomainDiskDefPtr disk = NULL;
|
|
|
d76c62 |
virDomainHostdevDefPtr hostdev = NULL;
|
|
|
d76c62 |
g_autofree char *sysfs_path = NULL;
|
|
|
d76c62 |
- const char *path = NULL;
|
|
|
d76c62 |
int val = 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
/* "sgio" is only valid for block disk; cdrom
|
|
|
d76c62 |
@@ -1797,13 +1796,12 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
|
d76c62 |
*/
|
|
|
d76c62 |
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
|
|
d76c62 |
disk = dev->data.disk;
|
|
|
d76c62 |
+ const char *path = virDomainDiskGetSource(disk);
|
|
|
d76c62 |
|
|
|
d76c62 |
if (disk->device != VIR_DOMAIN_DISK_DEVICE_LUN ||
|
|
|
d76c62 |
!virStorageSourceIsBlockLocal(disk->src))
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
- path = virDomainDiskGetSource(disk);
|
|
|
d76c62 |
-
|
|
|
d76c62 |
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
@@ -1843,7 +1841,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
|
|
|
d76c62 |
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
|
|
|
d76c62 |
*/
|
|
|
d76c62 |
if ((virFileExists(sysfs_path) || val == 1) &&
|
|
|
d76c62 |
- virSetDeviceUnprivSGIO(path, NULL, val) < 0)
|
|
|
d76c62 |
+ virSetDeviceUnprivSGIO(sysfs_path, val) < 0)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
return 0;
|
|
|
d76c62 |
diff --git a/src/util/virutil.c b/src/util/virutil.c
|
|
|
d76c62 |
index f142951acf..4198473fce 100644
|
|
|
d76c62 |
--- a/src/util/virutil.c
|
|
|
d76c62 |
+++ b/src/util/virutil.c
|
|
|
d76c62 |
@@ -1421,18 +1421,13 @@ virGetUnprivSGIOSysfsPath(const char *path,
|
|
|
d76c62 |
|
|
|
d76c62 |
int
|
|
|
d76c62 |
virSetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
- const char *sysfs_dir,
|
|
|
d76c62 |
int unpriv_sgio)
|
|
|
d76c62 |
{
|
|
|
d76c62 |
- char *sysfs_path = NULL;
|
|
|
d76c62 |
char *val = NULL;
|
|
|
d76c62 |
int ret = -1;
|
|
|
d76c62 |
int rc;
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
|
|
d76c62 |
- return -1;
|
|
|
d76c62 |
-
|
|
|
d76c62 |
- if (!virFileExists(sysfs_path)) {
|
|
|
d76c62 |
+ if (!virFileExists(path)) {
|
|
|
d76c62 |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
d76c62 |
_("unpriv_sgio is not supported by this kernel"));
|
|
|
d76c62 |
goto cleanup;
|
|
|
d76c62 |
@@ -1440,38 +1435,32 @@ virSetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
|
|
|
d76c62 |
val = g_strdup_printf("%d", unpriv_sgio);
|
|
|
d76c62 |
|
|
|
d76c62 |
- if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
|
|
|
d76c62 |
- virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
|
|
|
d76c62 |
+ if ((rc = virFileWriteStr(path, val, 0)) < 0) {
|
|
|
d76c62 |
+ virReportSystemError(-rc, _("failed to set %s"), path);
|
|
|
d76c62 |
goto cleanup;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
ret = 0;
|
|
|
d76c62 |
cleanup:
|
|
|
d76c62 |
- VIR_FREE(sysfs_path);
|
|
|
d76c62 |
VIR_FREE(val);
|
|
|
d76c62 |
return ret;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
int
|
|
|
d76c62 |
virGetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
- const char *sysfs_dir,
|
|
|
d76c62 |
int *unpriv_sgio)
|
|
|
d76c62 |
{
|
|
|
d76c62 |
- char *sysfs_path = NULL;
|
|
|
d76c62 |
char *buf = NULL;
|
|
|
d76c62 |
char *tmp = NULL;
|
|
|
d76c62 |
int ret = -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
|
|
d76c62 |
- return -1;
|
|
|
d76c62 |
-
|
|
|
d76c62 |
- if (!virFileExists(sysfs_path)) {
|
|
|
d76c62 |
+ if (!virFileExists(path)) {
|
|
|
d76c62 |
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
d76c62 |
_("unpriv_sgio is not supported by this kernel"));
|
|
|
d76c62 |
goto cleanup;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
|
|
|
d76c62 |
+ if (virFileReadAll(path, 1024, &buf) < 0)
|
|
|
d76c62 |
goto cleanup;
|
|
|
d76c62 |
|
|
|
d76c62 |
if ((tmp = strchr(buf, '\n')))
|
|
|
d76c62 |
@@ -1479,13 +1468,12 @@ virGetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
|
|
|
d76c62 |
if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) {
|
|
|
d76c62 |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
d76c62 |
- _("failed to parse value of %s"), sysfs_path);
|
|
|
d76c62 |
+ _("failed to parse value of %s"), path);
|
|
|
d76c62 |
goto cleanup;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
ret = 0;
|
|
|
d76c62 |
cleanup:
|
|
|
d76c62 |
- VIR_FREE(sysfs_path);
|
|
|
d76c62 |
VIR_FREE(buf);
|
|
|
d76c62 |
return ret;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
diff --git a/src/util/virutil.h b/src/util/virutil.h
|
|
|
d76c62 |
index 1a6ae1787a..a2530e21b5 100644
|
|
|
d76c62 |
--- a/src/util/virutil.h
|
|
|
d76c62 |
+++ b/src/util/virutil.h
|
|
|
d76c62 |
@@ -124,10 +124,8 @@ int virGetDeviceID(const char *path,
|
|
|
d76c62 |
int *maj,
|
|
|
d76c62 |
int *min);
|
|
|
d76c62 |
int virSetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
- const char *sysfs_dir,
|
|
|
d76c62 |
int unpriv_sgio);
|
|
|
d76c62 |
int virGetDeviceUnprivSGIO(const char *path,
|
|
|
d76c62 |
- const char *sysfs_dir,
|
|
|
d76c62 |
int *unpriv_sgio);
|
|
|
d76c62 |
char *virGetUnprivSGIOSysfsPath(const char *path,
|
|
|
d76c62 |
const char *sysfs_dir);
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.1
|
|
|
d76c62 |
|