]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: remove virGetUnprivSGIOSysfsPath
authorJán Tomko <jtomko@redhat.com>
Thu, 13 Jan 2022 12:09:31 +0000 (13:09 +0100)
committerJán Tomko <jtomko@redhat.com>
Wed, 19 Jan 2022 12:57:59 +0000 (13:57 +0100)
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>
src/libvirt_private.syms
src/qemu/qemu_conf.c
src/util/virutil.c
src/util/virutil.h

index 48235c34617042692108f654d02891f5314774bf..e2394318b3b2a2f50fbb124aafabc2134763f9dd 100644 (file)
@@ -3519,7 +3519,6 @@ virGetPassword;
 virGetSelfLastChanged;
 virGetSystemPageSize;
 virGetSystemPageSizeKB;
-virGetUnprivSGIOSysfsPath;
 virGetUserCacheDirectory;
 virGetUserConfigDirectory;
 virGetUserDirectory;
index 6077457ff4a8cde444750da595df4dc02b98f41e..73497ad84801153492c0ea86ef10addecd52ed5f 100644 (file)
@@ -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)
index e04f1343d84f3cdf850a64428e5e08f0ea6cddd7..0acdc052c3dcb29ee01c049f4a4a028945a8dbbd 100644 (file)
@@ -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 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);
-}
-
 int
-virSetDeviceUnprivSGIO(const char *path,
-                       const char *sysfs_dir,
-                       int unpriv_sgio)
+virSetDeviceUnprivSGIO(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;
+    virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                   _("unpriv_sgio is not supported by this kernel"));
+    return -1;
 }
 
 int
-virGetDeviceUnprivSGIO(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 *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;
 }
 
 
index 854b4948906721af3619785cfd2978df0501e2da..bd2c69bfaac1b4e89179815e289929cd85a91291 100644 (file)
@@ -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);