mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 22:25:25 +00:00
util: remove virGetUnprivSGIOSysfsPath
unpriv_sgio was a downstream-only feature in RHEL 6-8. The libvirt support was merged upstream by mistake. Remove the function that constructs the sysfs path and assume it does not exist in all the callers. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
ae8add363a
commit
f322018c23
@ -3519,7 +3519,6 @@ virGetPassword;
|
||||
virGetSelfLastChanged;
|
||||
virGetSystemPageSize;
|
||||
virGetSystemPageSizeKB;
|
||||
virGetUnprivSGIOSysfsPath;
|
||||
virGetUserCacheDirectory;
|
||||
virGetUserConfigDirectory;
|
||||
virGetUserDirectory;
|
||||
|
@ -1484,42 +1484,11 @@ qemuGetSharedDeviceKey(const char *device_path)
|
||||
* being used and in the future the hostdev information.
|
||||
*/
|
||||
static int
|
||||
qemuCheckUnprivSGIO(GHashTable *sharedDevices,
|
||||
const char *device_path,
|
||||
int sgio)
|
||||
qemuCheckUnprivSGIO(GHashTable *sharedDevices G_GNUC_UNUSED,
|
||||
const char *device_path G_GNUC_UNUSED,
|
||||
int sgio G_GNUC_UNUSED)
|
||||
{
|
||||
g_autofree char *sysfs_path = NULL;
|
||||
g_autofree char *key = NULL;
|
||||
int val;
|
||||
|
||||
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(device_path, NULL)))
|
||||
return -1;
|
||||
|
||||
/* It can't be conflict if unpriv_sgio is not supported by kernel. */
|
||||
if (!virFileExists(sysfs_path))
|
||||
return 0;
|
||||
|
||||
if (!(key = qemuGetSharedDeviceKey(device_path)))
|
||||
return -1;
|
||||
|
||||
/* It can't be conflict if no other domain is sharing it. */
|
||||
if (!(virHashLookup(sharedDevices, key)))
|
||||
return 0;
|
||||
|
||||
if (virGetDeviceUnprivSGIO(device_path, NULL, &val) < 0)
|
||||
return -1;
|
||||
|
||||
/* Error message on failure needs to be handled in caller
|
||||
* since there is more specific knowledge of device
|
||||
*/
|
||||
if (!((val == 0 &&
|
||||
(sgio == VIR_DOMAIN_DEVICE_SGIO_FILTERED ||
|
||||
sgio == VIR_DOMAIN_DEVICE_SGIO_DEFAULT)) ||
|
||||
(val == 1 &&
|
||||
sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED))) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1840,7 +1809,6 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
|
||||
{
|
||||
virDomainDiskDef *disk = NULL;
|
||||
virDomainHostdevDef *hostdev = NULL;
|
||||
g_autofree char *sysfs_path = NULL;
|
||||
const char *path = NULL;
|
||||
int val = -1;
|
||||
|
||||
@ -1873,9 +1841,6 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, NULL)))
|
||||
return -1;
|
||||
|
||||
/* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */
|
||||
val = (disk->sgio == VIR_DOMAIN_DEVICE_SGIO_UNFILTERED);
|
||||
|
||||
@ -1883,7 +1848,7 @@ qemuSetUnprivSGIO(virDomainDeviceDef *dev)
|
||||
* whitelist is enabled. But if requesting unfiltered access, always call
|
||||
* virSetDeviceUnprivSGIO, to report an error for unsupported unpriv_sgio.
|
||||
*/
|
||||
if (virFileExists(sysfs_path) || val == 1) {
|
||||
if (val == 1) {
|
||||
int curr_val;
|
||||
|
||||
if (virGetDeviceUnprivSGIO(path, NULL, &curr_val) < 0)
|
||||
|
@ -1354,96 +1354,24 @@ virGetDeviceID(const char *path G_GNUC_UNUSED,
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SYSFS_DEV_BLOCK_PATH "/sys/dev/block"
|
||||
|
||||
char *
|
||||
virGetUnprivSGIOSysfsPath(const char *path,
|
||||
const char *sysfs_dir)
|
||||
int
|
||||
virSetDeviceUnprivSGIO(const char *path G_GNUC_UNUSED,
|
||||
const char *sysfs_dir G_GNUC_UNUSED,
|
||||
int unpriv_sgio G_GNUC_UNUSED)
|
||||
{
|
||||
int maj, min;
|
||||
int rc;
|
||||
|
||||
if ((rc = virGetDeviceID(path, &maj, &min)) < 0) {
|
||||
virReportSystemError(-rc,
|
||||
_("Unable to get device ID '%s'"),
|
||||
path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return g_strdup_printf("%s/%d:%d/queue/unpriv_sgio",
|
||||
sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH, maj,
|
||||
min);
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("unpriv_sgio is not supported by this kernel"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
virSetDeviceUnprivSGIO(const char *path,
|
||||
const char *sysfs_dir,
|
||||
int unpriv_sgio)
|
||||
virGetDeviceUnprivSGIO(const char *path G_GNUC_UNUSED,
|
||||
const char *sysfs_dir G_GNUC_UNUSED,
|
||||
int *unpriv_sgio G_GNUC_UNUSED)
|
||||
{
|
||||
char *sysfs_path = NULL;
|
||||
char *val = NULL;
|
||||
int ret = -1;
|
||||
int rc;
|
||||
|
||||
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
||||
return -1;
|
||||
|
||||
if (!virFileExists(sysfs_path)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("unpriv_sgio is not supported by this kernel"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
val = g_strdup_printf("%d", unpriv_sgio);
|
||||
|
||||
if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
|
||||
virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(sysfs_path);
|
||||
VIR_FREE(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
virGetDeviceUnprivSGIO(const char *path,
|
||||
const char *sysfs_dir,
|
||||
int *unpriv_sgio)
|
||||
{
|
||||
char *sysfs_path = NULL;
|
||||
char *buf = NULL;
|
||||
char *tmp = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(sysfs_path = virGetUnprivSGIOSysfsPath(path, sysfs_dir)))
|
||||
return -1;
|
||||
|
||||
if (!virFileExists(sysfs_path)) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("unpriv_sgio is not supported by this kernel"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if ((tmp = strchr(buf, '\n')))
|
||||
*tmp = '\0';
|
||||
|
||||
if (virStrToLong_i(buf, NULL, 10, unpriv_sgio) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to parse value of %s"), sysfs_path);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
VIR_FREE(sysfs_path);
|
||||
VIR_FREE(buf);
|
||||
return ret;
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("unpriv_sgio is not supported by this kernel"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -125,8 +125,6 @@ int virSetDeviceUnprivSGIO(const char *path,
|
||||
int virGetDeviceUnprivSGIO(const char *path,
|
||||
const char *sysfs_dir,
|
||||
int *unpriv_sgio);
|
||||
char *virGetUnprivSGIOSysfsPath(const char *path,
|
||||
const char *sysfs_dir);
|
||||
|
||||
int virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user