From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============6574706164201569079==" MIME-Version: 1.0 From: Ramesh Thomas Subject: [Accel-config] [PATCH 3/4] accel-config: Add "forced" option to load-config command Date: Tue, 07 Dec 2021 19:51:51 -0500 Message-ID: <20211208005152.220518-4-ramesh.thomas@intel.com> In-Reply-To: 20211208005152.220518-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============6574706164201569079== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add forced disabling of devices option as a convenience. Disabling of devices also disables wqs so users can use different configuration files without having to manually disable enabled devices and wqs before reconfiguring. The option is -f, forced=3Dtrue Signed-off-by: Ramesh Thomas --- accfg/config.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/accfg/config.c b/accfg/config.c index 9fb8874..e96d3fb 100644 --- a/accfg/config.c +++ b/accfg/config.c @@ -22,6 +22,7 @@ = static bool verbose; static bool enable; +static bool forced; static struct util_filter_params util_param; = static LIST_HEAD(activate_dev_list); @@ -526,10 +527,21 @@ static int configure_json_value(struct accfg_ctx *ctx, } dev_state =3D accfg_device_get_state(dev); if (dev_state =3D=3D ACCFG_DEVICE_ENABLED) { - fprintf(stderr, - "%s is active, will skip...\n", parsed_string); - dev =3D NULL; - return 0; + fprintf(stderr, "%s is active. ", + parsed_string); + if (forced) { + fprintf(stderr, "Disabling...\n"); + rc =3D accfg_device_disable(dev, true); + if (rc) { + fprintf(stderr, + "Failed disabling device\n"); + return rc; + } + } else { + fprintf(stderr, "Skipping...\n"); + dev =3D NULL; + return 0; + } } = if (enable) { @@ -1065,6 +1077,8 @@ int cmd_config(int argc, const char **argv, void *ctx) "emit extra debug messages to stderr"), OPT_BOOLEAN('e', "enable", &enable, "enable configured devices and wqs"), + OPT_BOOLEAN('f', "forced", &forced, + "enabled devices will be disabled before configuring"), OPT_END(), }; const char *const u[] =3D { -- = 2.26.3 --===============6574706164201569079==--