From 7f65c97341b27bc5d1992ef773bc234be480a055 Mon Sep 17 00:00:00 2001
From: David Lehman <dlehman@redhat.com>
Date: Wed, 8 Apr 2015 10:57:27 -0500
Subject: [PATCH 04/51] Do not generate "change" uevents directly from blivet.

These should be generated as needed by the underlying tools blivet uses.
---
 blivet/devices/storage.py  | 17 -----------------
 blivet/formats/__init__.py | 29 -----------------------------
 blivet/formats/fs.py       |  7 -------
 3 files changed, 53 deletions(-)

diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 052b397..86f3f63 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -290,23 +290,6 @@ class StorageDevice(Device):
                 (self.format.type is None or self.format.resizable or
                  not self.format.exists))
 
-    def notifyKernel(self):
-        """ Send a 'change' uevent to the kernel for this device. """
-        log_method_call(self, self.name, status=self.status)
-        if not self.exists:
-            log.debug("not sending change uevent for non-existent device")
-            return
-
-        if not self.status:
-            log.debug("not sending change uevent for inactive device")
-            return
-
-        path = os.path.normpath(self.sysfsPath)
-        try:
-            util.notify_kernel(path, action="change")
-        except (ValueError, IOError) as e:
-            log.warning("failed to notify kernel of change: %s", e)
-
     @property
     def fstabSpec(self):
         spec = self.path
diff --git a/blivet/formats/__init__.py b/blivet/formats/__init__.py
index d68f8ba..25beddf 100644
--- a/blivet/formats/__init__.py
+++ b/blivet/formats/__init__.py
@@ -325,33 +325,6 @@ class DeviceFormat(ObjectID):
     def type(self):
         return self._type
 
-    def notifyKernel(self):
-        log_method_call(self, device=self.device,
-                        type=self.type)
-        if not self.device:
-            return
-
-        if self.device.startswith("/dev/mapper/"):
-            try:
-                name = blockdev.dm.node_from_name(os.path.basename(self.device))
-            except blockdev.DMError:
-                log.warning("failed to get dm node for %s", self.device)
-                return
-        elif self.device.startswith("/dev/md/"):
-            try:
-                name = blockdev.md.node_from_name(os.path.basename(self.device))
-            except blockdev.MDRaidError:
-                log.warning("failed to get md node for %s", self.device)
-                return
-        else:
-            name = self.device
-
-        path = get_sysfs_path_by_name(name)
-        try:
-            notify_kernel(path, action="change")
-        except (ValueError, IOError) as e:
-            log.warning("failed to notify kernel of change: %s", e)
-
     def create(self, **kwargs):
         """ Write the formatting to the specified block device.
 
@@ -395,7 +368,6 @@ class DeviceFormat(ObjectID):
     # pylint: disable=unused-argument
     def _postCreate(self, **kwargs):
         self.exists = True
-        self.notifyKernel()
 
     def destroy(self, **kwargs):
         """ Remove the formatting from the associated block device.
@@ -437,7 +409,6 @@ class DeviceFormat(ObjectID):
 
     def _postDestroy(self, **kwargs):
         self.exists = False
-        self.notifyKernel()
 
     def setup(self, **kwargs):
         """ Activate the formatting.
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index dd282eb..ebbc218 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -513,7 +513,6 @@ class FS(DeviceFormat):
 
         # XXX must be a smarter way to do this
         self._size = self.targetSize
-        self.notifyKernel()
 
     def _getCheckArgs(self):
         argv = []
@@ -798,8 +797,6 @@ class FS(DeviceFormat):
         if rc:
             raise FSError("label failed")
 
-        self.notifyKernel()
-
     @property
     def mkfsProg(self):
         """ Program used to create filesystems of this type. """
@@ -1491,10 +1488,6 @@ class NoDevFS(FS):
     def mountType(self):
         return self.device  # this is probably set to the real/specific fstype
 
-    def notifyKernel(self):
-        # NoDevFS should not need to tell the kernel anything.
-        pass
-
 register_device_format(NoDevFS)
 
 
-- 
2.1.0

