python-blivet/0004-Add-NVDIMMNamespaceDevice-device-representing-NVDIMM.patch
David Lehman b04db7f630 Use bcond for with python3, allow it on RHEL > 7 (mhroncok)
Conditionalize the Python 2 subpackage and don't build it on EL > 7 and Fedora > 28 (mhroncok)
Add experimental support for NVDIMM. (vtrefny)
2018-04-02 15:06:24 -04:00

101 lines
4.1 KiB
Diff

From 6ae475fb80cdf1dd7f527ed0b952c613a5825ec3 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 7 Feb 2018 14:58:12 +0100
Subject: [PATCH 4/7] Add 'NVDIMMNamespaceDevice' device representing NVDIMM
namespaces
---
blivet/devices/__init__.py | 2 +-
blivet/devices/disk.py | 51 ++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 50 insertions(+), 3 deletions(-)
diff --git a/blivet/devices/__init__.py b/blivet/devices/__init__.py
index 5bae1cbe..aaad30c3 100644
--- a/blivet/devices/__init__.py
+++ b/blivet/devices/__init__.py
@@ -22,7 +22,7 @@
from .lib import device_path_to_name, device_name_to_disk_by_path, ParentList
from .device import Device
from .storage import StorageDevice
-from .disk import DiskDevice, DiskFile, DMRaidArrayDevice, MultipathDevice, iScsiDiskDevice, FcoeDiskDevice, DASDDevice, ZFCPDiskDevice
+from .disk import DiskDevice, DiskFile, DMRaidArrayDevice, MultipathDevice, iScsiDiskDevice, FcoeDiskDevice, DASDDevice, ZFCPDiskDevice, NVDIMMNamespaceDevice
from .partition import PartitionDevice
from .dm import DMDevice, DMLinearDevice, DMCryptDevice, DM_MAJORS
from .luks import LUKSDevice
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
index 26448640..dc796cf0 100644
--- a/blivet/devices/disk.py
+++ b/blivet/devices/disk.py
@@ -63,7 +63,7 @@ class DiskDevice(StorageDevice):
def __init__(self, name, fmt=None,
size=None, major=None, minor=None, sysfs_path='',
parents=None, serial=None, vendor="", model="", bus="", wwn=None,
- exists=True):
+ uuid=None, exists=True):
"""
:param name: the device name (generally a device node's basename)
:type name: str
@@ -96,7 +96,7 @@ class DiskDevice(StorageDevice):
major=major, minor=minor, exists=exists,
sysfs_path=sysfs_path, parents=parents,
serial=serial, model=model,
- vendor=vendor, bus=bus)
+ vendor=vendor, bus=bus, uuid=uuid)
self.wwn = wwn or None
@@ -660,3 +660,50 @@ class DASDDevice(DiskDevice):
":".join(opts))])
else:
return set(["rd.dasd=%s" % self.busid])
+
+
+class NVDIMMNamespaceDevice(DiskDevice):
+
+ """ Non-volatile memory namespace """
+ _type = "nvdimm"
+
+ def __init__(self, device, **kwargs):
+ """
+ :param name: the device name (generally a device node's basename)
+ :type name: str
+ :keyword exists: does this device exist?
+ :type exists: bool
+ :keyword size: the device's size
+ :type size: :class:`~.size.Size`
+ :keyword parents: a list of parent devices
+ :type parents: list of :class:`StorageDevice`
+ :keyword format: this device's formatting
+ :type format: :class:`~.formats.DeviceFormat` or a subclass of it
+ :keyword mode: mode of the namespace
+ :type mode: str
+ :keyword devname: name of the namespace (e.g. 'namespace0.0')
+ :type devname: str
+ :keyword sector_size: sector size of the namespace in sector mode
+ :type sector_size: str
+ """
+ self.mode = kwargs.pop("mode")
+ self.devname = kwargs.pop("devname")
+ self.sector_size = kwargs.pop("sector_size")
+
+ DiskDevice.__init__(self, device, **kwargs)
+
+ def __repr__(self):
+ s = DiskDevice.__repr__(self)
+ s += (" mode = %(mode)s devname = %(devname)s" %
+ {"mode": self.mode,
+ "devname": self.devname})
+ if self.sector_size:
+ s += (" sector size = %(sector_size)s" % {"sector_size": self.sector_size})
+ return s
+
+ @property
+ def description(self):
+ return "NVDIMM namespace %(devname)s in %(mode)s mode exported as %(path)s" \
+ % {'devname': self.devname,
+ 'mode': self.mode,
+ 'path': self.path}
--
2.14.3