|
|
38b7b2 |
From 7dc7ab8e99005da29aba22df2bb67e58e19a50f0 Mon Sep 17 00:00:00 2001
|
|
|
38b7b2 |
From: David Teigland <teigland@redhat.com>
|
|
|
38b7b2 |
Date: Thu, 24 Feb 2022 16:10:37 -0600
|
|
|
38b7b2 |
Subject: [PATCH 37/54] devices: initial use of existing option
|
|
|
38b7b2 |
|
|
|
38b7b2 |
Use dev_cache_get_existing() in a few common, high level
|
|
|
38b7b2 |
locations where it's obvious that only existing dev-cache
|
|
|
38b7b2 |
entries are wanted. This can be expanded and used in more
|
|
|
38b7b2 |
locations (or dev_cache_get can stop creating new entries.)
|
|
|
38b7b2 |
---
|
|
|
38b7b2 |
lib/device/device_id.c | 4 ++--
|
|
|
38b7b2 |
tools/toollib.c | 6 +++---
|
|
|
38b7b2 |
2 files changed, 5 insertions(+), 5 deletions(-)
|
|
|
38b7b2 |
|
|
|
38b7b2 |
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
|
|
|
38b7b2 |
index 7fe581571..bcb2e6bcf 100644
|
|
|
38b7b2 |
--- a/lib/device/device_id.c
|
|
|
38b7b2 |
+++ b/lib/device/device_id.c
|
|
|
38b7b2 |
@@ -1565,7 +1565,7 @@ void device_ids_match(struct cmd_context *cmd)
|
|
|
38b7b2 |
dm_list_iterate_items(du, &cmd->use_devices) {
|
|
|
38b7b2 |
if (du->dev)
|
|
|
38b7b2 |
continue;
|
|
|
38b7b2 |
- if (!(du->dev = dev_cache_get(cmd, du->devname, NULL))) {
|
|
|
38b7b2 |
+ if (!(du->dev = dev_cache_get_existing(cmd, du->devname, NULL))) {
|
|
|
38b7b2 |
log_warn("Device not found for %s.", du->devname);
|
|
|
38b7b2 |
} else {
|
|
|
38b7b2 |
/* Should we set dev->id? Which idtype? Use --deviceidtype? */
|
|
|
38b7b2 |
@@ -1603,7 +1603,7 @@ void device_ids_match(struct cmd_context *cmd)
|
|
|
38b7b2 |
* the du/dev pairs in preparation for using the filters.
|
|
|
38b7b2 |
*/
|
|
|
38b7b2 |
if (du->devname &&
|
|
|
38b7b2 |
- (dev = dev_cache_get(cmd, du->devname, NULL))) {
|
|
|
38b7b2 |
+ (dev = dev_cache_get_existing(cmd, du->devname, NULL))) {
|
|
|
38b7b2 |
/* On successful match, du, dev, and id are linked. */
|
|
|
38b7b2 |
if (_match_du_to_dev(cmd, du, dev))
|
|
|
38b7b2 |
continue;
|
|
|
38b7b2 |
diff --git a/tools/toollib.c b/tools/toollib.c
|
|
|
38b7b2 |
index d6f48aad2..16be336d4 100644
|
|
|
38b7b2 |
--- a/tools/toollib.c
|
|
|
38b7b2 |
+++ b/tools/toollib.c
|
|
|
38b7b2 |
@@ -1434,7 +1434,7 @@ int process_each_label(struct cmd_context *cmd, int argc, char **argv,
|
|
|
38b7b2 |
goto out;
|
|
|
38b7b2 |
}
|
|
|
38b7b2 |
|
|
|
38b7b2 |
- if (!(dev = dev_cache_get(cmd, argv[opt], cmd->filter))) {
|
|
|
38b7b2 |
+ if (!(dev = dev_cache_get_existing(cmd, argv[opt], cmd->filter))) {
|
|
|
38b7b2 |
log_error("Failed to find device "
|
|
|
38b7b2 |
"\"%s\".", argv[opt]);
|
|
|
38b7b2 |
ret_max = ECMD_FAILED;
|
|
|
38b7b2 |
@@ -3870,7 +3870,7 @@ static int _get_arg_devices(struct cmd_context *cmd,
|
|
|
38b7b2 |
return ECMD_FAILED;
|
|
|
38b7b2 |
}
|
|
|
38b7b2 |
|
|
|
38b7b2 |
- if (!(dil->dev = dev_cache_get(cmd, sl->str, cmd->filter))) {
|
|
|
38b7b2 |
+ if (!(dil->dev = dev_cache_get_existing(cmd, sl->str, cmd->filter))) {
|
|
|
38b7b2 |
log_error("Cannot use %s: %s", sl->str, devname_error_reason(sl->str));
|
|
|
38b7b2 |
ret_max = EINIT_FAILED;
|
|
|
38b7b2 |
} else {
|
|
|
38b7b2 |
@@ -5206,7 +5206,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
|
|
|
38b7b2 |
struct device *dev;
|
|
|
38b7b2 |
|
|
|
38b7b2 |
/* No filter used here */
|
|
|
38b7b2 |
- if (!(dev = dev_cache_get(cmd, pd->name, NULL))) {
|
|
|
38b7b2 |
+ if (!(dev = dev_cache_get_existing(cmd, pd->name, NULL))) {
|
|
|
38b7b2 |
log_error("No device found for %s.", pd->name);
|
|
|
38b7b2 |
dm_list_del(&pd->list);
|
|
|
38b7b2 |
dm_list_add(&pp->arg_fail, &pd->list);
|
|
|
38b7b2 |
--
|
|
|
38b7b2 |
2.34.3
|
|
|
38b7b2 |
|