From: Alain Spineux Date: Tue, 24 Nov 2020 13:11:40 +0000 (+0100) Subject: dedup: Fix #7033 device not initialized when using legacy config format X-Git-Tag: Release-11.3.2~829 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=823f83a6ea18a4afd6f2511795d052f70f223425;p=thirdparty%2Fbacula.git dedup: Fix #7033 device not initialized when using legacy config format - the default dedupengine had no driver_type and was not initialized as a Legacy or Dedup2 dedupengine - When no Dedupengine is specified in a Device resource and if there is only one dedupengine specified in the Storage resource or in a Dedupengine resource then use this one. Else return an error. --- diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index baa1d6187..f66803d34 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -1096,12 +1096,25 @@ bool save_resource(CONFIG *config, int type, RES_ITEM *items, int pass) * "default_legacy_dedupengine" aka the DDE defined in storage */ if (res->res_dev.dev_type == B_DEDUP_DEV && res->res_dev.dedup == NULL) { - URES *dedup; - if ((dedup = (URES *)GetResWithName(R_DEDUP, default_legacy_dedupengine)) == NULL) { - Mmsg(config->m_errmsg, _("Cannot find dedupengine for device %s\n"), res_all.res_dir.hdr.name); + /* The "Dedupengine" is not specified in this Device resource */ + /* If there is only one Dedupengine defined use it */ + int i = 0; + DEDUPRES *dedup, *prev_dedup = NULL; + foreach_res(dedup, R_DEDUP) { + prev_dedup = dedup; + i++; + } + if (i == 1) { + res->res_dev.dedup = prev_dedup; + Dmsg2(0, "Select dedupengine %s for device %s\n", prev_dedup->hdr.name, res_all.res_dir.hdr.name); + } else if (i == 0){ + Mmsg(config->m_errmsg, _("Cannot find any dedupengine for the device %s\n"), res_all.res_dir.hdr.name); + return false; + } else { + /* i > 1 */ + Mmsg(config->m_errmsg, _("Dedupengine unspecified for device %s\n"), res_all.res_dir.hdr.name); return false; } - res->res_dev.dedup = &dedup->res_dedup; } #endif break;