Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From bda7c937ba544182a5cae2a9cf0c173e0ba268c9 Mon Sep 17 00:00:00 2001 |
| 2 | From: Hongxu Jia <hongxu.jia@windriver.com> |
| 3 | Date: Thu, 27 Jul 2017 09:47:23 +0800 |
| 4 | Subject: [PATCH 3/3] remove dmraid while compiling with --with-dm |
| 5 | |
| 6 | Fix the following failure: |
| 7 | |
| 8 | ... |
| 9 | Perhaps you should add the directory containing `dmraid.pc' |
| 10 | to the PKG_CONFIG_PATH environment variable |
| 11 | No package 'dmraid' found |
| 12 | ... |
| 13 | |
| 14 | ... |
| 15 | ../../../git/src/plugins/dm.c:24:10: fatal error: dmraid/dmraid.h: No |
| 16 | such file or directory |
| 17 | #include <dmraid/dmraid.h> |
| 18 | ^~~~~~~~~~~~~~~~~ |
| 19 | ... |
| 20 | |
| 21 | Upstream-Status: Inappropriate [oe specific] |
| 22 | |
| 23 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
| 24 | --- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | src/lib/plugin_apis/dm.api | 50 ------ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 26 | src/plugins/Makefile.am | 2 +- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 27 | src/plugins/dm.c | 330 ------------------------------------ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 28 | src/plugins/dm.h | 5 - |
| 29 | src/python/gi/overrides/BlockDev.py | 6 - |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 30 | 5 files changed, 1 insertion(+), 392 deletions(-) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 31 | |
| 32 | diff --git a/src/lib/plugin_apis/dm.api b/src/lib/plugin_apis/dm.api |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 | index 04fd8d8..5d30b6a 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 34 | --- a/src/lib/plugin_apis/dm.api |
| 35 | +++ b/src/lib/plugin_apis/dm.api |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 36 | @@ -111,53 +111,3 @@ gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error); |
| 37 | * Tech category: %BD_DM_TECH_MAP-%BD_DM_TECH_MODE_QUERY |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 38 | */ |
| 39 | gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean active_only, GError **error); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | - |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 41 | -/** |
| 42 | - * bd_dm_get_member_raid_sets: |
| 43 | - * @name: (allow-none): name of the member |
| 44 | - * @uuid: (allow-none): uuid of the member |
| 45 | - * @major: major number of the device or -1 if not specified |
| 46 | - * @minor: minor number of the device or -1 if not specified |
| 47 | - * @error: (out): variable to store error (if any) |
| 48 | - * |
| 49 | - * Returns: (transfer full) (array zero-terminated=1): list of names of the RAID sets related to |
| 50 | - * the member or %NULL in case of error |
| 51 | - * |
| 52 | - * One of @name, @uuid or @major:@minor has to be given. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 53 | - * |
| 54 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_QUERY |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 55 | - */ |
| 56 | -gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error); |
| 57 | - |
| 58 | -/** |
| 59 | - * bd_dm_activate_raid_set: |
| 60 | - * @name: name of the DM RAID set to activate |
| 61 | - * @error: (out): variable to store error (if any) |
| 62 | - * |
| 63 | - * Returns: whether the RAID set @name was successfully activate or not |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | - * |
| 65 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_CREATE_ACTIVATE |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 66 | - */ |
| 67 | -gboolean bd_dm_activate_raid_set (const gchar *name, GError **error); |
| 68 | - |
| 69 | -/** |
| 70 | - * bd_dm_deactivate_raid_set: |
| 71 | - * @name: name of the DM RAID set to deactivate |
| 72 | - * @error: (out): variable to store error (if any) |
| 73 | - * |
| 74 | - * Returns: whether the RAID set @name was successfully deactivate or not |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 75 | - * |
| 76 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_REMOVE_DEACTIVATE |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 77 | - */ |
| 78 | -gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error); |
| 79 | - |
| 80 | -/** |
| 81 | - * bd_dm_get_raid_set_type: |
| 82 | - * @name: name of the DM RAID set to get the type of |
| 83 | - * @error: (out): variable to store error (if any) |
| 84 | - * |
| 85 | - * Returns: string representation of the @name RAID set's type |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 86 | - * |
| 87 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_QUERY |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 88 | - */ |
| 89 | -gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error); |
| 90 | diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 91 | index b69c8f7..7575f4a 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 92 | --- a/src/plugins/Makefile.am |
| 93 | +++ b/src/plugins/Makefile.am |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 94 | @@ -75,7 +75,7 @@ endif |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 95 | |
| 96 | if WITH_DM |
| 97 | libbd_dm_la_CFLAGS = $(GLIB_CFLAGS) $(DEVMAPPER_CFLAGS) $(UDEV_CFLAGS) -Wall -Wextra -Werror |
| 98 | -libbd_dm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) $(UDEV_LIBS) -ldmraid ${builddir}/../utils/libbd_utils.la |
| 99 | +libbd_dm_la_LIBADD = $(GLIB_LIBS) $(DEVMAPPER_LIBS) $(UDEV_LIBS) ${builddir}/../utils/libbd_utils.la |
| 100 | libbd_dm_la_LDFLAGS = -L${srcdir}/../utils/ -version-info 2:0:0 -Wl,--no-undefined |
| 101 | # Dear author of libdmdraid, VERSION really is not a good name for an enum member! |
| 102 | libbd_dm_la_CPPFLAGS = -I${builddir}/../../include/ -UVERSION |
| 103 | diff --git a/src/plugins/dm.c b/src/plugins/dm.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 104 | index 0e5466c..31ebe96 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 105 | --- a/src/plugins/dm.c |
| 106 | +++ b/src/plugins/dm.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 107 | @@ -21,17 +21,11 @@ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 108 | #include <unistd.h> |
| 109 | #include <blockdev/utils.h> |
| 110 | #include <libdevmapper.h> |
| 111 | -#include <dmraid/dmraid.h> |
| 112 | #include <libudev.h> |
| 113 | |
| 114 | #include "dm.h" |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 115 | #include "check_deps.h" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 116 | |
| 117 | -/* macros taken from the pyblock/dmraid.h file plus one more*/ |
| 118 | -#define for_each_raidset(_c, _n) list_for_each_entry(_n, LC_RS(_c), list) |
| 119 | -#define for_each_subset(_rs, _n) list_for_each_entry(_n, &(_rs)->sets, list) |
| 120 | -#define for_each_device(_rs, _d) list_for_each_entry(_d, &(_rs)->devs, devs) |
| 121 | - |
| 122 | /** |
| 123 | * SECTION: dm |
| 124 | * @short_description: plugin for basic operations with device mapper |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 125 | @@ -380,327 +374,3 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a |
| 126 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 127 | return ret; |
| 128 | } |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 129 | - |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 130 | -/** |
| 131 | - * init_dmraid_stack: (skip) |
| 132 | - * |
| 133 | - * Initializes the dmraid stack by creating the library context, discovering |
| 134 | - * devices, raid sets, etc. |
| 135 | - */ |
| 136 | -static struct lib_context* init_dmraid_stack (GError **error) { |
| 137 | - gint rc = 0; |
| 138 | - gchar *argv[] = {"blockdev.dmraid", NULL}; |
| 139 | - struct lib_context *lc; |
| 140 | - |
| 141 | - /* the code for this function was cherry-picked from the pyblock code */ |
| 142 | - /* XXX: do this all just once, store global lc and provide a reinit |
| 143 | - * function? */ |
| 144 | - |
| 145 | - /* initialize dmraid library context */ |
| 146 | - lc = libdmraid_init (1, (gchar **)argv); |
| 147 | - |
| 148 | - rc = discover_devices (lc, NULL); |
| 149 | - if (!rc) { |
| 150 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, |
| 151 | - "Failed to discover devices"); |
| 152 | - libdmraid_exit (lc); |
| 153 | - return NULL; |
| 154 | - } |
| 155 | - discover_raid_devices (lc, NULL); |
| 156 | - |
| 157 | - if (!count_devices (lc, RAID)) { |
| 158 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_DEVS, |
| 159 | - "No RAIDs discovered"); |
| 160 | - libdmraid_exit (lc); |
| 161 | - return NULL; |
| 162 | - } |
| 163 | - |
| 164 | - argv[0] = NULL; |
| 165 | - if (!group_set (lc, argv)) { |
| 166 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, |
| 167 | - "Failed to group_set"); |
| 168 | - libdmraid_exit (lc); |
| 169 | - return NULL; |
| 170 | - } |
| 171 | - |
| 172 | - return lc; |
| 173 | -} |
| 174 | - |
| 175 | -/** |
| 176 | - * raid_dev_matches_spec: (skip) |
| 177 | - * |
| 178 | - * Returns: whether the device specified by @sysname matches the spec given by @name, |
| 179 | - * @uuid, @major and @minor |
| 180 | - */ |
| 181 | -static gboolean raid_dev_matches_spec (struct raid_dev *raid_dev, const gchar *name, const gchar *uuid, gint major, gint minor) { |
| 182 | - gchar const *dev_name = NULL; |
| 183 | - gchar const *dev_uuid; |
| 184 | - gchar const *major_str; |
| 185 | - gchar const *minor_str; |
| 186 | - struct udev *context; |
| 187 | - struct udev_device *device; |
| 188 | - gboolean ret = TRUE; |
| 189 | - |
| 190 | - /* find the second '/' to get name (the rest of the string) */ |
| 191 | - dev_name = strchr (raid_dev->di->path, '/'); |
| 192 | - if (dev_name && strlen (dev_name) > 1) { |
| 193 | - dev_name++; |
| 194 | - dev_name = strchr (dev_name, '/'); |
| 195 | - } |
| 196 | - if (dev_name && strlen (dev_name) > 1) { |
| 197 | - dev_name++; |
| 198 | - } |
| 199 | - else |
| 200 | - dev_name = NULL; |
| 201 | - |
| 202 | - /* if we don't have the name, we cannot check any match */ |
| 203 | - g_return_val_if_fail (dev_name, FALSE); |
| 204 | - |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 205 | - /* g_return_val_if_fail above checks value of dev_name and returns FALSE if |
| 206 | - * it is NULL so we don't need to check it here */ |
| 207 | - /* coverity[var_deref_model] */ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 208 | - if (name && strcmp (dev_name, name) != 0) { |
| 209 | - return FALSE; |
| 210 | - } |
| 211 | - |
| 212 | - context = udev_new (); |
| 213 | - device = udev_device_new_from_subsystem_sysname (context, "block", dev_name); |
| 214 | - dev_uuid = udev_device_get_property_value (device, "UUID"); |
| 215 | - major_str = udev_device_get_property_value (device, "MAJOR"); |
| 216 | - minor_str = udev_device_get_property_value (device, "MINOR"); |
| 217 | - |
| 218 | - if (uuid && (g_strcmp0 (uuid, "") != 0) && (g_strcmp0 (uuid, dev_uuid) != 0)) |
| 219 | - ret = FALSE; |
| 220 | - |
| 221 | - if (major >= 0 && (atoi (major_str) != major)) |
| 222 | - ret = FALSE; |
| 223 | - |
| 224 | - if (minor >= 0 && (atoi (minor_str) != minor)) |
| 225 | - ret = FALSE; |
| 226 | - |
| 227 | - udev_device_unref (device); |
| 228 | - udev_unref (context); |
| 229 | - |
| 230 | - return ret; |
| 231 | -} |
| 232 | - |
| 233 | -/** |
| 234 | - * find_raid_sets_for_dev: (skip) |
| 235 | - */ |
| 236 | -static void find_raid_sets_for_dev (const gchar *name, const gchar *uuid, gint major, gint minor, struct lib_context *lc, struct raid_set *rs, GPtrArray *ret_sets) { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 237 | - struct raid_set *subset = NULL; |
| 238 | - struct raid_dev *dev = NULL; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 239 | - |
| 240 | - if (T_GROUP(rs) || !list_empty(&(rs->sets))) { |
| 241 | - for_each_subset (rs, subset) |
| 242 | - find_raid_sets_for_dev (name, uuid, major, minor, lc, subset, ret_sets); |
| 243 | - } else { |
| 244 | - for_each_device (rs, dev) { |
| 245 | - if (raid_dev_matches_spec (dev, name, uuid, major, minor)) |
| 246 | - g_ptr_array_add (ret_sets, g_strdup (rs->name)); |
| 247 | - } |
| 248 | - } |
| 249 | -} |
| 250 | - |
| 251 | -/** |
| 252 | - * bd_dm_get_member_raid_sets: |
| 253 | - * @name: (allow-none): name of the member |
| 254 | - * @uuid: (allow-none): uuid of the member |
| 255 | - * @major: major number of the device or -1 if not specified |
| 256 | - * @minor: minor number of the device or -1 if not specified |
| 257 | - * @error: (out): variable to store error (if any) |
| 258 | - * |
| 259 | - * Returns: (transfer full) (array zero-terminated=1): list of names of the RAID sets related to |
| 260 | - * the member or %NULL in case of error |
| 261 | - * |
| 262 | - * One of @name, @uuid or @major:@minor has to be given. |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 263 | - * |
| 264 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_MODE_QUERY |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 265 | - */ |
| 266 | -gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error) { |
| 267 | - guint64 i = 0; |
| 268 | - struct lib_context *lc = NULL; |
| 269 | - struct raid_set *rs = NULL; |
| 270 | - GPtrArray *ret_sets = g_ptr_array_new (); |
| 271 | - gchar **ret = NULL; |
| 272 | - |
| 273 | - lc = init_dmraid_stack (error); |
| 274 | - if (!lc) |
| 275 | - /* error is already populated */ |
| 276 | - return NULL; |
| 277 | - |
| 278 | - for_each_raidset (lc, rs) { |
| 279 | - find_raid_sets_for_dev (name, uuid, major, minor, lc, rs, ret_sets); |
| 280 | - } |
| 281 | - |
| 282 | - /* now create the return value -- NULL-terminated array of strings */ |
| 283 | - ret = g_new0 (gchar*, ret_sets->len + 1); |
| 284 | - for (i=0; i < ret_sets->len; i++) |
| 285 | - ret[i] = (gchar*) g_ptr_array_index (ret_sets, i); |
| 286 | - ret[i] = NULL; |
| 287 | - |
| 288 | - g_ptr_array_free (ret_sets, FALSE); |
| 289 | - |
| 290 | - libdmraid_exit (lc); |
| 291 | - return ret; |
| 292 | -} |
| 293 | - |
| 294 | -/** |
| 295 | - * find_in_raid_sets: (skip) |
| 296 | - * |
| 297 | - * Runs @eval_fn with @data on each set (traversing recursively) and returns the |
| 298 | - * first RAID set that @eval_fn returns. Thus the @eval_fn should return %NULL |
| 299 | - * on all RAID sets that don't fulfill the search criteria. |
| 300 | - */ |
| 301 | -static struct raid_set* find_in_raid_sets (struct raid_set *rs, RSEvalFunc eval_fn, gpointer data) { |
| 302 | - struct raid_set *subset = NULL; |
| 303 | - struct raid_set *ret = NULL; |
| 304 | - |
| 305 | - ret = eval_fn (rs, data); |
| 306 | - if (ret) |
| 307 | - return ret; |
| 308 | - |
| 309 | - if (T_GROUP(rs) || !list_empty(&(rs->sets))) { |
| 310 | - for_each_subset (rs, subset) { |
| 311 | - ret = find_in_raid_sets (subset, eval_fn, data); |
| 312 | - if (ret) |
| 313 | - return ret; |
| 314 | - } |
| 315 | - } |
| 316 | - |
| 317 | - return ret; |
| 318 | -} |
| 319 | - |
| 320 | -static struct raid_set* rs_matches_name (struct raid_set *rs, gpointer *name_data) { |
| 321 | - gchar *name = (gchar*) name_data; |
| 322 | - |
| 323 | - if (g_strcmp0 (rs->name, name) == 0) |
| 324 | - return rs; |
| 325 | - else |
| 326 | - return NULL; |
| 327 | -} |
| 328 | - |
| 329 | -static gboolean change_set_by_name (const gchar *name, enum activate_type action, GError **error) { |
| 330 | - gint rc = 0; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 331 | - struct lib_context *lc = NULL; |
| 332 | - struct raid_set *iter_rs = NULL; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 333 | - struct raid_set *match_rs = NULL; |
| 334 | - |
| 335 | - lc = init_dmraid_stack (error); |
| 336 | - if (!lc) |
| 337 | - /* error is already populated */ |
| 338 | - return FALSE; |
| 339 | - |
| 340 | - for_each_raidset (lc, iter_rs) { |
| 341 | - match_rs = find_in_raid_sets (iter_rs, (RSEvalFunc)rs_matches_name, (gchar *)name); |
| 342 | - if (match_rs) |
| 343 | - break; |
| 344 | - } |
| 345 | - |
| 346 | - if (!match_rs) { |
| 347 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_EXIST, |
| 348 | - "RAID set %s doesn't exist", name); |
| 349 | - libdmraid_exit (lc); |
| 350 | - return FALSE; |
| 351 | - } |
| 352 | - |
| 353 | - rc = change_set (lc, action, match_rs); |
| 354 | - if (!rc) { |
| 355 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, |
| 356 | - "Failed to activate the RAID set '%s'", name); |
| 357 | - libdmraid_exit (lc); |
| 358 | - return FALSE; |
| 359 | - } |
| 360 | - |
| 361 | - libdmraid_exit (lc); |
| 362 | - return TRUE; |
| 363 | -} |
| 364 | - |
| 365 | -/** |
| 366 | - * bd_dm_activate_raid_set: |
| 367 | - * @name: name of the DM RAID set to activate |
| 368 | - * @error: (out): variable to store error (if any) |
| 369 | - * |
| 370 | - * Returns: whether the RAID set @name was successfully activate or not |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 371 | - * |
| 372 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_CREATE_ACTIVATE |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 373 | - */ |
| 374 | -gboolean bd_dm_activate_raid_set (const gchar *name, GError **error) { |
| 375 | - guint64 progress_id = 0; |
| 376 | - gchar *msg = NULL; |
| 377 | - gboolean ret = FALSE; |
| 378 | - |
| 379 | - msg = g_strdup_printf ("Activating DM RAID set '%s'", name); |
| 380 | - progress_id = bd_utils_report_started (msg); |
| 381 | - g_free (msg); |
| 382 | - ret = change_set_by_name (name, A_ACTIVATE, error); |
| 383 | - bd_utils_report_finished (progress_id, "Completed"); |
| 384 | - return ret; |
| 385 | -} |
| 386 | - |
| 387 | -/** |
| 388 | - * bd_dm_deactivate_raid_set: |
| 389 | - * @name: name of the DM RAID set to deactivate |
| 390 | - * @error: (out): variable to store error (if any) |
| 391 | - * |
| 392 | - * Returns: whether the RAID set @name was successfully deactivate or not |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 393 | - * |
| 394 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_REMOVE_DEACTIVATE |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 395 | - */ |
| 396 | -gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error) { |
| 397 | - guint64 progress_id = 0; |
| 398 | - gchar *msg = NULL; |
| 399 | - gboolean ret = FALSE; |
| 400 | - |
| 401 | - msg = g_strdup_printf ("Deactivating DM RAID set '%s'", name); |
| 402 | - progress_id = bd_utils_report_started (msg); |
| 403 | - g_free (msg); |
| 404 | - ret = change_set_by_name (name, A_DEACTIVATE, error); |
| 405 | - bd_utils_report_finished (progress_id, "Completed"); |
| 406 | - return ret; |
| 407 | -} |
| 408 | - |
| 409 | -/** |
| 410 | - * bd_dm_get_raid_set_type: |
| 411 | - * @name: name of the DM RAID set to get the type of |
| 412 | - * @error: (out): variable to store error (if any) |
| 413 | - * |
| 414 | - * Returns: string representation of the @name RAID set's type |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 415 | - * |
| 416 | - * Tech category: %BD_DM_TECH_RAID-%BD_DM_TECH_QUERY |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 417 | - */ |
| 418 | -gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error) { |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 419 | - struct lib_context *lc = NULL; |
| 420 | - struct raid_set *iter_rs = NULL; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 421 | - struct raid_set *match_rs = NULL; |
| 422 | - const gchar *type = NULL; |
| 423 | - |
| 424 | - lc = init_dmraid_stack (error); |
| 425 | - if (!lc) |
| 426 | - /* error is already populated */ |
| 427 | - return NULL; |
| 428 | - |
| 429 | - for_each_raidset (lc, iter_rs) { |
| 430 | - match_rs = find_in_raid_sets (iter_rs, (RSEvalFunc)rs_matches_name, (gchar *)name); |
| 431 | - if (match_rs) |
| 432 | - break; |
| 433 | - } |
| 434 | - |
| 435 | - if (!match_rs) { |
| 436 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_NO_EXIST, |
| 437 | - "RAID set %s doesn't exist", name); |
| 438 | - libdmraid_exit (lc); |
| 439 | - return NULL; |
| 440 | - } |
| 441 | - |
| 442 | - type = get_set_type (lc, match_rs); |
| 443 | - if (!type) { |
| 444 | - g_set_error (error, BD_DM_ERROR, BD_DM_ERROR_RAID_FAIL, |
| 445 | - "Failed to get RAID set's type"); |
| 446 | - libdmraid_exit (lc); |
| 447 | - return NULL; |
| 448 | - } |
| 449 | - |
| 450 | - libdmraid_exit (lc); |
| 451 | - return g_strdup (type); |
| 452 | -} |
| 453 | diff --git a/src/plugins/dm.h b/src/plugins/dm.h |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 454 | index 0dce6ac..1ee3788 100644 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 455 | --- a/src/plugins/dm.h |
| 456 | +++ b/src/plugins/dm.h |
| 457 | @@ -1,5 +1,4 @@ |
| 458 | #include <glib.h> |
| 459 | -#include <dmraid/dmraid.h> |
| 460 | |
| 461 | #ifndef BD_DM |
| 462 | #define BD_DM |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 463 | @@ -48,9 +47,5 @@ gboolean bd_dm_map_exists (const gchar *map_name, gboolean live_only, gboolean a |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 464 | gchar* bd_dm_name_from_node (const gchar *dm_node, GError **error); |
| 465 | gchar* bd_dm_node_from_name (const gchar *map_name, GError **error); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 466 | gchar* bd_dm_get_subsystem_from_name (const gchar *device_name, GError **error); |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 467 | -gchar** bd_dm_get_member_raid_sets (const gchar *name, const gchar *uuid, gint major, gint minor, GError **error); |
| 468 | -gboolean bd_dm_activate_raid_set (const gchar *name, GError **error); |
| 469 | -gboolean bd_dm_deactivate_raid_set (const gchar *name, GError **error); |
| 470 | -gchar* bd_dm_get_raid_set_type (const gchar *name, GError **error); |
| 471 | |
| 472 | #endif /* BD_DM */ |
| 473 | diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py |
| 474 | index fb3ffb4..eed0a38 100644 |
| 475 | --- a/src/python/gi/overrides/BlockDev.py |
| 476 | +++ b/src/python/gi/overrides/BlockDev.py |
| 477 | @@ -233,12 +233,6 @@ def dm_create_linear(map_name, device, length, uuid=None): |
| 478 | return _dm_create_linear(map_name, device, length, uuid) |
| 479 | __all__.append("dm_create_linear") |
| 480 | |
| 481 | -_dm_get_member_raid_sets = BlockDev.dm_get_member_raid_sets |
| 482 | -@override(BlockDev.dm_get_member_raid_sets) |
| 483 | -def dm_get_member_raid_sets(name=None, uuid=None, major=-1, minor=-1): |
| 484 | - return _dm_get_member_raid_sets(name, uuid, major, minor) |
| 485 | -__all__.append("dm_get_member_raid_sets") |
| 486 | - |
| 487 | |
| 488 | _loop_setup = BlockDev.loop_setup |
| 489 | @override(BlockDev.loop_setup) |
| 490 | -- |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 491 | 2.14.3 |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 492 | |